| | |
| | | |
| | | |
| | | //查询物料是否存在 |
| | | Integer MaterialInventoryCount=0; |
| | | List<MaterialInventory> MaterialInventoryCount; |
| | | if (materialInventory.getDateOfManufacture()!=null){ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture()); |
| | | }else{ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(materialCode); |
| | | } |
| | | |
| | | if(MaterialInventoryCount==1){ |
| | | if(MaterialInventoryCount.size()==1){ |
| | | materialInventory.setId(MaterialInventoryCount.get(0).getId()); |
| | | if (materialInventory.getDateOfManufacture()!=null){ |
| | | materialInventoryMapper.updateMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryNull(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | } |
| | | log.setFunction("saveMaterialInventory修改"); |
| | | }else if(MaterialInventoryCount==0) { |
| | | }else if(MaterialInventoryCount.isEmpty()) { |
| | | materialInventoryMapper.insertMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | log.setFunction("saveMaterialInventory新增"); |
| | | }else { |
| | |
| | | MaterialStore materialStore=materialStoreMapper.getSelectMaterialStoreById(materialCode); |
| | | json=materialStore.getJson().substring(1, materialStore.getJson().length() - 1); |
| | | MaterialLog materialLog=new MaterialLog(); |
| | | if(materialInventory.getDateOfManufacture()!=null){ |
| | | materialLog.setOperationOrderNumber(materialInventory.getDateOfManufacture().toString()); |
| | | } |
| | | materialLog.setOperateType("物料新增"); |
| | | materialLog.setMaterialCode(materialCode); |
| | | materialLog.setMaterialName(convertString(json,"\"name\"")); |
| | |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId); |
| | | if (!materialOutboundDetailList.isEmpty()) { |
| | | for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) { |
| | | |
| | | if(materialOutboundDetail.getUseId()!=null){ |
| | | //修改物料库存数量 |
| | | materialInventoryMapper.updateMaterialInventoryInventoryPlanQuantityOut(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity()); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryInventoryOut(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity()); |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId); |
| | | if (!materialOutboundDetailList.isEmpty()) { |
| | | for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) { |
| | | |
| | | if(materialOutboundDetail.getUseId()!=null){ |
| | | //修改物料库存数量 |
| | | materialInventoryMapper.updateMaterialInventoryInventoryPlanQuantityInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity()); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryInventoryInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity()); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | //查询物料是否存在 |
| | | Integer MaterialInventoryCount=0; |
| | | List<MaterialInventory> MaterialInventoryCount; |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture()); |
| | | }else{ |
| | |
| | | } |
| | | |
| | | |
| | | if(MaterialInventoryCount>0){ |
| | | if(!MaterialInventoryCount.isEmpty()){ |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | materialInventoryMapper.updateMaterialInventoryReturning(returningWarehouseDetail.getId(),singlePieceArea,totalArea,returningWarehouseDetail); |
| | | }else{ |
| | |
| | | } |
| | | |
| | | |
| | | public String cancelMaterialAdditionRecord(Map<String,Object> object) { |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | Log log = new Log(); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setFunction("cancelMaterialAdditionRecord物料新增撤销"); |
| | | log.setContent(object.toString()); |
| | | //获取对象集合循环进行新增修改 |
| | | List<MaterialLog> materialLoglist = JSONArray.parseArray(JSONObject.toJSONString(object.get("materialAdd")), MaterialLog.class); |
| | | if (!materialLoglist.isEmpty()){ |
| | | for (MaterialLog materialLog : materialLoglist) { |
| | | |
| | | //查询物料是否存在 |
| | | List<MaterialInventory> MaterialInventoryList; |
| | | if (materialLog.getOperationOrderNumber()!=null){ |
| | | MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCount(materialLog.getMaterialCode(), LocalDate.parse(materialLog.getOperationOrderNumber())); |
| | | }else{ |
| | | MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCountNull(materialLog.getMaterialCode()); |
| | | } |
| | | |
| | | if(MaterialInventoryList.size()==1){ |
| | | if(MaterialInventoryList.get(0).getAvailableQuantity()>=materialLog.getQuantity()){ |
| | | if (materialLog.getOperationOrderNumber()!=null){ |
| | | materialInventoryMapper.updateMaterialInventoryOut(materialLog.getMaterialCode(),materialLog.getQuantity(),materialLog.getOperationOrderNumber()); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryNullOut(materialLog.getMaterialCode(),materialLog.getQuantity()); |
| | | } |
| | | materialInventoryMapper.deleteMaterialLogById(materialLog.getId()); |
| | | }else{ |
| | | return "false1"; |
| | | } |
| | | |
| | | }else{ |
| | | return "false2"; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | logService.saveLog(log); |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("cancelFinishedGoodsInventoryStorage"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false"; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getOptimizeOutboundReport(String type, Integer pageNum, Integer pageSize, List<String> selectDate, MaterialLog materialLog) { |
| | | Integer offset = (pageNum-1)*pageSize; |
| | | String endDate = LocalDate.now().toString(); |
| | | String startDate = LocalDate.now().minusDays(15).toString(); |
| | | if(selectDate !=null && selectDate.size()==2){ |
| | | if(!selectDate.get(0).isEmpty()){ |
| | | startDate = selectDate.get(0); |
| | | } |
| | | if(!selectDate.get(1).isEmpty()){ |
| | | endDate = selectDate.get(1); |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", materialInventoryMapper.getOptimizeOutboundReport(offset, pageSize,startDate, endDate, materialLog,type)); |
| | | map.put("total", materialInventoryMapper.getOptimizeOutboundReportTotal(offset, pageSize,startDate, endDate, materialLog,type)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | } |