Commit 1873b733 authored by 温志超's avatar 温志超

Merge remote-tracking branch 'origin/master'

parents 0b655343 deff2fc1
......@@ -22,6 +22,7 @@ import com.ximai.mes.cal.service.ICalPlanService;
import com.ximai.mes.cal.service.ICalPlanTeamService;
import com.ximai.mes.cal.service.ICalShiftService;
import io.swagger.annotations.ApiOperation;
import org.aspectj.bridge.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
......@@ -31,7 +32,10 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static com.ximai.common.utils.data.DateUtils.formatShiftDate;
......@@ -84,10 +88,12 @@ public class CalPlanController extends BaseController {
@PostMapping
@ApiOperation("排班计划新增")
public AjaxResult add(@RequestBody CalPlan calPlan) {
checkPlan(calPlan);
List<CalPlan> calPlans = calPlanMapper.selectListByQw(new QueryWrapper<CalPlan>().eq("plan_code", calPlan.getPlanCode()));
ExceptionUtil.checkTrueThrowException(CollectionUtil.isNotEmpty(calPlans), MessageUtils.message("cal.error.error1"));
checkPlan(calPlan);
// 插入方案
calPlanService.insertCalPlan(calPlan);
......@@ -117,168 +123,104 @@ public class CalPlanController extends BaseController {
private static void checkPlan(CalPlan calPlan) {
List<CalShift> calShifts = calPlan.getCalShifts();
ExceptionUtil.checkTrueThrowException(calShifts == null || CollectionUtil.isEmpty(calShifts), MessageUtils.message("cal.error.error2"));
Date planStartDate = calPlan.getStartDate();
Date planEndDate = calPlan.getEndDate();
ExceptionUtil.checkTrueThrowException(planStartDate == null || planEndDate == null, MessageUtils.message("cal.error.error3"));
ExceptionUtil.checkTrueThrowException(planStartDate.getTime() > planEndDate.getTime(), MessageUtils.message("cal.error.error4"));
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(calShifts), MessageUtils.message("cal.error.error5"));
ExceptionUtil.checkTrueThrowException(calPlan.getStartDate() == null || calPlan.getEndDate() == null, MessageUtils.message("cal.error.error3"));
ExceptionUtil.checkTrueThrowException(calPlan.getStartDate().getTime() > calPlan.getEndDate().getTime(), MessageUtils.message("cal.error.error4"));
long count = calShifts.stream().filter(x ->
ExceptionUtil.checkTrueThrowException(calShifts.stream().filter(x ->
(x.getEndTime() == null && x.getEndTime() == "") ||
(x.getStartTime() == null && x.getStartTime() == "")
).count();
ExceptionUtil.checkTrueThrowException(count > 0, MessageUtils.message("cal.error.error5"));
).count() > 0, MessageUtils.message("cal.error.error5"));
String shiftType = calPlan.getShiftType();
int size = calShifts.size();
ExceptionUtil.checkTrueThrowException(UserConstants.CAL_SHIFT_TYPE_SINGLE.equals(shiftType) && size != 1, MessageUtils.message("cal.error.error7"));
ExceptionUtil.checkTrueThrowException(UserConstants.CAL_SHIFT_TYPE_SINGLE.equals(shiftType) && size != 1, MessageUtils.message("cal.error.error6"));
ExceptionUtil.checkTrueThrowException(UserConstants.CAL_SHIFT_TYPE_TWO.equals(shiftType) && size != 2, MessageUtils.message("cal.error.error7"));
ExceptionUtil.checkTrueThrowException(UserConstants.CAL_SHIFT_TYPE_THREE.equals(shiftType) && size != 3, MessageUtils.message("cal.error.error8"));
Date shiftStartDate = null;
Date shiftEndDate = null;
Date startDate = calPlan.getStartDate();
Date endDate = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowDateFormat = sdf.format(planStartDate);
String startDateFormat = sdf.format(startDate);
String endDateFormat = sdf.format(startDate);
Set<Integer> collect2 = calShifts.stream().map(CalShift::getOrderNum).filter(Objects::nonNull).collect(Collectors.toSet());
ExceptionUtil.checkTrueThrowException(collect2.size() != calShifts.size(), MessageUtils.message("cal.error.error9"));
for (CalShift calShift : calShifts) {
String shiftName = calShift.getShiftName();
String nextDateFormat = null;
String endTime = calShift.getEndTime();
shiftStartDate = formatShiftDate(nowDateFormat, calShift.getStartTime());
shiftEndDate = formatShiftDate(nowDateFormat, endTime);
endDate = formatShiftDate(endDateFormat, calShift.getEndTime());
startDate = formatShiftDate(startDateFormat, calShift.getStartTime());
if (Objects.equals(shiftName, "夜班")) {
if (shiftStartDate.getTime() > shiftEndDate.getTime()) {
Date nextDay = DateUtils.getNextDay(planStartDate);
if (startDate.getTime() > endDate.getTime()) {
startDate = calPlan.getStartDate();
Date nextDay = DateUtils.getNextDay(startDate);
//今天日期
sdf = new SimpleDateFormat("yyyy-MM-dd");
nextDateFormat = sdf.format(nextDay);
shiftEndDate = formatShiftDate(nextDateFormat, endTime);
endDateFormat = sdf.format(nextDay);
endDate = formatShiftDate(endDateFormat, calShift.getEndTime());
}
}
ExceptionUtil.checkTrueThrowException(planStartDate.getTime() >= shiftStartDate.getTime(), shiftName + MessageUtils.message("cal.error.error22"));
ExceptionUtil.checkTrueThrowException(planEndDate.getTime() <= shiftEndDate.getTime(), shiftName + MessageUtils.message("cal.error.error23"));
calShift.setExecEndTime(shiftEndDate);
calShift.setExecStartTime(shiftStartDate);
ExceptionUtil.checkTrueThrowException(shiftEndDate.getTime() < shiftStartDate.getTime(),shiftName+ MessageUtils.message("cal.error.error24", shiftName));
List<CalShift> breakTimeList = calShift.getBreakTimeList();
if (CollectionUtil.isNotEmpty(breakTimeList)) {
Set<Integer> collect = breakTimeList.stream().map(CalShift::getOrderNum).filter(Objects::nonNull).collect(Collectors.toSet());
ExceptionUtil.checkTrueThrowException(collect.size() != breakTimeList.size(), MessageUtils.message("cal.error.error10"));
ExceptionUtil.checkTrueThrowException(endDate.getTime() <= startDate.getTime(),
MessageUtils.message("cal.error.error11", shiftName));
ExceptionUtil.checkTrueThrowException(shiftEndDate.getTime() <= shiftStartDate.getTime(), shiftName + MessageUtils.message("cal.error.error24", shiftName));
breakTimeList.sort(Comparator.comparing(CalShift::getOrderNum));
if (breakTimeList.size() == 2) {
CalShift calShift1 = breakTimeList.get(0);
Date breakStartDate1 = formatShiftDate(startDateFormat, calShift1.getBreakStartTime());
Date breakEndDate1 = formatShiftDate(endDateFormat, calShift1.getBreakEndTime());
CalShift calShift2 = breakTimeList.get(1);
String breakStartTime1 = calShift1.getBreakStartTime();
String breakEndTime1 = calShift1.getBreakEndTime();
ExceptionUtil.checkTrueThrowException(Objects.equals(breakStartTime1, breakEndTime1), MessageUtils.message("cal.error.error25"));
String breakStartTime2 = calShift2.getBreakStartTime();
String breakEndTime2 = calShift2.getBreakEndTime();
ExceptionUtil.checkTrueThrowException(Objects.equals(breakStartTime2, breakEndTime2), MessageUtils.message("cal.error.error25"));
Date breakStartDate1 = formatShiftDate(nowDateFormat, breakStartTime1);
Date breakEndDate1 = formatShiftDate(nowDateFormat, breakEndTime1);
Date breakStartDate2 = formatShiftDate(nowDateFormat, breakStartTime2);
Date breakEndDate2 = formatShiftDate(nowDateFormat, breakEndTime2);
Integer nextDay1 = calShift1.getNextDay();
if (nextDay1 != null && nextDay1 == 1) {
if (breakEndDate1.after(breakStartDate1)) {
breakStartDate1 = formatShiftDate(nextDateFormat, breakStartTime1);
breakEndDate1 = formatShiftDate(nextDateFormat, breakEndTime1);
} else {
breakEndDate1 = formatShiftDate(nextDateFormat, breakEndTime1);
}
}
Integer nextDay2 = calShift2.getNextDay();
if (nextDay2 != null && nextDay2 == 1) {
if (breakEndDate2.after(breakStartDate2)) {
breakStartDate2 = formatShiftDate(nextDateFormat, breakStartTime2);
breakEndDate2 = formatShiftDate(nextDateFormat, breakEndTime2);
} else {
breakEndDate2 = formatShiftDate(nextDateFormat, breakEndTime2);
}
}
Date breakStartDate2 = formatShiftDate(startDateFormat, calShift2.getBreakStartTime());
Date breakEndDate2 = formatShiftDate(endDateFormat, calShift2.getBreakEndTime());
ExceptionUtil.checkTrueThrowException(
!breakEndDate2.after(breakStartDate1),
shiftName + MessageUtils.message("cal.error.error28"));
(breakEndDate1.getTime() <= breakStartDate1.getTime()) ||
(breakEndDate2.getTime() <= breakStartDate2.getTime()),
MessageUtils.message("cal.error.error12", shiftName));
ExceptionUtil.checkTrueThrowException(shiftStartDate.after(breakStartDate1), shiftName + MessageUtils.message("cal.error.error26"));
ExceptionUtil.checkTrueThrowException(breakStartDate2.after(shiftEndDate), shiftName + MessageUtils.message("cal.error.error27"));
boolean afterA = breakEndDate1.after(breakStartDate1);
boolean afterB = breakStartDate2.after(breakEndDate1);
boolean afterC = breakEndDate2.after(breakStartDate2);
ExceptionUtil.checkTrueThrowException(
!(afterA && afterB && afterC),
MessageUtils.message("cal.error.error13", shiftName));
CalShift o1 = calShift1.deepCopyObj();
o1.setExecStartTime(breakStartDate1);
o1.setExecEndTime(breakEndDate1);
o1.setRestFlag(1);
o1.setOperType(1);
o1.setShiftName(shiftName);
CalShift o2 = calShift2.deepCopyObj();
o2.setExecStartTime(breakStartDate2);
o2.setExecEndTime(breakEndDate2);
o2.setRestFlag(1);
o2.setOperType(1);
o2.setShiftName(shiftName);
calShift.setBreakTimeList(Arrays.asList(o1, o2));
continue;
(breakEndDate1.getTime() > breakEndDate2.getTime() || breakStartDate1
.getTime() > breakStartDate2.getTime()) ||
!DateUtils.isTimePeriodOverlapping(breakStartDate1, breakEndDate1, breakStartDate2, breakEndDate2) ||
DateUtils.hasTimeOverlap(breakStartDate1, breakEndDate1, breakStartDate2, breakEndDate2),
MessageUtils.message("cal.error.error13", shiftName));
ExceptionUtil.checkTrueThrowException(
(breakStartDate1.getTime() < startDate.getTime()) ||
(breakStartDate2.getTime() < startDate.getTime()),
MessageUtils.message("cal.error.error14", shiftName));
ExceptionUtil.checkTrueThrowException(
(breakEndDate1.getTime() > endDate.getTime()) ||
(breakEndDate2.getTime() > endDate.getTime()),
MessageUtils.message("cal.error.error15", shiftName));
}
if (breakTimeList.size() == 1) {
CalShift calShift1 = breakTimeList.get(0);
String breakStartTime1 = calShift1.getBreakStartTime();
String breakEndTime1 = calShift1.getBreakEndTime();
Date breakStartDate1 = formatShiftDate(nowDateFormat, breakStartTime1);
Date breakEndDate1 = formatShiftDate(nowDateFormat, breakEndTime1);
Integer nextDay = calShift1.getNextDay();
if (nextDay != null && nextDay == 1) {
if (breakEndDate1.after(breakStartDate1)) {
breakStartDate1 = formatShiftDate(nextDateFormat, breakStartTime1);
breakEndDate1 = formatShiftDate(nextDateFormat, breakEndTime1);
} else {
breakEndDate1 = formatShiftDate(nextDateFormat, breakEndTime1);
}
}
ExceptionUtil.checkTrueThrowException(shiftStartDate.after(breakStartDate1), shiftName + MessageUtils.message("cal.error.error26"));
ExceptionUtil.checkTrueThrowException(breakEndDate1.after(shiftEndDate), shiftName + MessageUtils.message("cal.error.error27"));
ExceptionUtil.checkTrueThrowException(!breakEndDate1.after(breakStartDate1), MessageUtils.message("cal.error.error13"));
CalShift o = calShift1.deepCopyObj();
o.setExecEndTime(breakEndDate1);
o.setExecStartTime(breakStartDate1);
o.setRestFlag(1);
o.setOperType(1);
o.setShiftName(shiftName);
calShift.setBreakTimeList(Collections.singletonList(o));
continue;
Date breakStartDate1 = formatShiftDate(startDateFormat, calShift1.getBreakStartTime());
Date breakEndDate1 = formatShiftDate(endDateFormat, calShift1.getBreakEndTime());
ExceptionUtil.checkTrueThrowException(breakEndDate1.getTime() <= breakStartDate1.getTime(), MessageUtils.message("cal.error.error16", shiftName));
ExceptionUtil.checkTrueThrowException(breakStartDate1.getTime() < startDate.getTime(), MessageUtils.message("cal.error.error14", shiftName));
ExceptionUtil.checkTrueThrowException(breakEndDate1.getTime() > endDate.getTime(), MessageUtils.message("cal.error.error15", shiftName));
}
}
......@@ -294,13 +236,11 @@ public class CalPlanController extends BaseController {
@Log(title = "排班计划修改完成", businessType = BusinessType.UPDATE)
@PutMapping("/releasePlan")
public AjaxResult releasePlan(@RequestBody CalPlan calPlan) {
ExceptionUtil.checkTrueThrowException(!UserConstants.ORDER_STATUS_CONFIRMED.equals(calPlan.getStatus()), MessageUtils.message("cal.error.error17"));
checkPlan(calPlan);
ExceptionUtil.checkTrueThrowException(!UserConstants.ORDER_STATUS_CONFIRMED.equals(calPlan.getStatus()), MessageUtils.message("cal.error.error17"));
calPlan.setUpdateBy(SecurityUtils.getUsername());
calPlan.setUpdateTime(DateUtils.getNowDate());
calPlan.setCreateTime(DateUtils.getNowDate());
calPlan.setCreateBy(SecurityUtils.getUsername());
calPlanService.releasePlan(calPlan);
return AjaxResult.success();
}
......
......@@ -7,11 +7,13 @@ import com.ximai.common.core.controller.BaseController;
import com.ximai.common.core.domain.AjaxResult;
import com.ximai.common.core.page.TableDataInfo;
import com.ximai.common.enums.BusinessType;
import com.ximai.common.utils.MessageUtils;
import com.ximai.common.utils.data.ExceptionUtil;
import com.ximai.mes.cal.domain.CalPlanWorkunit;
import com.ximai.mes.cal.service.ICalPlanWorkunitService;
import com.ximai.mes.constant.CalPlanWorkunitEnum;
import io.swagger.annotations.ApiOperation;
import org.aspectj.bridge.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -95,14 +97,14 @@ public class CalPlanWorkunitController extends BaseController {
@Log(title = "计划工作单元", businessType = BusinessType.UPDATE)
@PutMapping(value = "/editList")
public AjaxResult editList(@RequestBody List<CalPlanWorkunit> calPlanWorkunits) {
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(calPlanWorkunits), "没有指定放假对象");
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(calPlanWorkunits), MessageUtils.message("cal.error.error20"));
long count = calPlanWorkunits.stream().filter(
x -> x.getWorkunitId() == null ||
x.getTheDay() == null ||
x.getShiftName() == null ||
x.getIsWork() == null).count();
ExceptionUtil.checkTrueThrowException(count > 0, "非法的更新数据");
ExceptionUtil.checkTrueThrowException(count > 0, MessageUtils.message("cal.error.error21"));
// workunit_id,the_day,shift_name
for (CalPlanWorkunit calPlanWorkunit : calPlanWorkunits) {
......@@ -130,6 +132,6 @@ public class CalPlanWorkunitController extends BaseController {
@Log(title = "计划工作单元删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{planWorkunitIds}")
public AjaxResult remove(@PathVariable Long[] planWorkunitIds) {
return toAjax(calPlanWorkunitService.deleteListByIds(planWorkunitIds));
return toAjax(calPlanWorkunitService.deleteCalPlanWorkunitByPlanWorkunitIds(planWorkunitIds));
}
}
......@@ -82,10 +82,10 @@ public class CalShiftController extends BaseController {
calShiftVoQueryWrapper.eq(StringUtils.isNotEmpty(calPlanWorkunit.getWorkunitId()), "cpw.workunit_id", calPlanWorkunit.getWorkunitId());
calShiftVoQueryWrapper.eq(StringUtils.isNotEmpty(calPlanWorkunit.getTheDay()), "cpw.the_day", calPlanWorkunit.getTheDay());
calShiftVoQueryWrapper.eq(StringUtils.isNotEmpty(calPlanWorkunit.getShiftName()), "ash.shift_name", calPlanWorkunit.getShiftName());
calShiftVoQueryWrapper.like(StringUtils.isNotEmpty(calPlanWorkunit.getWorkunitCode()), "cpw.workunit_code", calPlanWorkunit.getWorkunitCode());
calShiftVoQueryWrapper.apply(StringUtils.isNotEmpty(calPlanWorkunit.getWorkstationName()), "LOWER(mws.workstation_name) like CONCAT('%',LOWER({0}),'%')", calPlanWorkunit.getWorkstationName());
calShiftVoQueryWrapper.apply(StringUtils.isNotEmpty(calPlanWorkunit.getWorkshopName()), "LOWER(mws.workshop_name) like CONCAT('%',LOWER({0}),'%')", calPlanWorkunit.getWorkshopName());
calShiftVoQueryWrapper.like(StringUtils.isNotEmpty(calPlanWorkunit.getWorkstationName()), "mws.workstation_name", calPlanWorkunit.getWorkstationName());
calShiftVoQueryWrapper.like(StringUtils.isNotEmpty(calPlanWorkunit.getWorkshopName()), "mws.workshop_name", calPlanWorkunit.getWorkshopName());
return getDataTable(calShiftMapper.selectOnWorkShiftByQw(calShiftVoQueryWrapper));
}
......
......@@ -8,6 +8,7 @@ import com.ximai.common.enums.BusinessType;
import com.ximai.mes.cal.domain.CalWorkunit;
import com.ximai.mes.cal.service.ICalWorkunitService;
import com.ximai.mes.md.domain.MdWorkunit;
import com.ximai.mes.md.service.IMdWorkunitService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -32,6 +33,8 @@ public class CalWorkunitController extends BaseController {
@Autowired
private ICalWorkunitService calWorkunitService;
@Autowired
private IMdWorkunitService mdWorkunitService;
/**
* 查询计划工作单元列表
......@@ -55,26 +58,6 @@ public class CalWorkunitController extends BaseController {
return getDataTable(list);
}
/**
* 查询计划勾选的工作单元之外的所有工作的单元
*/
// @PreAuthorize("@ss.hasPermi('md:workunit:list')")
@GetMapping("/getWorkunitByPlanId")
public TableDataInfo getWorkunitByPlanId(CalWorkunit calWorkunit) {
List<CalWorkunit> calWorkunits = new ArrayList<>();
if (calWorkunit.getPlanId() != null) {
CalWorkunit checkAll = new CalWorkunit();
checkAll.setPlanId(calWorkunit.getPlanId());
calWorkunits = calWorkunitService.selectCalWorkunitList(checkAll);
}
startPage();
List<MdWorkunit> mdWorkunits = calWorkunitService.getWorkunitByPlanId(calWorkunit,calWorkunits);
return getDataTable(mdWorkunits);
}
@GetMapping("/calWorkunitList")
public AjaxResult calWorkunitList() {
List<CalWorkunit> list = calWorkunitService.selectCalWorkunitList(new CalWorkunit());
......@@ -102,7 +85,7 @@ public class CalWorkunitController extends BaseController {
@PreAuthorize("@ss.hasPermi('md:workunit:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(calWorkunitService.getObjById(id));
return AjaxResult.success(calWorkunitService.selectCalWorkunitById(id));
}
/**
......
......@@ -6,8 +6,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ximai.common.annotation.Excel;
import com.ximai.common.core.domain.BaseEntity;
......
......@@ -106,6 +106,7 @@ public class CalPlan extends BaseEntity {
* 预留字段4
*/
private Long attr4;
@ApiModelProperty(value = "轮班班次列表")
private List<CalShift> calShifts;
......
......@@ -35,20 +35,7 @@ public class CalPlanWorkunit extends BaseEntity {
@ApiModelProperty(value = "计划id")
@Excel(name = "计划ID")
private Long planId;
/**
* 计划ID
*/
@ApiModelProperty(value = "计划id")
@Excel(name = "计划ID")
private String planCode;
/**
* 计划ID
*/
@ApiModelProperty(value = "计划id")
@Excel(name = "计划ID")
private String planName;
@ApiModelProperty(value = "班次类型")
private String shiftType;
......@@ -134,12 +121,6 @@ public class CalPlanWorkunit extends BaseEntity {
@Excel(name = "结束时间")
private Date endDate;
/**
* 开始数据和结束时间
*/
@TableField(exist = false)
private String workDate;
// /**
// * 开始时间
......
......@@ -26,8 +26,6 @@ public class CalShift extends BaseEntity {
@TableField(exist = false)
private int restFlag = 0;
@TableField(exist = false)
private Integer nextDay;
/**
......@@ -45,7 +43,6 @@ public class CalShift extends BaseEntity {
private Long planId;
private String planCode;
private String planName;
@ApiModelProperty(value = "排列顺序")
/**
......@@ -79,20 +76,20 @@ public class CalShift extends BaseEntity {
@Excel(name = "结束时间")
private String endTime;
//
// /**
// * 开始时间
// */
// @ApiModelProperty(value = "开始时间")
// @Excel(name = "开始时间")
// private Date startDate;
//
// /**
// * 结束时间
// */
// @ApiModelProperty(value = "结束时间")
// @Excel(name = "结束时间")
// private Date endDate;
/**
* 开始时间
*/
@ApiModelProperty(value = "开始时间")
@Excel(name = "开始时间")
private Date startDate;
/**
* 结束时间
*/
@ApiModelProperty(value = "结束时间")
@Excel(name = "结束时间")
private Date endDate;
@ApiModelProperty(value = "休息开始时间")
private String breakStartTime;
......@@ -124,7 +121,4 @@ public class CalShift extends BaseEntity {
private List<CalShift> breakTimeList = new ArrayList<>();
private Date execStartTime;
private Date execEndTime;
}
......@@ -66,7 +66,7 @@ public class CalWorkunit extends BaseEntity {
@TableField(exist = false)
private String workstationCode;
@TableField(exist = false)
private String workstationName;
......
......@@ -40,7 +40,6 @@ public class CalShiftVo extends BaseEntity implements Comparable<CalShiftVo> {
*/
private Long planId;
private String planCode;
private String planName;
/**
* 序号
......@@ -117,6 +116,5 @@ public class CalShiftVo extends BaseEntity implements Comparable<CalShiftVo> {
private String workstationName;
private String workshopName;
private Integer nextDay;
private List<CalShiftVo> breakTimeList = new ArrayList<>();
}
......@@ -3,7 +3,6 @@ package com.ximai.mes.cal.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ximai.mes.cal.domain.CalPlanWorkunit;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
......@@ -55,11 +54,6 @@ public interface CalPlanWorkunitMapper extends BaseMapper<CalPlanWorkunit> {
*/
int deleteCalPlanWorkunitByid(Long planWorkunitId);
@Delete("delete from cal_plan_workunit where plan_code = #{planCode}")
int deleteByPlanCode(@Param("planCode") String planCode);
/**
* 批量删除计划工作单元
*
......
......@@ -3,10 +3,8 @@ package com.ximai.mes.cal.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ximai.mes.cal.domain.CalWorkunit;
import com.ximai.mes.md.domain.MdWorkunit;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.core.parameters.P;
import java.util.List;
......@@ -43,17 +41,6 @@ public interface CalWorkunitMapper extends BaseMapper<CalWorkunit> {
@Select("select t1.*,t2.workstation_id,t2.workstation_code,t3.workstation_name,t4.workshop_id,t4.workshop_code,t4.workshop_name,t5.factory_id,t5.factory_code,t5.factory_name from cal_workunit t1 inner join md_workunit t2 on t1.workunit_id = t2.workunit_id inner join md_workstation t3 on t2.workstation_id = t3.workstation_id inner join md_workshop t4 on t4.workshop_id = t3.workshop_id inner join md_factory t5 on t5.factory_id = t4.factory_id ${ew.customSqlSegment}")
List<CalWorkunit> selectListByQw(@Param("ew") QueryWrapper<CalWorkunit> query);
/**
* 关联工作中心查询作业单元列表
*
* @param query
* @return
*/
@Select("select distinct t1.*,t2.workstation_id,t2.workstation_code,t3.workstation_name,t4.workshop_id,t4.workshop_code,t4.workshop_name,t5.factory_id,t5.factory_code,t5.factory_name from cal_workunit t1 inner join md_workunit t2 on t1.workunit_id = t2.workunit_id inner join md_workstation t3 on t2.workstation_id = t3.workstation_id inner join md_workshop t4 on t4.workshop_id = t3.workshop_id inner join md_factory t5 on t5.factory_id = t4.factory_id ${ew.customSqlSegment}")
List<MdWorkunit> selectListByQwV2(@Param("ew") QueryWrapper<CalWorkunit> query);
/**
* 新增计划工作单元
*
......@@ -89,10 +76,4 @@ public interface CalWorkunitMapper extends BaseMapper<CalWorkunit> {
int deleteCalWorkunitByPlanId(Long planId);
int deleteCalWorkunitByPlanCode(String planCode);
List<MdWorkunit> selectMdworkunitList(@Param("workunitCode") String workunitCode,
@Param("workunitName") String workunitName,
@Param("workstationName")String workstationName,
@Param("workshopName")String workshopName,
@Param("workunitCodes")List<String> workunitCodes);
}
......@@ -70,7 +70,7 @@ public interface ICalPlanWorkunitService {
* @param planWorkunitIds 需要删除的计划工作单元主键集合
* @return 结果
*/
int deleteListByIds(Long[] planWorkunitIds);
int deleteCalPlanWorkunitByPlanWorkunitIds(Long[] planWorkunitIds);
/**
* 删除计划工作单元信息
......
......@@ -2,7 +2,6 @@ package com.ximai.mes.cal.service;
import java.util.List;
import com.ximai.mes.cal.domain.CalPlan;
import com.ximai.mes.cal.domain.CalTeamshift;
import org.springframework.scheduling.annotation.Async;
......
package com.ximai.mes.cal.service;
import com.ximai.common.core.page.TableDataInfo;
import com.ximai.mes.cal.domain.CalWorkunit;
import com.ximai.mes.md.domain.MdWorkunit;
......@@ -19,7 +18,7 @@ public interface ICalWorkunitService {
* @param id 计划工作单元主键
* @return 计划工作单元
*/
CalWorkunit getObjById(Long id);
CalWorkunit selectCalWorkunitById(Long id);
/**
* 查询计划工作单元列表
......@@ -67,6 +66,4 @@ public interface ICalWorkunitService {
void deleteCalWorkunitByPlanCode(String planCode);
List<MdWorkunit> getWorkunitByPlanId(CalWorkunit calWorkunit,List<CalWorkunit> calWorkunits);
}
......@@ -14,13 +14,10 @@ import com.ximai.mes.cal.mapper.CalTeamMemberMapper;
import com.ximai.mes.cal.mapper.CalTeamshiftMapper;
import com.ximai.mes.cal.service.ICalCalendarService;
import com.ximai.mes.cal.utils.MesCalendarUtil;
import com.ximai.mes.md.domain.MdWorkunit;
import com.ximai.mes.md.mapper.MdWorkunitMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -37,9 +34,6 @@ public class CalCalendarServiceImpl implements ICalCalendarService {
@Autowired
private CalTeamMemberMapper calTeamMemberMapper;
@Autowired
private MdWorkunitMapper mdWorkunitMapper;
@Autowired
private CalPlanWorkunitMapper calPlanWorkunitMapper;
......@@ -129,23 +123,6 @@ public class CalCalendarServiceImpl implements ICalCalendarService {
List<CalPlanWorkunit> resultCalPlanWorkunits = new ArrayList<>();
for (Map.Entry<String, List<CalPlanWorkunit>> entry : groupBy.entrySet()) {
//获取当天的时间
switch ( entry.getValue().get(0).getShiftName()){
case "白班":
String s = CalPlanWorkunitUp(entry);
entry.getValue().get(0).setWorkDate(s);
break;
case "中班":
String s1 = CalPlanWorkunitCentre(entry);
entry.getValue().get(0).setWorkDate(s1);
break;
case "夜班":
String s2 = CalPlanWorkunitCentre(entry);
entry.getValue().get(0).setWorkDate(s2);
break;
default:
break;
}
resultCalPlanWorkunits.add(entry.getValue().get(0));
}
if (CollUtil.isNotEmpty(resultCalPlanWorkunits)) {
......@@ -190,15 +167,11 @@ public class CalCalendarServiceImpl implements ICalCalendarService {
public List<CalCalendar> getCalendarByWorkunit(Date day, CalCalendar calCalendar) {
List<CalCalendar> calendars = MesCalendarUtil.getDays(day);
for (CalCalendar cal : calendars) {
MdWorkunit mdWorkunit1 = new MdWorkunit();
mdWorkunit1.setWorkunitId(calCalendar.getWorkunitId());
mdWorkunitMapper.selectMdWorkunitLists(mdWorkunit1);
CalPlanWorkunit param = new CalPlanWorkunit();
param.setIsWork(calCalendar.getIsWork());
param.setTheDay(cal.getTheDay());
if (calCalendar.getWorkunitName() != null && calCalendar.getWorkunitId() != null) {
if (calCalendar.getWorkunitName() != null) {
param.setWorkunitName(calCalendar.getWorkunitName());
param.setWorkunitId(calCalendar.getWorkunitId());
}
List<CalPlanWorkunit> calPlanWorkunits = calPlanWorkunitMapper.selectCalPlanWorkunitListV2(param);
......@@ -206,25 +179,7 @@ public class CalCalendarServiceImpl implements ICalCalendarService {
List<CalPlanWorkunit> resultCalPlanWorkunits = new ArrayList<>();
for (Map.Entry<String, List<CalPlanWorkunit>> entry : groupBy.entrySet()) {
//获取当天的时间
switch ( entry.getValue().get(0).getShiftName()){
case "白班":
String s = CalPlanWorkunitUp(entry);
entry.getValue().get(0).setWorkDate(s);
break;
case "中班":
String s1 = CalPlanWorkunitCentre(entry);
entry.getValue().get(0).setWorkDate(s1);
break;
case "夜班":
String s2 = CalPlanWorkunitCentre(entry);
entry.getValue().get(0).setWorkDate(s2);
break;
default:
break;
}
resultCalPlanWorkunits.add(entry.getValue().get(0));
resultCalPlanWorkunits.add(entry.getValue().get(0));
}
if (CollUtil.isNotEmpty(resultCalPlanWorkunits)) {
......@@ -239,38 +194,6 @@ public class CalCalendarServiceImpl implements ICalCalendarService {
}
//白天的时间拼接
public String CalPlanWorkunitUp(Map.Entry<String, List<CalPlanWorkunit>> entry){
Date startDate = entry.getValue().get(0).getStartDate();
Date endDate = entry.getValue().get(0).getEndDate();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDates= formatter.format(startDate);
String endDates = formatter.format(endDate);
String a=startDates+"--"+endDates+"\n";
Date startDate1 = entry.getValue().get(1).getStartDate();
Date endDate1 = entry.getValue().get(1).getEndDate();
String startDates1= formatter.format(startDate1);
String endDates1 = formatter.format(endDate1);
String b=startDates1+"--"+endDates1+"\n";
Date startDate2 = entry.getValue().get(2).getStartDate();
Date endDate2 = entry.getValue().get(2).getEndDate();
String startDates2= formatter.format(startDate2);
String endDates2 = formatter.format(endDate2);
String c=startDates2+"--"+endDates2;
return a+b+c;
}
//中班和中班
public String CalPlanWorkunitCentre(Map.Entry<String, List<CalPlanWorkunit>> entry){
Date startDate = entry.getValue().get(0).getStartDate();
Date endDate = entry.getValue().get(0).getEndDate();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDates= formatter.format(startDate);
String endDates = formatter.format(endDate);
String a=startDates+"--"+endDates;
return a;
}
private List<CalPlanWorkunit> queryCalendarMountData(CalPlanWorkunit calPlanWorkunit) {
List<CalPlanWorkunit> calPlanWorkunits = calPlanWorkunitMapper.selectCalPlanWorkunitListV2(calPlanWorkunit);
Map<String, List<CalPlanWorkunit>> groupBy = calPlanWorkunits.stream().collect(Collectors.groupingBy(x -> x.getWorkunitId() + ":" + x.getShiftName()));
......
......@@ -2,6 +2,7 @@ package com.ximai.mes.cal.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.common.utils.MessageUtils;
import com.ximai.common.utils.data.DateUtils;
import com.ximai.common.utils.data.ExceptionUtil;
import com.ximai.mes.cal.domain.CalPlan;
......@@ -32,6 +33,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import static com.ximai.common.utils.data.DateUtils.formatShiftDate;
import static com.ximai.common.utils.data.DateUtils.getWeekendByMonth;
import static com.ximai.mes.cal.utils.MesCalendarUtil.addDays;
......@@ -98,38 +100,23 @@ public class CalPlanServiceImpl implements ICalPlanService {
@Override
public void updateRelationship(CalPlan calPlan) {
// String planCode = calPlan.getPlanCode();
CalPlan calPlan1 = this.selectCalPlanByPlanId(calPlan.getPlanId());
String planCode = calPlan1.getPlanCode();
String planName = calPlan1.getPlanName();
calPlan.setPlanCode(planCode);
calPlan.setPlanName(planName);
String planCode = calPlan.getPlanCode();
List<CalShift> calShifts2 = new ArrayList<>();
List<CalShift> calShifts = calPlan.getCalShifts();
calShiftMapper.deleteByPlanCode(planCode);
for (CalShift calShift : calShifts) {
calShift = calPlan.deepSetObjParameter(calShift);
calShift = calPlan.deepSetObj(calShift);
calShift.setShiftId(null);
calShift.setCreateTime(calPlan.getCreateTime());
calShift.setCreateBy(calPlan.getCreateBy());
calShift.setUpdateBy(calPlan.getUpdateBy());
calShift.setUpdateTime(calPlan.getUpdateTime());
calShift.setManualUpdate(true);
calShiftService.insertCalShift(calShift);
List<CalShift> breakTimeList = calShift.getBreakTimeList();
if (CollectionUtil.isNotEmpty(breakTimeList)) {
for (CalShift shift : breakTimeList) {
shift = calPlan.deepSetObjParameter(shift);
if (CollectionUtil.isNotEmpty(calShift.getBreakTimeList())) {
for (CalShift shift : calShift.getBreakTimeList()) {
shift = calPlan.deepSetObj(shift);
shift.setShiftId(null);
shift.setOrderNum(calShift.getOrderNum());
shift.setOperType(1);
shift.setShiftName(calShift.getShiftName());
shift.setCreateTime(calPlan.getCreateTime());
shift.setCreateBy(calPlan.getCreateBy());
shift.setUpdateBy(calPlan.getUpdateBy());
shift.setUpdateTime(calPlan.getUpdateTime());
shift.setManualUpdate(true);
calShiftService.insertCalShift(shift);
}
......@@ -200,16 +187,13 @@ public class CalPlanServiceImpl implements ICalPlanService {
* @param calWorkunits
*/
private static List<CalPlanWorkunit> generateShiftRecords(List<CalShift> shifts, CalPlan plan, List<String> list, List<CalWorkunit> calWorkunits) {
List<CalPlanWorkunit> saveList = new ArrayList<>();
for (String nowDate : list) {
for (CalWorkunit calWorkunit : calWorkunits) {
for (CalShift shift : shifts) {
CalPlanWorkunit calPlanWorkunit = new CalPlanWorkunit();
calPlanWorkunit.setPlanId(plan.getPlanId());
calPlanWorkunit.setPlanCode(plan.getPlanCode());
calPlanWorkunit.setPlanName(plan.getPlanName());
calPlanWorkunit.setShiftType(shift.getShiftType());
calPlanWorkunit.setShiftType(plan.getShiftType());
calPlanWorkunit.setShiftId(shift.getShiftId());
calPlanWorkunit.setShiftName(shift.getShiftName());
calPlanWorkunit.setIsWork(CalPlanWorkunitEnum.YES.getType());
......@@ -217,17 +201,14 @@ public class CalPlanServiceImpl implements ICalPlanService {
calPlanWorkunit.setWorkunitId(calWorkunit.getWorkunitId());
calPlanWorkunit.setWorkunitCode(calWorkunit.getWorkunitCode());
calPlanWorkunit.setWorkunitName(calWorkunit.getWorkunitName());
Date startDate = shift.getExecStartTime();
Date endDate = shift.getExecEndTime();
// Date Sdate = MesCalendarUtil.dateStrToDate(nowDate + " " + MesCalendarUtil.getDateHourStr(startDate));
// Date Edate = MesCalendarUtil.dateStrToDate(nowDate + " " + MesCalendarUtil.getDateHourStr(endDate));
if (startDate.getTime() > endDate.getTime()) {
calPlanWorkunit.setEndDate(addDays(endDate, 1));
Date date1 = MesCalendarUtil.dateStrToDate(nowDate + " " + MesCalendarUtil.getDateHourStr(shift.getStartDate()));
calPlanWorkunit.setStartDate(date1);
Date date = MesCalendarUtil.dateStrToDate(nowDate + " " + MesCalendarUtil.getDateHourStr(shift.getEndDate()));
if (date1.getTime() > date.getTime()) {
calPlanWorkunit.setEndDate(addDays(date, 1));
} else {
calPlanWorkunit.setEndDate(endDate);
calPlanWorkunit.setEndDate(date);
}
calPlanWorkunit.setStartDate(startDate);
calPlanWorkunit.setRestFlag(shift.getRestFlag());
saveList.add(calPlanWorkunit);
}
......@@ -277,55 +258,54 @@ public class CalPlanServiceImpl implements ICalPlanService {
@Override
public void genRecords(CalPlan calPlan) {
List<CalShift> shifts = calPlan.getCalShifts();
List<CalShift> execShiftList = new ArrayList<>();
List<CalShift> shiftList = new ArrayList<>();
Date startDate = calPlan.getStartDate();
Date endDate = calPlan.getEndDate();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String startDateFormat = sdf.format(startDate);
for (CalShift shift : shifts) {
List<CalShift> breakTimeList = shift.getBreakTimeList();
if (CollectionUtil.isNotEmpty(breakTimeList)) {
breakTimeList.sort(Comparator.comparing(CalShift::getOrderNum));
CalShift calShift1 = breakTimeList.get(0);
if (breakTimeList.size() == 2) {
CalShift startCalShift = shift.deepCopyObj();
startCalShift.setExecEndTime(calShift1.getExecStartTime());
execShiftList.add(startCalShift);
for (CalShift calShift : breakTimeList) {
CalShift o = calShift.deepCopyObj();
o.setShiftName(shift.getShiftName());
execShiftList.add(o);
}
CalShift calShift2 = breakTimeList.get(1);
if (breakTimeList.size() == 2) {
CalShift calShift = calShift1.deepCopyObj();
calShift.setExecStartTime(calShift1.getExecEndTime());
calShift.setExecEndTime(calShift2.getExecStartTime());
calShift.setRestFlag(0);
execShiftList.add(calShift);
}
CalShift endCalShift = shift.deepCopyObj();
endCalShift.setExecStartTime(calShift2.getExecEndTime());
execShiftList.add(endCalShift);
} else {
CalShift startCalShift = shift.deepCopyObj();
startCalShift.setExecEndTime(calShift1.getExecStartTime());
execShiftList.add(startCalShift);
for (CalShift calShift : breakTimeList) {
execShiftList.add(calShift.deepCopyObj());
}
CalShift endCalShift = shift.deepCopyObj();
endCalShift.setExecStartTime(calShift1.getExecEndTime());
execShiftList.add(endCalShift);
breakTimeList = breakTimeList.stream().sorted(Comparator.comparing(CalShift::getOrderNum)).collect(Collectors.toList());
Date shift1StartDate = formatShiftDate(startDateFormat, shift.getStartTime());
Date shift1EndDate = formatShiftDate(startDateFormat, breakTimeList.get(0).getBreakStartTime());
CalShift shift1 = shift.deepCopyObj();
shift1.setStartDate(shift1StartDate);
shift1.setEndDate(shift1EndDate);
shiftList.add(shift1);
for (CalShift calShift : breakTimeList) {
shift1StartDate = formatShiftDate(startDateFormat, calShift.getBreakStartTime());
shift1EndDate = formatShiftDate(startDateFormat, calShift.getBreakEndTime());
shift1 = new CalShift();
shift1.setStartDate(shift1StartDate);
shift1.setEndDate(shift1EndDate);
shift1.setOperType(1);
shift1.setShiftName(calShift.getShiftName());
shift1.setShiftId(calShift.getShiftId());
shiftList.add(shift1);
}
Date shift3EndDate = formatShiftDate(startDateFormat, shift.getEndTime());
CalShift shift3 = shift.deepCopyObj();
shift3.setStartDate(shift1EndDate);
shift3.setEndDate(shift3EndDate);
shiftList.add(shift3);
} else {
execShiftList.add(shift.deepCopyObj());
Date shift1StartDate = formatShiftDate(startDateFormat, shift.getStartTime());
Date shift1EndDate = formatShiftDate(startDateFormat, shift.getEndTime());
CalShift shift1 = shift.deepCopyObj();
shift1.setStartDate(shift1StartDate);
shift1.setEndDate(shift1EndDate);
shiftList.add(shift1);
}
}
List<CalWorkunit> calWorkunits = calWorkunitMapper.selectListByQw(new QueryWrapper<CalWorkunit>().eq("t1.plan_id", calPlan.getPlanId()));
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(calWorkunits), "工作单元为空,无法排班");
List<CalWorkunit> calWorkunits = calWorkunitMapper.selectListByQw(new QueryWrapper<CalWorkunit>().eq("plan_id", calPlan.getPlanId()));
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(calWorkunits), MessageUtils.message("cal.error.error19"));
List<Integer> weekList = new ArrayList<>();
if (Objects.equals(calPlan.getSaturday(), CalPlanWorkDayEnum.WEEKEND.getType())) {
......@@ -340,21 +320,18 @@ public class CalPlanServiceImpl implements ICalPlanService {
List<String> weekendMonthStrList = weekendByMonth.stream().filter(Objects::nonNull).map(MesCalendarUtil::getDateDayStr).collect(Collectors.toList());
List<Long> taskWorkunitIds = calWorkunits.stream().map(CalWorkunit::getWorkunitId).collect(Collectors.toList());
List<String> shiftNames = shifts.stream().map(CalShift::getShiftName).collect(Collectors.toList());
calPlanWorkunitMapper.deleteByPlanCode(calPlan.getPlanCode());
// 删除同一天在同一个工作单元已经粗在上的旧数据
QueryWrapper<CalPlanWorkunit> qw = new QueryWrapper<>();
qw.in("t1.the_day", weekendMonthStrList);
qw.in("t1.shift_name", shiftNames);
qw.in("t1.workunit_id", taskWorkunitIds);
List<Long> ids = calPlanWorkunitService.selectListByQw(qw).stream().map(CalPlanWorkunit::getId).collect(Collectors.toList());
QueryWrapper<CalPlanWorkunit> calPlanWorkunitQueryWrapper = new QueryWrapper<>();
calPlanWorkunitQueryWrapper.in("t1.the_day", weekendMonthStrList);
calPlanWorkunitQueryWrapper.in("t1.shift_name", shiftNames);
calPlanWorkunitQueryWrapper.in("t1.workunit_id", taskWorkunitIds);
List<Long> ids = calPlanWorkunitService.selectListByQw(calPlanWorkunitQueryWrapper).stream().map(CalPlanWorkunit::getId).collect(Collectors.toList());
List<List<Long>> deletelists = chunkList(ids, 500);
for (List<Long> list : deletelists) {
EXECUTOR.execute(() -> calPlanWorkunitService.deleteListByIds(list.toArray(new Long[]{})));
EXECUTOR.execute(() -> calPlanWorkunitService.deleteCalPlanWorkunitByPlanWorkunitIds(list.toArray(new Long[]{})));
}
List<CalPlanWorkunit> calPlanWorkunits = generateShiftRecords(execShiftList, calPlan, weekendMonthStrList, calWorkunits);
List<CalPlanWorkunit> calPlanWorkunits = generateShiftRecords(shiftList, calPlan, weekendMonthStrList, calWorkunits);
calPlanWorkunits.forEach(x -> {
String updateBy = calPlan.getUpdateBy();
x.setCreateBy(updateBy);
......@@ -389,7 +366,7 @@ public class CalPlanServiceImpl implements ICalPlanService {
calWorkunitService.deleteCalWorkunitByPlanCode(calPlan.getPlanCode());
List<CalWorkunit> calWorkunits = calPlan.getCalWorkunits();
for (CalWorkunit calWorkunit : calWorkunits) {
calWorkunit = calPlan.deepSetObjParameter(calWorkunit);
calWorkunit = calPlan.deepSetObj(calWorkunit);
calWorkunit.setManualUpdate(true);
calWorkunit.setId(null);
calWorkunitService.insertCalWorkunit(calWorkunit);
......
......@@ -111,7 +111,7 @@ public class CalPlanWorkunitServiceImpl implements ICalPlanWorkunitService {
* @return 结果
*/
@Override
public int deleteListByIds(Long[] planWorkunitIds) {
public int deleteCalPlanWorkunitByPlanWorkunitIds(Long[] planWorkunitIds) {
return calPlanWorkunitMapper.deleteCalPlanWorkunitByids(planWorkunitIds);
}
......
......@@ -8,9 +8,9 @@ import com.ximai.mes.cal.domain.CalShift;
import com.ximai.mes.cal.domain.vo.CalShiftVo;
import com.ximai.mes.cal.mapper.CalShiftMapper;
import com.ximai.mes.cal.service.ICalShiftService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -24,7 +24,7 @@ import java.util.stream.Collectors;
*/
@Service
public class CalShiftServiceImpl implements ICalShiftService {
@Resource
@Autowired
private CalShiftMapper calShiftMapper;
/**
......@@ -188,7 +188,6 @@ public class CalShiftServiceImpl implements ICalShiftService {
breakShift2.setStartTime(null);
breakShift2.setEndTime(null);
breakShift2.setOrderNum(1);
breakShift2.setNextDay(1);
list2.add(breakShift2);
shiftNight.setBreakTimeList(list2);
......@@ -229,9 +228,9 @@ public class CalShiftServiceImpl implements ICalShiftService {
List<CalShiftVo> list3 = new ArrayList<>();
CalShiftVo breakShift3 = new CalShiftVo();
breakShift3.setBreakStartTime("00:00");
breakShift3.setBreakEndTime("1:00");
breakShift3.setNextDay(1);
breakShift3.setStartTime(null);
breakShift3.setEndTime(null);
breakShift3.setOrderNum(1);
......
......@@ -7,7 +7,6 @@ import com.ximai.mes.cal.domain.CalWorkunit;
import com.ximai.mes.cal.mapper.CalWorkunitMapper;
import com.ximai.mes.cal.service.ICalWorkunitService;
import com.ximai.mes.md.domain.MdWorkunit;
import com.ximai.mes.md.mapper.MdWorkunitMapper;
import com.ximai.mes.md.service.IMdWorkunitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -28,12 +27,10 @@ public class CalWorkunitServiceImpl implements ICalWorkunitService {
@Resource
private CalWorkunitMapper calWorkunitMapper;
@Resource
private MdWorkunitMapper mdWorkunitMapper;
@Autowired
private IMdWorkunitService mdWorkunitService;
/**
* 查询计划工作单元
*
......@@ -41,7 +38,7 @@ public class CalWorkunitServiceImpl implements ICalWorkunitService {
* @return 计划工作单元
*/
@Override
public CalWorkunit getObjById(Long id) {
public CalWorkunit selectCalWorkunitById(Long id) {
return calWorkunitMapper.selectCalWorkunitById(id);
}
......@@ -165,34 +162,14 @@ public class CalWorkunitServiceImpl implements ICalWorkunitService {
@Override
public List<MdWorkunit> selectUnSelectList(CalWorkunit calWorkunit) {
Long planId = calWorkunit.getPlanId();
String workunitCode = calWorkunit.getWorkunitCode();
String workunitName = calWorkunit.getWorkunitName();
String workstationName = calWorkunit.getWorkstationName();
String workshopName = calWorkunit.getWorkshopName();
QueryWrapper<CalWorkunit> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StringUtils.isNotEmpty(planId), "t1.plan_id", planId);
queryWrapper.eq(StringUtils.isNotEmpty(workunitCode), "t2.workunit_code", workunitCode);
queryWrapper.like(StringUtils.isNotEmpty(workunitName), "t2.workunit_name", workunitName);
queryWrapper.like(StringUtils.isNotEmpty(workstationName), "t3.workstation_name", workstationName);
queryWrapper.like(StringUtils.isNotEmpty(workshopName), "t4.workshop_name", workshopName);
queryWrapper.isNotNull("t2.workunit_name");
List<MdWorkunit> calWorkunits = calWorkunitMapper.selectListByQwV2(queryWrapper);
return calWorkunits;
}
QueryWrapper<MdWorkunit> qw = new QueryWrapper<>();
qw.eq(StringUtils.isNotEmpty(calWorkunit.getWorkunitCode()), "t1.workunit_code", calWorkunit.getWorkunitCode());
qw.like(StringUtils.isNotEmpty(calWorkunit.getWorkunitName()), "t1.workunit_name", calWorkunit.getWorkunitName());
qw.like(StringUtils.isNotEmpty(calWorkunit.getWorkstationName()), "mws.workstation_name", calWorkunit.getWorkstationName());
qw.like(StringUtils.isNotEmpty(calWorkunit.getWorkshopName()), "mws.workshop_name", calWorkunit.getWorkshopName());
List<MdWorkunit> mdWorkunits = mdWorkunitService.selectListByQw(qw);
@Override
public List<MdWorkunit> getWorkunitByPlanId(CalWorkunit calWorkunit,List<CalWorkunit> calWorkunits) {
String workunitCode = calWorkunit.getWorkunitCode();
String workunitName = calWorkunit.getWorkunitName();
String workstationName = calWorkunit.getWorkstationName();
String workshopName = calWorkunit.getWorkshopName();
List<String> workunitCodes = calWorkunits.stream().map(calWorkunit1 -> calWorkunit1.getWorkunitCode()).collect(Collectors.toList());
List<MdWorkunit> mdWorkunits = calWorkunitMapper.selectMdworkunitList(workunitCode,workunitName,workstationName,workshopName,workunitCodes.size() > 0 ? workunitCodes : null);
return mdWorkunits;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment