|
|
|
|
@ -19,14 +19,18 @@ import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.desk.basic.constant.FlowConst; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.OemCraftAbilityEntity; |
|
|
|
|
import org.springblade.desk.basic.service.IOemCraftAbilityService; |
|
|
|
|
import org.springblade.desk.basic.service.IOemService; |
|
|
|
|
import org.springblade.desk.basic.service.IProcessAbilityService; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.BsProcessSetEntity; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.BsTeamSetEntity; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.DsPartEntity; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.DsProcessProjectEntity; |
|
|
|
|
import org.springblade.desk.dashboard.service.IBsProcessSetService; |
|
|
|
|
import org.springblade.desk.dashboard.service.IBsTeamSetService; |
|
|
|
|
import org.springblade.desk.dashboard.service.IDsPartService; |
|
|
|
|
import org.springblade.desk.dashboard.service.IDsProcessProjectService; |
|
|
|
|
import org.springblade.desk.device.pojo.entity.EquipmentEntity; |
|
|
|
|
import org.springblade.desk.device.pojo.entity.FeiBaSetEntity; |
|
|
|
|
import org.springblade.desk.device.pojo.entity.RackSetEntity; |
|
|
|
|
@ -50,6 +54,7 @@ import org.springblade.desk.produce.pojo.vo.*; |
|
|
|
|
import org.springblade.desk.produce.service.*; |
|
|
|
|
import org.springblade.desk.quality.pojo.entity.*; |
|
|
|
|
import org.springblade.desk.quality.service.*; |
|
|
|
|
import org.springblade.desk.util.date.DateUtils; |
|
|
|
|
import org.springblade.scheduling.pojo.entity.WorkOrderEntity; |
|
|
|
|
import org.springblade.erpdata.feign.IErpDataProduceClient; |
|
|
|
|
import org.springblade.system.cache.DictCache; |
|
|
|
|
@ -136,6 +141,10 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
|
|
|
|
|
private final IOemService oemService; |
|
|
|
|
|
|
|
|
|
private final IReviewSheetService reviewSheetService; |
|
|
|
|
|
|
|
|
|
private final IOemCraftAbilityService oemCraftAbilityService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<WorkOrderVO> selectWorkOrderPage(IPage<WorkOrderVO> page, WorkOrderDTO workOrder) { |
|
|
|
|
return page.setRecords(baseMapper.selectWorkOrderPage(page, workOrder)); |
|
|
|
|
@ -1449,6 +1458,196 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean workPlanReceive(Long wpId) { |
|
|
|
|
WorkPlan workPlan = workPlanService.getById(wpId); |
|
|
|
|
WorkPlan frontWorkPlan = workPlanService.getById(workPlan.getFrontWpId()); |
|
|
|
|
WorkOrder workOrder = this.getById(workPlan.getWoId()); |
|
|
|
|
// 上序不为空时进行审理单验证
|
|
|
|
|
if (frontWorkPlan != null) { |
|
|
|
|
// 验证上序是否存在未完成审理,如果存在则不允许接收
|
|
|
|
|
InspectionTask checkByWpId = iInspectionTaskService.getPrWorkCheckByWpId(frontWorkPlan.getId()); |
|
|
|
|
if (checkByWpId != null) { |
|
|
|
|
// 查询是否存在未完的审理单
|
|
|
|
|
List<ReviewSheet> rsLst = reviewSheetService.getNoCompleteByWcId(checkByWpId.getId()); |
|
|
|
|
if (CollectionUtils.isNotEmpty(rsLst)) { |
|
|
|
|
throw new ServiceException("存在未完成审理单,请处理后再进行接收"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 验证车间订单状态
|
|
|
|
|
if (!WorkOrder.RUN_STATUS_RECEIVE.equals(workOrder.getRunStatus())) { |
|
|
|
|
throw new ServiceException("存在未完成审理单,请处理后再进行接收"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Date newDate = new Date(); |
|
|
|
|
// 完成上序
|
|
|
|
|
this.workPlanEnd(frontWorkPlan, newDate, workOrder.getMakeQty()); |
|
|
|
|
|
|
|
|
|
// 开始本序
|
|
|
|
|
this.workPlanStart(workPlan, newDate, AuthUtil.getUserId(), workOrder); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void workPlanStart(WorkPlan workPlan, Date startDate, Long userId, WorkOrder workOrder) { |
|
|
|
|
if (workPlan == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// 开始本序
|
|
|
|
|
workPlan.setFactStartTime(startDate); |
|
|
|
|
workPlan.setStatus(WorkPlan.STATUS_START); |
|
|
|
|
if ("1".equals(workPlan.getOem())) { |
|
|
|
|
workPlan.setStatus(WorkPlan.STATUS_WORK_OK); |
|
|
|
|
} |
|
|
|
|
workPlan.setQualifiedQty(workOrder.getMakeQty()); |
|
|
|
|
workPlan.setReceiveMan(userId); |
|
|
|
|
workPlanService.updateById(workPlan); |
|
|
|
|
|
|
|
|
|
// 修改车间订单当前加工工序
|
|
|
|
|
workOrder.setWpId(workPlan.getId()); |
|
|
|
|
workOrder.setOemType(-1); |
|
|
|
|
|
|
|
|
|
//第一道工序更改车间状态
|
|
|
|
|
log.info("工序接收,当前工序ID:{}", workPlan.getId()); |
|
|
|
|
if (workPlan.getFrontWpId() == null) { |
|
|
|
|
log.info("第一道工序更改车间状态为加工中,车间订单ID:{}", workOrder.getId()); |
|
|
|
|
// 快速将Long转换为List<Long>
|
|
|
|
|
this.updateStatus(List.of(workPlan.getId()), WorkOrder.RUN_STATUS_RECEIVE, userId, null); |
|
|
|
|
// 如果是返工回来的不验证子件
|
|
|
|
|
if (StringUtils.isBlank(workOrder.getReworkCode())) { |
|
|
|
|
// yieldOrderService.verifyYield(workOrder.getYoId());
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
YieldOrder yieldOrder = yieldOrderService.getById(workOrder.getYoId()); |
|
|
|
|
|
|
|
|
|
// 根据零件号、工序ID、版本号、工艺级别查询对应的检验项目
|
|
|
|
|
List<DsProcessProjectEntity> projects = dsPartService.selectDsProcessProjectByPartNoAndPpsId(workOrder.getPartCode(), workPlan.getOrders(), yieldOrder.getPartVersion(), yieldOrder.getRank()); |
|
|
|
|
if (CollectionUtils.isNotEmpty(projects)) { |
|
|
|
|
// 保存检验任务
|
|
|
|
|
InspectionTask inspectionTask = new InspectionTask(); |
|
|
|
|
inspectionTask.setWpId(workPlan.getId()); |
|
|
|
|
inspectionTaskService.saveOrEdit(inspectionTask, userId); |
|
|
|
|
|
|
|
|
|
// 保存检验项目
|
|
|
|
|
List<WorkPlanItem> workPlanItems = new ArrayList<>(); |
|
|
|
|
WorkPlanItem workPlanItem; |
|
|
|
|
for (DsProcessProjectEntity project : projects) { |
|
|
|
|
workPlanItem = new WorkPlanItem(); |
|
|
|
|
workPlanItem.setWpId(workPlan.getId()); |
|
|
|
|
workPlanItem.setItemCode(project.getProjectCode()); |
|
|
|
|
workPlanItem.setItemName(project.getProjectName()); |
|
|
|
|
workPlanItem.setStandardId(Long.valueOf(project.getProjectStandard())); |
|
|
|
|
workPlanItem.setStandardName(project.getProjectStandardName()); |
|
|
|
|
workPlanItem.setHourQuota(project.getProHours()); |
|
|
|
|
workPlanItem.setHourPrepare(project.getPrepareHours()); |
|
|
|
|
workPlanItem.setTaskId(inspectionTask.getId()); |
|
|
|
|
workPlanItem.setItemId(project.getId()); |
|
|
|
|
workPlanItems.add(workPlanItem); |
|
|
|
|
} |
|
|
|
|
workPlanItemService.saveBatch(workPlanItems); |
|
|
|
|
// 修改车间订单为检验中
|
|
|
|
|
workOrder.setRunStatus(WorkOrder.RUN_STATUS_CHECK); |
|
|
|
|
} else { |
|
|
|
|
// 更新调度员
|
|
|
|
|
this.updateHostWorkUnit(workOrder); |
|
|
|
|
} |
|
|
|
|
this.updateById(workOrder); |
|
|
|
|
|
|
|
|
|
if (yieldOrder.getFatherYoId() != null) { |
|
|
|
|
List<WorkOrder> prWorkOrderList = baseMapper.listByYoId(yieldOrder.getFatherYoId()); |
|
|
|
|
if (CollectionUtils.isNotEmpty(prWorkOrderList)) { |
|
|
|
|
for (WorkOrder order : prWorkOrderList) { |
|
|
|
|
if (StringUtils.isBlank(order.getMesCardNo())) { |
|
|
|
|
String code = this.cardNextCode(); |
|
|
|
|
//验证此编码是否重复
|
|
|
|
|
if (this.getMaxByMesCard(code)) { |
|
|
|
|
code = this.cardNextCode(); |
|
|
|
|
} |
|
|
|
|
order.setMesCardNo(code); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.updateBatchById(prWorkOrderList); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean getMaxByMesCard(String code) { |
|
|
|
|
WorkOrder workOrder = baseMapper.getMaxByMesCard(code); |
|
|
|
|
if (workOrder != null) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void updateHostWorkUnit(WorkOrder wo) { |
|
|
|
|
Long caId = null; |
|
|
|
|
if (wo != null) { |
|
|
|
|
//查到了代表存在主工序标识,反之则默认当前工序的作业单位
|
|
|
|
|
WorkPlan wp = workPlanService.findMaxHostWorkUnitByWoId(wo.getId(), 1); |
|
|
|
|
if (wp != null) { |
|
|
|
|
wo.setTsId(wp.getMakeTeam()); |
|
|
|
|
wo.setOcId(wp.getOcId()); |
|
|
|
|
} else { |
|
|
|
|
wp = workPlanService.findMaxHostWorkUnitByWoId(wo.getId(), 0); |
|
|
|
|
if (wp != null) { |
|
|
|
|
wo.setTsId(wp.getMakeTeam()); |
|
|
|
|
wo.setOcId(wp.getOcId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//根据规则拿到主工序,如果没有主工序或者主工序没有加工单位,则默认获取当前工序
|
|
|
|
|
if (wp == null || (wp.getMakeTeam() == null && wp.getOcId() == null)) { |
|
|
|
|
wp = workPlanService.getById(wo.getWpId()); |
|
|
|
|
//如果当前工序已经报工完成,则默认获取下道工序的加工单位,反之则获取当前工序的加工作单位
|
|
|
|
|
if (wp.getStatus().equals(WorkPlan.STATUS_WORK_OK)) { |
|
|
|
|
WorkPlan nextWorkPlan = workPlanService.getById(wp.getNextWpId()); |
|
|
|
|
wo.setTsId(nextWorkPlan.getMakeTeam()); |
|
|
|
|
wo.setOcId(nextWorkPlan.getOcId()); |
|
|
|
|
caId = nextWorkPlan.getCaId(); |
|
|
|
|
} else { |
|
|
|
|
wo.setTsId(wp.getMakeTeam()); |
|
|
|
|
wo.setOcId(wp.getOcId()); |
|
|
|
|
caId = wp.getCaId(); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
caId = wp.getCaId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//如果当前订单的主作业单位不为空,重新赋值一下调度员和计划员
|
|
|
|
|
if (wo.getTsId() != null) { |
|
|
|
|
BsTeamSetEntity bsTeamSet = teamSetService.getById(wo.getTsId()); |
|
|
|
|
if (bsTeamSet != null) { |
|
|
|
|
wo.setPlanner(bsTeamSet.getPlanner()); |
|
|
|
|
wo.setDispatcher(bsTeamSet.getDispatcher()); |
|
|
|
|
} |
|
|
|
|
wo.setTsId(null); |
|
|
|
|
} else if (wo.getOcId() != null) { |
|
|
|
|
OemCraftAbilityEntity oa = oemCraftAbilityService.findBsOemAbility(wo.getOcId(), caId); |
|
|
|
|
if (oa == null) { |
|
|
|
|
throw new ServiceException("外协商【" + wo.getOcId() + "】没有配置对应的工艺能力!!!"); |
|
|
|
|
} |
|
|
|
|
wo.setPlanner(oa.getPlanner()); |
|
|
|
|
wo.setDispatcher(oa.getDispatcher()); |
|
|
|
|
wo.setTsId(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void workPlanEnd(WorkPlan workPlan, Date newDate, Double makeQty) { |
|
|
|
|
if (workPlan == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
workPlan.setStatus(WorkPlan.STATUS_COMPLETE); |
|
|
|
|
workPlan.setFactEndTime(newDate); |
|
|
|
|
if (workPlan.getWorkQty() < 1) { |
|
|
|
|
workPlan.setWorkQty(makeQty); |
|
|
|
|
} |
|
|
|
|
workPlan.setHours(BigDecimal.valueOf(DateUtils.differentDaysByMin(workPlan.getFactStartTime(), newDate))); |
|
|
|
|
workPlanService.updateById(workPlan); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setRbFilePreserveData(List<MesRbFilePreserveSlotEntity> preserveSlotList, List<MesQcProduceRunEntity> qcProduceRunsList, WorkPlan workPlan, List<ProduceMonitorFileSlotVO> dsRbFilePreserveSlotList, MacToolUse prMacToolUse) { |
|
|
|
|
List<MesRbFilePreserveDetailEntity> dsRbFilePreserveDetailList = null; |
|
|
|
|
ProduceMonitorFileSlotVO newDsRbFilePreserveSlot = null; |
|
|
|
|
|