New file |
| | |
| | | package com.example.erp.service.mm; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.mm.*; |
| | | import com.example.erp.entity.pp.OptimizeUse; |
| | | 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.userInfo.SysError; |
| | | import com.example.erp.mapper.mm.BasicWarehouseTypeMapper; |
| | | import com.example.erp.mapper.mm.MaterialInventoryMapper; |
| | | import com.example.erp.mapper.mm.MaterialStoreMapper; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | import java.util.List; |
| | | import java.util.ArrayList; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @DS("mm") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class MaterialInventoryService { |
| | | @Autowired |
| | | MaterialInventoryMapper materialInventoryMapper; |
| | | @Autowired |
| | | MaterialStoreMapper materialStoreMapper; |
| | | @Autowired |
| | | BasicWarehouseTypeMapper basicWarehouseTypeMapper; |
| | | @Autowired |
| | | SysErrorService sysErrorService; |
| | | |
| | | public Boolean saveMaterialOutbound(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | String materialOutboundId = ""; |
| | | String oddNumber; |
| | | if (object.get("materialOutboundId") != null) { |
| | | materialOutboundId = object.get("materialOutboundId").toString(); |
| | | } |
| | | try { |
| | | MaterialOutbound materialOutbound = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialOutbound.class); |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = JSONArray.parseArray(JSONObject.toJSONString(object.get("materialOutboundDetail")), MaterialOutboundDetail.class); |
| | | //查询出库单是否存在 |
| | | Integer MaterialOutboundConut = materialInventoryMapper.getMaterialOutboundCount(materialOutboundId); |
| | | if (MaterialOutboundConut != 0) { |
| | | |
| | | List<MaterialOutboundDetail> materialOutboundDetailLists = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId); |
| | | if (!materialOutboundDetailLists.isEmpty()) { |
| | | for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailLists) { |
| | | //还原物料库存数 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableInt(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity()); |
| | | /*if(materialOutboundDetail.getUseId()!=null){ |
| | | //还原优化工程库存数 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableOptInt(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity()); |
| | | }else{ |
| | | //还原物料库存数 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableInt(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity()); |
| | | }*/ |
| | | |
| | | } |
| | | } |
| | | //删除材料出库明细的数据 |
| | | materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId); |
| | | oddNumber = materialOutboundId; |
| | | } else { |
| | | //获取单号 |
| | | oddNumber = orderNumberSetting("出库"); |
| | | //新增材料出库表数据 |
| | | materialInventoryMapper.insertMaterialOutbound(materialOutbound, oddNumber); |
| | | } |
| | | |
| | | //获取对象集合循环进行新增修改 |
| | | |
| | | if (!materialOutboundDetailList.isEmpty()) { |
| | | for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) { |
| | | |
| | | Integer materialOutboundDetailMaximum = materialInventoryMapper.getMaterialOutboundDetailMaximum(oddNumber); |
| | | //新增材料出库明细数据 |
| | | materialInventoryMapper.insertMaterialOutboundDetail(materialOutboundDetail, oddNumber, materialOutboundDetailMaximum + 1); |
| | | //修改物料库存表出库数量 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity()); |
| | | /*if(materialOutboundDetail.getUseId()!=null){ |
| | | //修改优化工程表出库数量 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableOptOut(materialOutboundDetail.getUseId(), materialOutboundDetail.getOutboundQuantity()); |
| | | }else{ |
| | | //修改物料库存表出库数量 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableOut(materialOutboundDetail.getId(), materialOutboundDetail.getOutboundQuantity()); |
| | | }*/ |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Boolean saveMaterialInventory(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | Double singlePieceArea = 0.0; |
| | | Double totalArea = 0.0; |
| | | Long materialCode = 0L; |
| | | if (object.get("singlePieceArea") != null) { |
| | | singlePieceArea = Double.valueOf(object.get("singlePieceArea").toString()); |
| | | } |
| | | if (object.get("totalArea") != null) { |
| | | totalArea = Double.valueOf(object.get("totalArea").toString()); |
| | | } |
| | | if (object.get("materialCode") != null) { |
| | | materialCode = Long.valueOf(object.get("materialCode").toString()); |
| | | } |
| | | |
| | | MaterialInventory materialInventory = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), MaterialInventory.class); |
| | | |
| | | //查询物料是否存在 |
| | | Integer MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(materialCode,materialInventory.getDateOfManufacture()); |
| | | |
| | | if(MaterialInventoryCount>0){ |
| | | materialInventoryMapper.updateMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | }else { |
| | | materialInventoryMapper.insertMaterialInventory(materialCode,singlePieceArea,totalArea,materialInventory); |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Map<String, Object> getSelectMaterialInventoryDate(Integer pageNum, Integer pageSize, List<String> selectDate, MaterialInventory materialInventory) { |
| | | 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.getSelectMaterialInventoryDate(offset, pageSize,startDate, endDate, materialInventory)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialInventoryDatePageTotal(offset, pageSize,startDate, endDate, materialInventory)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectMaterialInventoryEngineeringDate(Integer pageNum, Integer pageSize, List<String> selectDate, MaterialInventory materialInventory) { |
| | | 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.getSelectMaterialInventoryEngineeringDate(offset, pageSize,startDate, endDate, materialInventory)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialInventoryEngineeringDatePageTotal(offset, pageSize,startDate, endDate, materialInventory)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectMaterialInventory(Integer pageNum, Integer pageSize, MaterialInventory materialInventory) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Long> ids=new ArrayList<>();; |
| | | if(materialInventory.getStockId()!=null && !materialInventory.getStockId().isEmpty()){ |
| | | List<String> result = StrUtil.split(materialInventory.getStockId(), '|'); |
| | | ids=result.stream().map(Long::valueOf).collect(Collectors.toList()); |
| | | } |
| | | map.put("data", materialInventoryMapper.getSelectMaterialInventory(offset, pageSize, materialInventory,ids)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialInventoryPageTotal(offset, pageSize, materialInventory,ids)); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectMaterialInventoryEngineering(Integer pageNum, Integer pageSize, OptimizeUse optimizeUse) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Long> ids=new ArrayList<>();; |
| | | if(optimizeUse.getRawStockCode()!=null && !optimizeUse.getRawStockCode().isEmpty()){ |
| | | List<String> result = StrUtil.split(optimizeUse.getRawStockCode(), '|'); |
| | | ids=result.stream().map(Long::valueOf).collect(Collectors.toList()); |
| | | } |
| | | map.put("data", materialInventoryMapper.getSelectMaterialInventoryEngineering(offset, pageSize, optimizeUse,ids)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialInventoryEngineeringPageTotal(offset, pageSize, optimizeUse,ids)); |
| | | return map; |
| | | } |
| | | |
| | | public Boolean deleteMaterialOutbound(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String materialOutboundId = ""; |
| | | if (object.get("materialOutboundId") != null) { |
| | | materialOutboundId = object.get("materialOutboundId").toString(); |
| | | } |
| | | if(materialOutboundId!=null){ |
| | | materialInventoryMapper.deleteMaterialOutboundDetail(materialOutboundId); |
| | | materialInventoryMapper.deleteMaterialOutbound(materialOutboundId); |
| | | } |
| | | |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Map<String, Object> getSelectMaterialOutboundDate(Integer pageNum, Integer pageSize, List<String> selectDate, MaterialOutbound materialOutbound) { |
| | | 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.getSelectMaterialOutboundDate(offset, pageSize,startDate, endDate, materialOutbound)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialOutboundDatePageTotal(offset, pageSize,startDate, endDate, materialOutbound)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> getSelectMaterialOutbound(Integer pageNum, Integer pageSize, MaterialOutboundDetail materialOutboundDetail) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<MaterialOutboundDetail> materialOutboundDetailList= materialInventoryMapper.SelectMaterialOutboundDetail(offset, pageSize, materialOutboundDetail); |
| | | if(materialOutboundDetailList.get(0).getUseId()==null){ |
| | | map.put("materialOutbound", materialInventoryMapper.getSelectMaterialOutbound(offset, pageSize, materialOutboundDetail)); |
| | | map.put("data", materialInventoryMapper.getSelectMaterialOutboundDetail(offset, pageSize, materialOutboundDetail)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialOutboundDetailPageTotal(offset, pageSize, materialOutboundDetail)); |
| | | }else{ |
| | | map.put("materialOutbound", materialInventoryMapper.getSelectMaterialOutbound(offset, pageSize, materialOutboundDetail)); |
| | | map.put("data", materialInventoryMapper.getSelectMaterialOutboundEngineering(offset, pageSize, materialOutboundDetail)); |
| | | map.put("total", materialInventoryMapper.getSelectMaterialOutboundDetailPageTotal(offset, pageSize, materialOutboundDetail)); |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | public Boolean updateMaterialOutboundToExamine(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String materialOutboundId = ""; |
| | | String reviewed = ""; |
| | | int type =0; |
| | | if (object.get("materialOutboundId") != null) { |
| | | materialOutboundId = object.get("materialOutboundId").toString(); |
| | | } |
| | | |
| | | if (object.get("type") != null) { |
| | | type = Integer.parseInt(object.get("type").toString()); |
| | | } |
| | | if (object.get("reviewed") != null) { |
| | | reviewed = object.get("reviewed").toString(); |
| | | } |
| | | |
| | | if (type==1){ |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId); |
| | | if (!materialOutboundDetailList.isEmpty()) { |
| | | for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) { |
| | | |
| | | //修改物料库存数量 |
| | | materialInventoryMapper.updateMaterialInventoryInventoryOut(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity()); |
| | | |
| | | |
| | | } |
| | | } |
| | | materialInventoryMapper.updateMaterialOutboundToExamine(materialOutboundId,type,reviewed); |
| | | }else{ |
| | | List<MaterialOutboundDetail> materialOutboundDetailList = materialInventoryMapper.getIsNotMaterialOutboundDetail(materialOutboundId); |
| | | if (!materialOutboundDetailList.isEmpty()) { |
| | | for (MaterialOutboundDetail materialOutboundDetail : materialOutboundDetailList) { |
| | | |
| | | //修改物料库存数量 |
| | | materialInventoryMapper.updateMaterialInventoryInventoryInt(materialOutboundDetail.getInventoryId(), materialOutboundDetail.getOutboundQuantity()); |
| | | |
| | | |
| | | } |
| | | } |
| | | materialInventoryMapper.updateMaterialOutboundCounterExamination(materialOutboundId,type,reviewed); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | public Boolean saveReturningWarehouse(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | String returningId = ""; |
| | | String oddNumber; |
| | | if (object.get("returningId") != null) { |
| | | returningId = object.get("returningId").toString(); |
| | | } |
| | | ReturningWarehouse returningWarehouse = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), ReturningWarehouse.class); |
| | | List<ReturningWarehouseDetail> returningWarehouseDetailList = JSONArray.parseArray(JSONObject.toJSONString(object.get("returningWarehouseDetail")), ReturningWarehouseDetail.class); |
| | | //查询出库单是否存在 |
| | | Integer ReturningWarehouseConut = materialInventoryMapper.getReturningWarehouseCount(returningId); |
| | | if (ReturningWarehouseConut != 0) { |
| | | |
| | | List<ReturningWarehouseDetail> returningWarehouseDetailLists = materialInventoryMapper.getIsNotReturningWarehouseDetail(returningId); |
| | | if (!returningWarehouseDetailLists.isEmpty()) { |
| | | for (ReturningWarehouseDetail returningWarehouseDetail : returningWarehouseDetailLists) { |
| | | //还原物料库存数 |
| | | materialInventoryMapper.updateMaterialInventoryAvailableOut(returningWarehouseDetail.getInventoryId(), returningWarehouseDetail.getReturnQuantity()); |
| | | } |
| | | } |
| | | //删除材料出库明细的数据 |
| | | materialInventoryMapper.deleteReturningWarehouseDetail(returningId); |
| | | oddNumber = returningId; |
| | | } else { |
| | | //获取单号 |
| | | oddNumber = orderNumberSetting("返库"); |
| | | //新增材料出库表数据 |
| | | materialInventoryMapper.insertReturningWarehouse(returningWarehouse, oddNumber); |
| | | } |
| | | |
| | | |
| | | //获取对象集合循环进行新增修改 |
| | | if (!returningWarehouseDetailList.isEmpty()) { |
| | | for (ReturningWarehouseDetail returningWarehouseDetail : returningWarehouseDetailList) { |
| | | |
| | | Integer returningWarehouseDetailMaximum = materialInventoryMapper.getReturningWarehouseDetailMaximum(oddNumber); |
| | | //新增材料出库明细数据 |
| | | materialInventoryMapper.insertReturningWarehouseDetail(returningWarehouseDetail, oddNumber, returningWarehouseDetailMaximum + 1); |
| | | |
| | | double singlePieceArea=0.0; |
| | | double totalArea=0.0; |
| | | String json=""; |
| | | MaterialStore materialStore=materialStoreMapper.getSelectMaterialStoreById(returningWarehouseDetail.getId()); |
| | | json=materialStore.getJson().substring(1, materialStore.getJson().length() - 1); |
| | | |
| | | |
| | | double width= convert(json,"\"width\""); |
| | | double height=convert(json,"\"height\""); |
| | | DecimalFormat decimalFormat = new DecimalFormat("#0.00"); |
| | | singlePieceArea= Double.parseDouble(decimalFormat.format(width * height / 100000)); |
| | | totalArea= Double.parseDouble(decimalFormat.format(singlePieceArea * returningWarehouseDetail.getReturnQuantity())); |
| | | |
| | | |
| | | //查询物料是否存在 |
| | | Integer MaterialInventoryCount=0; |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCount(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture()); |
| | | }else{ |
| | | MaterialInventoryCount = materialInventoryMapper.getMaterialInventoryCountNull(returningWarehouseDetail.getId()); |
| | | } |
| | | |
| | | |
| | | if(MaterialInventoryCount>0){ |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | materialInventoryMapper.updateMaterialInventoryReturning(returningWarehouseDetail.getId(),singlePieceArea,totalArea,returningWarehouseDetail); |
| | | }else{ |
| | | materialInventoryMapper.updateMaterialInventoryReturningNull(returningWarehouseDetail.getId(),singlePieceArea,totalArea,returningWarehouseDetail); |
| | | } |
| | | |
| | | }else { |
| | | materialInventoryMapper.insertMaterialInventoryReturning(returningWarehouseDetail.getId(),singlePieceArea,totalArea,returningWarehouseDetail); |
| | | } |
| | | |
| | | //获取库存编号添加到返库明细表 |
| | | List<MaterialInventory> MaterialInventoryId; |
| | | if (returningWarehouseDetail.getDateOfManufacture()!=null){ |
| | | MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountId(returningWarehouseDetail.getId(),returningWarehouseDetail.getDateOfManufacture()); |
| | | }else{ |
| | | MaterialInventoryId = materialInventoryMapper.getMaterialInventoryCountNullId(returningWarehouseDetail.getId()); |
| | | } |
| | | materialInventoryMapper.updateReturningWarehouseDetail(oddNumber, returningWarehouseDetailMaximum + 1,MaterialInventoryId.get(0).getId()); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getSelectReturningWarehouse(Integer pageNum, Integer pageSize, ReturningWarehouseDetail returningWarehouseDetail) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("returningWarehouse", materialInventoryMapper.getSelectReturningWarehouse(offset, pageSize, returningWarehouseDetail)); |
| | | map.put("data", materialInventoryMapper.getSelectReturningWarehouseDetail(offset, pageSize, returningWarehouseDetail)); |
| | | map.put("total", materialInventoryMapper.getSelectReturningWarehouseDetailPageTotal(offset, pageSize, returningWarehouseDetail)); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public Boolean updateReturningWarehouseToExamine(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | String returningId = ""; |
| | | String reviewed = ""; |
| | | int type =0; |
| | | if (object.get("returningId") != null) { |
| | | returningId = object.get("returningId").toString(); |
| | | } |
| | | |
| | | if (object.get("type") != null) { |
| | | type = Integer.parseInt(object.get("type").toString()); |
| | | } |
| | | if (object.get("reviewed") != null) { |
| | | reviewed = object.get("reviewed").toString(); |
| | | } |
| | | |
| | | if (type==1){ |
| | | List<ReturningWarehouseDetail> returningWarehouseDetailList = materialInventoryMapper.getIsNotReturningWarehouseDetail(returningId); |
| | | if (!returningWarehouseDetailList.isEmpty()) { |
| | | for (ReturningWarehouseDetail returningWarehouseDetail : returningWarehouseDetailList) { |
| | | //修改物料库存数量 |
| | | materialInventoryMapper.updateMaterialInventoryInventoryInt(returningWarehouseDetail.getInventoryId(), returningWarehouseDetail.getReturnQuantity()); |
| | | } |
| | | } |
| | | materialInventoryMapper.updateReturningWarehouseToExamine(returningId,type,reviewed); |
| | | }else{ |
| | | List<ReturningWarehouseDetail> returningWarehouseDetailList = materialInventoryMapper.getIsNotReturningWarehouseDetail(returningId); |
| | | if (!returningWarehouseDetailList.isEmpty()) { |
| | | for (ReturningWarehouseDetail returningWarehouseDetail : returningWarehouseDetailList) { |
| | | //修改物料库存数量 |
| | | materialInventoryMapper.updateMaterialInventoryInventoryOut(returningWarehouseDetail.getInventoryId(), returningWarehouseDetail.getReturnQuantity()); |
| | | } |
| | | } |
| | | materialInventoryMapper.updateReturningWarehouseCounterExamination(returningId,type,reviewed); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getSelectReturningWarehouseDate(Integer pageNum, Integer pageSize, List<String> selectDate, ReturningWarehouse returningWarehouse) { |
| | | 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.getSelectReturningWarehouseDate(offset, pageSize,startDate, endDate, returningWarehouse)); |
| | | map.put("total", materialInventoryMapper.getSelectReturningWarehouseDatePageTotal(offset, pageSize,startDate, endDate, returningWarehouse)); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(startDate); |
| | | list.add(endDate); |
| | | map.put("selectDate",list); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | public String orderNumberSetting(String type) { |
| | | //根据类型自动生成不同的操作单号 |
| | | String alias=""; |
| | | Integer maximum=0; |
| | | if(Objects.equals(type, "出库")){ |
| | | alias="CK"; |
| | | maximum=materialInventoryMapper.getMaximum(type); |
| | | } |
| | | if(Objects.equals(type, "返库")){ |
| | | alias="FK"; |
| | | maximum=materialInventoryMapper.getMaximums(type); |
| | | } |
| | | //查询当天的最大数量 |
| | | |
| | | //设置两位不够补0 |
| | | String formattedNumber = String.format("%02d", maximum+1); |
| | | //格式化当前日期 |
| | | Date currentDate = new Date(); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd"); |
| | | String formattedDate = dateFormat.format(currentDate); |
| | | String oddNumbers = alias+formattedDate+formattedNumber; |
| | | return oddNumbers; |
| | | } |
| | | |
| | | |
| | | public double convert(String json,String string) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String[] keyValues = json.split(","); |
| | | for (String keyValue : keyValues) { |
| | | String[] pair = keyValue.split(":"); |
| | | if (pair.length == 2) { |
| | | map.put(pair[0], pair[1]); |
| | | } |
| | | } |
| | | double number=0.0; |
| | | if(map.get(string)!=null){ |
| | | String[] widthStrings = map.get(string).toString().split("\\D+"); |
| | | for (String numberString : widthStrings) { |
| | | if (!numberString.isEmpty()) { |
| | | number= Double.parseDouble(numberString); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return number; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |