|
|
|
|
@ -19,6 +19,7 @@ import org.springblade.desk.basic.service.ITeamSetService; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.BsTeamSetEntity; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.DsPartEntity; |
|
|
|
|
import org.springblade.desk.dashboard.service.IDsPartService; |
|
|
|
|
import org.springblade.desk.oem.service.IOemStatementService; |
|
|
|
|
import org.springblade.desk.order.pojo.entity.YieldOrder; |
|
|
|
|
import org.springblade.desk.order.service.IYieldOrderService; |
|
|
|
|
import org.springblade.desk.produce.mapper.PlateAroundMapper; |
|
|
|
|
@ -34,6 +35,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
@ -55,10 +57,6 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
|
|
|
|
|
private final IPlateAroundDelLogService plateAroundDelLogService; |
|
|
|
|
|
|
|
|
|
private final IPdaLoadService pdaLoadService; |
|
|
|
|
|
|
|
|
|
private final IWorkOrderRunService workOrderRunService; |
|
|
|
|
|
|
|
|
|
private final IDsPartService dsPartService; |
|
|
|
|
|
|
|
|
|
private final WorkPlanMapper workPlanMapper; |
|
|
|
|
@ -67,6 +65,10 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
|
|
|
|
|
private final IOemService oemService; |
|
|
|
|
|
|
|
|
|
private final IHandoverRecordService handoverRecordService; |
|
|
|
|
|
|
|
|
|
private final IOemStatementService oemStatementService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<PlateAroundVO> queryByReadStatus(IPage<PlateAroundVO> page, PlateAroundDto plateAroundDto) { |
|
|
|
|
return page.setRecords(baseMapper.queryByReadStatus(page, plateAroundDto)); |
|
|
|
|
@ -78,7 +80,12 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
if (wo == null) { |
|
|
|
|
throw new ServiceException("车间订单不存在!"); |
|
|
|
|
} |
|
|
|
|
return baseMapper.getBeforePlatInCardNo(wo.getId(), tsIds, AuthUtil.getUserId()); |
|
|
|
|
WorkPlan beforePlatInCardNo = baseMapper.getBeforePlatInCardNo(wo.getId(), tsIds, AuthUtil.getUserId()); |
|
|
|
|
long count = this.count(Wrappers.lambdaQuery(PlateAround.class).eq(PlateAround::getWpId, beforePlatInCardNo.getId()).eq(PlateAround::getPaType, PlateAround.BEFORE_PLAT_IN)); |
|
|
|
|
if (count > 0) { |
|
|
|
|
throw new ServiceException("此订单已存在镀前入库记录!"); |
|
|
|
|
} |
|
|
|
|
return beforePlatInCardNo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -87,7 +94,12 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
if (wo == null) { |
|
|
|
|
throw new ServiceException("车间订单不存在!"); |
|
|
|
|
} |
|
|
|
|
return baseMapper.getBeforePlatOutCardNo(wo.getId(), tsIds, AuthUtil.getUserId()); |
|
|
|
|
PlateAround plateAround = baseMapper.getBeforePlatOutCardNo(wo.getId(), tsIds, AuthUtil.getUserId()); |
|
|
|
|
long count = this.count(Wrappers.lambdaQuery(PlateAround.class).eq(PlateAround::getWpId, plateAround.getWpId()).eq(PlateAround::getPaType, PlateAround.BEFORE_PLAN_OUT)); |
|
|
|
|
if (count > 0) { |
|
|
|
|
throw new ServiceException("此订单已存在镀前出库记录!"); |
|
|
|
|
} |
|
|
|
|
return plateAround; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -127,6 +139,10 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
// if (pjYieldOrder.getNextRoam()!=null) {
|
|
|
|
|
// pjYieldOrder.setNextRoamName(dsPartService.findNameByRoamNo(pjYieldOrder.getPartCode(), pjYieldOrder.getNextRoam()));
|
|
|
|
|
// }
|
|
|
|
|
long count = this.count(Wrappers.lambdaQuery(PlateAround.class).eq(PlateAround::getWpId, afterPlateInVO.getId()).eq(PlateAround::getPaType, PlateAround.AFTER_PLAN_IN)); |
|
|
|
|
if (count > 0) { |
|
|
|
|
throw new ServiceException("此订单已存在镀后入库记录!"); |
|
|
|
|
} |
|
|
|
|
return afterPlateInVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -191,20 +207,24 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
int next = 0; |
|
|
|
|
List<WorkOrder> woList = new ArrayList<>(list.size()); |
|
|
|
|
WorkOrder wo; |
|
|
|
|
Date date = new Date(); |
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
for (PlateAround plateAround : list) { |
|
|
|
|
this.savePlateAround(AuthUtil.getUser(), plateAround, paType, next, Boolean.FALSE); |
|
|
|
|
if (paType.equals(PlateAround.AFTER_PLAN_IN)) { |
|
|
|
|
WorkPlan prWorkPlan = workPlanMapper.selectById(plateAround.getWpId()); |
|
|
|
|
wo = workOrderService.getById(prWorkPlan.getWoId()); |
|
|
|
|
wo.setHandoverTime(date); |
|
|
|
|
wo.setUseDept(plateAround.getUseDept()); |
|
|
|
|
wo.setHrTypeBool(plateAround.getHrTypeBool()); |
|
|
|
|
woList.add(wo); |
|
|
|
|
// 计算主工序对应的金额
|
|
|
|
|
//bsTeamWagesLevelService.countTeamSalary(wo.getWoId());
|
|
|
|
|
// todo 计算主工序对应的金额
|
|
|
|
|
// bsTeamWagesLevelService.countTeamSalary(wo.getWoId());
|
|
|
|
|
// 调用外协结算
|
|
|
|
|
oemStatementService.autoSettlement(wo.getWoCode(), now); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (paType.equals(PlateAround.AFTER_PLAN_IN)) { |
|
|
|
|
// prHandoverRecordService.saveHandoverRecord(woList, AuthUtil.getUser());
|
|
|
|
|
// 保存移交记录
|
|
|
|
|
handoverRecordService.saveHandoverRecord(woList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -238,136 +258,47 @@ public class PlateAroundServiceImpl extends BaseServiceImpl<PlateAroundMapper, P |
|
|
|
|
|
|
|
|
|
private void savePlateAround(BladeUser user, PlateAround plateAround, Short paType, int next, Boolean aTure) { |
|
|
|
|
PlateAround newPa = null; |
|
|
|
|
PlateAround oldPa = null; |
|
|
|
|
PlateAround oldPa; |
|
|
|
|
Date date = new Date(); |
|
|
|
|
WorkPlan wp = workPlanMapper.selectById(plateAround.getWpId()); |
|
|
|
|
if (paType.equals(PlateAround.BEFORE_PLAT_IN) || paType.equals(PlateAround.AFTER_PLAN_IN)) { |
|
|
|
|
plateAround.setPaType(paType); |
|
|
|
|
plateAround.setCreateUser(user.getUserId()); |
|
|
|
|
plateAround.setCreateTime(date); |
|
|
|
|
if (aTure) { |
|
|
|
|
plateAround.setPaCode(this.nextCode(paType, next)); |
|
|
|
|
plateAround.setMakeTime(new Date()); |
|
|
|
|
plateAround.setMakeMan(user.getUserId()); |
|
|
|
|
} |
|
|
|
|
plateAround = this.updatePrPlateAround(plateAround); |
|
|
|
|
this.updatePrPlateAround(plateAround); |
|
|
|
|
baseMapper.insert(plateAround); |
|
|
|
|
if (paType.equals(PlateAround.BEFORE_PLAT_IN)) { |
|
|
|
|
WorkPlan nextWorkPlan = workPlanMapper.selectById(wp.getNextWpId()); |
|
|
|
|
if (nextWorkPlan != null && nextWorkPlan.getNextWpId() == null) { |
|
|
|
|
throw new ServiceException("工序已是最后一道!"); |
|
|
|
|
} |
|
|
|
|
WorkOrder prWorkOrder = workOrderService.getById(wp.getWoId()); |
|
|
|
|
pdaLoadService.checkPrWorkOrder(prWorkOrder.getCardNo()); |
|
|
|
|
|
|
|
|
|
//下序不能为空,并且下序班组或者供应商都没有值的情况下再进行自动分派
|
|
|
|
|
if (nextWorkPlan != null && nextWorkPlan.getMakeTeam() == null && nextWorkPlan.getOcId() == null) { |
|
|
|
|
//调用自动分派处理类
|
|
|
|
|
//pjAutomaticDispatchService.beforePlatingAutomatic(prWorkOrder.getCardNo(), pfUserInfo);
|
|
|
|
|
} else { |
|
|
|
|
// 如果下序是外协,将订单发外协的标记标为未发送
|
|
|
|
|
if (nextWorkPlan != null && nextWorkPlan.getOcId() != null && nextWorkPlan.getMakeTeam() == null) { |
|
|
|
|
prWorkOrder.setOem("1"); |
|
|
|
|
prWorkOrder.setOemOut("0"); |
|
|
|
|
if (prWorkOrder.getOcId() == null) { |
|
|
|
|
prWorkOrder.setTsId(null); |
|
|
|
|
prWorkOrder.setOcId(nextWorkPlan.getOcId()); |
|
|
|
|
} |
|
|
|
|
prWorkOrder.setOemType(WorkOrder.OEM_TYPE_WHOLE); |
|
|
|
|
nextWorkPlan.setPlanEndTime(LocalDateTime.now()); |
|
|
|
|
workPlanMapper.updateById(nextWorkPlan); |
|
|
|
|
//产生外协生产进度记录信息
|
|
|
|
|
WorkOrderRun wr = new WorkOrderRun(); |
|
|
|
|
wr.setWoId(prWorkOrder.getId()); |
|
|
|
|
wr.setWoCode(prWorkOrder.getWoCode()); |
|
|
|
|
wr.setRunType(WorkOrderRun.RUN_TYPE_1); |
|
|
|
|
wr.setInTeam(wp.getMakeTeam()); |
|
|
|
|
wr.setInCustomer(nextWorkPlan.getOcId()); |
|
|
|
|
wr.setMemo("入库派外协"); |
|
|
|
|
wr.setCreateTime(date); |
|
|
|
|
wr.setCreateUser(user.getUserId()); |
|
|
|
|
wr.setUpdateTime(date); |
|
|
|
|
wr.setUpdateUser(user.getUserId()); |
|
|
|
|
wr.setStatus(Integer.valueOf(WorkOrderRun.RUN_STATUS_UNDER)); |
|
|
|
|
wr.setSystemData("1"); |
|
|
|
|
wr.setCollaborate("1"); |
|
|
|
|
wr.setRunStatus(WorkOrderRun.RUN_STATUS_UNDER); |
|
|
|
|
workOrderRunService.save(wr); |
|
|
|
|
prWorkOrder.setWorId(wr.getId()); |
|
|
|
|
workOrderService.updateById(prWorkOrder); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
wp = workPlanMapper.selectById(wp.getId()); |
|
|
|
|
//通知下序进行镀前出库
|
|
|
|
|
if (nextWorkPlan.getMakeTeam() != null) { |
|
|
|
|
String str = "流程卡号:【" + prWorkOrder.getCardNo() + "】,零件号:【" + prWorkOrder |
|
|
|
|
.getPartCode() + "】批次号:【" + prWorkOrder.getBatchNo() + "】,已入镀前库,请及时处理!"; |
|
|
|
|
// pfMessageService.sendMessage(str, nextWorkPlan.getMakeTeam().getTeamLeader().getUserId(),
|
|
|
|
|
// PfMessageType.MTCODE_0200, null, Boolean.FALSE, null);
|
|
|
|
|
} |
|
|
|
|
//镀前入库后默认拉满当前工序完成进度
|
|
|
|
|
wp.setFactEndTime(date); |
|
|
|
|
workPlanMapper.updateById(wp); |
|
|
|
|
} |
|
|
|
|
if (paType.equals(PlateAround.AFTER_PLAN_IN)) { |
|
|
|
|
WorkOrder prWorkOrder = workOrderService.getById(wp.getWoId()); |
|
|
|
|
pdaLoadService.checkPrWorkOrder(prWorkOrder.getCardNo()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
WorkPlan nextWorkPlan = workPlanMapper.selectById(plateAround.getWpId()); |
|
|
|
|
if (wp.getNextWpId() != null && nextWorkPlan.getNextWpId() == null) { |
|
|
|
|
throw new ServiceException("pda.nextWorkPlan.noNext"); |
|
|
|
|
} |
|
|
|
|
//如果是镀前出库,判定是否下序有班组或者供应商,若没有重新自动分派
|
|
|
|
|
if (nextWorkPlan.getNextWpId() != null) { |
|
|
|
|
if (nextWorkPlan.getMakeTeam() == null && nextWorkPlan.getOcId() == null) { |
|
|
|
|
//调用自动分派处理类
|
|
|
|
|
WorkOrderRun wor = workOrderRunService.getById(nextWorkPlan.getWoId()); |
|
|
|
|
// pjAutomaticDispatchService.beforePlatingAutomatic(wp.getPrWorkOrder().getCardNo(), pfUserInfo);
|
|
|
|
|
wp = workPlanMapper.selectById(wp.getId()); |
|
|
|
|
//如果当前序是供应商,下序分派至班组(不是检验),或者其他供应商则调用erp关闭订单(待定)
|
|
|
|
|
if (nextWorkPlan.getOcId() != null && nextWorkPlan.getNextWpId() != null) { |
|
|
|
|
if (nextWorkPlan.getPpsId() != null) { |
|
|
|
|
if (StringUtils.isNotBlank(wor.getDeliverKey())) { |
|
|
|
|
//调用erp检验接口
|
|
|
|
|
// prWorkCheckService.checkCompleteErpBackFill(wor.getWoCode(), wor.getDeliverKey(), wp.getWorkQty(),
|
|
|
|
|
// 0, pfUserInfo);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//如果下序供应商不为空,则代表存在原有供应商,则根据此供应商获取最后一个该供应商未关闭的运行记录,并绑定
|
|
|
|
|
} else if (wp.getNextWpId() != null && nextWorkPlan.getOcId() != null) { |
|
|
|
|
WorkOrderRun prWorkOrderRun = workOrderRunService.getById(nextWorkPlan.getOcId()); |
|
|
|
|
if (prWorkOrderRun != null) { |
|
|
|
|
WorkOrder workOrder = workOrderService.getById(prWorkOrderRun.getWoId()); |
|
|
|
|
workOrder.setWorId(prWorkOrderRun.getId()); |
|
|
|
|
workOrderService.updateById(workOrder); |
|
|
|
|
//改回下达状态,让调度收回
|
|
|
|
|
prWorkOrderRun.setRunStatus(WorkOrderRun.RUN_STATUS_ISSUED); |
|
|
|
|
workOrderRunService.updateById(prWorkOrderRun); |
|
|
|
|
} else { |
|
|
|
|
throw new ServiceException("pda.dataFormat.error"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
throw new ServiceException("工序已是最后一道!"); |
|
|
|
|
} |
|
|
|
|
// 新增镀前出库记录
|
|
|
|
|
BeanUtils.copyProperties(plateAround, newPa); |
|
|
|
|
newPa.setPaCode(plateAround.getPaCode()); |
|
|
|
|
newPa.setId(null); |
|
|
|
|
newPa.setPaType(paType); |
|
|
|
|
newPa.setCreateUser(user.getUserId()); |
|
|
|
|
newPa.setCreateTime(date); |
|
|
|
|
newPa.setPaCode(this.nextCode(paType, next)); |
|
|
|
|
if (aTure) { |
|
|
|
|
newPa.setMakeTime(date); |
|
|
|
|
newPa.setMakeMan(user.getUserId()); |
|
|
|
|
} |
|
|
|
|
newPa.setWpId(wp.getNextWpId()); |
|
|
|
|
|
|
|
|
|
newPa = this.updatePrPlateAround(newPa); |
|
|
|
|
newPa.setTsId(wp.getMakeTeam()); |
|
|
|
|
this.updatePrPlateAround(newPa); |
|
|
|
|
baseMapper.insert(newPa); |
|
|
|
|
// 修改镀前入库记录状态
|
|
|
|
|
oldPa = baseMapper.selectById(plateAround.getId()); |
|
|
|
|
oldPa.setCurStatus(PlateAround.CUR_STATUS_OK); |
|
|
|
|
baseMapper.updateById(oldPa); |
|
|
|
|
} |
|
|
|
|
next++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private PlateAround updatePrPlateAround(PlateAround plateAround) { |
|
|
|
|
|