| | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.*; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.pojo.web_site.WorkflowLink; |
| | | import com.whyc.pojo.web_site.WorkflowMain; |
| | | import com.whyc.pojo.web_site.*; |
| | | import com.whyc.util.CommonUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private WorkflowMainService mainService; |
| | | |
| | | @Autowired |
| | | private WorkflowDeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private DeviceSpareService deviceSpareService; |
| | | @Autowired |
| | | private DeviceScrapService deviceScrapService; |
| | | |
| | | |
| | | public void addBatch(List<WorkflowLink> links) { |
| | |
| | | mainService.updateById(mainInDB); |
| | | link.setDealAndClose(1); |
| | | } |
| | | } |
| | | }break; |
| | | //设备入库申请 |
| | | case 2: |
| | | //设备报废申请 |
| | | case 3:{ |
| | | if(link.getStatus() == WorkflowEnum.LINK_STATUS_PASS.getValue().intValue()){ |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_WAIT_FOR_DEALING.getValue()); |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_END_PASS.getValue()); |
| | | mainInDB.setEndTime(now); |
| | | mainInDB.setEndReason(link.getDealReason()); |
| | | mainService.updateById(mainInDB); |
| | | |
| | | List<WorkflowDevice> deviceListInDB = deviceService.getByMainId(mainInDB.getId()); |
| | | //入库 |
| | | if(mainInDB.getType() == 2){ |
| | | List<DeviceSpare> spareList = new ArrayList<>(); |
| | | deviceListInDB.forEach(device -> { |
| | | DeviceSpare spare = new DeviceSpare(); |
| | | /*spare.setName(device.getName()); |
| | | spare.setModel(device.getModel()); |
| | | spare.setVersion(device.getVersion()); |
| | | spare.setQuantity(device.getQuantity()); |
| | | spare.setBrand(device.getBrand()); |
| | | spare.setType(device.getType()); |
| | | spare.setSupplier(device.getSupplier());*/ |
| | | BeanUtils.copyProperties(device,spare); |
| | | |
| | | spareList.add(spare); |
| | | }); |
| | | deviceSpareService.addOrUpdate(spareList); |
| | | }else{ //进入报废库 |
| | | List<DeviceScrap> scrapList = new ArrayList<>(); |
| | | deviceListInDB.forEach(device -> { |
| | | DeviceScrap deviceScrap = new DeviceScrap(); |
| | | BeanUtils.copyProperties(device,deviceScrap); |
| | | deviceScrap.setApplyUserId(mainInDB.getCreateUserId()); |
| | | deviceScrap.setApplyUserName(mainInDB.getCreateUserName()); |
| | | deviceScrap.setCreateTime(now); |
| | | deviceScrap.setMainId(mainInDB.getId()); |
| | | scrapList.add(deviceScrap); |
| | | }); |
| | | deviceScrapService.add(scrapList); |
| | | |
| | | } |
| | | }else if(link.getStatus() == WorkflowEnum.LINK_STATUS_REJECT.getValue().intValue()){ |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_END_REJECT.getValue()); |
| | | mainInDB.setEndReason(link.getDealRejectReason()); |
| | | mainInDB.setEndTime(now); |
| | | //检查是否有关联工单.如果有关联工单,关联工单状态重置为完结待处理,完成时间重置为空 |
| | | //检查是否有关联工单. |
| | | // 如果有关联工单,关联工单状态重置为完结待处理,完成时间重置为空 |
| | | if(mainInDB.getRelatedId() != null){ |
| | | Integer relatedId = mainInDB.getRelatedId(); |
| | | mainService.resetRepairStatus(relatedId,mainInDB.getQuantity()); |
| | | mainService.resetRepairStatus(relatedId); |
| | | //关联工单的设备附属表未处理数量也要回退,等于主表设备数量 |
| | | List<WorkflowDevice> deviceRelatedListInDB = deviceService.getByMainId(mainInDB.getRelatedId()); |
| | | List<WorkflowDevice> deviceListInDB = deviceService.getByMainId(mainInDB.getId()); |
| | | for (int i = 0; i < deviceListInDB.size(); i++) { |
| | | WorkflowDevice deviceInDB = deviceListInDB.get(i); |
| | | for (int j = 0; j < deviceRelatedListInDB.size(); j++) { |
| | | WorkflowDevice deviceRelatedInDB = deviceRelatedListInDB.get(j); |
| | | if (deviceInDB.getName().equals(deviceRelatedInDB.getName()) |
| | | && deviceInDB.getModel().equals(deviceRelatedInDB.getModel()) |
| | | && deviceInDB.getVersion().equals(deviceRelatedInDB.getVersion()) |
| | | && deviceInDB.getBrand().equals(deviceRelatedInDB.getBrand()) |
| | | && deviceInDB.getType().equals(deviceRelatedInDB.getType()) |
| | | && deviceInDB.getSupplier().equals(deviceRelatedInDB.getSupplier()) |
| | | ) { |
| | | deviceRelatedInDB.setQuantityUnprocessed(deviceInDB.getQuantity()); |
| | | //关联工单当前设备附属的未处理数量回退完成,下一个 |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | deviceService.updateQuantityUnprocessedBatch(deviceRelatedListInDB); |
| | | } |
| | | mainService.updateById(mainInDB); |
| | | link.setDealAndClose(1); |
| | | } |
| | | } |
| | | }break; |
| | | case 4:{ // 出库申请 |
| | | if(link.getStatus() == WorkflowEnum.LINK_STATUS_PASS.getValue().intValue()){ |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_END_PASS.getValue()); |
| | | mainInDB.setEndTime(now); |
| | | mainInDB.setEndReason(link.getDealReason()); |
| | | mainService.updateById(mainInDB); |
| | | //获取出库申请单设备 |
| | | List<WorkflowDevice> deviceListInDB = deviceService.getByMainId(mainInDB.getId()); |
| | | List<DeviceSpare> spareList = new ArrayList<>(); |
| | | deviceListInDB.forEach(device -> { |
| | | DeviceSpare spare = new DeviceSpare(); |
| | | BeanUtils.copyProperties(device,spare); |
| | | spareList.add(spare); |
| | | }); |
| | | //更新库存 |
| | | deviceSpareService.outBound(spareList); |
| | | }else if(link.getStatus() == WorkflowEnum.LINK_STATUS_REJECT.getValue().intValue()){ |
| | | mainInDB.setStatus(WorkflowEnum.MAIN_STATUS_END_REJECT.getValue()); |
| | | mainInDB.setEndReason(link.getDealRejectReason()); |
| | | mainInDB.setEndTime(now); |
| | | mainService.updateById(mainInDB); |
| | | link.setDealAndClose(1); |
| | | } |
| | | }break; |
| | | default: |
| | | break; |
| | | |
| | | } |
| | | |