添加排班类型

This commit is contained in:
JinLu.Yin 2022-06-08 20:16:44 +08:00
parent bae7d944b6
commit 1d2e7d5e3a
15 changed files with 155 additions and 30 deletions

View File

@ -131,8 +131,14 @@ public class UserConstants
public static final String TRANSACTION_TYPE_MISC_RECPT = "MISC_RECPT"; //杂项入库 public static final String TRANSACTION_TYPE_MISC_RECPT = "MISC_RECPT"; //杂项入库
public static final String TRANSACTION_TYPE_MISC_ISSUE = "MISC_ISSUE"; //杂项出库 public static final String TRANSACTION_TYPE_MISC_ISSUE = "MISC_ISSUE"; //杂项出库
/**
* 轮班方式
*/
public static final String CAL_SHIFT_TYPE_SINGLE="SINGLE"; public static final String CAL_SHIFT_TYPE_SINGLE="SINGLE";
public static final String CAL_SHIFT_TYPE_TWO="SHIFT_TWO"; public static final String CAL_SHIFT_TYPE_TWO="SHIFT_TWO";
public static final String CAL_SHIFT_TYPE_THREE="SHIFT_THREE"; public static final String CAL_SHIFT_TYPE_THREE="SHIFT_THREE";
public static final String CAL_SHIFT_NAME_DAY="白班";
public static final String CAL_SHIFT_NAME_NIGHT="夜班";
public static final String CAL_SHIFT_NAME_MID="中班";
} }

View File

@ -2,8 +2,12 @@ package com.ktg.mes.cal.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ktg.mes.cal.service.ICalPlanTeamService;
import com.ktg.mes.cal.service.ICalShiftService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -34,6 +38,12 @@ public class CalPlanController extends BaseController
@Autowired @Autowired
private ICalPlanService calPlanService; private ICalPlanService calPlanService;
@Autowired
private ICalShiftService calShiftService;
@Autowired
private ICalPlanTeamService calPlanTeamService;
/** /**
* 查询排班计划列表 * 查询排班计划列表
*/ */
@ -74,10 +84,14 @@ public class CalPlanController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('mes:cal:calplan:add')") @PreAuthorize("@ss.hasPermi('mes:cal:calplan:add')")
@Log(title = "排班计划", businessType = BusinessType.INSERT) @Log(title = "排班计划", businessType = BusinessType.INSERT)
@Transactional
@PostMapping @PostMapping
public AjaxResult add(@RequestBody CalPlan calPlan) public AjaxResult add(@RequestBody CalPlan calPlan)
{ {
return toAjax(calPlanService.insertCalPlan(calPlan)); int ret = calPlanService.insertCalPlan(calPlan);
//根据选择的轮班方式生成默认的班次
calShiftService.addDefaultShift(calPlan.getPlanId(),calPlan.getShiftType());
return toAjax(ret);
} }
/** /**
@ -96,9 +110,15 @@ public class CalPlanController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('mes:cal:calplan:remove')") @PreAuthorize("@ss.hasPermi('mes:cal:calplan:remove')")
@Log(title = "排班计划", businessType = BusinessType.DELETE) @Log(title = "排班计划", businessType = BusinessType.DELETE)
@Transactional
@DeleteMapping("/{planIds}") @DeleteMapping("/{planIds}")
public AjaxResult remove(@PathVariable Long[] planIds) public AjaxResult remove(@PathVariable Long[] planIds)
{ {
for (Long planId:planIds
) {
calShiftService.deleteByPlanId(planId);
calPlanTeamService.deleteByPlanId(planId);
}
return toAjax(calPlanService.deleteCalPlanByPlanIds(planIds)); return toAjax(calPlanService.deleteCalPlanByPlanIds(planIds));
} }
} }

View File

@ -107,17 +107,6 @@ public class CalShiftController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody CalShift calShift) public AjaxResult edit(@RequestBody CalShift calShift)
{ {
int count = calShiftService.checkShiftCount(calShift.getPlanId());
CalPlan plan = calPlanService.selectCalPlanByPlanId(calShift.getPlanId());
if(UserConstants.CAL_SHIFT_TYPE_SINGLE.equals(plan.getShiftType())&&count>0){
return AjaxResult.error("轮班方式为 白班 时只能有一个班次!");
}
if(UserConstants.CAL_SHIFT_TYPE_TWO.equals(plan.getShiftType())&&count>1){
return AjaxResult.error("轮班方式为 白班 时只能有两个班次!");
}
if(UserConstants.CAL_SHIFT_TYPE_THREE.equals(plan.getShiftType())&&count>2){
return AjaxResult.error("轮班方式为 白班 时只能有三个班次!");
}
return toAjax(calShiftService.updateCalShift(calShift)); return toAjax(calShiftService.updateCalShift(calShift));
} }

View File

@ -28,6 +28,8 @@ public class CalPlan extends BaseEntity
@Excel(name = "计划名称") @Excel(name = "计划名称")
private String planName; private String planName;
private String calendarType;
/** 开始日期 */ /** 开始日期 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "开始日期", width = 30, dateFormat = "yyyy-MM-dd")
@ -94,7 +96,15 @@ public class CalPlan extends BaseEntity
this.startDate = startDate; this.startDate = startDate;
} }
public Date getStartDate() public String getCalendarType() {
return calendarType;
}
public void setCalendarType(String calendarType) {
this.calendarType = calendarType;
}
public Date getStartDate()
{ {
return startDate; return startDate;
} }
@ -179,6 +189,7 @@ public class CalPlan extends BaseEntity
.append("planName", getPlanName()) .append("planName", getPlanName())
.append("startDate", getStartDate()) .append("startDate", getStartDate())
.append("endDate", getEndDate()) .append("endDate", getEndDate())
.append("calendarType", getCalendarType())
.append("shiftType", getShiftType()) .append("shiftType", getShiftType())
.append("shiftMethod", getShiftMethod()) .append("shiftMethod", getShiftMethod())
.append("shiftCount", getShiftCount()) .append("shiftCount", getShiftCount())

View File

@ -26,6 +26,8 @@ public class CalTeam extends BaseEntity
@Excel(name = "班组名称") @Excel(name = "班组名称")
private String teamName; private String teamName;
private String calendarType;
/** 预留字段1 */ /** 预留字段1 */
private String attr1; private String attr1;
@ -70,7 +72,15 @@ public class CalTeam extends BaseEntity
this.attr1 = attr1; this.attr1 = attr1;
} }
public String getAttr1() public String getCalendarType() {
return calendarType;
}
public void setCalendarType(String calendarType) {
this.calendarType = calendarType;
}
public String getAttr1()
{ {
return attr1; return attr1;
} }
@ -104,19 +114,15 @@ public class CalTeam extends BaseEntity
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return "CalTeam{" +
.append("teamId", getTeamId()) "teamId=" + teamId +
.append("teamCode", getTeamCode()) ", teamCode='" + teamCode + '\'' +
.append("teamName", getTeamName()) ", teamName='" + teamName + '\'' +
.append("remark", getRemark()) ", calendarType='" + calendarType + '\'' +
.append("attr1", getAttr1()) ", attr1='" + attr1 + '\'' +
.append("attr2", getAttr2()) ", attr2='" + attr2 + '\'' +
.append("attr3", getAttr3()) ", attr3=" + attr3 +
.append("attr4", getAttr4()) ", attr4=" + attr4 +
.append("createBy", getCreateBy()) '}';
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
} }
} }

