| | |
| | | package com.example.erp.service.mm; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | 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; |
| | | import com.example.erp.entity.sd.DeliveryDetail; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.entity.sd.OrderProcessDetail; |
| | | import com.example.erp.entity.userInfo.Log; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.mapper.mm.BasicWarehouseTypeMapper; |
| | | import com.example.erp.mapper.mm.MaterialInventoryMapper; |
| | | import com.example.erp.mapper.mm.MaterialLogMapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | 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("originalList", materialInventoryMapper.getSelectMaterialInventoryMes()); |
| | | return map; |
| | | public List<Map<String,Object>> mesOriginalSelect() { |
| | | return materialInventoryMapper.getSelectMaterialInventoryMes(); |
| | | } |
| | | |
| | | public String saveToExamineMaterialOutbound(Map<String,Object> object) { |
| | |
| | | materialInventoryMapper.insertMaterialOutbound(materialOutbound, oddNumber); |
| | | log.setFunction("saveMaterialOutbound新增:"+oddNumber); |
| | | } |
| | | |
| | | //获取对象集合循环进行新增修改 |
| | | |
| | | if (!materialOutboundDetailList.isEmpty()) { |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | return "false1"; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | log.setFunction("updateMaterialInventory物料库存修改"); |
| | | MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class); |
| | | |
| | | materialInventoryMapper.updateMaterialInventoryAll(materialInventoryId,materialInventory); |
| | | 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) { |
| | |
| | | |
| | | } |
| | | |
| | | public Object appGetStockList() { |
| | | //ExecutorService executor = Executors.newFixedThreadPool(2); |
| | | List<MaterialInventory> materialInventoryList = materialInventoryMapper.selectGetStockList(); |
| | | //executor.shutdown(); |
| | | |
| | | Map<String, Object> totalSum = new HashMap<>(); |
| | | |
| | | Integer inventoryQuantity = 0; |
| | | Integer availableQuantity = 0; |
| | | Double totalArea = 0.00; |
| | | for (MaterialInventory materialInventory : materialInventoryList) { |
| | | inventoryQuantity += materialInventory.getInventoryQuantity(); |
| | | availableQuantity += materialInventory.getAvailableQuantity(); |
| | | totalArea += materialInventory.getTotalArea(); |
| | | } |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | totalSum.put("inventoryQuantity",inventoryQuantity); |
| | | totalSum.put("availableQuantity",availableQuantity); |
| | | totalSum.put("totalArea", df.format(totalArea)); |
| | | |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("glassStock", materialInventoryList); |
| | | map.put("totalSum", totalSum); |
| | | return map; |
| | | } |
| | | } |