diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java index f22f3597..0b4e657e 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -1208,7 +1208,7 @@ public class DepositoryRecordController { List placeCodes = (List) map.get("placeCodes"); List applyRemarks = (List) map.get("applyRemarks"); List units = (List) map.get("units"); - String errMsg = ""; + StringBuilder errMsg = new StringBuilder(); Integer id = 0; if ("in".equals(type)) { for (int i = 0; i < mids.size(); i++) { @@ -1335,7 +1335,7 @@ public class DepositoryRecordController { Material materialById = materialService.findMaterialById(mid); // 获取失败的仓库信息 Depository depositoryRecordById = depositoryService.findDepositoryById(depositoryId); - errMsg += materialById.getMname() + "在" + depositoryRecordById.getDname() + "出库数量为" + quantity + "失败,数量不足;"; + errMsg.append(materialById.getMname()).append("在").append(depositoryRecordById.getDname()).append("出库数量为").append(quantity).append("失败,数量不足;"); } } Integer finalId = id; @@ -1378,7 +1378,7 @@ public class DepositoryRecordController { } if (success < mids.size()) { // 如果申请成功数量小于申请数量 - return new RestResponse(errMsg, 1234, new StatusInfo("出库失败", "数量不足")); + return new RestResponse(errMsg.toString(), 1234, new StatusInfo("出库失败", "数量不足")); } return CrudUtil.postHandle(success, mids.size()); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java b/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java index 83b677b8..0a04938c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java @@ -16,58 +16,66 @@ import java.util.Map; public interface DepositoryRecordService { /** * 提交申请,插入一条仓库调度记录 + * * @param map 仓库调度信息 * @return 受影响的行数 */ - Integer apply(Map map); + Integer apply(Map map); /** * 插入一条入库记录 + * * @param map * @return */ - Integer applicationIn(Map map); + Integer applicationIn(Map map); /** * 转移申请 + * * @param map 仓库调度信息 * @return 受影响的行数 */ - Integer transferApply(Map map,UserByPort userByPort); + Integer transferApply(Map map, UserByPort userByPort); /** * 出库审核申请 + * * @param map 仓库调度信息 * @return 受影响的行数 */ - Integer review(Map map,Integer userId,UserByPort userToken,String userAgent); + Integer review(Map map, Integer userId, UserByPort userToken, String userAgent); /** * 入库审核申请 + * * @param map 仓库调度信息 * @return 受影响的行数 */ - Integer reviewIn(Map map,Integer userId,UserByPort userToken,String userAgent); + Integer reviewIn(Map map, Integer userId, UserByPort userToken, String userAgent); /** * 用于企业微信的审核申请处理 + * * @param templateCard * @return */ - Integer reviewByQyWx(TemplateCard templateCard,String userAgent); + Integer reviewByQyWx(TemplateCard templateCard, String userAgent); /** * 根据id修改仓库调度记录 + * * @param map 参数map * @return 受影响的行数 */ - Integer updateDepositoryRecord(Map map); + Integer updateDepositoryRecord(Map map); /** * 根据id主键查询数据 + * * @param id id * @return 该id的数据记录 */ @@ -75,77 +83,85 @@ public interface DepositoryRecordService { /** * 查找所有仓库调度记录 + * * @return 所有的仓库调度记录集合 */ List findDepositoryRecordAll(); /** * 根据条件查询仓库调度记录,同时支持分页查询(需要begin和size参数) + * * @param map 查询参数 * @return 符合条件的仓库调度记录集合 */ - List findDepositoryRecordPByCondition(Map map,UserByPort userToken); + List findDepositoryRecordPByCondition(Map map, UserByPort userToken); /** * 根据条件查询入库记录,同时支持分页查询 + * * @param map * @return */ - List findApplicationInRecordPByCondition(Map map,UserByPort userToken); + List findApplicationInRecordPByCondition(Map map, UserByPort userToken); /** * 查询当前用户入库记录及其管理仓库的入库记录 + * * @param userByPort 待查询用户 - * @param map 查询条件 + * @param map 查询条件 * @return */ - List findApplicationInRecordPByUser(UserByPort userByPort,Map map); + List findApplicationInRecordPByUser(UserByPort userByPort, Map map); /** * 查询当前用户入库记录及其管理仓库的入库记录数目 + * * @param map 查询条件 * @return */ - Integer findApplicationInRecordPCountByUser(UserByPort userByPort,Map map); - - + Integer findApplicationInRecordPCountByUser(UserByPort userByPort, Map map); /** * 查询当前用户出库记录及其管理仓库的出库记录 + * * @param userByPort 待查询用户 - * @param map 查询条件 + * @param map 查询条件 * @return */ - List findApplicationOutRecordPByUser(UserByPort userByPort,Map map); + List findApplicationOutRecordPByUser(UserByPort userByPort, Map map); /** * 查询当前用户出库记录及其管理仓库的出库记录数目 + * * @param map 查询条件 * @return */ - Integer findApplicationOutRecordPCountByUser(UserByPort userByPort,Map map); + Integer findApplicationOutRecordPCountByUser(UserByPort userByPort, Map map); /** * 根据条件查询出库记录,同时支持分页查询 + * * @param map * @return */ - List findApplicationOutRecordPByCondition(Map map,UserByPort userToken); + List findApplicationOutRecordPByCondition(Map map, UserByPort userToken); /** * 查询当前仓库的入库记录 - * @param depositoryId 待查询仓库id + * + * @param depositoryId 待查询仓库id * @return */ List findApplicationInRecordByDepository(String depositoryId); /** * 查询当前仓库的出库记录 + * * @param depositoryId 待查询仓库id * @return */ @@ -154,13 +170,15 @@ public interface DepositoryRecordService { /** * 根据条件查询出库记录数目 + * * @param map * @return */ - Integer findApplicationOutRecordPCountByCondition(Map map); + Integer findApplicationOutRecordPCountByCondition(Map map); /** * 根据id查询出库申请 + * * @param id * @return */ @@ -168,12 +186,15 @@ public interface DepositoryRecordService { /** * 根据条件查询入库记录数目 + * * @param map * @return */ - Integer findApplicationInRecordPCountByCondition(Map map); + Integer findApplicationInRecordPCountByCondition(Map map); + /** * 根据条件查询自己的任务(根据isDone来决定查询已完成或者未完成的任务),同时支持分页查询(需要begin和size参数) + * * @param map 查询参数 * @return 我的任务 */ @@ -181,6 +202,7 @@ public interface DepositoryRecordService { /** * 根据条件查询自己的任务(根据isDone来决定查询已完成或者未完成的任务),同时支持分页查询(需要begin和size参数) + * * @param map 查询参数 * @return 我的任务 */ @@ -189,13 +211,15 @@ public interface DepositoryRecordService { /** * 根据id删除仓库记录 - * @return 受影响的行数 + * * @param id + * @return 受影响的行数 */ Integer deleteDepositoryRecordById(Integer id); /** * 根据id集合删除多条仓库记录 + * * @param list id集合 * @return 受影响的行数 */ @@ -203,53 +227,65 @@ public interface DepositoryRecordService { /** * 返回该表的总条数 + * * @return 条数 */ Integer findCount(); /** * 返回该我的任务数(完成或者未完成) + * * @return 条数 */ - Integer findMyTaskCount(Map map); + Integer findMyTaskCount(Map map); + /** * 返回该我的任务数(完成或者未完成) + * * @return 条数 */ - Integer findMyTaskOutCount(Map map); + Integer findMyTaskOutCount(Map map); /** * 返回该我的任务数(完成或者未完成) + * * @return 条数 */ - Integer findMyTaskInCount(Map map); + Integer findMyTaskInCount(Map map); /** * 根据查询条件返回该表的总条数 + * * @param map 条件参数 * @return 条数 */ - Integer findCountByCondition(Map map); + Integer findCountByCondition(Map map); /** * 计算物料总数 + * * @return */ - Double CalculateAllCount(Integer type,String state); + Double CalculateAllCount(Integer type, String state); /** * 计算物料总额 + * * @return */ - Double CalculateAllPrice(Integer type,String state); + Double CalculateAllPrice(Integer type, String state); + /** * 计算入库物料总额 + * * @return */ - Map CalculateAllApplicationInAll(List list); + Map CalculateAllApplicationInAll(List list); + /** * 计算出库物料总额 + * * @return */ Double CalculateAllApplicationOutPrice(String state); @@ -263,7 +299,8 @@ public interface DepositoryRecordService { * @param depositoryId * @return */ - Double findDepositoryRecordByDate(Long end,Long start,Integer type,Integer depositoryId); + Double findDepositoryRecordByDate(Long end, Long start, Integer type, Integer depositoryId); + /** * 获取一段时间内的库存额度 * @@ -273,7 +310,8 @@ public interface DepositoryRecordService { * @param depositoryId * @return */ - Integer findApplicationRecordByDate(Long end,Long start,Integer type,Integer depositoryId); + Integer findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId); + /** * 获取一段时间内的入库额度 * @@ -282,7 +320,7 @@ public interface DepositoryRecordService { * @param depositoryId * @return */ - Integer findApplicationInRecordByDate(Long end,Long start,Integer depositoryId); + Integer findApplicationInRecordByDate(Long end, Long start, Integer depositoryId); /** * 获取一段时间内的出库额度 @@ -292,35 +330,42 @@ public interface DepositoryRecordService { * @param depositoryId * @return */ - Integer findApplicationOutRecordByDate(Long end,Long start,Integer depositoryId); + Integer findApplicationOutRecordByDate(Long end, Long start, Integer depositoryId); + /** * 根据条件获取月份中物料的总额 + * * @param map * @return */ - Integer findMaterialCountByMonth(Map map); + Integer findMaterialCountByMonth(Map map); + /** * 根据条件获取月份中物料的总额 + * * @param map * @return */ - Integer findMaterialCountByMonth1(Map map); + Integer findMaterialCountByMonth1(Map map); /** * 根据条件获取月份中物料的总额 + * * @param map 条件 * @return */ - Integer findMaterialCountByMonth2(Map map); + Integer findMaterialCountByMonth2(Map map); /** * 查询仓库当天流水 + * * @return */ - Integer findWarehouseRecord(Map map); + Integer findWarehouseRecord(Map map); /** * 根据id查询入库记录 + * * @param id * @return */ @@ -328,59 +373,68 @@ public interface DepositoryRecordService { /** * 根据id删除入库记录 - * @return 受影响的行数 + * * @param id + * @return 受影响的行数 */ - Integer deleteApplicationInRecordById(Integer id,UserByPort userToken,String userAgent); + Integer deleteApplicationInRecordById(Integer id, UserByPort userToken, String userAgent); /** * 根据id集合删除多条入库记录 + * * @param list id集合 * @return 受影响的行数 */ - Integer deleteApplicationInRecordByIds(List list,UserByPort userToken,String userAgent); + Integer deleteApplicationInRecordByIds(List list, UserByPort userToken, String userAgent); /** * 插入一条出库记录 + * * @param map * @return */ - Integer insertApplicationOutRecord(Map map, UserByPort userToken); + Integer insertApplicationOutRecord(Map map, UserByPort userToken); /** * 根据id删除出库记录 - * @return 受影响的行数 + * * @param id + * @return 受影响的行数 */ - Integer deleteApplicationOutRecordById(Integer id,UserByPort userToken); + Integer deleteApplicationOutRecordById(Integer id, UserByPort userToken); /** * 根据id集合删除多条出库记录 + * * @param list id集合 * @return 受影响的行数 */ - Integer deleteApplicationOutRecordByIds(List list,UserByPort userByPort); + Integer deleteApplicationOutRecordByIds(List list, UserByPort userByPort); /** * 计算入库物料总数 + * * @return */ - Map CalculateAllApplicationInCount(List list); + Map CalculateAllApplicationInCount(List list); + /** * 计算出库物料总数 + * * @return */ - Map CalculateAllApplicationOutCount(String state,List list); + Map CalculateAllApplicationOutCount(String state, List list); /** * 将物料入库到库位 + * * @param map * @return */ - Integer applicationInPlace(Map map,boolean isApprovalPass); + Integer applicationInPlace(Map map, boolean isApprovalPass); /** @@ -389,26 +443,29 @@ public interface DepositoryRecordService { * @param depositoryName * @return */ - String createCode(String depositoryName, String key, String type, String mainDeparmentName) ; + String createCode(String depositoryName, String key, String type, String mainDeparmentName); /** * 将刚入库的记录删除 + * * @param map * @return */ - Integer deleteApplicaionInPlace(Map map); + Integer deleteApplicaionInPlace(Map map); /** * 插入一条出库子订单 + * * @param map * @return */ - Integer insertApplicationOutMin(Map map); + Integer insertApplicationOutMin(Map map); /** * 根据主表获取所有子表 + * * @param id * @return */ @@ -416,6 +473,7 @@ public interface DepositoryRecordService { /** * 根据主键获取子表信息 + * * @param id * @return */ @@ -423,13 +481,15 @@ public interface DepositoryRecordService { /** * 根据条件获取子订单 + * * @param map * @return */ - List findApplicationOutMinByCondition(Map map); + List findApplicationOutMinByCondition(Map map); /** * 根据主订单获取子订单 + * * @param parentId * @return */ @@ -438,24 +498,27 @@ public interface DepositoryRecordService { /** * 完成对应的子订单 + * * @param map * @param userByPort * @return */ - RestResponse completeApplicationOutMinRecord(Map map,UserByPort userByPort,String userAgent); + RestResponse completeApplicationOutMinRecord(Map map, UserByPort userByPort, String userAgent); /** * 用于企业微信物料出库审批处理 - * @param mainId 主表id - * @param userAgent 加密后的user-agent + * + * @param mainId 主表id + * @param userAgent 加密后的user-agent * @param approvalInfo_details 审批详情 - * @param flagForFirst 用于标志是否为第一次审批 + * @param flagForFirst 用于标志是否为第一次审批 * @return */ Integer reviewByQyWxApprovalOut(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo, boolean flagForFirst, int flagForDepository); /** * 判断当前出库记录运行状态否可以直接删除 + * * @param id * @return */ @@ -463,6 +526,7 @@ public interface DepositoryRecordService { /** * 根据主键查询转移记录 + * * @param id * @return */ @@ -471,13 +535,26 @@ public interface DepositoryRecordService { /** * 用于企业微信的物料入库审批处理 - * @param mainId 需要进行审批的单号 + * + * @param mainId 需要进行审批的单号 * @param approvalInfo_details 审批详情 - * @param userAgent 加密后的user-agent - * @param spStatus 审批状态 - * @param spNo 审批订单号 + * @param userAgent 加密后的user-agent + * @param spStatus 审批状态 + * @param spNo 审批订单号 */ - void reviewByQyWxApprovalIn(String mainId,ApprovalInfo_Details approvalInfo_details,String userAgent,String spStatus,String spNo); + void reviewByQyWxApprovalIn(String mainId, ApprovalInfo_Details approvalInfo_details, String userAgent, String spStatus, String spNo); + /** + * 用于有父级拆单记录的出库处理 + * + * @param splitInfo 父级拆单记录 + * @param materialAndPlace 当前库存记录 + * @param quantity 当前出库总量 + * @param nowQuantity 当前未出库数量 + * @param realSplitInfo 实际出库的拆单记录 + * @return + */ + RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo); + } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java index b1c3159a..d4dbc63d 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java @@ -1114,7 +1114,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); - } else { + } + else { // 如果不能满足需求 // 获取对应的拆单记录 @@ -1158,7 +1159,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); - } else { + } + else { // 如果当前拆单没有父级 @@ -1243,7 +1245,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { restResponse.setData(""); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); } - } else { + } + else { // 如果大于 // 获取库存重要减少的数量 @@ -1416,7 +1419,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { * @param realSplitInfo 实际出库的拆单记录 * @return */ - RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo) { + public RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo) { // 定义返回值 RestResponse restResponse = new RestResponse(); // 用于获取当前拆单记录对应的拆单库存记录 @@ -4105,13 +4108,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 根据入库的物料id与仓库id获取库存记录 Inventory inventory = materialMapper.findInventoryByMidAndDid(paramForMidAndDid); + // 查询当前物料与库位的映射关系 Map paramForMaterialAndPlace = new HashMap<>(); paramForMaterialAndPlace.put("mid", inventory.getId()); paramForMaterialAndPlace.put("pid", placeId); MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); - if (unit.equals(material.getUnit())) { // 如果存在库存记录 @@ -4119,16 +4122,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { Place place = placeMapper.findPlaceById(placeId); if (placeAndMaterialByMidAndPid != null) { // 修改当前库存记录 - placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - quantity); - place.setQuantity(place.getQuantity() - quantity); - inventory.setQuantity(inventory.getQuantity() - quantity); + placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - quantity, 0)); + place.setQuantity(Math.max(place.getQuantity() - quantity, 0)); + inventory.setQuantity(Math.max(inventory.getQuantity() - quantity,0)); materialMapper.updateInventory(inventory); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); placeMapper.UpdatePlace(place); } - } else { + } + else { // 如果不是基础单位 Map paramForSplitInfo = new HashMap<>(); paramForSplitInfo.put("newUnit", unit); @@ -4150,7 +4154,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (splitInventory.getSaveQuantity() >= quantity) { // 如果当前待处理数目可以满足需求 - splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - quantity); + splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity,0)); // 修改库存处理记录 splitUnitMapper.updateSplitInventory(splitInventory); @@ -4207,7 +4211,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (inventory.getQuantity() >= 1 && flag) { // 令库存-1 - inventory.setQuantity(inventory.getQuantity() - 1); + inventory.setQuantity(Math.max(inventory.getQuantity() - 1,0)); // 修改库存记录 @@ -4215,12 +4219,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 修改当前库位存放物料的数量 - placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - 1); + placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - 1,0)); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); // 修改库位数量 Place placeById = placeMapper.findPlaceById(placeId); - placeById.setQuantity(placeById.getQuantity() - 1); + placeById.setQuantity(Math.max(placeById.getQuantity() - 1,0)); placeMapper.UpdatePlace(placeById); @@ -4231,7 +4235,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { splitInventory.setOutQuantity(splitInventory.getOutQuantity() + quantity); splitUnitMapper.updateSplitInventory(splitInventory); } - } else { + } + else { // 如果大于 // 获取库存重要减少的数量 diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java index 08c176d8..25d5050f 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java @@ -915,8 +915,8 @@ public class MaterialServiceImpl implements MaterialService { Integer mid = inventory.getId(); List placeByMidAndDid = placeService.findPlaceByMidAndDid(mid, depositoryId); StringBuilder placeCode = new StringBuilder(); - for (int j = 0; j < placeByMidAndDid.size(); j++) { - placeCode.append(placeByMidAndDid.get(j).getCode()).append(" "); + for (PlaceP placeP : placeByMidAndDid) { + placeCode.append(placeP.getCode()).append(" "); } inventory.setPlaceCode(placeCode.toString()); if (inventory.getPrice() != null) { diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java index e37350fc..b2a3e614 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java @@ -5,7 +5,9 @@ import com.dreamchaser.depository_manage.config.PortConfig; import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.exception.MyException; import com.dreamchaser.depository_manage.mapper.*; +import com.dreamchaser.depository_manage.pojo.RestResponse; import com.dreamchaser.depository_manage.pojo.SimpleStockTakingP; +import com.dreamchaser.depository_manage.pojo.StatusInfo; import com.dreamchaser.depository_manage.pojo.StockTakingChildP; import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details; import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver; @@ -270,7 +272,7 @@ public class StockTakingServiceImpl implements StockTakingService { stockTakingChildP.setTakingResultShow("正常"); } stockTakingChildP.setShowUnit(stockTakingChildP.getUnit()); - if("-1".equals(stockTakingChildP.getShowUnit())){ + if ("-1".equals(stockTakingChildP.getShowUnit())) { Inventory inventoryById = materialMapper.findInventoryById(stockTakingChildP.getMid()); stockTakingChildP.setShowUnit(inventoryById.getUnit()); } @@ -391,7 +393,6 @@ public class StockTakingServiceImpl implements StockTakingService { MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); - // 根据盘点结果重新计算物料的单价 @@ -407,8 +408,7 @@ public class StockTakingServiceImpl implements StockTakingService { int newNumberForPlace = 0; // 用于计算新的库位与物料对应关系的数量 int newNumberForMatrialAndPlace = 0; - if ("Inventory_up".equals(takingResult)) - { + if ("Inventory_up".equals(takingResult)) { // 如果盘盈 // 更新当前库位数量 @@ -432,8 +432,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 更新物料与库位对应关系的数量 placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); - } - else { + } else { // 如果盘亏 newNumberForPlace = placeById.getQuantity() - inventory; @@ -536,7 +535,7 @@ public class StockTakingServiceImpl implements StockTakingService { } String s = QyWxUid.toString(); s = "PangFuZhen,"; - qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(mainId),s,userAgent,2); + qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(mainId), s, userAgent, 2); } }).start(); @@ -594,6 +593,8 @@ public class StockTakingServiceImpl implements StockTakingService { List minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); // 遍历当前拆单的子单详情 for (StockTakingChildP minRecord : minRecordList) { + + // 获取子单详情 Integer placeId = minRecord.getPid(); @@ -605,13 +606,6 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取当前盘点的计量单位 String unit = minRecord.getUnit(); - if ("Inventory_normal".equals(takingResult)) { - // 如果盘点结果正常 - continue; - } - - // 获取盈亏数量 - Integer inventory = minRecord.getInventory(); // 获取盘点物料信息 Inventory inventoryById = materialMapper.findInventoryById(minRecord.getMid()); @@ -623,6 +617,20 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取物料与库位的对应关系 MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); + String key = "wms_stockTaking_" + userToken.getId() + "_" + DateUtil.getNowTime() + "_" + placeAndMaterialByMidAndPid.getId(); + + redisTemplate.delete(key); + + + if ("Inventory_normal".equals(takingResult)) { + // 如果盘点结果正常 + continue; + } + + // 获取盈亏数量 + Integer inventory = minRecord.getInventory(); + + // 获取判断对应的生产日期 Long producedDate = minRecord.getProducedDate(); @@ -667,18 +675,6 @@ public class StockTakingServiceImpl implements StockTakingService { materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); } - else { - // 如果没有生产日期 - - // 获取当前库位以外的物料数量 - Integer oldQuantity = inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); - // 获取新的物料数目 - int quantity = oldQuantity + newInventory; - - - // 更新物料数目 - inventoryById.setQuantity(quantity); - } // 用于计算新的库位数量 int newNumberForPlace = 0; @@ -706,13 +702,13 @@ public class StockTakingServiceImpl implements StockTakingService { continue; } + inventoryById.setQuantity(inventoryById.getQuantity() + inventory); newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() + inventory; // 更新物料与库位对应关系的数量 placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); - } - else { + } else { // 如果是拆单单位 @@ -726,7 +722,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 查找当前拆单记录对应的库存记录 SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); // 如果存在拆单库存记录 - if(splitInventory != null){ + if (splitInventory != null) { // 获取当前盘点后的库存数 int realQuantity = Math.round(inventory) + splitInventory.getSaveQuantity(); // 定义当前进制 @@ -759,8 +755,7 @@ public class StockTakingServiceImpl implements StockTakingService { placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + disposeQuantity); } - } - else { + } else { // 如果不需要进位 // 修改当前库存 @@ -768,27 +763,24 @@ public class StockTakingServiceImpl implements StockTakingService { // 修改拆单库存 splitUnitMapper.updateSplitInventory(splitInventory); } - } - else{ + } else { // 如果不存在拆单库存记录 Map paramForUpdateSplitInventory = new HashMap<>(); - paramForUpdateSplitInventory.put("placeId",minRecord.getPid()); - paramForUpdateSplitInventory.put("depositoryId",mainRecord.getDepositoryId()); - paramForUpdateSplitInventory.put("quantity",inventory); - paramForUpdateSplitInventory.put("mid",inventoryById.getMid()); - paramForUpdateSplitInventory.put("unit",minRecord.getUnit()); + paramForUpdateSplitInventory.put("placeId", minRecord.getPid()); + paramForUpdateSplitInventory.put("depositoryId", mainRecord.getDepositoryId()); + paramForUpdateSplitInventory.put("quantity", inventory); + paramForUpdateSplitInventory.put("mid", inventoryById.getMid()); + paramForUpdateSplitInventory.put("unit", minRecord.getUnit()); - splitUnitService.realInInventoryToDepository(Double.valueOf(inventory), null,paramForUpdateSplitInventory,splitInfo,placeAndMaterialByMidAndPid,false); + splitUnitService.realInInventoryToDepository(Double.valueOf(inventory), null, paramForUpdateSplitInventory, splitInfo, placeAndMaterialByMidAndPid, false); if (paramForUpdateSplitInventory.containsKey("applicationInId")) { depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateSplitInventory.get("applicationInId"))); } } - } - } - else { + } else { // 如果盘亏 if ("-1".equals(unit) || inventoryById.getUnit().equals(minRecord.getUnit())) { @@ -810,11 +802,11 @@ public class StockTakingServiceImpl implements StockTakingService { newNumberForMatrialAndPlace = 0; } + inventoryById.setQuantity(inventoryById.getQuantity() - inventory); placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); - } - else { + } else { // 如果是拆单单位 // 用于查找对应的拆单记录 Map paramForSplitInfo = new HashMap<>(); @@ -826,40 +818,145 @@ public class StockTakingServiceImpl implements StockTakingService { // 查找当前拆单记录对应的库存记录 SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); - if(splitInventory != null){ + if (splitInventory != null) { // 如果存在拆单记录 - - if (splitInventory.getSaveQuantity() - inventory > 0) { - // 如果当前数量没有下溢 + if (splitInventory.getSaveQuantity() - inventory >= 0) { + // 如果单纯的拆单库存满足数量 // 设置当前拆单库存的数量 splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory); // 修改拆单库存 splitUnitMapper.updateSplitInventory(splitInventory); - } - else { - // 如果发生下溢 + } else { + // 拆单库存如果不能满足 + // 获取当前拆单单位对应的所有库存 + int allSplitInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true); + if (allSplitInventory - inventory >= 0) { - // 设置当前拆单库存的数量 - splitInventory.setSaveQuantity(0); - // 修改拆单库存 - splitUnitMapper.updateSplitInventory(splitInventory); + // 获取剩余不足的数量 + int surplus = inventory - splitInventory.getSaveQuantity(); + // 如果盘点后库存数大于0 + if (splitInfo.getParentId() != null) { + // 如果当前拆单有父级 + + + // 设置剩余拆单库存处理数量 + + + // 设置当前拆单库存出库数量 + splitInventory.setOutQuantity(splitInventory.getOutQuantity() + splitInventory.getSaveQuantity()); + + // 将当前库存设置为0 + splitInventory.setSaveQuantity(0); + // 修改库存数量 + splitUnitMapper.updateSplitInventory(splitInventory); + + + // 获取当前父级拆单记录 + SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); + + depositoryRecordService.updateOutSplitInventoryInfo(parentSplitInfo, placeAndMaterialByMidAndPid, inventory, surplus, splitInfo); + + } else { + // 如果没有父级 + if (surplus <= splitInfo.getQuantity()) { + + // 如果当前未处理的数量小于当前拆单库存数量 + + // 如果物料数量可以出库并且库位数量充足 + if (placeAndMaterialByMidAndPid.getQuantity() >= 1) { + + + // 令库存-1 + inventoryById.setQuantity(inventoryById.getQuantity() - 1); + + + // 修改当前库位存放物料的数量 + placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - 1); + placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); + + + placeById.setQuantity(placeById.getQuantity() - 1); + + + // 设置剩余拆单库存处理数量 + splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - inventory); + splitInventory.setOutQuantity(splitInventory.getOutQuantity() + inventory); + splitUnitMapper.updateSplitInventory(splitInventory); + } + } else { + // 如果大于 + + // 获取库存重要减少的数量 + int surplus_redundant = surplus / splitInfo.getQuantity(); + // 获取拆单库存处理中要处理数量 + int saveQuantity = surplus - surplus_redundant * splitInfo.getQuantity(); + + if (saveQuantity > splitInventory.getSaveQuantity()) { + // 如果要处理的数量大于剩余数量 + + // 获取一个数量 + surplus_redundant += 1; + splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - saveQuantity); + } else { + // 如果不大于 + splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - saveQuantity); + } + + + if (placeAndMaterialByMidAndPid.getQuantity() >= surplus_redundant) { + // 如果能够出库 + + // 令库存-1 + inventoryById.setQuantity(inventoryById.getQuantity() - surplus_redundant); + + + // 修改当前库位存放物料的数量 + placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - surplus_redundant); + + + placeById.setQuantity(placeById.getQuantity() - surplus_redundant); + + } else { + inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); + placeById.setQuantity(placeById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); + placeAndMaterialByMidAndPid.setQuantity(0); + } + } + } + + + } else { + // 如果盘点后的库存数非法 + + placeById.setQuantity(placeById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); + + inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); + + placeAndMaterialByMidAndPid.setQuantity(0); + List splitInventoryList = splitUnitMapper.findSplitInventoryByIid(placeAndMaterialByMidAndPid.getId()); + for (SplitInventory si : splitInventoryList + ) { + si.setSaveQuantity(0); + splitUnitMapper.updateSplitInventory(si); + } + } } - }else{ + } else { // 如果不存在拆单记录 // 获取当前拆单单位对应的库存数 - int splitInfoInventory = splitUnitService.findAllInventoryForSplitInfo(-1,placeAndMaterialByMidAndPid,splitInfo.getId(), 0,true); + int splitInfoInventory = splitUnitService.findAllInventoryForSplitInfo(-1, placeAndMaterialByMidAndPid, splitInfo.getId(), 0, true); - if(Integer.compare(minRecord.getNewInventory(),0) == 0){ + if (Integer.compare(minRecord.getNewInventory(), 0) == 0) { // 如果盘点数量为0 placeById.setQuantity(placeById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); placeAndMaterialByMidAndPid.setQuantity(0); - }else{ + } else { // 如果不是0 // 获取当前拆单单位与基础单位之间的进制 @@ -872,7 +969,6 @@ public class StockTakingServiceImpl implements StockTakingService { int residue_realQuantity = residue * scale - inventory; - // 更新库存数量 inventoryById.setQuantity(inventoryById.getQuantity() - residue); @@ -887,7 +983,7 @@ public class StockTakingServiceImpl implements StockTakingService { insertForSplitInventory.put("price", 0); insertForSplitInventory.put("quantity", residue_realQuantity); insertForSplitInventory.put("unit", unit); - insertForSplitInventory.put("depositoryId",mainRecord.getDepositoryId()); + insertForSplitInventory.put("depositoryId", mainRecord.getDepositoryId()); insertForSplitInventory.put("placeId", placeAndMaterialByMidAndPid.getPid()); insertForSplitInventory.put("type", "in"); splitUnitService.addSplitInventory(insertForSplitInventory); @@ -899,7 +995,6 @@ public class StockTakingServiceImpl implements StockTakingService { } - } } @@ -1106,8 +1201,7 @@ public class StockTakingServiceImpl implements StockTakingService { inventoryById.setPrice(avgPrice); materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); - } - else { + } else { // 如果没有生产日期 // 获取当前生产日期中的物料 @@ -1196,8 +1290,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 更新物料与库位对应关系的数量 placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); - } - else { + } else { // 如果是拆单单位 // 更新当前库位数量 newNumberForPlace = placeById.getQuantity() + inventory; @@ -1219,7 +1312,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 查找当前拆单记录对应的库存记录 SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); - if(splitInventory != null){ + if (splitInventory != null) { int realQuantity = Math.round(inventory) + splitInventory.getSaveQuantity(); // 定义当前进制 int scale = splitInfo.getQuantity(); @@ -1253,8 +1346,7 @@ public class StockTakingServiceImpl implements StockTakingService { placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + disposeQuantity); } - } - else { + } else { // 如果不需要进位 // 修改当前库存 @@ -1262,22 +1354,21 @@ public class StockTakingServiceImpl implements StockTakingService { // 修改拆单库存 splitUnitMapper.updateSplitInventory(splitInventory); } - } - else{ + } else { // 获取进制数目 int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); - Map insertForSplitInventory = new HashMap<>(); + Map insertForSplitInventory = new HashMap<>(); - insertForSplitInventory.put("mid",inventoryById.getMid()); - insertForSplitInventory.put("mcode",inventoryById.getCode()); - insertForSplitInventory.put("price",inventoryById.getPrice() / scale); - insertForSplitInventory.put("quantity",inventory); - insertForSplitInventory.put("unit",unit); - insertForSplitInventory.put("depositoryId",mainRecord.getDepositoryId()); - insertForSplitInventory.put("placeId",placeAndMaterialByMidAndPid.getPid()); - insertForSplitInventory.put("type","in"); + insertForSplitInventory.put("mid", inventoryById.getMid()); + insertForSplitInventory.put("mcode", inventoryById.getCode()); + insertForSplitInventory.put("price", inventoryById.getPrice() / scale); + insertForSplitInventory.put("quantity", inventory); + insertForSplitInventory.put("unit", unit); + insertForSplitInventory.put("depositoryId", mainRecord.getDepositoryId()); + insertForSplitInventory.put("placeId", placeAndMaterialByMidAndPid.getPid()); + insertForSplitInventory.put("type", "in"); splitUnitService.addSplitInventory(insertForSplitInventory); Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("newInMid")); depositoryRecordMapper.deleteApplicationInRecordById(new_id); @@ -1285,8 +1376,7 @@ public class StockTakingServiceImpl implements StockTakingService { } } - } - else { + } else { // 如果盘亏 if ("-1".equals(unit)) { @@ -1311,8 +1401,7 @@ public class StockTakingServiceImpl implements StockTakingService { placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); - } - else { + } else { // 如果是拆单单位 // 用于查找对应的拆单记录 @@ -1325,7 +1414,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 查找当前拆单记录对应的库存记录 SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); - if(splitInventory != null){ + if (splitInventory != null) { // 如果存在拆单记录 if (splitInventory.getSaveQuantity() - inventory > 0) { // 如果当前数量没有下溢 @@ -1334,8 +1423,7 @@ public class StockTakingServiceImpl implements StockTakingService { splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory); // 修改拆单库存 splitUnitMapper.updateSplitInventory(splitInventory); - } - else { + } else { // 如果发生下溢 @@ -1344,7 +1432,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 修改拆单库存 splitUnitMapper.updateSplitInventory(splitInventory); } - } else{ + } else { // 如果不存在 @@ -1359,16 +1447,16 @@ public class StockTakingServiceImpl implements StockTakingService { // 当前盘点数目 int new_inventory = now_inventory - inventory; - Map insertForSplitInventory = new HashMap<>(); - - insertForSplitInventory.put("mid",inventoryById.getMid()); - insertForSplitInventory.put("mcode",inventoryById.getCode()); - insertForSplitInventory.put("price",inventoryById.getPrice() / scale); - insertForSplitInventory.put("quantity",new_inventory); - insertForSplitInventory.put("unit",unit); - insertForSplitInventory.put("depositoryId",mainRecord.getDepositoryId()); - insertForSplitInventory.put("placeId",placeAndMaterialByMidAndPid.getPid()); - insertForSplitInventory.put("type","in"); + Map insertForSplitInventory = new HashMap<>(); + + insertForSplitInventory.put("mid", inventoryById.getMid()); + insertForSplitInventory.put("mcode", inventoryById.getCode()); + insertForSplitInventory.put("price", inventoryById.getPrice() / scale); + insertForSplitInventory.put("quantity", new_inventory); + insertForSplitInventory.put("unit", unit); + insertForSplitInventory.put("depositoryId", mainRecord.getDepositoryId()); + insertForSplitInventory.put("placeId", placeAndMaterialByMidAndPid.getPid()); + insertForSplitInventory.put("type", "in"); splitUnitService.addSplitInventory(insertForSplitInventory); Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("newInMid")); depositoryRecordMapper.deleteApplicationInRecordById(new_id); @@ -1542,7 +1630,6 @@ public class StockTakingServiceImpl implements StockTakingService { // 根据盘点结果重新计算物料的单价 - Integer newInventory = minRecord.getNewInventory(); // 获取当前库位上物料数量 @@ -1727,8 +1814,8 @@ public class StockTakingServiceImpl implements StockTakingService { // 用于调用现有入库逻辑时使用的数据 map.put("unit", unit); map.put("mid", inventoryById.getMid()); - map.put("depositoryId",newPlace.getDid()); - map.put("placeId",newPlace.getId()); + map.put("depositoryId", newPlace.getDid()); + map.put("placeId", newPlace.getId()); // 获取转移后的数量 Integer newInventory = minRecord.getNewInventory() - inventory_transfer; @@ -1786,8 +1873,7 @@ public class StockTakingServiceImpl implements StockTakingService { newPlaceAndMaterial.setQuantity(newPlaceAndMaterial.getQuantity() + inventory_transfer); placeMapper.updateMaterialAndPlace(newPlaceAndMaterial); } - } - else { + } else { // 如果盘点的是拆单单位 // 用于获取当前拆单记录 @@ -1832,7 +1918,7 @@ public class StockTakingServiceImpl implements StockTakingService { if (splitInfo.getParentId() != null) { // 如果当前拆单还有父级 SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); - map.put("price",String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo,-1))); + map.put("price", String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1))); // 调用现有的拆单库存变化逻辑 splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(paramForMaterialAndPlace.get("id")), map, disposeQuantity, splitInfo); @@ -1841,14 +1927,13 @@ public class StockTakingServiceImpl implements StockTakingService { map.put("price", String.valueOf(inventoryById.getPrice() / 100)); // 调用现有入库逻辑进行修改库存 - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除入库单 depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); } - } - else { + } else { // 如果不大于 @@ -1859,8 +1944,7 @@ public class StockTakingServiceImpl implements StockTakingService { } - } - else { + } else { // 如果转移后的库位有该物料 // 用于查询对应的拆单库存 @@ -1937,14 +2021,13 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取当前的单价 map.put("price", String.valueOf(inventoryById.getPrice() / 100)); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); } } - } - else { + } else { // 如果不存在拆单记录 @@ -1989,7 +2072,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取对应的父级 SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); // 设置当前的单价 - map.put("price",String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo,-1))); + map.put("price", String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1))); // 调用现有的拆单库存修改逻辑 splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, newPlaceAndMaterial.getId(), map, inventory_transfer, splitInfo); } else { @@ -1997,7 +2080,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 设置单价 map.put("price", String.valueOf(inventoryById.getPrice() / 100)); // 调用相关的入库逻辑 - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除对应的入库订单 depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); @@ -2018,8 +2101,7 @@ public class StockTakingServiceImpl implements StockTakingService { } - } - else { + } else { // 如果不存在 // 定义库存对象 @@ -2115,9 +2197,10 @@ public class StockTakingServiceImpl implements StockTakingService { splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(paramForMaterialAndPlace.get("id")), map, disposeQuantity, splitInfo); } else { // 如果没有父级 - map.put("price", String.valueOf(inventoryById.getPrice() / 100));; + map.put("price", String.valueOf(inventoryById.getPrice() / 100)); + ; map.put("quantity", String.valueOf(disposeQuantity)); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); } @@ -2140,8 +2223,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 如果是基础单位 oldPlaceAndMaterial.setQuantity(newInventory); placeMapper.updateMaterialAndPlace(oldPlaceAndMaterial); - } - else { + } else { // 如果是拆单单位 // 用于获取拆单单位 @@ -2165,8 +2247,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 修改当前拆单库存 splitUnitMapper.updateSplitInventory(splitInventory); - } - else { + } else { // 如果不存在 // 用于添加一条拆单库存 @@ -2183,8 +2264,7 @@ public class StockTakingServiceImpl implements StockTakingService { } - } - else { + } else { // 如果在同一仓库 // 更新物料容量 @@ -2216,8 +2296,7 @@ public class StockTakingServiceImpl implements StockTakingService { newPlaceAndMaterial.setQuantity(newPlaceAndMaterial.getQuantity() + inventory_transfer); placeMapper.updateMaterialAndPlace(newPlaceAndMaterial); } - } - else{ + } else { // 如果是拆单单位 @@ -2236,33 +2315,32 @@ public class StockTakingServiceImpl implements StockTakingService { // 查找转移前拆单库位记录 SplitInventory oldSplitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); - paramForMaterialAndPlace.put("pid",newPlace.getId()); + paramForMaterialAndPlace.put("pid", newPlace.getId()); // 获取物料与转移后库位的对应关系 MaterialAndPlace newPlaceAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); - if(oldSplitInventory != null){ + if (oldSplitInventory != null) { // 如果该拆单库存存在 oldSplitInventory.setSaveQuantity(newInventory); // 修改当前物料库存 splitUnitMapper.updateSplitInventory(oldSplitInventory); - } - else{ + } else { // 如果该拆单库存不存在 // 添加相关数据 - paramForSplitInventory.put("outQuantity",0); - paramForSplitInventory.put("inQuantity",newInventory); - paramForSplitInventory.put("saveQuantity",newInventory); + paramForSplitInventory.put("outQuantity", 0); + paramForSplitInventory.put("inQuantity", newInventory); + paramForSplitInventory.put("saveQuantity", newInventory); // 添加一条拆单库存记录 splitUnitMapper.addSplitInventory(paramForSplitInventory); } - if(newPlaceAndMaterial != null){ + if (newPlaceAndMaterial != null) { // 如果物料与转移后的库位存在对应关系 - paramForSplitInventory.put("iid",newPlaceAndMaterial.getId()); + paramForSplitInventory.put("iid", newPlaceAndMaterial.getId()); // 查找转移后拆单库位记录 SplitInventory newSplitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); @@ -2275,13 +2353,10 @@ public class StockTakingServiceImpl implements StockTakingService { // 最终存储到拆单处理的数量 double saveQuantity = inventory_transfer - disposeQuantity * splitInfo.getQuantity(); - if(newSplitInventory != null){ + if (newSplitInventory != null) { // 如果转移后的拆单库存存在 - - - // 当前拆单库存最终存储数量 int realQuantity = (int) Math.round(saveQuantity) + newSplitInventory.getSaveQuantity(); @@ -2335,14 +2410,13 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取当前的单价 map.put("price", String.valueOf(inventoryById.getPrice() / 100)); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); } } - } - else { + } else { // 如果不存在拆单记录 @@ -2387,7 +2461,7 @@ public class StockTakingServiceImpl implements StockTakingService { // 获取对应的父级 SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); // 设置当前的单价 - map.put("price",String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo,-1))); + map.put("price", String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1))); // 调用现有的拆单库存修改逻辑 splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, newPlaceAndMaterial.getId(), map, inventory_transfer, splitInfo); } else { @@ -2395,14 +2469,13 @@ public class StockTakingServiceImpl implements StockTakingService { // 设置单价 map.put("price", String.valueOf(inventoryById.getPrice() / 100)); // 调用相关的入库逻辑 - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除对应的入库订单 depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); } - } - else { + } else { insertForSplitInventory.put("saveQuantity", realQuantity); insertForSplitInventory.put("inQuantity", realQuantity); @@ -2413,8 +2486,7 @@ public class StockTakingServiceImpl implements StockTakingService { } } - } - else{ + } else { // 如果转移之后的库位没有该物料 paramForMaterialAndPlace.put("quantity", 0); @@ -2452,7 +2524,7 @@ public class StockTakingServiceImpl implements StockTakingService { SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); // 计算当前拆单下的单价 - map.put("price",String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo,-1))); + map.put("price", String.valueOf(inventoryById.getPrice() / splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1))); // 调用现有的拆单库存变化逻辑 splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(paramForMaterialAndPlace.get("id")), map, disposeQuantity, splitInfo); @@ -2462,14 +2534,13 @@ public class StockTakingServiceImpl implements StockTakingService { // 设置单价 map.put("price", String.valueOf(inventoryById.getPrice() / 100)); // 调用现有入库逻辑进行修改库存 - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除入库单 depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); map.remove("id"); } - } - else { + } else { // 如果不大于 insertForSplitInventory.put("saveQuantity", inventory_transfer); @@ -2584,8 +2655,6 @@ public class StockTakingServiceImpl implements StockTakingService { List err = new ArrayList<>(); - - // 获取所有子单 List minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); for (int i = 0; i < minRecordList.size(); i++) { @@ -2618,7 +2687,6 @@ public class StockTakingServiceImpl implements StockTakingService { // 根据盘点结果重新计算物料的单价 - Integer newInventory = minRecord.getNewInventory();