View File

@ -60,4 +60,6 @@ public interface CalPlanTeamMapper
* @return 结果 * @return 结果
*/ */
public int deleteCalPlanTeamByRecordIds(Long[] recordIds); public int deleteCalPlanTeamByRecordIds(Long[] recordIds);
public int deleteByPlanId(Long planId);
} }

View File

@ -61,4 +61,6 @@ public interface CalShiftMapper
* @return 结果 * @return 结果
*/ */
public int deleteCalShiftByShiftIds(Long[] shiftIds); public int deleteCalShiftByShiftIds(Long[] shiftIds);
public int deleteByPlanId(Long planId);
} }

View File

@ -60,4 +60,6 @@ public interface ICalPlanTeamService
* @return 结果 * @return 结果
*/ */
public int deleteCalPlanTeamByRecordId(Long recordId); public int deleteCalPlanTeamByRecordId(Long recordId);
public int deleteByPlanId(Long plandId);
} }

View File

@ -29,6 +29,9 @@ public interface ICalShiftService
public int checkShiftCount(Long planId); public int checkShiftCount(Long planId);
public void addDefaultShift(Long plandId,String shiftType);
/** /**
* 新增计划班次 * 新增计划班次
* *
@ -60,4 +63,7 @@ public interface ICalShiftService
* @return 结果 * @return 结果
*/ */
public int deleteCalShiftByShiftId(Long shiftId); public int deleteCalShiftByShiftId(Long shiftId);
public int deleteByPlanId(Long planId);
} }

View File

@ -106,4 +106,9 @@ public class CalPlanTeamServiceImpl implements ICalPlanTeamService
{ {
return calPlanTeamMapper.deleteCalPlanTeamByRecordId(recordId); return calPlanTeamMapper.deleteCalPlanTeamByRecordId(recordId);
} }
@Override
public int deleteByPlanId(Long plandId) {
return calPlanTeamMapper.deleteByPlanId(plandId);
}
} }

View File

