根据排班计划展示排班日历
This commit is contained in:
parent
84b9a07519
commit
c3e3503409
@ -141,4 +141,12 @@ public class UserConstants
|
||||
public static final String CAL_SHIFT_NAME_NIGHT="夜班";
|
||||
public static final String CAL_SHIFT_NAME_MID="中班";
|
||||
|
||||
/**
|
||||
* 排班日历的查询方式
|
||||
*/
|
||||
public static final String CAL_QUERY_BY_TYPE="TYPE";
|
||||
public static final String CAL_QUERY_BY_TEAM="TEAM";
|
||||
public static final String CAL_QUERY_BY_USER="USER";
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.ktg.mes.cal.controller;
|
||||
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.cal.domain.CalCalendar;
|
||||
import com.ktg.mes.cal.service.ICalCalendarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 排班日历
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2022-06-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/mes/cal/calendar")
|
||||
public class CalCalendarController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ICalCalendarService calCalendarService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('mes:cal:calendar:list')")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult getCalendars(CalCalendar calCalendar){
|
||||
|
||||
Date day = calCalendar.getDate();
|
||||
List<CalCalendar> days = null;
|
||||
if(StringUtils.isNull(day)){
|
||||
day = new Date();
|
||||
}
|
||||
|
||||
if(UserConstants.CAL_QUERY_BY_TYPE.equals(calCalendar.getQueryType())){
|
||||
days=calCalendarService.getCalendarByType(day,calCalendar.getCalendarType());
|
||||
}else if(UserConstants.CAL_QUERY_BY_TEAM.equals(calCalendar.getQueryType())){
|
||||
days=calCalendarService.getCalendarByTeam(day,calCalendar.getTeamId());
|
||||
}else {
|
||||
days=calCalendarService.getCalendarByUser(day,calCalendar.getUserId());
|
||||
}
|
||||
|
||||
return AjaxResult.success(days);
|
||||
}
|
||||
}
|
113
ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalCalendar.java
Normal file
113
ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalCalendar.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.ktg.mes.cal.domain;
|
||||
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class CalCalendar extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 查询参数部分
|
||||
*/
|
||||
private String queryType;
|
||||
|
||||
private Date date;
|
||||
|
||||
private String calendarType;
|
||||
|
||||
private Long teamId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
|
||||
/**
|
||||
* 返回值部分
|
||||
*/
|
||||
private String theDay;
|
||||
|
||||
private String shiftType;
|
||||
|
||||
private List<CalTeamshift> teamShifts;
|
||||
|
||||
|
||||
public String getQueryType() {
|
||||
return queryType;
|
||||
}
|
||||
|
||||
public void setQueryType(String queryType) {
|
||||
this.queryType = queryType;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getCalendarType() {
|
||||
return calendarType;
|
||||
}
|
||||
|
||||
public void setCalendarType(String calendarType) {
|
||||
this.calendarType = calendarType;
|
||||
}
|
||||
|
||||
public Long getTeamId() {
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public void setTeamId(Long teamId) {
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTheDay() {
|
||||
return theDay;
|
||||
}
|
||||
|
||||
public void setTheDay(String theDay) {
|
||||
this.theDay = theDay;
|
||||
}
|
||||
|
||||
public String getShiftType() {
|
||||
return shiftType;
|
||||
}
|
||||
|
||||
public void setShiftType(String shiftType) {
|
||||
this.shiftType = shiftType;
|
||||
}
|
||||
|
||||
public List<CalTeamshift> getTeamShifts() {
|
||||
return teamShifts;
|
||||
}
|
||||
|
||||
public void setTeamShifts(List<CalTeamshift> teamShifts) {
|
||||
this.teamShifts = teamShifts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CalCalendar{" +
|
||||
"queryType='" + queryType + '\'' +
|
||||
", date='" + date + '\'' +
|
||||
", calendarType='" + calendarType + '\'' +
|
||||
", teamId=" + teamId +
|
||||
", userId=" + userId +
|
||||
", theDay=" + theDay +
|
||||
", shiftType='" + shiftType + '\'' +
|
||||
", teamShifts=" + teamShifts +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -52,6 +52,8 @@ public class CalPlan extends BaseEntity
|
||||
@Excel(name = "数")
|
||||
private Long shiftCount;
|
||||
|
||||
private String status;
|
||||
|
||||
/** 预留字段1 */
|
||||
private String attr1;
|
||||
|
||||
@ -149,6 +151,14 @@ public class CalPlan extends BaseEntity
|
||||
this.attr1 = attr1;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getAttr1()
|
||||
{
|
||||
return attr1;
|
||||
@ -183,25 +193,21 @@ public class CalPlan extends BaseEntity
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("planId", getPlanId())
|
||||
.append("planCode", getPlanCode())
|
||||
.append("planName", getPlanName())
|
||||
.append("startDate", getStartDate())
|
||||
.append("endDate", getEndDate())
|
||||
.append("calendarType", getCalendarType())
|
||||
.append("shiftType", getShiftType())
|
||||
.append("shiftMethod", getShiftMethod())
|
||||
.append("shiftCount", getShiftCount())
|
||||
.append("remark", getRemark())
|
||||
.append("attr1", getAttr1())
|
||||
.append("attr2", getAttr2())
|
||||
.append("attr3", getAttr3())
|
||||
.append("attr4", getAttr4())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
return "CalPlan{" +
|
||||
"planId=" + planId +
|
||||
", planCode='" + planCode + '\'' +
|
||||
", planName='" + planName + '\'' +
|
||||
", calendarType='" + calendarType + '\'' +
|
||||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", shiftType='" + shiftType + '\'' +
|
||||
", shiftMethod='" + shiftMethod + '\'' +
|
||||
", shiftCount=" + shiftCount +
|
||||
", status='" + status + '\'' +
|
||||
", attr1='" + attr1 + '\'' +
|
||||
", attr2='" + attr2 + '\'' +
|
||||
", attr3=" + attr3 +
|
||||
", attr4=" + attr4 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package com.ktg.mes.cal.domain;
|
||||
|
||||
public enum CalQueryType {
|
||||
|
||||
BY_CALTYPE,BY_TEAM,BY_USER
|
||||
}
|
213
ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalTeamshift.java
Normal file
213
ktg-mes/src/main/java/com/ktg/mes/cal/domain/CalTeamshift.java
Normal file
@ -0,0 +1,213 @@
|
||||
package com.ktg.mes.cal.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ktg.common.annotation.Excel;
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 班组排班对象 cal_teamshift
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2022-06-11
|
||||
*/
|
||||
public class CalTeamshift extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 流水号 */
|
||||
private Long recordId;
|
||||
|
||||
/** 日期 */
|
||||
private String theDay;
|
||||
|
||||
/** 班组ID */
|
||||
@Excel(name = "班组ID")
|
||||
private Long teamId;
|
||||
|
||||
/** 班组名称 */
|
||||
@Excel(name = "班组名称")
|
||||
private String teamName;
|
||||
|
||||
/** 班次ID */
|
||||
@Excel(name = "班次ID")
|
||||
private Long shiftId;
|
||||
|
||||
/** 班次名称 */
|
||||
@Excel(name = "班次名称")
|
||||
private String shiftName;
|
||||
|
||||
/** 序号 */
|
||||
@Excel(name = "序号")
|
||||
private Long orderNum;
|
||||
|
||||
/** 计划ID */
|
||||
@Excel(name = "计划ID")
|
||||
private Long planId;
|
||||
|
||||
private String calendarType;
|
||||
|
||||
/** 轮班方式 */
|
||||
@Excel(name = "轮班方式")
|
||||
private String shiftType;
|
||||
|
||||
/** 预留字段1 */
|
||||
private String attr1;
|
||||
|
||||
/** 预留字段2 */
|
||||
private String attr2;
|
||||
|
||||
/** 预留字段3 */
|
||||
private Long attr3;
|
||||
|
||||
/** 预留字段4 */
|
||||
private Long attr4;
|
||||
|
||||
public void setRecordId(Long recordId)
|
||||
{
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public Long getRecordId()
|
||||
{
|
||||
return recordId;
|
||||
}
|
||||
public void setTheDay(String theDay)
|
||||
{
|
||||
this.theDay = theDay;
|
||||
}
|
||||
|
||||
public String getTheDay()
|
||||
{
|
||||
return theDay;
|
||||
}
|
||||
public void setTeamId(Long teamId)
|
||||
{
|
||||
this.teamId = teamId;
|
||||
}
|
||||
|
||||
public Long getTeamId()
|
||||
{
|
||||
return teamId;
|
||||
}
|
||||
public void setTeamName(String teamName)
|
||||
{
|
||||
this.teamName = teamName;
|
||||
}
|
||||
|
||||
public String getTeamName()
|
||||
{
|
||||
return teamName;
|
||||
}
|
||||
public void setShiftId(Long shiftId)
|
||||
{
|
||||
this.shiftId = shiftId;
|
||||
}
|
||||
|
||||
public Long getShiftId()
|
||||
{
|
||||
return shiftId;
|
||||
}
|
||||
public void setShiftName(String shiftName)
|
||||
{
|
||||
this.shiftName = shiftName;
|
||||
}
|
||||
|
||||
public String getShiftName()
|
||||
{
|
||||
return shiftName;
|
||||
}
|
||||
public void setOrderNum(Long orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public Long getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
public void setPlanId(Long planId)
|
||||
{
|
||||
this.planId = planId;
|
||||
}
|
||||
|
||||
public Long getPlanId()
|
||||
{
|
||||
return planId;
|
||||
}
|
||||
public void setShiftType(String shiftType)
|
||||
{
|
||||
this.shiftType = shiftType;
|
||||
}
|
||||
|
||||
public String getCalendarType() {
|
||||
return calendarType;
|
||||
}
|
||||
|
||||
public void setCalendarType(String calendarType) {
|
||||
this.calendarType = calendarType;
|
||||
}
|
||||
|
||||
public String getShiftType()
|
||||
{
|
||||
return shiftType;
|
||||
}
|
||||
public void setAttr1(String attr1)
|
||||
{
|
||||
this.attr1 = attr1;
|
||||
}
|
||||
|
||||
public String getAttr1()
|
||||
{
|
||||
return attr1;
|
||||
}
|
||||
public void setAttr2(String attr2)
|
||||
{
|
||||
this.attr2 = attr2;
|
||||
}
|
||||
|
||||
public String getAttr2()
|
||||
{
|
||||
return attr2;
|
||||
}
|
||||
public void setAttr3(Long attr3)
|
||||
{
|
||||
this.attr3 = attr3;
|
||||
}
|
||||
|
||||
public Long getAttr3()
|
||||
{
|
||||
return attr3;
|
||||
}
|
||||
public void setAttr4(Long attr4)
|
||||
{
|
||||
this.attr4 = attr4;
|
||||
}
|
||||
|
||||
public Long getAttr4()
|
||||
{
|
||||
return attr4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CalTeamshift{" +
|
||||
"recordId=" + recordId +
|
||||
", theDay=" + theDay +
|
||||
", teamId=" + teamId +
|
||||
", teamName='" + teamName + '\'' +
|
||||
", shiftId=" + shiftId +
|
||||
", shiftName='" + shiftName + '\'' +
|
||||
", orderNum=" + orderNum +
|
||||
", planId=" + planId +
|
||||
", calendarType='" + calendarType + '\'' +
|
||||
", shiftType='" + shiftType + '\'' +
|
||||
", attr1='" + attr1 + '\'' +
|
||||
", attr2='" + attr2 + '\'' +
|
||||
", attr3=" + attr3 +
|
||||
", attr4=" + attr4 +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -27,6 +27,9 @@ public interface CalPlanMapper
|
||||
*/
|
||||
public List<CalPlan> selectCalPlanList(CalPlan calPlan);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增排班计划
|
||||
*
|
||||
|
@ -0,0 +1,61 @@
|
||||
package com.ktg.mes.cal.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.cal.domain.CalTeamshift;
|
||||
|
||||
/**
|
||||
* 班组排班Mapper接口
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2022-06-11
|
||||
*/
|
||||
public interface CalTeamshiftMapper
|
||||
{
|
||||
/**
|
||||
* 查询班组排班
|
||||
*
|
||||
* @param recordId 班组排班主键
|
||||
* @return 班组排班
|
||||
*/
|
||||
public CalTeamshift selectCalTeamshiftByRecordId(Long recordId);
|
||||
|
||||
/**
|
||||
* 查询班组排班列表
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 班组排班集合
|
||||
*/
|
||||
public List<CalTeamshift> selectCalTeamshiftList(CalTeamshift calTeamshift);
|
||||
|
||||
/**
|
||||
* 新增班组排班
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCalTeamshift(CalTeamshift calTeamshift);
|
||||
|
||||
/**
|
||||
* 修改班组排班
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCalTeamshift(CalTeamshift calTeamshift);
|
||||
|
||||
/**
|
||||
* 删除班组排班
|
||||
*
|
||||
* @param recordId 班组排班主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCalTeamshiftByRecordId(Long recordId);
|
||||
|
||||
/**
|
||||
* 批量删除班组排班
|
||||
*
|
||||
* @param recordIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCalTeamshiftByRecordIds(Long[] recordIds);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.ktg.mes.cal.service;
|
||||
|
||||
import com.ktg.mes.cal.domain.CalCalendar;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ICalCalendarService {
|
||||
|
||||
/**
|
||||
* 查询某个班组类型在某月的排班日历
|
||||
* @param day
|
||||
* @param calenderType
|
||||
* @return
|
||||
*/
|
||||
List<CalCalendar> getCalendarByType(Date day, String calenderType);
|
||||
|
||||
/**
|
||||
* 查询某个班组在某个月的排班日历
|
||||
* @param day
|
||||
* @param teamId
|
||||
* @return
|
||||
*/
|
||||
List<CalCalendar> getCalendarByTeam(Date day,Long teamId);
|
||||
|
||||
/**
|
||||
* 查询某个人在某月的排班日历
|
||||
* @param day
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<CalCalendar> getCalendarByUser(Date day,Long userId);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.ktg.mes.cal.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.cal.domain.CalTeamshift;
|
||||
|
||||
/**
|
||||
* 班组排班Service接口
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2022-06-11
|
||||
*/
|
||||
public interface ICalTeamshiftService
|
||||
{
|
||||
/**
|
||||
* 查询班组排班
|
||||
*
|
||||
* @param recordId 班组排班主键
|
||||
* @return 班组排班
|
||||
*/
|
||||
public CalTeamshift selectCalTeamshiftByRecordId(Long recordId);
|
||||
|
||||
/**
|
||||
* 查询班组排班列表
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 班组排班集合
|
||||
*/
|
||||
public List<CalTeamshift> selectCalTeamshiftList(CalTeamshift calTeamshift);
|
||||
|
||||
/**
|
||||
* 新增班组排班
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCalTeamshift(CalTeamshift calTeamshift);
|
||||
|
||||
/**
|
||||
* 修改班组排班
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCalTeamshift(CalTeamshift calTeamshift);
|
||||
|
||||
/**
|
||||
* 批量删除班组排班
|
||||
*
|
||||
* @param recordIds 需要删除的班组排班主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCalTeamshiftByRecordIds(Long[] recordIds);
|
||||
|
||||
/**
|
||||
* 删除班组排班信息
|
||||
*
|
||||
* @param recordId 班组排班主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCalTeamshiftByRecordId(Long recordId);
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.ktg.mes.cal.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ktg.mes.cal.domain.CalCalendar;
|
||||
import com.ktg.mes.cal.domain.CalTeamshift;
|
||||
import com.ktg.mes.cal.mapper.CalPlanMapper;
|
||||
import com.ktg.mes.cal.mapper.CalTeamshiftMapper;
|
||||
import com.ktg.mes.cal.service.ICalCalendarService;
|
||||
import com.ktg.mes.cal.utils.CalendarUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CalCalendarServiceImpl implements ICalCalendarService {
|
||||
|
||||
@Autowired
|
||||
private CalPlanMapper calPlanMapper;
|
||||
|
||||
@Autowired
|
||||
private CalTeamshiftMapper calTeamshiftMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 1.循环生成当前月份每一天的CalCalendar
|
||||
* 2.根据月份和班组类型查询合适的plan
|
||||
* 3.根据plan上的Shift_type和shift_method计算每个班组的班次
|
||||
* 4.设置CalShiftTeamBean
|
||||
* @param day
|
||||
* @param calenderType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CalCalendar> getCalendarByType(Date day, String calenderType) {
|
||||
List<CalCalendar> calendars = null;
|
||||
calendars = CalendarUtil.getDays(day);
|
||||
for (CalCalendar cal:calendars
|
||||
) {
|
||||
CalTeamshift param2 = new CalTeamshift();
|
||||
param2.setTheDay(cal.getTheDay());
|
||||
param2.setCalendarType(calenderType);
|
||||
List<CalTeamshift> teamshifts = calTeamshiftMapper.selectCalTeamshiftList(param2);
|
||||
cal.setTeamShifts(teamshifts);
|
||||
if(CollUtil.isNotEmpty(teamshifts)){
|
||||
cal.setShiftType(teamshifts.get(0).getShiftType());
|
||||
}
|
||||
}
|
||||
return calendars;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CalCalendar> getCalendarByTeam(Date day, Long teamId) {
|
||||
List<CalCalendar> calendars = null;
|
||||
calendars = CalendarUtil.getDays(day);
|
||||
for (CalCalendar cal:calendars
|
||||
) {
|
||||
CalTeamshift param2 = new CalTeamshift();
|
||||
param2.setTheDay(cal.getTheDay());
|
||||
param2.setTeamId(teamId);
|
||||
List<CalTeamshift> teamshifts = calTeamshiftMapper.selectCalTeamshiftList(param2);
|
||||
cal.setTeamShifts(teamshifts);
|
||||
if(CollUtil.isNotEmpty(teamshifts)){
|
||||
cal.setShiftType(teamshifts.get(0).getShiftType());
|
||||
}
|
||||
}
|
||||
return calendars;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CalCalendar> getCalendarByUser(Date day, Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.ktg.mes.cal.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ktg.mes.cal.mapper.CalTeamshiftMapper;
|
||||
import com.ktg.mes.cal.domain.CalTeamshift;
|
||||
import com.ktg.mes.cal.service.ICalTeamshiftService;
|
||||
|
||||
/**
|
||||
* 班组排班Service业务层处理
|
||||
*
|
||||
* @author yinjinlu
|
||||
* @date 2022-06-11
|
||||
*/
|
||||
@Service
|
||||
public class CalTeamshiftServiceImpl implements ICalTeamshiftService
|
||||
{
|
||||
@Autowired
|
||||
private CalTeamshiftMapper calTeamshiftMapper;
|
||||
|
||||
/**
|
||||
* 查询班组排班
|
||||
*
|
||||
* @param recordId 班组排班主键
|
||||
* @return 班组排班
|
||||
*/
|
||||
@Override
|
||||
public CalTeamshift selectCalTeamshiftByRecordId(Long recordId)
|
||||
{
|
||||
return calTeamshiftMapper.selectCalTeamshiftByRecordId(recordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询班组排班列表
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 班组排班
|
||||
*/
|
||||
@Override
|
||||
public List<CalTeamshift> selectCalTeamshiftList(CalTeamshift calTeamshift)
|
||||
{
|
||||
return calTeamshiftMapper.selectCalTeamshiftList(calTeamshift);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增班组排班
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCalTeamshift(CalTeamshift calTeamshift)
|
||||
{
|
||||
calTeamshift.setCreateTime(DateUtils.getNowDate());
|
||||
return calTeamshiftMapper.insertCalTeamshift(calTeamshift);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改班组排班
|
||||
*
|
||||
* @param calTeamshift 班组排班
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCalTeamshift(CalTeamshift calTeamshift)
|
||||
{
|
||||
calTeamshift.setUpdateTime(DateUtils.getNowDate());
|
||||
return calTeamshiftMapper.updateCalTeamshift(calTeamshift);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除班组排班
|
||||
*
|
||||
* @param recordIds 需要删除的班组排班主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCalTeamshiftByRecordIds(Long[] recordIds)
|
||||
{
|
||||
return calTeamshiftMapper.deleteCalTeamshiftByRecordIds(recordIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除班组排班信息
|
||||
*
|
||||
* @param recordId 班组排班主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCalTeamshiftByRecordId(Long recordId)
|
||||
{
|
||||
return calTeamshiftMapper.deleteCalTeamshiftByRecordId(recordId);
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.ktg.mes.cal.utils;
|
||||
|
||||
import com.ktg.mes.cal.domain.CalCalendar;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
|
||||
public class CalendarUtil {
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
private static Date getMonthStart(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
int index = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
calendar.add(Calendar.DATE, (1 - index));
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
private static Date getMonthEnd(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.MONTH, 1);
|
||||
int index = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
calendar.add(Calendar.DATE, (-index));
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
private static Date getNext(Date date) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
public static Long getDateDiff(Date start,Date end){
|
||||
LocalDate sdate = LocalDate.parse(sdf.format(start),formatter);
|
||||
LocalDate edate = LocalDate.parse(sdf.format(end),formatter);
|
||||
return edate.until(sdate,ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
public static Long getDateDiff(String start,Date end){
|
||||
LocalDate sdate = LocalDate.parse(start,formatter);
|
||||
LocalDate edate = LocalDate.parse(sdf.format(end),formatter);
|
||||
return edate.until(sdate,ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
public static Long getDateDiff(Date start,String end){
|
||||
LocalDate sdate = LocalDate.parse(sdf.format(start),formatter);
|
||||
LocalDate edate = LocalDate.parse(sdf.format(end),formatter);
|
||||
return edate.until(sdate,ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个日期之间的天数差值
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
public static Long getDateDiff(String start,String end){
|
||||
LocalDate sdate = LocalDate.parse(start,formatter);
|
||||
LocalDate edate = LocalDate.parse(end,formatter);
|
||||
return edate.until(sdate,ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定月份的所有日期
|
||||
* @param d
|
||||
* @return
|
||||
*/
|
||||
public static List<CalCalendar> getDays(Date d){
|
||||
List<CalCalendar> lst=new ArrayList();
|
||||
Date date = getMonthStart(d);
|
||||
Date monthEnd = getMonthEnd(d);
|
||||
while (!date.after(monthEnd)) {
|
||||
CalCalendar cal = new CalCalendar();
|
||||
cal.setTheDay(sdf.format(date));
|
||||
lst.add(cal);
|
||||
date = getNext(date);
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="shiftType" column="shift_type" />
|
||||
<result property="shiftMethod" column="shift_method" />
|
||||
<result property="shiftCount" column="shift_count" />
|
||||
<result property="status" column="status" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="attr1" column="attr1" />
|
||||
<result property="attr2" column="attr2" />
|
||||
@ -26,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCalPlanVo">
|
||||
select plan_id, plan_code, plan_name,calendar_type, start_date, end_date, shift_type, shift_method, shift_count, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_plan
|
||||
select plan_id, plan_code, plan_name,calendar_type, start_date, end_date, shift_type, shift_method, shift_count,status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_plan
|
||||
</sql>
|
||||
|
||||
<select id="selectCalPlanList" parameterType="CalPlan" resultMap="CalPlanResult">
|
||||
@ -35,11 +36,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="planCode != null "> and plan_code like concat('%', #{planCode}, '%')</if>
|
||||
<if test="planName != null and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
|
||||
<if test="calendarType != null and calendarType != ''"> and calendar_type =#{calendarType}</if>
|
||||
<if test="startDate != null "> and start_date = #{startDate}</if>
|
||||
<if test="endDate != null "> and end_date = #{endDate}</if>
|
||||
<if test="startDate != null "> and start_date >= #{startDate}</if>
|
||||
<if test="endDate != null "> and end_date $lt; #{endDate}</if>
|
||||
<if test="shiftType != null and shiftType != ''"> and shift_type = #{shiftType}</if>
|
||||
<if test="shiftMethod != null and shiftMethod != ''"> and shift_method = #{shiftMethod}</if>
|
||||
<if test="shiftCount != null "> and shift_count = #{shiftCount}</if>
|
||||
<if test="status != and status !='' "> and status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
@ -59,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="shiftType != null">shift_type,</if>
|
||||
<if test="shiftMethod != null">shift_method,</if>
|
||||
<if test="shiftCount != null">shift_count,</if>
|
||||
<if test="status != null and status !=''">status,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="attr1 != null">attr1,</if>
|
||||
<if test="attr2 != null">attr2,</if>
|
||||
@ -78,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="shiftType != null">#{shiftType},</if>
|
||||
<if test="shiftMethod != null">#{shiftMethod},</if>
|
||||
<if test="shiftCount != null">#{shiftCount},</if>
|
||||
<if test="status != null and status !=''">#{status},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
<if test="attr2 != null">#{attr2},</if>
|
||||
@ -101,6 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="shiftType != null">shift_type = #{shiftType},</if>
|
||||
<if test="shiftMethod != null">shift_method = #{shiftMethod},</if>
|
||||
<if test="shiftCount != null">shift_count = #{shiftCount},</if>
|
||||
<if test="status != null and status !=''">status = #{status},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="attr1 != null">attr1 = #{attr1},</if>
|
||||
<if test="attr2 != null">attr2 = #{attr2},</if>
|
||||
|
133
ktg-mes/src/main/resources/mapper/cal/CalTeamshiftMapper.xml
Normal file
133
ktg-mes/src/main/resources/mapper/cal/CalTeamshiftMapper.xml
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ktg.mes.cal.mapper.CalTeamshiftMapper">
|
||||
|
||||
<resultMap type="CalTeamshift" id="CalTeamshiftResult">
|
||||
<result property="recordId" column="record_id" />
|
||||
<result property="theDay" column="the_day" />
|
||||
<result property="teamId" column="team_id" />
|
||||
<result property="teamName" column="team_name" />
|
||||
<result property="shiftId" column="shift_id" />
|
||||
<result property="shiftName" column="shift_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="planId" column="plan_id" />
|
||||
<result property="calendarType" column="calendar_type" />
|
||||
<result property="shiftType" column="shift_type" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="attr1" column="attr1" />
|
||||
<result property="attr2" column="attr2" />
|
||||
<result property="attr3" column="attr3" />
|
||||
<result property="attr4" column="attr4" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCalTeamshiftVo">
|
||||
select record_id, the_day, team_id, team_name, shift_id, shift_name, order_num, plan_id,calendar_type, shift_type, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_teamshift
|
||||
</sql>
|
||||
|
||||
<select id="selectCalTeamshiftList" parameterType="CalTeamshift" resultMap="CalTeamshiftResult">
|
||||
<include refid="selectCalTeamshiftVo"/>
|
||||
<where>
|
||||
<if test="theDay != null "> and the_day = #{theDay}</if>
|
||||
<if test="teamId != null "> and team_id = #{teamId}</if>
|
||||
<if test="teamName != null and teamName != ''"> and team_name like concat('%', #{teamName}, '%')</if>
|
||||
<if test="shiftId != null "> and shift_id = #{shiftId}</if>
|
||||
<if test="shiftName != null and shiftName != ''"> and shift_name like concat('%', #{shiftName}, '%')</if>
|
||||
<if test="orderNum != null "> and order_num = #{orderNum}</if>
|
||||
<if test="planId != null "> and plan_id = #{planId}</if>
|
||||
<if test="calendarType != null "> and calendar_type = #{calendarType}</if>
|
||||
<if test="shiftType != null and shiftType != ''"> and shift_type = #{shiftType}</if>
|
||||
</where>
|
||||
order by order_num asc
|
||||
</select>
|
||||
|
||||
<select id="selectCalTeamshiftByRecordId" parameterType="Long" resultMap="CalTeamshiftResult">
|
||||
<include refid="selectCalTeamshiftVo"/>
|
||||
where record_id = #{recordId}
|
||||
</select>
|
||||
|
||||
<insert id="insertCalTeamshift" parameterType="CalTeamshift" useGeneratedKeys="true" keyProperty="recordId">
|
||||
insert into cal_teamshift
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="theDay != null">the_day,</if>
|
||||
<if test="teamId != null">team_id,</if>
|
||||
<if test="teamName != null">team_name,</if>
|
||||
<if test="shiftId != null">shift_id,</if>
|
||||
<if test="shiftName != null">shift_name,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="planId != null">plan_id,</if>
|
||||
<if test="calendarType != null">calendar_type,</if>
|
||||
<if test="shiftType != null">shift_type,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="attr1 != null">attr1,</if>
|
||||
<if test="attr2 != null">attr2,</if>
|
||||
<if test="attr3 != null">attr3,</if>
|
||||
<if test="attr4 != null">attr4,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="theDay != null">#{theDay},</if>
|
||||
<if test="teamId != null">#{teamId},</if>
|
||||
<if test="teamName != null">#{teamName},</if>
|
||||
<if test="shiftId != null">#{shiftId},</if>
|
||||
<if test="shiftName != null">#{shiftName},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="planId != null">#{planId},</if>
|
||||
<if test="calendarType != null">#{calendarType},</if>
|
||||
<if test="shiftType != null">#{shiftType},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
<if test="attr2 != null">#{attr2},</if>
|
||||
<if test="attr3 != null">#{attr3},</if>
|
||||
<if test="attr4 != null">#{attr4},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateCalTeamshift" parameterType="CalTeamshift">
|
||||
update cal_teamshift
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="theDay != null">the_day = #{theDay},</if>
|
||||
<if test="teamId != null">team_id = #{teamId},</if>
|
||||
<if test="teamName != null">team_name = #{teamName},</if>
|
||||
<if test="shiftId != null">shift_id = #{shiftId},</if>
|
||||
<if test="shiftName != null">shift_name = #{shiftName},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="planId != null">plan_id = #{planId},</if>
|
||||
<if test="calendarType != null">calendar_type = #{calendarType},</if>
|
||||
<if test="shiftType != null">shift_type = #{shiftType},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="attr1 != null">attr1 = #{attr1},</if>
|
||||
<if test="attr2 != null">attr2 = #{attr2},</if>
|
||||
<if test="attr3 != null">attr3 = #{attr3},</if>
|
||||
<if test="attr4 != null">attr4 = #{attr4},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCalTeamshiftByRecordId" parameterType="Long">
|
||||
delete from cal_teamshift where record_id = #{recordId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCalTeamshiftByRecordIds" parameterType="String">
|
||||
delete from cal_teamshift where record_id in
|
||||
<foreach item="recordId" collection="array" open="(" separator="," close=")">
|
||||
#{recordId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user