| | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.*; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.pojo.web_site.WorkflowDevice; |
| | | 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 |
| | | private WorkflowDeviceService deviceService; |
| | | |
| | | @Autowired |
| | | private DeviceSpareService deviceSpareService; |
| | | @Autowired |
| | | private DeviceScrapService deviceScrapService; |
| | | |
| | | |
| | | public void addBatch(List<WorkflowLink> links) { |
| | |
| | | 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()); |
| | |
| | | link.setDealAndClose(1); |
| | | } |
| | | }break; |
| | | case 4:{ //TODO 出库申请 |
| | | case 4:{ // 出库申请 |
| | | 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()); |
| | | 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); |
| | | //检查是否有关联工单.如果有关联工单,关联工单状态重置为完结待处理,完成时间重置为空 |
| | | if(mainInDB.getRelatedId() != null){ |
| | | Integer relatedId = mainInDB.getRelatedId(); |
| | | //mainService.resetRepairStatus(relatedId,mainInDB.getQuantity()); |
| | | } |
| | | mainService.updateById(mainInDB); |
| | | link.setDealAndClose(1); |
| | | } |