@ -1,6 +1,8 @@
package com.ktg.mes.cal.service.impl; package com.ktg.mes.cal.service.impl;
import java.util.List; import java.util.List;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -49,6 +51,56 @@ public class CalShiftServiceImpl implements ICalShiftService
return calShiftMapper.checkShiftCount(planId); return calShiftMapper.checkShiftCount(planId);
} }
@Override
public void addDefaultShift(Long plandId,String shiftType) {
if(UserConstants.CAL_SHIFT_TYPE_SINGLE.equals(shiftType)){
CalShift shift = new CalShift();
shift.setPlanId(plandId);
shift.setShiftName(UserConstants.CAL_SHIFT_NAME_DAY);
shift.setOrderNum(1);
shift.setStartTime("8:00");
shift.setEndTime("18:00");
calShiftMapper.insertCalShift(shift);
}else if(UserConstants.CAL_SHIFT_TYPE_TWO.equals(shiftType)){
CalShift shiftDay = new CalShift();
shiftDay.setPlanId(plandId);
shiftDay.setShiftName(UserConstants.CAL_SHIFT_NAME_DAY);
shiftDay.setOrderNum(1);
shiftDay.setStartTime("8:00");
shiftDay.setEndTime("20:00");
CalShift shiftNight = new CalShift();
shiftNight.setPlanId(plandId);
shiftNight.setShiftName(UserConstants.CAL_SHIFT_NAME_NIGHT);
shiftNight.setOrderNum(2);
shiftNight.setStartTime("20:00");
shiftNight.setEndTime("8:00");
calShiftMapper.insertCalShift(shiftDay);
calShiftMapper.insertCalShift(shiftNight);
}else {
CalShift shiftDay = new CalShift();
shiftDay.setPlanId(plandId);
shiftDay.setShiftName(UserConstants.CAL_SHIFT_NAME_DAY);
shiftDay.setOrderNum(1);
shiftDay.setStartTime("8:00");
shiftDay.setEndTime("16:00");
CalShift shiftMid = new CalShift();
shiftMid.setPlanId(plandId);
shiftMid.setShiftName(UserConstants.CAL_SHIFT_NAME_MID);
shiftMid.setOrderNum(2);
shiftMid.setStartTime("16:00");
shiftMid.setEndTime("24:00");
CalShift shiftNight = new CalShift();
shiftNight.setPlanId(plandId);
shiftNight.setShiftName(UserConstants.CAL_SHIFT_NAME_NIGHT);
shiftNight.setOrderNum(3);
shiftNight.setStartTime("00:00");
shiftNight.setEndTime("8:00");
calShiftMapper.insertCalShift(shiftDay);
calShiftMapper.insertCalShift(shiftMid);
calShiftMapper.insertCalShift(shiftNight);
}
}
/** /**
* 新增计划班次 * 新增计划班次
* *
@ -98,4 +150,9 @@ public class CalShiftServiceImpl implements ICalShiftService
{ {
return calShiftMapper.deleteCalShiftByShiftId(shiftId); return calShiftMapper.deleteCalShiftByShiftId(shiftId);
} }
@Override
public int deleteByPlanId(Long planId) {
return calShiftMapper.deleteByPlanId(planId);
}
} }

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="planId" column="plan_id" /> <result property="planId" column="plan_id" />
<result property="planCode" column="plan_code" /> <result property="planCode" column="plan_code" />
<result property="planName" column="plan_name" /> <result property="planName" column="plan_name" />
<result property="calendarType" column="calendar_type" />
<result property="startDate" column="start_date" /> <result property="startDate" column="start_date" />
<result property="endDate" column="end_date" /> <result property="endDate" column="end_date" />
<result property="shiftType" column="shift_type" /> <result property="shiftType" column="shift_type" />
@ -25,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectCalPlanVo"> <sql id="selectCalPlanVo">
select plan_id, plan_code, plan_name, 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, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_plan
</sql> </sql>
<select id="selectCalPlanList" parameterType="CalPlan" resultMap="CalPlanResult"> <select id="selectCalPlanList" parameterType="CalPlan" resultMap="CalPlanResult">
@ -33,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
<if test="planCode != null "> and plan_code like concat('%', #{planCode}, '%')</if> <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="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="startDate != null "> and start_date = #{startDate}</if>
<if test="endDate != null "> and end_date = #{endDate}</if> <if test="endDate != null "> and end_date = #{endDate}</if>
<if test="shiftType != null and shiftType != ''"> and shift_type = #{shiftType}</if> <if test="shiftType != null and shiftType != ''"> and shift_type = #{shiftType}</if>
@ -51,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planCode != null">plan_code,</if> <if test="planCode != null">plan_code,</if>
<if test="planName != null and planName != ''">plan_name,</if> <if test="planName != null and planName != ''">plan_name,</if>
<if test="calendarType != null and calendarType != ''">calendar_type,</if>
<if test="startDate != null">start_date,</if> <if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if> <if test="endDate != null">end_date,</if>
<if test="shiftType != null">shift_type,</if> <if test="shiftType != null">shift_type,</if>
@ -69,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planCode != null">#{planCode},</if> <if test="planCode != null">#{planCode},</if>
<if test="planName != null and planName != ''">#{planName},</if> <if test="planName != null and planName != ''">#{planName},</if>
<if test="calendarType != null and calendarType != ''">#{calendarType},</if>
<if test="startDate != null">#{startDate},</if> <if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if> <if test="endDate != null">#{endDate},</if>
<if test="shiftType != null">#{shiftType},</if> <if test="shiftType != null">#{shiftType},</if>
@ -91,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="planCode != null">plan_code = #{planCode},</if> <if test="planCode != null">plan_code = #{planCode},</if>
<if test="planName != null and planName != ''">plan_name = #{planName},</if> <if test="planName != null and planName != ''">plan_name = #{planName},</if>
<if test="calendarType != null and calendarType != ''">calendar_type = #{calendarType},</if>
<if test="startDate != null">start_date = #{startDate},</if> <if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if> <if test="endDate != null">end_date = #{endDate},</if>
<if test="shiftType != null">shift_type = #{shiftType},</if> <if test="shiftType != null">shift_type = #{shiftType},</if>

View File

@ -109,4 +109,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{recordId} #{recordId}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteByPlanId" parameterType="Long">
delete from cal_plan_team where plan_id = #{planId}
</delete>
</mapper> </mapper>

View File

@ -115,4 +115,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{shiftId} #{shiftId}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteByPlanId" parameterType="Long">
delete from cal_shift where plan_id = #{planId}
</delete>
</mapper> </mapper>

View File

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="teamId" column="team_id" /> <result property="teamId" column="team_id" />
<result property="teamCode" column="team_code" /> <result property="teamCode" column="team_code" />
<result property="teamName" column="team_name" /> <result property="teamName" column="team_name" />
<result property="calendarType" column="calendar_type" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="attr1" column="attr1" /> <result property="attr1" column="attr1" />
<result property="attr2" column="attr2" /> <result property="attr2" column="attr2" />
@ -20,13 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectCalTeamVo"> <sql id="selectCalTeamVo">
select team_id, team_code, team_name, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_team select team_id, team_code, team_name,calendar_type, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from cal_team
</sql> </sql>
<select id="selectCalTeamList" parameterType="CalTeam" resultMap="CalTeamResult"> <select id="selectCalTeamList" parameterType="CalTeam" resultMap="CalTeamResult">
<include refid="selectCalTeamVo"/> <include refid="selectCalTeamVo"/>
<where> <where>
<if test="teamCode != null and teamCode != ''"> and team_code = #{teamCode}</if> <if test="teamCode != null and teamCode != ''"> and team_code = #{teamCode}</if>
<if test="calendarType != null and calendarType != ''"> and calendar_type = #{calendarType}</if>
<if test="teamName != null and teamName != ''"> and team_name like concat('%', #{teamName}, '%')</if> <if test="teamName != null and teamName != ''"> and team_name like concat('%', #{teamName}, '%')</if>
</where> </where>
</select> </select>
@ -41,6 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="teamCode != null and teamCode != ''">team_code,</if> <if test="teamCode != null and teamCode != ''">team_code,</if>
<if test="teamName != null and teamName != ''">team_name,</if> <if test="teamName != null and teamName != ''">team_name,</if>
<if test="calendarType != null and calendarType != ''">calendar_type,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if> <if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if> <if test="attr2 != null">attr2,</if>
@ -54,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="teamCode != null and teamCode != ''">#{teamCode},</if> <if test="teamCode != null and teamCode != ''">#{teamCode},</if>
<if test="teamName != null and teamName != ''">#{teamName},</if> <if test="teamName != null and teamName != ''">#{teamName},</if>
<if test="calendarType != null and calendarType != ''">#{calendarType},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if> <if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if> <if test="attr2 != null">#{attr2},</if>
@ -71,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="teamCode != null and teamCode != ''">team_code = #{teamCode},</if> <if test="teamCode != null and teamCode != ''">team_code = #{teamCode},</if>
<if test="teamName != null and teamName != ''">team_name = #{teamName},</if> <if test="teamName != null and teamName != ''">team_name = #{teamName},</if>
<if test="calendarType != null and calendarType != ''">calendar_type = #{calendarType},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="attr1 != null">attr1 = #{attr1},</if> <if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if> <if test="attr2 != null">attr2 = #{attr2},</if>