|  |  |  | 
|---|
|  |  |  | package com.dy.pmsStation.assemblyStep; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | 
|---|
|  |  |  | import com.dy.pmsGlobal.daoPlt.PltProductQualityInspectionItemsMapper; | 
|---|
|  |  |  | import com.dy.pmsGlobal.daoPlt.PltProductTestInspectionItemsMapper; | 
|---|
|  |  |  | import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper; | 
|---|
|  |  |  | import com.dy.pmsGlobal.daoPr.PrProductionNodeMapper; | 
|---|
|  |  |  | import com.dy.pmsGlobal.daoSta.*; | 
|---|
|  |  |  | import com.dy.pmsGlobal.pojoPlt.PltProductQualityInspectionItems; | 
|---|
|  |  |  | import com.dy.pmsGlobal.pojoPlt.PltProductTestInspectionItems; | 
|---|
|  |  |  | import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan; | 
|---|
|  |  |  | import com.dy.pmsGlobal.pojoPr.PrProductionNode; | 
|---|
|  |  |  | import com.dy.pmsGlobal.pojoSta.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | private StaDeviceProductionLogMapper deviceProductionLogDao; | 
|---|
|  |  |  | private StaAssemblyWorkLastMapper assemblyWorkLastDao; | 
|---|
|  |  |  | private PrAssemblyPlanMapper assemblyPlanDao; | 
|---|
|  |  |  | //    private PrProductionProcessMapper processDao; | 
|---|
|  |  |  | //    private PrProductionProcessMapper processDao; | 
|---|
|  |  |  | private PrProductionNodeMapper nodeDao; | 
|---|
|  |  |  | private StaRepairInfoMapper repairInfoDao; | 
|---|
|  |  |  | private PltProductQualityInspectionItemsMapper qualityItemsDao; | 
|---|
|  |  |  | private PltProductTestInspectionItemsMapper testItemsDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setDeviceLastDao(StaDeviceLastMapper deviceLastDao) { | 
|---|
|  |  |  | this.deviceLastDao = deviceLastDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setDeviceLifeDao(StaDeviceLifeMapper deviceLifeDao) { | 
|---|
|  |  |  | this.deviceLifeDao = deviceLifeDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setWipSnExDao(StaWipSnExMapper wipSnExDao) { | 
|---|
|  |  |  | this.wipSnExDao = wipSnExDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setDeviceProductionLogDao(StaDeviceProductionLogMapper deviceProductionLogDao) { | 
|---|
|  |  |  | this.deviceProductionLogDao = deviceProductionLogDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setAssemblyWorkLastDao(StaAssemblyWorkLastMapper assemblyWorkLastDao) { | 
|---|
|  |  |  | this.assemblyWorkLastDao = assemblyWorkLastDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setAssemblyPlanDao(PrAssemblyPlanMapper assemblyPlanDao) { | 
|---|
|  |  |  | this.assemblyPlanDao = assemblyPlanDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setNodeDao(PrProductionNodeMapper nodeDao) { | 
|---|
|  |  |  | this.nodeDao = nodeDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setRepairInfoDao(StaRepairInfoMapper repairInfoDao) { | 
|---|
|  |  |  | this.repairInfoDao = repairInfoDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setQualityItemsDao(PltProductQualityInspectionItemsMapper qualityItemsDao) { | 
|---|
|  |  |  | this.qualityItemsDao = qualityItemsDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public void setTestItemsDao(PltProductTestInspectionItemsMapper testItemsDao) { | 
|---|
|  |  |  | this.testItemsDao = testItemsDao; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (deviceList.isEmpty()) { | 
|---|
|  |  |  | throw new RuntimeException("设备号("+ params.deviceNo +")均不属于当前任务计划"); | 
|---|
|  |  |  | throw new RuntimeException("设备号(" + params.deviceNo + ")均不属于当前任务计划"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (deviceList.size() > 1) { | 
|---|
|  |  |  | throw new RuntimeException("设备号有且只能有一个属于当前任务计划"); | 
|---|
|  |  |  | 
|---|
|  |  |  | deviceLifeDao.insertSelective(life); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private StaDeviceLast buildDeviceLast(QueryVo params, StaAssemblyWorkLast workLast, String deviceNo){ | 
|---|
|  |  |  | private StaDeviceLast buildDeviceLast(QueryVo params, StaAssemblyWorkLast workLast, String deviceNo) { | 
|---|
|  |  |  | //组装数据 | 
|---|
|  |  |  | StaDeviceLast record = new StaDeviceLast(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StaDeviceLast preRecord = deviceLastDao.selectByDeviceNo(deviceNo); | 
|---|
|  |  |  | if(preRecord != null){ | 
|---|
|  |  |  | if (preRecord != null) { | 
|---|
|  |  |  | record.id = preRecord.id; | 
|---|
|  |  |  | record.inTime = preRecord.outTime; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PrProductionNode node = nodeDao.selectByPrimaryKey(workLast.nodeId); | 
|---|
|  |  |  | record.nodeContent = node.content; | 
|---|
|  |  |  | if(node.isRecord){ | 
|---|
|  |  |  | if (node.isRecord) { | 
|---|
|  |  |  | record.equipCycleContent = node.equipCycleContent; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | record.status = getStatus(params.status,node.isEnd); | 
|---|
|  |  |  | record.status = getStatus(params.status, node.isEnd); | 
|---|
|  |  |  | return record; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private void saveSnEx(StaAssemblyWorkLast workLast, List<String> deviceList,List<String> materialList, PrAssemblyPlan plan){ | 
|---|
|  |  |  | for (String material:materialList) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void saveSnEx(StaAssemblyWorkLast workLast, List<String> deviceList, List<String> materialList, PrAssemblyPlan plan) { | 
|---|
|  |  |  | for (String material : materialList) { | 
|---|
|  |  |  | StaWipSnEx snEx = new StaWipSnEx(); | 
|---|
|  |  |  | snEx.deviceNo = deviceList.get(0); | 
|---|
|  |  |  | snEx.productId = plan.process.proId; | 
|---|
|  |  |  | 
|---|
|  |  |  | wipSnExDao.insertSelective(snEx); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 状态: 1:组装中,2:完成,3:维修,4:报废 | 
|---|
|  |  |  | * @param status 状态 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param status    状态 | 
|---|
|  |  |  | * @param isEndNode 是否结束节点 | 
|---|
|  |  |  | * @return 状态 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private int getStatus(String status,boolean isEndNode){ | 
|---|
|  |  |  | private int getStatus(String status, boolean isEndNode) { | 
|---|
|  |  |  | return switch (status) { | 
|---|
|  |  |  | case QrCodeConstant.MarkOk -> isEndNode? STATUS_COMPLETE:STATUS_OK; | 
|---|
|  |  |  | case QrCodeConstant.MarkOk -> isEndNode ? STATUS_COMPLETE : STATUS_OK; | 
|---|
|  |  |  | case QrCodeConstant.MarkUnqualified -> STATUS_REPAIR; | 
|---|
|  |  |  | case QrCodeConstant.MarkWaste -> STATUS_WASTE; | 
|---|
|  |  |  | default -> throw new RuntimeException("状态错误"); | 
|---|
|  |  |  | 
|---|
|  |  |  | deviceLast.assistants = vo.assistants; | 
|---|
|  |  |  | //如果原节点是结束节点或之后的节点,是则更新为完成,否则更新为组装中(默认维修节点的状态只能为 确定或 报废) | 
|---|
|  |  |  | boolean isEndNode = nodeDao.isEndNode(preDeviceRecord.currNode); | 
|---|
|  |  |  | if(QrCodeConstant.MarkWaste.equals(vo.status)){ | 
|---|
|  |  |  | if (QrCodeConstant.MarkWaste.equals(vo.status)) { | 
|---|
|  |  |  | deviceLast.status = STATUS_WASTE; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | deviceLast.status = isEndNode? STATUS_COMPLETE:STATUS_OK; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | deviceLast.status = isEndNode ? STATUS_COMPLETE : STATUS_OK; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int count = deviceLast.id == null ? deviceLastDao.insertSelective(deviceLast) : | 
|---|
|  |  |  | deviceLastDao.updateByPrimaryKeySelective(deviceLast); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return count; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<PltProductQualityInspectionItems> getQualityItems(String proId) { | 
|---|
|  |  |  | Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | params.put("proId", proId);//item  start  count | 
|---|
|  |  |  | //查询符合条件的记录 | 
|---|
|  |  |  | return qualityItemsDao.selectSome(params); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<PltProductTestInspectionItems> getTestItems(String proId) { | 
|---|
|  |  |  | Map<String, Object> params = new HashMap<>(); | 
|---|
|  |  |  | params.put("proId", proId); | 
|---|
|  |  |  | return testItemsDao.selectSome(params); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|