diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java index 1a6683eb..a25f14f9 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java @@ -157,7 +157,7 @@ public class DepositoryController { Map depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user); Iterator it = depositoryAllNameAndId.keySet().iterator(); //result用来接收每个仓库每天的库存 - List result = new ArrayList<>(); + ArrayList result = new ArrayList<>(); // map用来存储仓库与库存的映射 Map map = new HashMap<>(); // 只获取当天 @@ -167,9 +167,9 @@ public class DepositoryController { int i; String key = it.next().toString(); String dname = key.split(",")[0]; - Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); + Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); result.add(inventoryByDname); - map.put(key, ((ArrayList) result).clone()); + map.put(key, result.clone()); result.clear(); } } else { @@ -190,7 +190,7 @@ public class DepositoryController { // 获取今天容量 String dname = key.split(",")[0]; - Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); + Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); result.add(inventoryByDname); // 判断当天是否有出入口记录 @@ -211,7 +211,7 @@ public class DepositoryController { break; } // 当前日期额度 - Integer aDouble = result.get(j++); + Double aDouble = result.get(j++); // 获取当前仓库 Integer val = (Integer) depositoryAllNameAndId.get(key); // 如果今天有出入库记录 @@ -226,11 +226,11 @@ public class DepositoryController { Integer depositoryRecordByDateByIn1 = depositoryRecordService.findApplicationInRecordByDate(days.get(i), days.get(i + 1), val); // 获取一段时间内的出库额度 Integer depositoryRecordByDateByOut1 = depositoryRecordService.findApplicationOutRecordByDate(days.get(i), days.get(i + 1), val); - Integer warehouserCount1 = (int) aDouble - depositoryRecordByDateByIn1 + depositoryRecordByDateByOut1; + Double warehouserCount1 = aDouble - depositoryRecordByDateByIn1 + depositoryRecordByDateByOut1; result.add(warehouserCount1); } Collections.reverse(result); - map.put(key.toString(), ((ArrayList) result).clone()); + map.put(key.toString(), result.clone()); result.clear(); } } @@ -254,12 +254,12 @@ public class DepositoryController { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); instance.add(Calendar.MONTH, 1); instance.set(Calendar.DATE, 1); - List result = new ArrayList<>(); + List result = new ArrayList<>(); String month = formatter.format(instance.getTime()); List toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); for (int i = 0; i < depositoryAll.size(); i++) { String dname = depositoryAll.get(i).getDname(); - Integer todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest); + Double todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest); result.add(todayDepositoryInventory); todayInventory.put(dname, todayDepositoryInventory); ((Map) sourceList.get(0)).put(dname, result.get(i)); @@ -284,13 +284,13 @@ public class DepositoryController { parmOut.put("end", months.get(num)); // 获取月份中入库物料的总额 // 测试 - Integer wareHouseInCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmIn); + Double wareHouseInCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmIn); // 获取月份中出库物料的总额 // 测试 - Integer wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); + Double wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); // 获取当前月库存容量 // 测试 - Integer wareHouseCount1 = result.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; + Double wareHouseCount1 = result.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; result.add(wareHouseCount1); ((Map) sourceList.get(num)).put(depositoryAll.get(j).getDname(), wareHouseCount1); } @@ -300,7 +300,7 @@ public class DepositoryController { } for (int i = 0; i < depositoryAll.size(); i++) { String dname = depositoryAll.get(i).getDname(); - Integer todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest); + Double todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest); ((Map) sourceList.get(0)).put(dname, todayDepositoryInventory); } List barSource = new ArrayList<>(); @@ -320,13 +320,13 @@ public class DepositoryController { * @param list * @return */ - public Integer getInventoryByDname(String dname, List list) { + public Double getInventoryByDname(String dname, List list) { for (InventoryByDname inventoryByDname : list) { if (dname.equals(inventoryByDname.getDname())) { return inventoryByDname.getInventory(); } } - return 0; + return 0.0; } /** @@ -353,11 +353,11 @@ public class DepositoryController { } mapDataList.add(title); List toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); - for (int i = 0; i < depositoryAll.size(); i++) { + for (Depository depository : depositoryAll) { List productData = new ArrayList<>(); - String dname = depositoryAll.get(i).getDname(); + String dname = depository.getDname(); productData.add(dname); - Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); + Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); productData.add(inventoryByDname); int k = 1; for (int j = 0; j < months.size() - 1; j++) { @@ -365,21 +365,21 @@ public class DepositoryController { Map parmOut = new HashMap<>(); parmIn.put("type", 1); parmIn.put("state", "已入库"); - parmIn.put("depository_id", depositoryAll.get(i).getId()); + parmIn.put("depository_id", depository.getId()); parmIn.put("start", months.get(j + 1)); parmIn.put("end", months.get(j)); parmOut.put("type", 2); parmOut.put("state", "已出库"); - parmOut.put("depository_id", depositoryAll.get(i).getId()); + parmOut.put("depository_id", depository.getId()); parmOut.put("start", months.get(j + 1)); parmOut.put("end", months.get(j)); // 获取某个月某物料入库总额 // 测试 - Integer wareHouseInCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmIn); + Double wareHouseInCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmIn); // 获取某个月某物料出库总额 // 测试 - Integer wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); - Integer wareHouseCount1 = (int) productData.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; + Double wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); + Double wareHouseCount1 = (double)productData.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; productData.add(wareHouseCount1); } List result = new ArrayList<>(); @@ -668,7 +668,7 @@ public class DepositoryController { parm.put("oldId", materialTypeAll.get(j).getOldId()); //根据条件获取月份中物料的总额 // 测试 - Integer materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm); + Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm); ((Map) sourceList.get(num)).put(materialTypeAll.get(j).getTname(), materialCountByMonth1); } } @@ -711,14 +711,14 @@ public class DepositoryController { List depositoryName = new ArrayList<>(); // 各仓库对应入库数目 - Map yesterdayData = new HashMap<>(); + Map yesterdayData = new HashMap<>(); // 获取昨天数据标志位 boolean flag = true; // 每天各仓库入库数目 Map show_data = new HashMap<>(); List days = getLastTimeInterval(); - List drCountbyDrName = new ArrayList<>(); + ArrayList drCountbyDrName = new ArrayList<>(); while (it.hasNext()) { @@ -732,14 +732,14 @@ public class DepositoryController { Integer val = (Integer) depositoryAllNameAndId.get(key); // 获取一段时间内的库存额度 // 测试 - Integer depositoryRecordByDateAndType1 = depositoryRecordService.findApplicationRecordByDate(days.get(i), days.get(i - 1), Integer.parseInt(type), val); + Double depositoryRecordByDateAndType1 = depositoryRecordService.findApplicationRecordByDate(days.get(i), days.get(i - 1), Integer.parseInt(type), val); drCountbyDrName.add(depositoryRecordByDateAndType1); if (i == 2 && flag) { yesterdayData.put(key.toString(), depositoryRecordByDateAndType1); } } Collections.reverse(drCountbyDrName); - show_data.put(key.toString(), ((ArrayList) drCountbyDrName).clone()); + show_data.put(key.toString(), drCountbyDrName.clone()); drCountbyDrName.clear(); } Map depository_data = new HashMap<>(); @@ -788,7 +788,7 @@ public class DepositoryController { // 仓库名称列表 List depositoryName = new ArrayList<>(); // 各仓库对应入库数目 - Map yesterdayData = new HashMap<>(); + Map yesterdayData = new HashMap<>(); // 每天各仓库入库数目 Map show_data = new HashMap<>(); // 各仓库当前库存数目 @@ -815,13 +815,13 @@ public class DepositoryController { depositoryName.add(key.toString()); Integer val = (Integer) depositoryAllNameAndId.get(key); // 获取一段时间内的库存额度 - Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); + Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); Integer toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); todayInventory.put(key.toString(), toDayInventoryByDName); yesterdayData.put(key.toString(), depositoryRecordByDate1); - List drCountbyDrName = new ArrayList<>(); + ArrayList drCountbyDrName = new ArrayList<>(); drCountbyDrName.add(depositoryRecordByDate1); - show_data.put(key.toString(), ((ArrayList) drCountbyDrName).clone()); + show_data.put(key.toString(), drCountbyDrName.clone()); } } else { int now = instance.get(Calendar.DAY_OF_WEEK) - 1 == 0 ? 7 : instance.get(Calendar.DAY_OF_WEEK) - 1; @@ -836,7 +836,7 @@ public class DepositoryController { Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())); days.add(format); } - List drCountbyDrName = new ArrayList<>(); + ArrayList drCountbyDrName = new ArrayList<>(); while (it.hasNext()) { int i; Object key = it.next(); @@ -850,13 +850,13 @@ public class DepositoryController { Integer val = (Integer) depositoryAllNameAndId.get(key); // 获取一段时间内的库存额度 - Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); + Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); drCountbyDrName.add(depositoryRecordByDate1); if (i == 2 && flag) { yesterdayData.put(key.toString(), depositoryRecordByDate1); } } - show_data.put(key.toString(), ((ArrayList) drCountbyDrName).clone()); + show_data.put(key.toString(), drCountbyDrName.clone()); drCountbyDrName.clear(); } } @@ -912,7 +912,7 @@ public class DepositoryController { // 仓库名称列表 List depositoryName = new ArrayList<>(); // 各仓库对应入库数目 - Map yesterdayData = new HashMap<>(); + Map yesterdayData = new HashMap<>(); // 每天各仓库入库数目 Map show_data = new HashMap<>(); // 各仓库当前库存数目 @@ -945,23 +945,23 @@ public class DepositoryController { // 获取仓库对应的id Integer val = (Integer) depositoryAllNameAndId.get(key); // 获取今天内的入库额度 - Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); + Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); todayInventory.put(key.toString(), depositoryRecordByDate1); //获取昨天的入库额度 - Integer yesterdayInData = depositoryRecordService.findApplicationRecordByDate(now, yesterday, Integer.parseInt(type), val); + Double yesterdayInData = depositoryRecordService.findApplicationRecordByDate(now, yesterday, Integer.parseInt(type), val); // 添加 yesterdayData.put(key.toString(), yesterdayInData); - List drCountbyDrName = new ArrayList<>(); + ArrayList drCountbyDrName = new ArrayList<>(); drCountbyDrName.add(depositoryRecordByDate1); - show_data.put(key.toString(), ((ArrayList) drCountbyDrName).clone()); + show_data.put(key.toString(), drCountbyDrName.clone()); } } else { - Future future = completionService.submit(new distributeTasks(type, 1, userByPort, yesterdayData, depositoryName)); + Future future = completionService.submit(new distributeTasks(depositoryAllNameAndId,type, 1, userByPort, yesterdayData, depositoryName)); futureList.add(future); taskNum += 1; } // 获取本月及之前月份各种类别入/出库总量 - Future future = completionService.submit(new distributeTasks(type, 3, userByPort, yesterdayData, depositoryName)); + Future future = completionService.submit(new distributeTasks(depositoryAllNameAndId,type, 3, userByPort, yesterdayData, depositoryName)); futureList.add(future); taskNum += 1; // 中国地图数据 @@ -971,7 +971,7 @@ public class DepositoryController { Map mapData = new HashMap<>(); if (!"0".equals(type)) { - Future future1 = completionService.submit(new distributeTasks(type, 4, userByPort, yesterdayData, depositoryName)); + Future future1 = completionService.submit(new distributeTasks(depositoryAllNameAndId,type, 4, userByPort, yesterdayData, depositoryName)); futureList.add(future1); taskNum += 1; } @@ -1004,14 +1004,14 @@ public class DepositoryController { if ("0".equals(type)) { // 如果是获取库存 - distributeTasks distributeTasks1 = new distributeTasks(type, 5, userByPort, yesterdayData, depositoryName); + distributeTasks distributeTasks1 = new distributeTasks(depositoryAllNameAndId,type, 5, userByPort, yesterdayData, depositoryName); distributeTasks1.setTodayInventory(todayInventory); distributeTasks1.setDepositoryService(depositoryService); distributeTasks1.setDepositoryRecordService(depositoryRecordService); - distributeTasks distributeTasks2 = new distributeTasks(type, 6, userByPort, yesterdayData, depositoryName); + distributeTasks distributeTasks2 = new distributeTasks(depositoryAllNameAndId,type, 6, userByPort, yesterdayData, depositoryName); distributeTasks2.setDepositoryService(depositoryService); distributeTasks2.setDepositoryRecordService(depositoryRecordService); - distributeTasks distributeTasks3 = new distributeTasks(type, 7, userByPort, yesterdayData, depositoryName); + distributeTasks distributeTasks3 = new distributeTasks(depositoryAllNameAndId,type, 7, userByPort, yesterdayData, depositoryName); distributeTasks3.setDepositoryService(depositoryService); distributeTasks3.setDepositoryRecordService(depositoryRecordService); Future future1 = completionService.submit(distributeTasks1); @@ -1062,13 +1062,10 @@ public class DepositoryController { return resMap; } - public Map getShowData(String type, UserByPort userByPort, Map yesterdayData, List depositoryName) { - // 获取各仓库名称以及id - Map depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort); + public Map getShowData(Map depositoryAllNameAndId,String type, UserByPort userByPort, Map yesterdayData, List depositoryName) { // 获取遍历器 Iterator it = depositoryAllNameAndId.keySet().iterator(); // 仓库名称列表 - //获取获取系统的当前日历对象 Calendar instance = Calendar.getInstance(); // 获取日期 @@ -1174,8 +1171,7 @@ public class DepositoryController { // 1.定义CompletionService CompletionService completionService = new ExecutorCompletionService(exs); - for (int i = 0; i < materialTypeAll.size(); i++) { - MaterialType mt = materialTypeAll.get(i); + for (MaterialType mt : materialTypeAll) { Future future = completionService.submit(new findMapData(previousMonth1, type, mt)); futureList.add(future); } @@ -1564,13 +1560,15 @@ public class DepositoryController { String type; //请求类型 int taskType; // 任务类型 UserByPort userByPort; // 登录用户 - Map yesterdayData; // 昨天的数据 + Map yesterdayData; // 昨天的数据 List depositoryName; // 仓库名称 DepositoryService depositoryService; // 操作depository的service DepositoryRecordService depositoryRecordService; // 操作订单的service Map todayInventory; // 当前仓库的额度 + Map depositoryAllNameAndId; // 仓库名称与仓库id的映射 - distributeTasks(String type, int taskType, UserByPort userByPort, Map yesterdayData, List depositoryName) { + distributeTasks(Map depositoryAllNameAndId,String type, int taskType, UserByPort userByPort, Map yesterdayData, List depositoryName) { + this.depositoryAllNameAndId = depositoryAllNameAndId;// 仓库名称与仓库id映射 this.taskType = taskType; // 任务类型 this.type = type; // 请求类型 this.userByPort = userByPort; // 登录用户 @@ -1585,7 +1583,7 @@ public class DepositoryController { Map result = new HashMap<>(); if (1 == taskType) { - Map showData = getShowData(type, userByPort, yesterdayData, depositoryName); + Map showData = getShowData(depositoryAllNameAndId,type, userByPort, yesterdayData, depositoryName); result.put("show_data", showData); } else if (2 == taskType) { @@ -1615,7 +1613,7 @@ public class DepositoryController { List days; Map depositoryAllNameAndId; List depositoryName; - Map yesterdayData; + Map yesterdayData; String type; Map show_data; @@ -1629,7 +1627,7 @@ public class DepositoryController { @Override public Object call() throws Exception { int i; - List drCountbyDrName = new ArrayList<>(); + List drCountbyDrName = new ArrayList<>(); for (i = days.size() - 1; i > 0; i--) { // 遍历 Map并计算各仓库的入库数 if (i == days.size() - 1) { @@ -1637,7 +1635,7 @@ public class DepositoryController { } Integer val = (Integer) depositoryAllNameAndId.get(key); // 获取一段时间内的库存额度 - Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); + Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); drCountbyDrName.add(depositoryRecordByDate1); if (i == 2) { yesterdayData.put(key.toString(), depositoryRecordByDate1); @@ -1716,7 +1714,7 @@ public class DepositoryController { @Override public Object call() throws Exception { Map result = new HashMap<>(); - Integer materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(map); + Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(map); Long oldId = Long.valueOf(map.get("oldId").toString()); MaterialType materialTypeByOldId = materialTypeService.findMaterialTypeByOldId(oldId); result.put(materialTypeByOldId.getTname(), materialCountByMonth1); @@ -1753,7 +1751,7 @@ public class DepositoryController { parm.put("oldId", mt.getOldId()); //根据条件获取月份中物料的总额 // 测试 - Integer materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm); + Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm); productData.add(materialCountByMonth1); } return productData; diff --git a/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationInRecord.java b/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationInRecord.java index 62e1216d..27c2af01 100644 --- a/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationInRecord.java +++ b/src/main/java/com/dreamchaser/depository_manage/entity/ApplicationInRecord.java @@ -8,39 +8,146 @@ public class ApplicationInRecord { /** * id */ - private Long id; + private Integer id; /** - * 入库物品编号 + * 入库物品名称 */ - private Integer mid; + private String mname; /** * 入库数量 */ - private int quantity; + private Integer quantity; /** * 入库金额 */ - private int price; + private Double price; /** - * 提交人编号 + * 入库物品类型 */ - private int applicant_id; + private String materialTypeName; + + /** + * 提交人姓名 + */ + private String applicantName; + + /** + * 提交人id + */ + private Integer applicantId; + /** * 提交时间 */ - private Long applicant_time; + private String applicantTime; /** * 货物单号 */ private String code; /** - * 仓库编号 + * 仓库名称 */ - private Integer depository_id; + private String depositoryName; + + + /** + * 仓库id + */ + private Integer depositoryId; + + + /** + * 提交备注 + */ + private String applyRemark; /** * 入库编码 */ private String aircode; + + /** + * 物品编码 + */ + private String mcode; + /** + * 物品规格型号 + */ + private String mversion; + /** + * 物品计量单位 + */ + private String munit; + /** + * 物品材质 + */ + private String mtexture; + /** + * 物品金蝶编码 + */ + private String mkingdeecode; + /** + * 物品仓库编码 + */ + private String mdepositoryCode; + + /** + * 入库时选中的单位 + */ + private String airUnit; + + /** + * 1物料2组合 + */ + private Integer flagForGroup; + + /** + * 入库物料 + */ + private Integer mid; + + + /** + * 入库库位 + */ + private Integer placeId; + + /** + * 用于标志该物料入库记录是那个组合下的入库记录 + */ + private Integer airtoGroupId; + + /** + * 1通过2驳回3待审批4无需审批 + */ + private Integer airapproverPass; + /** + * 审批时间 + */ + private String airapproverTime; + /** + * 审批人id + */ + private String airapproverId; + /** + * 审批人姓名 + */ + private String airapproverName; + /** + * 状态 + */ + private String airstate; + + /** + * 审批意见 + */ + private String airapproverMessage; + + + /** + * 入库时填写的生产日期 + */ + private Long mproducedDate; + } diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java index 1ad8c7e6..52b0cf1c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java @@ -1,7 +1,6 @@ package com.dreamchaser.depository_manage.mapper; import com.dreamchaser.depository_manage.entity.*; -import com.dreamchaser.depository_manage.pojo.ApplicationInRecordP; import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordMinP; import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP; import org.apache.ibatis.annotations.Mapper; @@ -73,26 +72,26 @@ public interface DepositoryRecordMapper { * 查找所有入库记录 * @return */ - List findApplicationInRecordPAll(); + List findApplicationInRecordPAll(); /** * 根据主键id列表获取入库订单列表 * @param ids * @return */ - List findApplicationInRecordsByIds(List ids); + List findApplicationInRecordsByIds(List ids); /** * 查找所有入库记录 * @return */ - List findApplicationInRecordPByDepositoryList(List list); + List findApplicationInRecordPByDepositoryList(List list); /** * 查询一段时间内的入库记录 * @param map 条件,起止时间 * @return */ - List findApplicationInRecordPForAPeriodOfTime(Map map); + List findApplicationInRecordPForAPeriodOfTime(Map map); /** * 查找所有出库记录 @@ -244,14 +243,14 @@ public interface DepositoryRecordMapper { * @param map * @return */ - List findApplicationInRecordPByCondition(Map map); + List findApplicationInRecordPByCondition(Map map); /** * 查询当前用户入库记录及其管理仓库的入库记录 * @param map 查询条件 * @return */ - List findApplicationInRecordPByUser(Map map); + List findApplicationInRecordPByUser(Map map); /** * 查询当前用户入库记录及其管理仓库的入库记录数目 @@ -265,7 +264,7 @@ public interface DepositoryRecordMapper { * @param depositoryId 待查询仓库id * @return */ - List findApplicationInRecordByDepository(String depositoryId); + List findApplicationInRecordByDepository(String depositoryId); /** * 查询当前仓库的出库记录 @@ -317,7 +316,7 @@ public interface DepositoryRecordMapper { * @param id * @return */ - ApplicationInRecordP findApplicationInRecordPById(Integer id); + ApplicationInRecord findApplicationInRecordPById(Integer id); /** @@ -325,7 +324,7 @@ public interface DepositoryRecordMapper { * @param id * @return */ - List findApplicationInRecordPByToGroupId(Integer id); + List findApplicationInRecordPByToGroupId(Integer id); diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml index 2dd16719..c7c09be5 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml @@ -53,7 +53,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java b/src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java index 944fcbde..0a62a23a 100644 --- a/src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java +++ b/src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java @@ -1,5 +1,6 @@ package com.dreamchaser.depository_manage.pojo; +import com.dreamchaser.depository_manage.entity.ApplicationInRecord; import lombok.Data; @Data @@ -15,7 +16,7 @@ public class ApplicationInRecordP { /** * 入库数量 */ - private int quantity; + private Double quantity; /** * 入库金额 */ @@ -149,4 +150,42 @@ public class ApplicationInRecordP { */ private Long mproducedDate; + public ApplicationInRecordP(ApplicationInRecord ar) { + this.id = ar.getId(); + this.mname = ar.getMname(); + this.quantity = (double)ar.getQuantity() / 100; + this.price = ar.getPrice(); + this.materialTypeName = ar.getMaterialTypeName(); + this.applicantName = ar.getApplicantName(); + this.applicantId = ar.getApplicantId(); + this.applicantTime = ar.getApplicantTime(); + this.code = ar.getCode(); + this.depositoryName = ar.getDepositoryName(); + this.depositoryId = ar.getDepositoryId(); + this.applyRemark = ar.getApplyRemark(); + this.aircode = ar.getAircode(); + this.mcode = ar.getMcode(); + this.mversion = ar.getMversion(); + this.munit = ar.getMunit(); + this.mtexture = ar.getMtexture(); + this.mkingdeecode = ar.getMkingdeecode(); + this.mdepositoryCode = ar.getMdepositoryCode(); + this.airUnit = ar.getAirUnit(); + this.flagForGroup = ar.getFlagForGroup(); + this.mid = ar.getMid(); + this.placeId = ar.getPlaceId(); + this.airtoGroupId = ar.getAirtoGroupId(); + this.airapproverPass = ar.getAirapproverPass(); + this.airapproverTime = ar.getAirapproverTime(); + this.airapproverId = ar.getAirapproverId(); + this.airapproverName = ar.getAirapproverName(); + this.airstate = ar.getAirstate(); + this.airapproverMessage = ar.getAirapproverMessage(); + this.mproducedDate = ar.getMproducedDate(); + } + + public ApplicationInRecordP() { + } } + + diff --git a/src/main/java/com/dreamchaser/depository_manage/pojo/InventoryByDname.java b/src/main/java/com/dreamchaser/depository_manage/pojo/InventoryByDname.java index 82343376..24150547 100644 --- a/src/main/java/com/dreamchaser/depository_manage/pojo/InventoryByDname.java +++ b/src/main/java/com/dreamchaser/depository_manage/pojo/InventoryByDname.java @@ -7,6 +7,6 @@ import lombok.Data; */ @Data public class InventoryByDname { - Integer inventory; + Double inventory; String dname; } 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 0a04938c..6c7acf86 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java @@ -310,7 +310,7 @@ public interface DepositoryRecordService { * @param depositoryId * @return */ - Integer findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId); + Double findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId); /** * 获取一段时间内的入库额度 @@ -354,7 +354,7 @@ public interface DepositoryRecordService { * @param map 条件 * @return */ - Integer findMaterialCountByMonth2(Map map); + Double findMaterialCountByMonth2(Map map); /** * 查询仓库当天流水 diff --git a/src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java b/src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java index 4238d59d..96b1c709 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java @@ -157,7 +157,7 @@ public interface SplitUnitService { * @param map 入库条件 * @param inQuantity 最终入库数量 */ - void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map map, int inQuantity, SplitInfo baseSplitInfo); + void updateSplitInfoSaveQuantity(SplitInfo splitInfo, double quantity, int iid, Map map, double inQuantity, SplitInfo baseSplitInfo); /** * 根据父级查询拆单记录 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 1f6d3454..1932968f 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 @@ -122,7 +122,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 根据物料id查询物料 Material material = materialMapper.findMaterialById(mid); // 判断剩余容量是否可以存入 - if (depositoryRecordById.getMaxNumber() - Inventory < quantity) { + if (depositoryRecordById.getMaxNumber() - (double) (Inventory / 100) < quantity) { return 0; } // 获取当前填写的生产日期 @@ -182,6 +182,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 如果不包含标志位. map.put("flagForGroup", 1); } + // 修改入库数量扩大100倍 + map.put("quantity", ObjectFormatUtil.toDouble(map.get("quantity")) * 100); return depositoryRecordMapper.insertApplicationInRecord(map); } @@ -203,7 +205,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (materialByCondition.size() > 0) { // 如果当前存在 Inventory mt = materialByCondition.get(0); map.put("mid", mt.getMid()); - mt.setQuantity((int) (mt.getQuantity() + quantity)); + mt.setQuantity((int) (mt.getQuantity() + quantity * 100)); mt.setProducedDate(producedDate); materialMapper.updateInventory(mt); newMid = mt.getId(); @@ -211,7 +213,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { Map insert = new HashMap<>(); Material materialById = materialMapper.findMaterialById(mid); insert.put("depositoryId", depositoryId); - insert.put("quantity", quantity); + insert.put("quantity", quantity * 100); insert.put("shelfLife", materialById.getShelfLife()); insert.put("producedDate", producedDate); insert.put("mid", map.get("mid")); @@ -402,24 +404,24 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { mapForYesterday.put("list", list); // 查询今天目前为止的入库 - List applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday); + List applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday); // 查询昨天的入库 - List applicationInRecordPForYesterday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForYesterday); + List applicationInRecordPForYesterday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForYesterday); // 今天的入库数量 - int sumForToday = 0; + double sumForToday = 0; // 今天的入库额度 double priceForToday = 0.0; // 昨天的入库数量 - int sumForYesterDay = 0; + double sumForYesterDay = 0; // 昨天的入库额度 double priceForYesterDay = 0.0; - for (ApplicationInRecordP applicationInRecordP : applicationInRecordPForToday) { + for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) { // 获取当前入库类型(1物料2组合) Integer flagForGroup = applicationInRecordP.getFlagForGroup(); - sumForToday += applicationInRecordP.getQuantity(); + sumForToday += (double)applicationInRecordP.getQuantity() / 100; if (applicationInRecordP.getPrice() != null) { - priceForToday += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity(); + priceForToday += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100); } else { priceForToday += 0; } @@ -427,24 +429,23 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } - for (int i = 0; i < applicationInRecordPForYesterday.size(); i++) { - ApplicationInRecordP applicationInRecordP = applicationInRecordPForYesterday.get(i); - sumForYesterDay += applicationInRecordP.getQuantity(); + for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) { + sumForYesterDay += (double)applicationInRecordP.getQuantity() / 100; if (applicationInRecordP.getPrice() != null) { - priceForYesterDay += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity(); + priceForYesterDay += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100); } else { priceForYesterDay += 0; } } Map result = new HashMap<>(); result.put("total", sumForToday); - Double ratioForCount = 0.0; - Double ratioForPrice = 0.0; + double ratioForCount = 0.0; + double ratioForPrice = 0.0; if (Double.compare(sumForYesterDay, 0.0) != 0) { - ratioForCount = ((sumForToday - sumForYesterDay) / Double.parseDouble(Integer.toString(sumForYesterDay))); + ratioForCount = ((sumForToday - sumForYesterDay) / sumForYesterDay); } if (Double.compare(priceForYesterDay, 0.0) != 0) { - ratioForPrice = (priceForToday - priceForYesterDay) / Double.parseDouble(Double.toString(priceForYesterDay)); + ratioForPrice = (priceForToday - priceForYesterDay) / priceForYesterDay; } BigDecimal bgForSum = new BigDecimal(ratioForCount); BigDecimal bgForPrice = new BigDecimal(ratioForPrice); @@ -652,12 +653,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (placeId == null) { placeId = 0; } - Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); + Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); Place placeById = placeMapper.findPlaceById(placeId); // 获取当前物料基本信息 Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); Material materialById = materialMapper.findMaterialById(mid); - map.put("mtId",materialById.getMaterialTypeId()); + map.put("mtId", materialById.getMaterialTypeId()); String unit = (String) map.get("unit"); if ("-1".equals(unit)) { map.put("unit", materialById.getUnit()); @@ -709,7 +710,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { * @param placeById 入库库位 * @return */ - Integer updateInventoryInfoForApproval(Map map, Integer quantity, Material materialById, Place placeById) { + Integer updateInventoryInfoForApproval(Map map, double quantity, Material materialById, Place placeById) { // 获取当前入库的物料id Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid")); // 获取当前入库记录id @@ -731,13 +732,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { MaterialAndProducedDate materialAndProducedDateByMidAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(insertProducedDate); if (materialAndProducedDateByMidAndProducedDate != null) { // 增加当前数量 - materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + quantity); - materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity); + materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + (int) quantity * 100); + materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + (int) quantity * 100); // 修改 materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate); } else { - insertProducedDate.put("quantity", quantity); - insertProducedDate.put("inventory", quantity); + insertProducedDate.put("quantity", quantity * 100); + insertProducedDate.put("inventory", quantity * 100); insertProducedDate.put("expendnum", 0); insertProducedDate.put("barCode", map.get("barCode")); insertProducedDate.put("qrCode", map.get("qrCode")); @@ -765,16 +766,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(insert); if (placeAndMaterialByMidAndPid == null) { // 如果没有当前记录 - insert.put("quantity", quantity); + insert.put("quantity", quantity * 100); // 插入记录 placeMapper.addMaterialOnPlace(insert); } else { - placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity); + placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) quantity * 100); // 修改数量 placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); } // 修改当前库位数量 - placeById.setQuantity(placeById.getQuantity() + quantity); + placeById.setQuantity(placeById.getQuantity() + (int) quantity * 100); return placeMapper.UpdatePlace(placeById); } @@ -813,7 +814,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 将库存还原 Material material = materialByCondition.get(0); Map update = new HashMap<>(); - update.put("quantity", material.getQuantity() - quantity); + update.put("quantity", material.getQuantity() - quantity * 100); update.put("price", oldPrice); update.put("amounts", material.getAmounts() - quantity * price); update.put("id", material.getId()); @@ -1053,8 +1054,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { restResponse.setData(""); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); } - } - else { + } else { // 如果是拆单后的出库 // 用于获取对应的拆单记录 @@ -1115,8 +1115,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); - } - else { + } else { // 如果不能满足需求 // 获取对应的拆单记录 @@ -1160,8 +1159,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); - } - else { + } else { // 如果当前拆单没有父级 @@ -1246,8 +1244,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { restResponse.setData(""); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); } - } - else { + } else { // 如果大于 // 获取库存重要减少的数量 @@ -1330,8 +1327,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } } - } - else { + } else { // 如果拆单库存处理记录不存在 int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); @@ -1397,8 +1393,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); - } - else { + } else { restResponse.setStatus(508); restResponse.setData(""); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); @@ -2096,57 +2091,57 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (!"".equals(sid) && flagForIn) { Integer id = ObjectFormatUtil.toInteger(sid.trim()); // 获取具体入库订单 - ApplicationInRecordP recordP = depositoryRecordMapper.findApplicationInRecordPById(id); + ApplicationInRecord record = depositoryRecordMapper.findApplicationInRecordPById(id); - if (Integer.compare(recordP.getAirapproverPass(), 1) == 0) { + if (Integer.compare(record.getAirapproverPass(), 1) == 0) { // 如果当前入库单已经被处理过,则跳过 continue; } // 获取当前入库对应的物料 - Material materialById = materialMapper.findMaterialById(recordP.getMid()); + Material materialById = materialMapper.findMaterialById(record.getMid()); - if (recordP.getAirtoGroupId() != null) { + if (record.getAirtoGroupId() != null) { // 如果该申请是组合入库下的申请 flagForGroupInfoInDepository = true; } // 用于调用入库方法而创建的 Map paramForUpdateInventory = new HashMap<>(); - paramForUpdateInventory.put("mid", recordP.getMid()); - paramForUpdateInventory.put("quantity", recordP.getQuantity()); - paramForUpdateInventory.put("depositoryId", recordP.getDepositoryId()); - paramForUpdateInventory.put("placeId", recordP.getPlaceId()); - if (materialById.getUnit().equals(recordP.getAirUnit())) { + paramForUpdateInventory.put("mid", record.getMid()); + paramForUpdateInventory.put("quantity", record.getQuantity()); + paramForUpdateInventory.put("depositoryId", record.getDepositoryId()); + paramForUpdateInventory.put("placeId", record.getPlaceId()); + if (materialById.getUnit().equals(record.getAirUnit())) { // 如果是基础单位 Map param = new HashMap<>(); - param.put("depositoryId", recordP.getDepositoryId()); + param.put("depositoryId", record.getDepositoryId()); param.put("mcode", materialById.getCode()); // 判断该仓库中有无该物物料 List materialByCondition = materialMapper.findInventory(param); // 修改仓库库存 - Long mproducedDate = recordP.getMproducedDate(); + Long mproducedDate = record.getMproducedDate(); if (mproducedDate == null) { mproducedDate = 0L; } // 获取当前库存id - Integer newMid = updateOrInsertInventory(paramForUpdateInventory, materialByCondition, (double) recordP.getQuantity(), materialById.getId(), recordP.getDepositoryId(), mproducedDate); + Integer newMid = updateOrInsertInventory(paramForUpdateInventory, materialByCondition, (double) record.getQuantity(), materialById.getId(), record.getDepositoryId(), mproducedDate); // 修改库位库存 paramForUpdateInventory.put("newInMid", newMid); - paramForUpdateInventory.put("id", recordP.getId()); - paramForUpdateInventory.put("producedDate", recordP.getMproducedDate()); - Place placeById = placeMapper.findPlaceById(recordP.getPlaceId()); + paramForUpdateInventory.put("id", record.getId()); + paramForUpdateInventory.put("producedDate", record.getMproducedDate()); + Place placeById = placeMapper.findPlaceById(record.getPlaceId()); // 修改当前库存容量 - updateInventoryInfoForApproval(paramForUpdateInventory, recordP.getQuantity(), materialById, placeById); + updateInventoryInfoForApproval(paramForUpdateInventory, record.getQuantity(), materialById, placeById); } else { // 如果是拆单单位 // 查询拆单记录 Map paramForSplitInfo = new HashMap<>(); - paramForSplitInfo.put("newUnit", recordP.getAirUnit()); - paramForSplitInfo.put("mid", recordP.getMid()); + paramForSplitInfo.put("newUnit", record.getAirUnit()); + paramForSplitInfo.put("mid", record.getMid()); // 查询当前拆单是否存在 SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); if (splitInfoForUnit != null) { @@ -2163,8 +2158,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId()); Map paramForInventory = new HashMap<>(); - paramForInventory.put("depositoryId", recordP.getDepositoryId()); - paramForInventory.put("mid", recordP.getMid()); + paramForInventory.put("depositoryId", record.getDepositoryId()); + paramForInventory.put("mid", record.getMid()); // 判断该仓库中有无该物物料 List inventoryList = materialMapper.findInventory(paramForInventory); @@ -2173,7 +2168,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 用于查找该库存对应库位 Map paramForInventoryToPlace = new HashMap<>(); - paramForInventoryToPlace.put("pid", recordP.getPlaceId()); + paramForInventoryToPlace.put("pid", record.getPlaceId()); paramForInventoryToPlace.put("mid", inventory.getId()); placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace); @@ -2184,7 +2179,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory); } } - splitUnitService.realInInventoryToDepository((double) recordP.getQuantity(), splitInventory, paramForUpdateInventory, splitInfoForUnit, placeAndMaterialByMidAndPid, true); + splitUnitService.realInInventoryToDepository((double) record.getQuantity(), splitInventory, paramForUpdateInventory, splitInfoForUnit, placeAndMaterialByMidAndPid, true); if (paramForUpdateInventory.containsKey("applicationInId")) { depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateInventory.get("applicationInId"))); } @@ -2609,7 +2604,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 获取具体入库订单 - ApplicationInRecordP recordP = depositoryRecordMapper.findApplicationInRecordPById(ObjectFormatUtil.toInteger(id)); + ApplicationInRecord recordP = depositoryRecordMapper.findApplicationInRecordPById(ObjectFormatUtil.toInteger(id)); // 获取当前入库对应的物料 @@ -3384,23 +3379,26 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { String applyTime = (String) map.get("applyTime"); map.put("applicantTime", DateUtil.DateTimeByDayToTimeStamp(applyTime)); } - List list = depositoryRecordMapper.findApplicationInRecordPByCondition(map); - for (ApplicationInRecordP applicationInRecordP : list) { - UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecordP.getApplicantId(), userToken); - String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecordP.getApplicantTime())); - applicationInRecordP.setApplicantName(userByPortById.getName()); - applicationInRecordP.setApplicantTime(time); - applicationInRecordP.setApplyRemark(applicationInRecordP.getApplyRemark() == null ? "" : applicationInRecordP.getApplyRemark()); - if (Integer.compare(applicationInRecordP.getFlagForGroup(), 2) == 0) { + List list = depositoryRecordMapper.findApplicationInRecordPByCondition(map); + List result = new ArrayList<>(); + + for (ApplicationInRecord applicationInRecord : list) { + UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userToken); + String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime())); + applicationInRecord.setApplicantName(userByPortById.getName()); + applicationInRecord.setApplicantTime(time); + applicationInRecord.setApplyRemark(applicationInRecord.getApplyRemark() == null ? "" : applicationInRecord.getApplyRemark()); + if (Integer.compare(applicationInRecord.getFlagForGroup(), 2) == 0) { // 如果入库的是组合 - Group group = groupMapper.findGroupOnlyById(applicationInRecordP.getMid()); - applicationInRecordP.setMname(group.getGname()); - applicationInRecordP.setAirUnit(""); - applicationInRecordP.setMcode(group.getCode()); - applicationInRecordP.setMversion("组合"); + Group group = groupMapper.findGroupOnlyById(applicationInRecord.getMid()); + applicationInRecord.setMname(group.getGname()); + applicationInRecord.setAirUnit(""); + applicationInRecord.setMcode(group.getCode()); + applicationInRecord.setMversion("组合"); } + ApplicationInRecordP ap = new ApplicationInRecordP(); } - return list; + return result; } /** @@ -3440,24 +3438,27 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } map.put("depositoryIdList", depositoryIdList); map.put("applicantId", userByPort.getId()); - List list = depositoryRecordMapper.findApplicationInRecordPByUser(map); - for (ApplicationInRecordP applicationInRecordP : list) { - UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecordP.getApplicantId(), userByPort); - String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecordP.getApplicantTime())); - applicationInRecordP.setApplicantName(userByPortById.getName()); - applicationInRecordP.setApplicantTime(time); - applicationInRecordP.setApplyRemark(applicationInRecordP.getApplyRemark() == null ? "" : applicationInRecordP.getApplyRemark()); - if (Integer.compare(applicationInRecordP.getFlagForGroup(), 2) == 0) { + List list = depositoryRecordMapper.findApplicationInRecordPByUser(map); + List result = new ArrayList<>(); + for (ApplicationInRecord applicationInRecord : list) { + UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userByPort); + String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime())); + applicationInRecord.setApplicantName(userByPortById.getName()); + applicationInRecord.setApplicantTime(time); + applicationInRecord.setApplyRemark(applicationInRecord.getApplyRemark() == null ? "" : applicationInRecord.getApplyRemark()); + if (Integer.compare(applicationInRecord.getFlagForGroup(), 2) == 0) { // 如果入库的是组合 - Group group = groupMapper.findGroupOnlyById(applicationInRecordP.getMid()); - applicationInRecordP.setMname(group.getGname()); - applicationInRecordP.setAirUnit(""); - applicationInRecordP.setMcode(group.getCode()); - applicationInRecordP.setMversion("组合"); + Group group = groupMapper.findGroupOnlyById(applicationInRecord.getMid()); + applicationInRecord.setMname(group.getGname()); + applicationInRecord.setAirUnit(""); + applicationInRecord.setMcode(group.getCode()); + applicationInRecord.setMversion("组合"); } + ApplicationInRecordP arp = new ApplicationInRecordP(applicationInRecord); + result.add(arp); } - return list; + return result; } @Override @@ -3584,7 +3585,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { */ @Override public List findApplicationInRecordByDepository(String depositoryId) { - return depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId); + List recordByDepository = depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId); + List list = new ArrayList<>(); + for (ApplicationInRecord record:recordByDepository + ) { + ApplicationInRecordP recordP = new ApplicationInRecordP(record); + list.add(recordP); + } + return list; } /** @@ -3808,17 +3816,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { @Override public Map CalculateAllApplicationInAll(List list) { Map result = new HashMap<>(); - List applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPByDepositoryList(list); - Double sum = 0.0; - Integer count = 0; - for (int i = 0; i < applicationInRecordPAll.size(); i++) { - ApplicationInRecordP applicationInRecordP = applicationInRecordPAll.get(i); + List applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPByDepositoryList(list); + double sum = 0.0; + double count = 0; + for (ApplicationInRecord applicationInRecordP : applicationInRecordPAll) { double price = 0.0; if (applicationInRecordP.getPrice() != null) { price = applicationInRecordP.getPrice(); } - sum += price * applicationInRecordP.getQuantity() / 100; - count += applicationInRecordP.getQuantity(); + sum += price * applicationInRecordP.getQuantity() / 10000; + count += (double)applicationInRecordP.getQuantity() / 100; } BigDecimal bg = new BigDecimal(sum); sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); @@ -3836,17 +3843,15 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { @Override public Double CalculateAllApplicationOutPrice(String state) { List applicationOutRecordPAll = depositoryRecordMapper.findApplicationOutRecordPAll(); - Double sum = 0.0; + double sum = 0.0; if (state.isEmpty()) { // 如果要获取所有待出库的金额 - for (int i = 0; i < applicationOutRecordPAll.size(); i++) { - ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i); + for (ApplicationOutRecordP applicationOutRecordP : applicationOutRecordPAll) { // 获取所有子物料 Map map = new HashMap<>(); map.put("parentId", applicationOutRecordP.getId()); List minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); - for (int k = 0; k < minByCondition.size(); k++) { - ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k); + for (ApplicationOutRecordMin applicationOutRecordMin : minByCondition) { Integer mid = applicationOutRecordMin.getMid(); Material materialById = materialMapper.findMaterialById(mid); if (materialById.getPrice() != null) { @@ -3911,16 +3916,19 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { * @return */ @Override - public Integer findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId) { + public Double findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId) { Map map = new HashMap<>(); map.put("start", start); map.put("end", end); map.put("depositoryId", depositoryId); + double quantity = 0.0; if (type == 1) { - return depositoryRecordMapper.findApplicationInRecordByDate(map); + quantity = (double) depositoryRecordMapper.findApplicationInRecordByDate(map) / 100; + return quantity; } else { map.put("state", "已出库"); - return depositoryRecordMapper.findApplicationOutRecordByDate(map); + quantity = (double) depositoryRecordMapper.findApplicationOutRecordByDate(map); + return quantity; } } @@ -4003,7 +4011,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { } @Override - public Integer findMaterialCountByMonth2(Map map) { + public Double findMaterialCountByMonth2(Map map) { Integer type = ObjectFormatUtil.toInteger(map.get("type")); Object o = map.get("oldId"); List allMtByParent = null; @@ -4013,10 +4021,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { allMtByParent = findChildForMaterialTypeByParent(mt); map.put("list", allMtByParent); } - Integer sumCount = 0; + double sumCount = 0; if (type == 1) { // 如果入库 - sumCount = depositoryRecordMapper.findApplicationInByMonthTest(map); + sumCount = (double)depositoryRecordMapper.findApplicationInByMonthTest(map) / 100; } else { // 如果出库 sumCount = depositoryRecordMapper.findApplicationOutByMonth(map); @@ -4042,7 +4050,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { */ @Override public ApplicationInRecordP findApplicationInRecordPById(Integer id) { - return depositoryRecordMapper.findApplicationInRecordPById(id); + ApplicationInRecord applicationInRecordPById = depositoryRecordMapper.findApplicationInRecordPById(id); + return new ApplicationInRecordP(applicationInRecordPById); } /** @@ -4053,7 +4062,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { */ @Override public Integer deleteApplicationInRecordById(Integer id, UserByPort userToken, String userAgent) { - ApplicationInRecordP record = depositoryRecordMapper.findApplicationInRecordPById(id); + ApplicationInRecord record = depositoryRecordMapper.findApplicationInRecordPById(id); new Thread(new Runnable() { @Override public void run() { @@ -4074,11 +4083,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { */ @Override public Integer deleteApplicationInRecordByIds(List list, UserByPort userToken, String userAgent) { - List applicationInRecordsByIds = depositoryRecordMapper.findApplicationInRecordsByIds(list); + List applicationInRecordsByIds = depositoryRecordMapper.findApplicationInRecordsByIds(list); new Thread(new Runnable() { @Override public void run() { - for (ApplicationInRecordP record : applicationInRecordsByIds + for (ApplicationInRecord record : applicationInRecordsByIds ) { if (Integer.compare(record.getAirapproverPass(), 4) == 0 || Integer.compare(record.getAirapproverPass(), 1) == 0) { updateInventoryForErrorInRecord(record.getMid(), record.getQuantity(), record.getAirUnit(), record.getPlaceId(), record.getDepositoryId()); @@ -4126,15 +4135,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 修改当前库存记录 placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - quantity, 0)); place.setQuantity(Math.max(place.getQuantity() - quantity, 0)); - inventory.setQuantity(Math.max(inventory.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); @@ -4156,7 +4164,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (splitInventory.getSaveQuantity() >= quantity) { // 如果当前待处理数目可以满足需求 - splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity,0)); + splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity, 0)); // 修改库存处理记录 splitUnitMapper.updateSplitInventory(splitInventory); @@ -4213,7 +4221,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { if (inventory.getQuantity() >= 1 && flag) { // 令库存-1 - inventory.setQuantity(Math.max(inventory.getQuantity() - 1,0)); + inventory.setQuantity(Math.max(inventory.getQuantity() - 1, 0)); // 修改库存记录 @@ -4221,12 +4229,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { // 修改当前库位存放物料的数量 - placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - 1,0)); + placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - 1, 0)); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); // 修改库位数量 Place placeById = placeMapper.findPlaceById(placeId); - placeById.setQuantity(Math.max(placeById.getQuantity() - 1,0)); + placeById.setQuantity(Math.max(placeById.getQuantity() - 1, 0)); placeMapper.UpdatePlace(placeById); @@ -4237,8 +4245,7 @@ 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/DepositoryServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java index 87ef5a6b..2806de6b 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java @@ -734,7 +734,12 @@ public class DepositoryServiceImpl implements DepositoryService { */ @Override public List getToDayInventoryByDNameTest() { - return depositoryMapper.getToDayInventoryByDNameTest(); + List toDayInventoryByDNameTest = depositoryMapper.getToDayInventoryByDNameTest(); + for (InventoryByDname inventoryByDName:toDayInventoryByDNameTest + ) { + inventoryByDName.setInventory(inventoryByDName.getInventory() / 100); + } + return toDayInventoryByDNameTest; } private boolean hasDepository(List list, Depository o) { diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java index 3df3fb0c..d8f499d5 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java @@ -1095,19 +1095,19 @@ public class GroupServiceImpl implements GroupService { Object id = map.get("id"); // 主订单编号 // 获取当前主订单 - ApplicationInRecordP mainRecordP = depositoryRecordMapper.findApplicationInRecordPById(ObjectFormatUtil.toInteger(id)); + ApplicationInRecord mainRecordP = depositoryRecordMapper.findApplicationInRecordPById(ObjectFormatUtil.toInteger(id)); // 获取当前审批结果 Integer approverPass = ObjectFormatUtil.toInteger(map.get("approverPass")); map.put("approverId", userToken.getId()); map.put("approverTime", System.currentTimeMillis()); // 根据当前主订单获取产生的对应子订单 - List minInRecordList = depositoryRecordMapper.findApplicationInRecordPByToGroupId(mainRecordP.getId()); + List minInRecordList = depositoryRecordMapper.findApplicationInRecordPByToGroupId(mainRecordP.getId()); // 用于存储最终要删除的id列表 List deleteIds = new ArrayList<>(); if (Integer.compare(approverPass, 1) == 0) { - for (ApplicationInRecordP minRecordP : + for (ApplicationInRecord minRecordP : minInRecordList) { map.put("id", minRecordP.getId()); depositoryRecordService.reviewIn(map, userId, userToken, userAgent); @@ -1117,7 +1117,7 @@ public class GroupServiceImpl implements GroupService { } else { // 如果是要驳回 map.put("state", "驳回"); - for (ApplicationInRecordP minRecordP : + for (ApplicationInRecord minRecordP : minInRecordList) { deleteIds.add(minRecordP.getId()); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java index 9499e2f2..47908caf 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java @@ -1782,7 +1782,7 @@ public class QyWxOperationService { public JSONObject sendApprovalTemplateIn(String userAgent, UserByPort userToken, List recordIdList, String QyWxUid) { // 获取当前出库明细 - List minRecordList = depositoryRecordMapper.findApplicationInRecordsByIds(recordIdList); + List minRecordList = depositoryRecordMapper.findApplicationInRecordsByIds(recordIdList); if (minRecordList.size() <= 0) { throw new MyException("参数错误"); @@ -1895,7 +1895,7 @@ public class QyWxOperationService { approval_template_apply_data_contents_info.setId("Table-1668220735636"); // 定义明细列表 List contents_detail = new ArrayList<>(); - for (ApplicationInRecordP recordMin : minRecordList) { + for (ApplicationInRecord recordMin : minRecordList) { // 获取明细信息 // 获取当前出库物料 Material materialById = materialMapper.findMaterialById(recordMin.getMid()); @@ -1952,7 +1952,7 @@ public class QyWxOperationService { detail_list_control_info_inNumber.put("title", detail_list_control_info_title_list_inNumber); Map detail_list_control_info_value_inNumber = new HashMap<>(); - detail_list_control_info_value_inNumber.put("new_number", String.valueOf(recordMin.getQuantity())); + detail_list_control_info_value_inNumber.put("new_number", String.valueOf((double)recordMin.getQuantity() / 100)); detail_list_control_info_inNumber.put("value", detail_list_control_info_value_inNumber); diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java index f3eff85e..031451f7 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java @@ -89,19 +89,18 @@ public class SplitUnitServiceImpl implements SplitUnitService { SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); - // 获取当前仓库是否有用户进行管理入库审批 Map paramForMtRole = new HashMap<>(); Material materialById = materialMapper.findMaterialById(ObjectFormatUtil.toInteger(map.get("mid"))); - paramForMtRole.put("mtid",materialById.getMaterialTypeId()); - map.put("mtId",materialById.getMaterialTypeId()); + paramForMtRole.put("mtid", materialById.getMaterialTypeId()); + map.put("mtId", materialById.getMaterialTypeId()); List roleAndMaterials = roleMapper.findRoleAndMaterialTypeByCondition(paramForMtRole); // 用于标志该仓库是否需要进行审批 boolean flagForApproval = false; // 默认不需要 if (roleAndMaterials.size() > 0) { flagForApproval = true; } - map.put("flagForApproval",flagForApproval); + map.put("flagForApproval", flagForApproval); // 用于存储最终计算结果 Integer result = 0; @@ -168,13 +167,13 @@ public class SplitUnitServiceImpl implements SplitUnitService { Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); if ("in".equals(type) && !flagForApproval) { // 如果是入库并且不需要审批 - result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid,false); + result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid, false); map.remove("applicationInId"); - }else if("in".equals(type)){ + } else if ("in".equals(type)) { // 如果是入库且需要审批 result = depositoryRecordService.applicationIn(map); - map.put("applicationInId",map.get("id")); + map.put("applicationInId", map.get("id")); map.remove("id"); } @@ -188,15 +187,16 @@ public class SplitUnitServiceImpl implements SplitUnitService { /** * 用于审批通过或无需审批时修改库存 - * @param quantity 库存数量 - * @param splitInventory 拆单库存记录 - * @param map 调剂 - * @param splitInfoForUnit 拆单记录 + * + * @param quantity 库存数量 + * @param splitInventory 拆单库存记录 + * @param map 调剂 + * @param splitInfoForUnit 拆单记录 * @param placeAndMaterialByMidAndPid 物料库位对应关系 - * @param flagForApprovalPass 用于标志是否为审批后调用该方法 + * @param flagForApprovalPass 用于标志是否为审批后调用该方法 * @return */ - public Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid,boolean flagForApprovalPass) { + public Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid, boolean flagForApprovalPass) { Integer result = 0; // 获取当前进制 @@ -218,14 +218,14 @@ public class SplitUnitServiceImpl implements SplitUnitService { // 如果有过记录 // 最终存储数量 - int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity(); - if (realQuantity >= scale) { + int realQuantity = (int) saveQuantity * 100 + splitInventory.getSaveQuantity(); + if (realQuantity >= scale * 100) { // 如果当前入库的数量大于拆单规定的进制数量 // 计算要进的数目 - int quantity_in = (realQuantity / scale); + int quantity_in = (realQuantity / (scale * 100)); // 更新处理数量 - disposeQuantity += quantity_in; + disposeQuantity = disposeQuantity * 100 + quantity_in; // 拆单库存实际入库的数量 realQuantity = realQuantity - quantity_in * scale; } @@ -234,16 +234,16 @@ public class SplitUnitServiceImpl implements SplitUnitService { // 设置当前计量单位的入库数目 if (splitInventory.getInQuantity() != null) { // 如果当前库存不为空 - splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity)); + splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity * 100)); } else { - splitInventory.setInQuantity((int) Math.round(quantity)); + splitInventory.setInQuantity((int) Math.round(quantity * 100)); } result += splitUnitMapper.updateSplitInventory(splitInventory); if (disposeQuantity != 0) { // 用于更改库存的数量 - map.put("quantity", String.valueOf(disposeQuantity)); + map.put("quantity", String.valueOf((double) disposeQuantity / 100)); } else { map.put("quantity", "0"); @@ -252,10 +252,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { map.put("realQuantity", quantity.toString()); if (splitInfoForUnit.getParentId() != null) { SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId()); - updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit); + updateSplitInfoSaveQuantity(parentSplitInfo, (double) disposeQuantity / 100, placeAndMaterialByMidAndPid.getId(), map, quantity.doubleValue(), splitInfoForUnit); } else { map.put("price", Double.toString(0)); - depositoryRecordService.applicationInPlace(map,flagForApprovalPass); + depositoryRecordService.applicationInPlace(map, flagForApprovalPass); } @@ -287,7 +287,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit); } else { map.put("price", Double.toString(0)); - result += depositoryRecordService.applicationInPlace(map,flagForApprovalPass); + result += depositoryRecordService.applicationInPlace(map, flagForApprovalPass); Map paramForInventoryToPlace = new HashMap<>(); paramForInventoryToPlace.put("mid", map.get("newInMid")); paramForInventoryToPlace.put("pid", map.get("placeId")); @@ -296,7 +296,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { } } else { map.put("price", Double.toString(0)); - result += depositoryRecordService.applicationInPlace(map,flagForApprovalPass); + result += depositoryRecordService.applicationInPlace(map, flagForApprovalPass); } } else { // 如果不大于设置的进制数量 @@ -320,12 +320,12 @@ public class SplitUnitServiceImpl implements SplitUnitService { // 先插入一条库存记录用于后续操作 map.put("quantity", "0"); - depositoryRecordService.applicationInPlace(map,flagForApprovalPass); + depositoryRecordService.applicationInPlace(map, flagForApprovalPass); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("applicationInId"))); } else { // 如果没有父级 - depositoryRecordService.applicationInPlace(map,flagForApprovalPass); + depositoryRecordService.applicationInPlace(map, flagForApprovalPass); } Map paramForInventoryToPlace = new HashMap<>(); paramForInventoryToPlace.put("mid", map.get("newInMid")); @@ -552,7 +552,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { * @param inQuantity 最终入库数量 * @param baseSplitInfo 基础拆单记录 */ - public void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map map, int inQuantity, SplitInfo baseSplitInfo) { + public void updateSplitInfoSaveQuantity(SplitInfo splitInfo, double quantity, int iid, Map map, double inQuantity, SplitInfo baseSplitInfo) { // 获取当前拆单记录的父级拆单记录 @@ -577,19 +577,19 @@ public class SplitUnitServiceImpl implements SplitUnitService { if (splitInventory != null) { // 如果拆单库存处理记录不为空 - if (splitInventory.getSaveQuantity() + saveQuantity >= splitInfo.getQuantity()) { + if ((double)(splitInventory.getSaveQuantity() / 100) + saveQuantity >= splitInfo.getQuantity()) { // 当前库存拆单记录与新入库的数目大于预设的进制 // 定义当前实际修改数量 - double new_saveQuantity = splitInventory.getSaveQuantity() + saveQuantity - splitInfo.getQuantity(); + double new_saveQuantity = (double)splitInventory.getSaveQuantity() / 100 + saveQuantity - splitInfo.getQuantity(); // 令计算处理数量+1 disposeQuantity += 1; // 定义保存数量 - splitInventory.setSaveQuantity((int) (splitInventory.getSaveQuantity() + new_saveQuantity)); + splitInventory.setSaveQuantity((int) (splitInventory.getSaveQuantity() + new_saveQuantity * 100)); // 定义添加数量 - splitInventory.setInQuantity((int) (splitInventory.getInQuantity() + new_saveQuantity)); + splitInventory.setInQuantity((int) (splitInventory.getInQuantity() + new_saveQuantity * 100)); // 修改库存拆单库存处理记录 splitUnitMapper.updateSplitInventory(splitInventory); @@ -606,41 +606,42 @@ public class SplitUnitServiceImpl implements SplitUnitService { map.put("price", Double.toString(0)); map.put("quantity", String.valueOf(disposeQuantity)); map.put("realQuantity", String.valueOf(inQuantity)); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除入库订单 // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); } } else { // 当前库存拆单记录与新入库的数目不大于预设的进制 - splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity); - splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity); + splitInventory.setSaveQuantity((int) (splitInventory.getSaveQuantity() + saveQuantity * 100)); + splitInventory.setInQuantity((int) (splitInventory.getInQuantity() + saveQuantity * 100)); splitUnitMapper.updateSplitInventory(splitInventory); map.put("price", "0"); map.put("quantity", "0"); map.put("realQuantity", String.valueOf(inQuantity)); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除入库订单 // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); } - } else { + } + else { // 如果为空 Map paramForInsertSplitInventory = new HashMap<>(); paramForInsertSplitInventory.put("sid", splitInfo.getId()); - paramForInsertSplitInventory.put("inQuantity", quantity); + paramForInsertSplitInventory.put("inQuantity", quantity * 100); paramForInsertSplitInventory.put("outQuantity", 0); paramForInsertSplitInventory.put("iid", iid); if (quantity > splitInfo.getQuantity()) { // 如果当前处理数量大于当前设置的进制数量 // 计算需要进位的数量 - int quantity_scale = quantity / splitInfo.getQuantity(); + double quantity_scale = quantity / splitInfo.getQuantity(); // 计算剩余处理的数量 - int quantity_residue = quantity - quantity_scale * splitInfo.getQuantity(); - paramForInsertSplitInventory.put("saveQuantity", quantity_residue); + double quantity_residue = quantity - quantity_scale * splitInfo.getQuantity(); + paramForInsertSplitInventory.put("saveQuantity", quantity_residue * 100); splitUnitMapper.addSplitInventory(paramForInsertSplitInventory); if (parentId != null) { @@ -654,18 +655,18 @@ public class SplitUnitServiceImpl implements SplitUnitService { map.put("price", Double.toString(0)); map.put("quantity", String.valueOf(quantity_scale)); map.put("realQuantity", String.valueOf(inQuantity)); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除入库订单 // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); } } else { // 如果不大于 - paramForInsertSplitInventory.put("saveQuantity", String.valueOf(quantity)); + paramForInsertSplitInventory.put("saveQuantity", String.valueOf(quantity * 100)); splitUnitMapper.addSplitInventory(paramForInsertSplitInventory); map.put("quantity", "0"); map.put("realQuantity", String.valueOf(inQuantity)); map.put("price", "0"); - depositoryRecordService.applicationInPlace(map,false); + depositoryRecordService.applicationInPlace(map, false); // 删除入库订单 // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); diff --git a/src/test/java/com/dreamchaser/depository_manage/TestForOther.java b/src/test/java/com/dreamchaser/depository_manage/TestForOther.java index 777b5bae..4c072716 100644 --- a/src/test/java/com/dreamchaser/depository_manage/TestForOther.java +++ b/src/test/java/com/dreamchaser/depository_manage/TestForOther.java @@ -16,6 +16,7 @@ import com.dreamchaser.depository_manage.service.DepositoryRecordService; import com.dreamchaser.depository_manage.service.DepositoryService; import com.dreamchaser.depository_manage.service.PlaceService; import com.dreamchaser.depository_manage.service.StockTakingService; +import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; import com.dreamchaser.depository_manage.utils.CreateQrCodeUtil; import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; import com.dreamchaser.depository_manage.utils.ZipMultiFileUtil; @@ -36,118 +37,19 @@ import java.util.concurrent.*; public class TestForOther { + @Autowired + DepositoryRecordService depositoryRecordService; @Test public void run() { - UserByPort userByPort = LinkInterfaceUtil.FindUserById(78, null); - List list = buildPostTree(userByPort); - System.out.println(JSONObject.toJSONString(list)); + ApprovalInfo_Details approvalInfo = new ApprovalInfo_Details(); + ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver(); + approver.setUserId("PangFuZhen"); + approvalInfo.setApprover(approver); + depositoryRecordService.reviewByQyWxApprovalIn("[1]",approvalInfo,"460f46eaefb46bb0c171029f62e2cea6","2","202303170008"); } - /** - * 用于构造当前用户可见的部门树 - * @param userByPort 当前用户 - * @return - */ - public List buildPostTree(UserByPort userByPort){ - JSONArray postTree = LinkInterfaceUtil.getPostTree(userByPort); - // 定义线程数量 - int threadSize = postTree.size(); - // 开启对应数量的线程 - ExecutorService exs = Executors.newFixedThreadPool(threadSize); - // 树结构结果集 - List list = new ArrayList<>(); - // 线程结果集 - List> futureList = new ArrayList>(); - // 1.定义CompletionService - CompletionService completionService = new ExecutorCompletionService(exs); - for (Object o : postTree) { - JSONObject data = (JSONObject) o; - // 创建一个线程 - Future submit = completionService.submit(new PostTreeThreads(data)); - futureList.add(submit); - } - for (int i = 0; i < threadSize; i++) { - Object result = null; - try { - result = completionService.take().get(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - list.add( result); - } - return list; - } - - class PostTreeThreads implements Callable{ - - private JSONObject jsonObject; - - public PostTreeThreads(JSONObject jsonObject) { - this.jsonObject = jsonObject; - } - - @Override - public Object call() throws Exception { - // 定义结果 - Map result = new HashMap<>(); - // 获取当前的子类 - if (jsonObject.containsKey("child") && jsonObject.get("child") != null) { - // 如果存在子类 - List list = buildChildNodes(jsonObject); - result = buildTree(jsonObject, list); - }else{ - // 如果不存在子类 - result = buildTree(jsonObject, null); - } - return result; - } - } - - - /** - * 用于构造子节点 - * @param jsonObject 待构造父节点 - * @return - */ - public List buildChildNodes (JSONObject jsonObject){ - List result = new ArrayList<>(); - // 获取当前节点的子节点 - JSONArray child = jsonObject.getJSONArray("child"); - for (Object o:child - ) { - JSONObject data = (JSONObject) o; - if(data.containsKey("child") && data.get("child") != null){ - // 如果该节点存在子节点 - List list = buildChildNodes(data); - result.add(buildTree(data,list)); - }else{ - // 如果不存在子节点 - result.add(buildTree(data,null)); - } - } - return result; - } - - - - /** - * 用于构造节点 - * @param jsonObject 待构造节点数据 - * @param children 当前节点子节点 - * @return - */ - public Map buildTree(JSONObject jsonObject,List children){ - Map node = new HashMap<>(); - node.put("id",jsonObject.getInteger("id")); - node.put("title",jsonObject.getString("name")); - node.put("children",children); - node.put("wechatorganizationid",jsonObject.getInteger("wechatorganizationid")); - return node; - } diff --git a/target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml b/target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml index 2dd16719..c7c09be5 100644 --- a/target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml +++ b/target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml @@ -53,7 +53,7 @@ - + @@ -62,7 +62,7 @@ - +