| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.dto.mm.FinishedOperateLogDTO; |
| | | import com.example.erp.dto.mm.MaterialLogDTO; |
| | | import com.example.erp.entity.mm.*; |
| | | import com.example.erp.entity.pp.*; |
| | | import com.example.erp.entity.sd.Delivery; |
| | |
| | | |
| | | MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class); |
| | | |
| | | |
| | | if(materialInventory.getProducer()==null){ |
| | | materialInventory.setProducer(""); |
| | | } |
| | | //查询物料是否存在 |
| | | List<MaterialInventory> MaterialInventoryCount; |
| | | if (materialInventory.getDateOfManufacture()!=null){ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture()); |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture(),materialInventory.getProducer()); |
| | | }else{ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(materialCode); |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(materialCode,materialInventory.getProducer()); |
| | | } |
| | | |
| | | if(MaterialInventoryCount.size()==1){ |
| | |
| | | totalArea= Double.parseDouble(decimalFormat.format(singlePieceArea * returningWarehouseDetail.getReturnQuantity())); |
| | | |
| | | |
| | | if(returningWarehouseDetail.getProducer()==null){ |
| | | returningWarehouseDetail.setProducer(""); |
| | | } |
| | | //查询物料是否存在 |
| | | List<MaterialInventory> MaterialInventoryCount; |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture()); |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture(),returningWarehouseDetail.getProducer()); |
| | | }else{ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(returningWarehouseDetail.getId()); |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(returningWarehouseDetail.getId(),returningWarehouseDetail.getProducer()); |
| | | } |
| | | |
| | | |
| | |
| | | //获取库存编号添加到返库明细表 |
| | | List<MaterialInventory> MaterialInventoryId; |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountId(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture()); |
| | | MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountId(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture(),returningWarehouseDetail.getProducer()); |
| | | }else{ |
| | | MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountNullId(returningWarehouseDetail.getId()); |
| | | MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountNullId(returningWarehouseDetail.getId(),returningWarehouseDetail.getProducer()); |
| | | } |
| | | materialInventoryMapper.updateReturningWarehouseDetail(oddNumber, returningWarehouseDetailMaximum + 1,MaterialInventoryId.get(0).getId()); |
| | | |
| | |
| | | return map; |
| | | } |
| | | |
| | | public List<MaterialLog> exportMaterialLogReport(List<LocalDate> dates, String type) { |
| | | return materialInventoryMapper.exportMaterialLogReport(dates,type); |
| | | public List<MaterialLogDTO> exportMaterialLogReport(List<LocalDate> dates, String type) { |
| | | if(type.equals("物料出库")){ |
| | | return materialInventoryMapper.exportMaterialLogReport(dates,type); |
| | | }else if(type.equals("优化出库")){ |
| | | return materialInventoryMapper.exportMaterialLogOptimizeOutboundReport(dates,type); |
| | | }else{ |
| | | return materialInventoryMapper.exportMaterialLogReports(dates,type); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | materialInventoryMapper.updateMaterialInventoryAvailableInventoryOutMes(Long.valueOf(optimizeUses.getRawStockCode()),quantity); |
| | | materialInventoryMapper.updateOptimizeUsesMes(optimizeUses.getId(),quantity); |
| | | }else{ |
| | | return false; |
| | | } |
| | | |
| | | //保存日志 |
| | |
| | | if (!materialLoglist.isEmpty()){ |
| | | for (MaterialLog materialLog : materialLoglist) { |
| | | |
| | | if(materialLog.getProducer()==null){ |
| | | materialLog.setProducer(""); |
| | | } |
| | | //查询物料是否存在 |
| | | List<MaterialInventory> MaterialInventoryList; |
| | | if (materialLog.getOperationOrderNumber()!=null){ |
| | | MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCount(materialLog.getMaterialCode(), LocalDate.parse(materialLog.getOperationOrderNumber())); |
| | | MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCount(materialLog.getMaterialCode(), LocalDate.parse(materialLog.getOperationOrderNumber()),materialLog.getProducer()); |
| | | }else{ |
| | | MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCountNull(materialLog.getMaterialCode()); |
| | | MaterialInventoryList = materialInventoryMapper.getMaterialInventoryCountNull(materialLog.getMaterialCode(),materialLog.getProducer()); |
| | | } |
| | | |
| | | if(MaterialInventoryList.size()==1){ |
| | | if(MaterialInventoryList.get(0).getAvailableQuantity()>=materialLog.getQuantity()){ |
| | | if (materialLog.getOperationOrderNumber()!=null){ |
| | | materialInventoryMapper.updateMaterialInventoryOut(materialLog.getMaterialCode(),materialLog.getQuantity(),materialLog.getOperationOrderNumber()); |
| | | materialInventoryMapper.updateMaterialInventoryOut(materialLog.getMaterialCode(),materialLog.getQuantity(), |
| | | materialLog.getOperationOrderNumber(),materialLog.getProducer()); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryNullOut(materialLog.getMaterialCode(),materialLog.getQuantity()); |
| | | materialInventoryMapper.updateMaterialInventoryNullOut(materialLog.getMaterialCode(),materialLog.getQuantity(), |
| | | materialLog.getProducer()); |
| | | } |
| | | materialInventoryMapper.deleteMaterialLogById(materialLog.getId()); |
| | | }else{ |
| | |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> mesOriginalSelect() { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", materialInventoryMapper.getSelectMaterialInventoryMes()); |
| | | return map; |
| | | public List<Map<String,Object>> mesOriginalSelect() { |
| | | return materialInventoryMapper.getSelectMaterialInventoryMes(); |
| | | } |
| | | |
| | | public String saveToExamineMaterialOutbound(Map<String,Object> object) { |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | public String updateMaterialInventory(Map<String,Object> object) { |
| | | String saveState = "true"; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | |
| | | long materialInventoryId = 0L; |
| | | if (object.get("materialInventoryId") != null) { |
| | | materialInventoryId = Long.parseLong(object.get("materialInventoryId").toString()); |
| | | } |
| | | Log log = new Log(); |
| | | log.setOperatorId(object.get("userId").toString()); |
| | | log.setOperator(object.get("userName").toString()); |
| | | log.setContent(object.toString()); |
| | | log.setFunction("updateMaterialInventory物料库存修改"); |
| | | MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class); |
| | | |
| | | if(materialInventory.getProducer()==null){ |
| | | materialInventory.setProducer(""); |
| | | } |
| | | //查询物料是否存在 |
| | | List<MaterialInventory> MaterialInventoryCount; |
| | | if (materialInventory.getDateOfManufacture()!=null){ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount1(materialInventory.getMaterialCode(),materialInventory.getDateOfManufacture(),materialInventory.getProducer(),materialInventory.getId()); |
| | | }else{ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull1(materialInventory.getMaterialCode(),materialInventory.getProducer(),materialInventory.getId()); |
| | | } |
| | | |
| | | if(MaterialInventoryCount.size()==1){ |
| | | materialInventoryMapper.updateMaterialInventoryOne(MaterialInventoryCount.get(0).getId(),materialInventory); |
| | | List<Long> id=new ArrayList<>(); |
| | | id.add(materialInventoryId); |
| | | materialInventoryMapper.deleteMaterialInventory(id); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryAll(materialInventoryId,materialInventory); |
| | | } |
| | | |
| | | |
| | | |
| | | logService.saveLog(log); |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e+Arrays.toString(e.getStackTrace())); |
| | | sysError.setFunc("saveMaterialInventory"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = "false"; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | } |