Browse Source

入库数量修改

lwx_dev
erdanergou 3 years ago
parent
commit
82d4f993fa
  1. 118
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java
  2. 127
      src/main/java/com/dreamchaser/depository_manage/entity/ApplicationInRecord.java
  3. 19
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java
  4. 4
      src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml
  5. 41
      src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java
  6. 2
      src/main/java/com/dreamchaser/depository_manage/pojo/InventoryByDname.java
  7. 4
      src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java
  8. 2
      src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java
  9. 255
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  10. 7
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java
  11. 8
      src/main/java/com/dreamchaser/depository_manage/service/impl/GroupServiceImpl.java
  12. 6
      src/main/java/com/dreamchaser/depository_manage/service/impl/QyWxOperationService.java
  13. 77
      src/main/java/com/dreamchaser/depository_manage/service/impl/SplitUnitServiceImpl.java
  14. 114
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java
  15. 4
      target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

118
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java

@ -157,7 +157,7 @@ public class DepositoryController {
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user); Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user);
Iterator it = depositoryAllNameAndId.keySet().iterator(); Iterator it = depositoryAllNameAndId.keySet().iterator();
//result用来接收每个仓库每天的库存 //result用来接收每个仓库每天的库存
List<Integer> result = new ArrayList<>(); ArrayList<Double> result = new ArrayList<>();
// map用来存储仓库与库存的映射 // map用来存储仓库与库存的映射
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 只获取当天 // 只获取当天
@ -167,9 +167,9 @@ public class DepositoryController {
int i; int i;
String key = it.next().toString(); String key = it.next().toString();
String dname = key.split(",")[0]; String dname = key.split(",")[0];
Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest);
result.add(inventoryByDname); result.add(inventoryByDname);
map.put(key, ((ArrayList<Integer>) result).clone()); map.put(key, result.clone());
result.clear(); result.clear();
} }
} else { } else {
@ -190,7 +190,7 @@ public class DepositoryController {
// 获取今天容量 // 获取今天容量
String dname = key.split(",")[0]; String dname = key.split(",")[0];
Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest);
result.add(inventoryByDname); result.add(inventoryByDname);
// 判断当天是否有出入口记录 // 判断当天是否有出入口记录
@ -211,7 +211,7 @@ public class DepositoryController {
break; break;
} }
// 当前日期额度 // 当前日期额度
Integer aDouble = result.get(j++); Double aDouble = result.get(j++);
// 获取当前仓库 // 获取当前仓库
Integer val = (Integer) depositoryAllNameAndId.get(key); 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 depositoryRecordByDateByIn1 = depositoryRecordService.findApplicationInRecordByDate(days.get(i), days.get(i + 1), val);
// 获取一段时间内的出库额度 // 获取一段时间内的出库额度
Integer depositoryRecordByDateByOut1 = depositoryRecordService.findApplicationOutRecordByDate(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); result.add(warehouserCount1);
} }
Collections.reverse(result); Collections.reverse(result);
map.put(key.toString(), ((ArrayList<Integer>) result).clone()); map.put(key.toString(), result.clone());
result.clear(); result.clear();
} }
} }
@ -254,12 +254,12 @@ public class DepositoryController {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
instance.add(Calendar.MONTH, 1); instance.add(Calendar.MONTH, 1);
instance.set(Calendar.DATE, 1); instance.set(Calendar.DATE, 1);
List<Integer> result = new ArrayList<>(); List<Double> result = new ArrayList<>();
String month = formatter.format(instance.getTime()); String month = formatter.format(instance.getTime());
List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest();
for (int i = 0; i < depositoryAll.size(); i++) { for (int i = 0; i < depositoryAll.size(); i++) {
String dname = depositoryAll.get(i).getDname(); String dname = depositoryAll.get(i).getDname();
Integer todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest); Double todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest);
result.add(todayDepositoryInventory); result.add(todayDepositoryInventory);
todayInventory.put(dname, todayDepositoryInventory); todayInventory.put(dname, todayDepositoryInventory);
((Map<String, Object>) sourceList.get(0)).put(dname, result.get(i)); ((Map<String, Object>) sourceList.get(0)).put(dname, result.get(i));
@ -284,13 +284,13 @@ public class DepositoryController {
parmOut.put("end", months.get(num)); 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); result.add(wareHouseCount1);
((Map<String, Object>) sourceList.get(num)).put(depositoryAll.get(j).getDname(), wareHouseCount1); ((Map<String, Object>) sourceList.get(num)).put(depositoryAll.get(j).getDname(), wareHouseCount1);
} }
@ -300,7 +300,7 @@ public class DepositoryController {
} }
for (int i = 0; i < depositoryAll.size(); i++) { for (int i = 0; i < depositoryAll.size(); i++) {
String dname = depositoryAll.get(i).getDname(); String dname = depositoryAll.get(i).getDname();
Integer todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest); Double todayDepositoryInventory = getInventoryByDname(dname, toDayInventoryByDNameTest);
((Map<String, Object>) sourceList.get(0)).put(dname, todayDepositoryInventory); ((Map<String, Object>) sourceList.get(0)).put(dname, todayDepositoryInventory);
} }
List<String> barSource = new ArrayList<>(); List<String> barSource = new ArrayList<>();
@ -320,13 +320,13 @@ public class DepositoryController {
* @param list * @param list
* @return * @return
*/ */
public Integer getInventoryByDname(String dname, List<InventoryByDname> list) { public Double getInventoryByDname(String dname, List<InventoryByDname> list) {
for (InventoryByDname inventoryByDname : list) { for (InventoryByDname inventoryByDname : list) {
if (dname.equals(inventoryByDname.getDname())) { if (dname.equals(inventoryByDname.getDname())) {
return inventoryByDname.getInventory(); return inventoryByDname.getInventory();
} }
} }
return 0; return 0.0;
} }
/** /**
@ -353,11 +353,11 @@ public class DepositoryController {
} }
mapDataList.add(title); mapDataList.add(title);
List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest();
for (int i = 0; i < depositoryAll.size(); i++) { for (Depository depository : depositoryAll) {
List<Object> productData = new ArrayList<>(); List<Object> productData = new ArrayList<>();
String dname = depositoryAll.get(i).getDname(); String dname = depository.getDname();
productData.add(dname); productData.add(dname);
Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest);
productData.add(inventoryByDname); productData.add(inventoryByDname);
int k = 1; int k = 1;
for (int j = 0; j < months.size() - 1; j++) { for (int j = 0; j < months.size() - 1; j++) {
@ -365,21 +365,21 @@ public class DepositoryController {
Map<String, Object> parmOut = new HashMap<>(); Map<String, Object> parmOut = new HashMap<>();
parmIn.put("type", 1); parmIn.put("type", 1);
parmIn.put("state", "已入库"); 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("start", months.get(j + 1));
parmIn.put("end", months.get(j)); parmIn.put("end", months.get(j));
parmOut.put("type", 2); parmOut.put("type", 2);
parmOut.put("state", "已出库"); 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("start", months.get(j + 1));
parmOut.put("end", months.get(j)); parmOut.put("end", months.get(j));
// 获取某个月某物料入库总额 // 获取某个月某物料入库总额
// 测试 // 测试
Integer wareHouseInCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmIn); Double wareHouseInCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmIn);
// 获取某个月某物料出库总额 // 获取某个月某物料出库总额
// 测试 // 测试
Integer wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); Double wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut);
Integer wareHouseCount1 = (int) productData.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; Double wareHouseCount1 = (double)productData.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1;
productData.add(wareHouseCount1); productData.add(wareHouseCount1);
} }
List<Object> result = new ArrayList<>(); List<Object> result = new ArrayList<>();
@ -668,7 +668,7 @@ public class DepositoryController {
parm.put("oldId", materialTypeAll.get(j).getOldId()); parm.put("oldId", materialTypeAll.get(j).getOldId());
//根据条件获取月份中物料的总额 //根据条件获取月份中物料的总额
// 测试 // 测试
Integer materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm); Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm);
((Map<String, Object>) sourceList.get(num)).put(materialTypeAll.get(j).getTname(), materialCountByMonth1); ((Map<String, Object>) sourceList.get(num)).put(materialTypeAll.get(j).getTname(), materialCountByMonth1);
} }
} }
@ -711,14 +711,14 @@ public class DepositoryController {
List<String> depositoryName = new ArrayList<>(); List<String> depositoryName = new ArrayList<>();
// 各仓库对应入库数目 // 各仓库对应入库数目
Map<String, Integer> yesterdayData = new HashMap<>(); Map<String, Double> yesterdayData = new HashMap<>();
// 获取昨天数据标志位 // 获取昨天数据标志位
boolean flag = true; boolean flag = true;
// 每天各仓库入库数目 // 每天各仓库入库数目
Map<String, Object> show_data = new HashMap<>(); Map<String, Object> show_data = new HashMap<>();
List<Long> days = getLastTimeInterval(); List<Long> days = getLastTimeInterval();
List<Integer> drCountbyDrName = new ArrayList<>(); ArrayList<Double> drCountbyDrName = new ArrayList<>();
while (it.hasNext()) { while (it.hasNext()) {
@ -732,14 +732,14 @@ public class DepositoryController {
Integer val = (Integer) depositoryAllNameAndId.get(key); 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); drCountbyDrName.add(depositoryRecordByDateAndType1);
if (i == 2 && flag) { if (i == 2 && flag) {
yesterdayData.put(key.toString(), depositoryRecordByDateAndType1); yesterdayData.put(key.toString(), depositoryRecordByDateAndType1);
} }
} }
Collections.reverse(drCountbyDrName); Collections.reverse(drCountbyDrName);
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); show_data.put(key.toString(), drCountbyDrName.clone());
drCountbyDrName.clear(); drCountbyDrName.clear();
} }
Map<String, Object> depository_data = new HashMap<>(); Map<String, Object> depository_data = new HashMap<>();
@ -788,7 +788,7 @@ public class DepositoryController {
// 仓库名称列表 // 仓库名称列表
List<String> depositoryName = new ArrayList<>(); List<String> depositoryName = new ArrayList<>();
// 各仓库对应入库数目 // 各仓库对应入库数目
Map<String, Integer> yesterdayData = new HashMap<>(); Map<String, Double> yesterdayData = new HashMap<>();
// 每天各仓库入库数目 // 每天各仓库入库数目
Map<String, Object> show_data = new HashMap<>(); Map<String, Object> show_data = new HashMap<>();
// 各仓库当前库存数目 // 各仓库当前库存数目
@ -815,13 +815,13 @@ public class DepositoryController {
depositoryName.add(key.toString()); depositoryName.add(key.toString());
Integer val = (Integer) depositoryAllNameAndId.get(key); 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()); Integer toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString());
todayInventory.put(key.toString(), toDayInventoryByDName); todayInventory.put(key.toString(), toDayInventoryByDName);
yesterdayData.put(key.toString(), depositoryRecordByDate1); yesterdayData.put(key.toString(), depositoryRecordByDate1);
List<Integer> drCountbyDrName = new ArrayList<>(); ArrayList<Double> drCountbyDrName = new ArrayList<>();
drCountbyDrName.add(depositoryRecordByDate1); drCountbyDrName.add(depositoryRecordByDate1);
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); show_data.put(key.toString(), drCountbyDrName.clone());
} }
} else { } else {
int now = instance.get(Calendar.DAY_OF_WEEK) - 1 == 0 ? 7 : instance.get(Calendar.DAY_OF_WEEK) - 1; 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())); Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime()));
days.add(format); days.add(format);
} }
List<Integer> drCountbyDrName = new ArrayList<>(); ArrayList<Double> drCountbyDrName = new ArrayList<>();
while (it.hasNext()) { while (it.hasNext()) {
int i; int i;
Object key = it.next(); Object key = it.next();
@ -850,13 +850,13 @@ public class DepositoryController {
Integer val = (Integer) depositoryAllNameAndId.get(key); 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); drCountbyDrName.add(depositoryRecordByDate1);
if (i == 2 && flag) { if (i == 2 && flag) {
yesterdayData.put(key.toString(), depositoryRecordByDate1); yesterdayData.put(key.toString(), depositoryRecordByDate1);
} }
} }
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); show_data.put(key.toString(), drCountbyDrName.clone());
drCountbyDrName.clear(); drCountbyDrName.clear();
} }
} }
@ -912,7 +912,7 @@ public class DepositoryController {
// 仓库名称列表 // 仓库名称列表
List<String> depositoryName = new ArrayList<>(); List<String> depositoryName = new ArrayList<>();
// 各仓库对应入库数目 // 各仓库对应入库数目
Map<String, Integer> yesterdayData = new HashMap<>(); Map<String, Double> yesterdayData = new HashMap<>();
// 每天各仓库入库数目 // 每天各仓库入库数目
Map<String, Object> show_data = new HashMap<>(); Map<String, Object> show_data = new HashMap<>();
// 各仓库当前库存数目 // 各仓库当前库存数目
@ -945,23 +945,23 @@ public class DepositoryController {
// 获取仓库对应的id // 获取仓库对应的id
Integer val = (Integer) depositoryAllNameAndId.get(key); 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); 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); yesterdayData.put(key.toString(), yesterdayInData);
List<Integer> drCountbyDrName = new ArrayList<>(); ArrayList<Double> drCountbyDrName = new ArrayList<>();
drCountbyDrName.add(depositoryRecordByDate1); drCountbyDrName.add(depositoryRecordByDate1);
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); show_data.put(key.toString(), drCountbyDrName.clone());
} }
} else { } else {
Future<Object> future = completionService.submit(new distributeTasks(type, 1, userByPort, yesterdayData, depositoryName)); Future<Object> future = completionService.submit(new distributeTasks(depositoryAllNameAndId,type, 1, userByPort, yesterdayData, depositoryName));
futureList.add(future); futureList.add(future);
taskNum += 1; taskNum += 1;
} }
// 获取本月及之前月份各种类别入/出库总量 // 获取本月及之前月份各种类别入/出库总量
Future<Object> future = completionService.submit(new distributeTasks(type, 3, userByPort, yesterdayData, depositoryName)); Future<Object> future = completionService.submit(new distributeTasks(depositoryAllNameAndId,type, 3, userByPort, yesterdayData, depositoryName));
futureList.add(future); futureList.add(future);
taskNum += 1; taskNum += 1;
// 中国地图数据 // 中国地图数据
@ -971,7 +971,7 @@ public class DepositoryController {
Map<String, Object> mapData = new HashMap<>(); Map<String, Object> mapData = new HashMap<>();
if (!"0".equals(type)) { if (!"0".equals(type)) {
Future<Object> future1 = completionService.submit(new distributeTasks(type, 4, userByPort, yesterdayData, depositoryName)); Future<Object> future1 = completionService.submit(new distributeTasks(depositoryAllNameAndId,type, 4, userByPort, yesterdayData, depositoryName));
futureList.add(future1); futureList.add(future1);
taskNum += 1; taskNum += 1;
} }
@ -1004,14 +1004,14 @@ public class DepositoryController {
if ("0".equals(type)) { 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.setTodayInventory(todayInventory);
distributeTasks1.setDepositoryService(depositoryService); distributeTasks1.setDepositoryService(depositoryService);
distributeTasks1.setDepositoryRecordService(depositoryRecordService); 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.setDepositoryService(depositoryService);
distributeTasks2.setDepositoryRecordService(depositoryRecordService); 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.setDepositoryService(depositoryService);
distributeTasks3.setDepositoryRecordService(depositoryRecordService); distributeTasks3.setDepositoryRecordService(depositoryRecordService);
Future<Object> future1 = completionService.submit(distributeTasks1); Future<Object> future1 = completionService.submit(distributeTasks1);
@ -1062,13 +1062,10 @@ public class DepositoryController {
return resMap; return resMap;
} }
public Map<String, Object> getShowData(String type, UserByPort userByPort, Map<String, Integer> yesterdayData, List<String> depositoryName) { public Map<String, Object> getShowData(Map<String, Integer> depositoryAllNameAndId,String type, UserByPort userByPort, Map<String, Double> yesterdayData, List<String> depositoryName) {
// 获取各仓库名称以及id
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort);
// 获取遍历器 // 获取遍历器
Iterator it = depositoryAllNameAndId.keySet().iterator(); Iterator it = depositoryAllNameAndId.keySet().iterator();
// 仓库名称列表 // 仓库名称列表
//获取获取系统的当前日历对象 //获取获取系统的当前日历对象
Calendar instance = Calendar.getInstance(); Calendar instance = Calendar.getInstance();
// 获取日期 // 获取日期
@ -1174,8 +1171,7 @@ public class DepositoryController {
// 1.定义CompletionService // 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
for (int i = 0; i < materialTypeAll.size(); i++) { for (MaterialType mt : materialTypeAll) {
MaterialType mt = materialTypeAll.get(i);
Future<Object> future = completionService.submit(new findMapData(previousMonth1, type, mt)); Future<Object> future = completionService.submit(new findMapData(previousMonth1, type, mt));
futureList.add(future); futureList.add(future);
} }
@ -1564,13 +1560,15 @@ public class DepositoryController {
String type; //请求类型 String type; //请求类型
int taskType; // 任务类型 int taskType; // 任务类型
UserByPort userByPort; // 登录用户 UserByPort userByPort; // 登录用户
Map<String, Integer> yesterdayData; // 昨天的数据 Map<String, Double> yesterdayData; // 昨天的数据
List<String> depositoryName; // 仓库名称 List<String> depositoryName; // 仓库名称
DepositoryService depositoryService; // 操作depository的service DepositoryService depositoryService; // 操作depository的service
DepositoryRecordService depositoryRecordService; // 操作订单的service DepositoryRecordService depositoryRecordService; // 操作订单的service
Map<String, Object> todayInventory; // 当前仓库的额度 Map<String, Object> todayInventory; // 当前仓库的额度
Map<String, Integer> depositoryAllNameAndId; // 仓库名称与仓库id的映射
distributeTasks(String type, int taskType, UserByPort userByPort, Map<String, Integer> yesterdayData, List<String> depositoryName) { distributeTasks(Map<String, Integer> depositoryAllNameAndId,String type, int taskType, UserByPort userByPort, Map<String, Double> yesterdayData, List<String> depositoryName) {
this.depositoryAllNameAndId = depositoryAllNameAndId;// 仓库名称与仓库id映射
this.taskType = taskType; // 任务类型 this.taskType = taskType; // 任务类型
this.type = type; // 请求类型 this.type = type; // 请求类型
this.userByPort = userByPort; // 登录用户 this.userByPort = userByPort; // 登录用户
@ -1585,7 +1583,7 @@ public class DepositoryController {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (1 == taskType) { if (1 == taskType) {
Map<String, Object> showData = getShowData(type, userByPort, yesterdayData, depositoryName); Map<String, Object> showData = getShowData(depositoryAllNameAndId,type, userByPort, yesterdayData, depositoryName);
result.put("show_data", showData); result.put("show_data", showData);
} else if (2 == taskType) { } else if (2 == taskType) {
@ -1615,7 +1613,7 @@ public class DepositoryController {
List<Long> days; List<Long> days;
Map<String, Integer> depositoryAllNameAndId; Map<String, Integer> depositoryAllNameAndId;
List<String> depositoryName; List<String> depositoryName;
Map<String, Integer> yesterdayData; Map<String, Double> yesterdayData;
String type; String type;
Map<String, Object> show_data; Map<String, Object> show_data;
@ -1629,7 +1627,7 @@ public class DepositoryController {
@Override @Override
public Object call() throws Exception { public Object call() throws Exception {
int i; int i;
List<Integer> drCountbyDrName = new ArrayList<>(); List<Double> drCountbyDrName = new ArrayList<>();
for (i = days.size() - 1; i > 0; i--) { for (i = days.size() - 1; i > 0; i--) {
// 遍历 Map并计算各仓库的入库数 // 遍历 Map并计算各仓库的入库数
if (i == days.size() - 1) { if (i == days.size() - 1) {
@ -1637,7 +1635,7 @@ public class DepositoryController {
} }
Integer val = (Integer) depositoryAllNameAndId.get(key); 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); drCountbyDrName.add(depositoryRecordByDate1);
if (i == 2) { if (i == 2) {
yesterdayData.put(key.toString(), depositoryRecordByDate1); yesterdayData.put(key.toString(), depositoryRecordByDate1);
@ -1716,7 +1714,7 @@ public class DepositoryController {
@Override @Override
public Object call() throws Exception { public Object call() throws Exception {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
Integer materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(map); Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(map);
Long oldId = Long.valueOf(map.get("oldId").toString()); Long oldId = Long.valueOf(map.get("oldId").toString());
MaterialType materialTypeByOldId = materialTypeService.findMaterialTypeByOldId(oldId); MaterialType materialTypeByOldId = materialTypeService.findMaterialTypeByOldId(oldId);
result.put(materialTypeByOldId.getTname(), materialCountByMonth1); result.put(materialTypeByOldId.getTname(), materialCountByMonth1);
@ -1753,7 +1751,7 @@ public class DepositoryController {
parm.put("oldId", mt.getOldId()); parm.put("oldId", mt.getOldId());
//根据条件获取月份中物料的总额 //根据条件获取月份中物料的总额
// 测试 // 测试
Integer materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm); Double materialCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parm);
productData.add(materialCountByMonth1); productData.add(materialCountByMonth1);
} }
return productData; return productData;

127
src/main/java/com/dreamchaser/depository_manage/entity/ApplicationInRecord.java

@ -8,39 +8,146 @@ public class ApplicationInRecord {
/** /**
* id * 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 String code;
/** /**
* 仓库编号 * 仓库名称
*/ */
private Integer depository_id; private String depositoryName;
/**
* 仓库id
*/
private Integer depositoryId;
/**
* 提交备注
*/
private String applyRemark;
/** /**
* 入库编码 * 入库编码
*/ */
private String aircode; 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;
} }

19
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.java

@ -1,7 +1,6 @@
package com.dreamchaser.depository_manage.mapper; package com.dreamchaser.depository_manage.mapper;
import com.dreamchaser.depository_manage.entity.*; 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.ApplicationOutRecordMinP;
import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP; import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -73,26 +72,26 @@ public interface DepositoryRecordMapper {
* 查找所有入库记录 * 查找所有入库记录
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordPAll(); List<ApplicationInRecord> findApplicationInRecordPAll();
/** /**
* 根据主键id列表获取入库订单列表 * 根据主键id列表获取入库订单列表
* @param ids * @param ids
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordsByIds(List<Integer> ids); List<ApplicationInRecord> findApplicationInRecordsByIds(List<Integer> ids);
/** /**
* 查找所有入库记录 * 查找所有入库记录
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordPByDepositoryList(List<Integer> list); List<ApplicationInRecord> findApplicationInRecordPByDepositoryList(List<Integer> list);
/** /**
* 查询一段时间内的入库记录 * 查询一段时间内的入库记录
* @param map 条件起止时间 * @param map 条件起止时间
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordPForAPeriodOfTime(Map<String,Object> map); List<ApplicationInRecord> findApplicationInRecordPForAPeriodOfTime(Map<String,Object> map);
/** /**
* 查找所有出库记录 * 查找所有出库记录
@ -244,14 +243,14 @@ public interface DepositoryRecordMapper {
* @param map * @param map
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordPByCondition(Map<String,Object> map); List<ApplicationInRecord> findApplicationInRecordPByCondition(Map<String,Object> map);
/** /**
* 查询当前用户入库记录及其管理仓库的入库记录 * 查询当前用户入库记录及其管理仓库的入库记录
* @param map 查询条件 * @param map 查询条件
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordPByUser(Map<String,Object> map); List<ApplicationInRecord> findApplicationInRecordPByUser(Map<String,Object> map);
/** /**
* 查询当前用户入库记录及其管理仓库的入库记录数目 * 查询当前用户入库记录及其管理仓库的入库记录数目
@ -265,7 +264,7 @@ public interface DepositoryRecordMapper {
* @param depositoryId 待查询仓库id * @param depositoryId 待查询仓库id
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordByDepository(String depositoryId); List<ApplicationInRecord> findApplicationInRecordByDepository(String depositoryId);
/** /**
* 查询当前仓库的出库记录 * 查询当前仓库的出库记录
@ -317,7 +316,7 @@ public interface DepositoryRecordMapper {
* @param id * @param id
* @return * @return
*/ */
ApplicationInRecordP findApplicationInRecordPById(Integer id); ApplicationInRecord findApplicationInRecordPById(Integer id);
/** /**
@ -325,7 +324,7 @@ public interface DepositoryRecordMapper {
* @param id * @param id
* @return * @return
*/ */
List<ApplicationInRecordP> findApplicationInRecordPByToGroupId(Integer id); List<ApplicationInRecord> findApplicationInRecordPByToGroupId(Integer id);

4
src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -53,7 +53,7 @@
</resultMap> </resultMap>
<!-- 插入入库记录--> <!-- 插入入库记录-->
<resultMap id="applicationInRecord" type="com.dreamchaser.depository_manage.pojo.ApplicationInRecordP"> <resultMap id="applicationInRecord" type="com.dreamchaser.depository_manage.entity.ApplicationInRecord">
<id column="airid" property="id" jdbcType="INTEGER"/> <id column="airid" property="id" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/> <result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="INTEGER"/> <result column="quantity" property="quantity" jdbcType="INTEGER"/>
@ -62,7 +62,7 @@
<result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/> <result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/>
<result column="price" property="price" jdbcType="VARCHAR"/> <result column="price" property="price" jdbcType="VARCHAR"/>
<result column="tname" property="materialTypeName" jdbcType="VARCHAR"/> <result column="tname" property="materialTypeName" jdbcType="VARCHAR"/>
<result column="applicantTime" property="applicant_time" jdbcType="INTEGER"/> <result column="applicant_time" property="applicantTime" jdbcType="INTEGER"/>
<result column="airPlaceId" property="placeId" jdbcType="INTEGER"/> <result column="airPlaceId" property="placeId" jdbcType="INTEGER"/>
<result column="code" property="aircode" jdbcType="VARCHAR"/> <result column="code" property="aircode" jdbcType="VARCHAR"/>
<result column="dname" property="depositoryName" jdbcType="VARCHAR"/> <result column="dname" property="depositoryName" jdbcType="VARCHAR"/>

41
src/main/java/com/dreamchaser/depository_manage/pojo/ApplicationInRecordP.java

@ -1,5 +1,6 @@
package com.dreamchaser.depository_manage.pojo; package com.dreamchaser.depository_manage.pojo;
import com.dreamchaser.depository_manage.entity.ApplicationInRecord;
import lombok.Data; import lombok.Data;
@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; 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() {
}
} }

2
src/main/java/com/dreamchaser/depository_manage/pojo/InventoryByDname.java

@ -7,6 +7,6 @@ import lombok.Data;
*/ */
@Data @Data
public class InventoryByDname { public class InventoryByDname {
Integer inventory; Double inventory;
String dname; String dname;
} }

4
src/main/java/com/dreamchaser/depository_manage/service/DepositoryRecordService.java

@ -310,7 +310,7 @@ public interface DepositoryRecordService {
* @param depositoryId * @param depositoryId
* @return * @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 条件 * @param map 条件
* @return * @return
*/ */
Integer findMaterialCountByMonth2(Map<String, Object> map); Double findMaterialCountByMonth2(Map<String, Object> map);
/** /**
* 查询仓库当天流水 * 查询仓库当天流水

2
src/main/java/com/dreamchaser/depository_manage/service/SplitUnitService.java

@ -157,7 +157,7 @@ public interface SplitUnitService {
* @param map 入库条件 * @param map 入库条件
* @param inQuantity 最终入库数量 * @param inQuantity 最终入库数量
*/ */
void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity, SplitInfo baseSplitInfo); void updateSplitInfoSaveQuantity(SplitInfo splitInfo, double quantity, int iid, Map<String, Object> map, double inQuantity, SplitInfo baseSplitInfo);
/** /**
* 根据父级查询拆单记录 * 根据父级查询拆单记录

255
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -122,7 +122,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 根据物料id查询物料 // 根据物料id查询物料
Material material = materialMapper.findMaterialById(mid); Material material = materialMapper.findMaterialById(mid);
// 判断剩余容量是否可以存入 // 判断剩余容量是否可以存入
if (depositoryRecordById.getMaxNumber() - Inventory < quantity) { if (depositoryRecordById.getMaxNumber() - (double) (Inventory / 100) < quantity) {
return 0; return 0;
} }
// 获取当前填写的生产日期 // 获取当前填写的生产日期
@ -182,6 +182,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 如果不包含标志位. // 如果不包含标志位.
map.put("flagForGroup", 1); map.put("flagForGroup", 1);
} }
// 修改入库数量扩大100倍
map.put("quantity", ObjectFormatUtil.toDouble(map.get("quantity")) * 100);
return depositoryRecordMapper.insertApplicationInRecord(map); return depositoryRecordMapper.insertApplicationInRecord(map);
} }
@ -203,7 +205,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (materialByCondition.size() > 0) { // 如果当前存在 if (materialByCondition.size() > 0) { // 如果当前存在
Inventory mt = materialByCondition.get(0); Inventory mt = materialByCondition.get(0);
map.put("mid", mt.getMid()); map.put("mid", mt.getMid());
mt.setQuantity((int) (mt.getQuantity() + quantity)); mt.setQuantity((int) (mt.getQuantity() + quantity * 100));
mt.setProducedDate(producedDate); mt.setProducedDate(producedDate);
materialMapper.updateInventory(mt); materialMapper.updateInventory(mt);
newMid = mt.getId(); newMid = mt.getId();
@ -211,7 +213,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
Map<String, Object> insert = new HashMap<>(); Map<String, Object> insert = new HashMap<>();
Material materialById = materialMapper.findMaterialById(mid); Material materialById = materialMapper.findMaterialById(mid);
insert.put("depositoryId", depositoryId); insert.put("depositoryId", depositoryId);
insert.put("quantity", quantity); insert.put("quantity", quantity * 100);
insert.put("shelfLife", materialById.getShelfLife()); insert.put("shelfLife", materialById.getShelfLife());
insert.put("producedDate", producedDate); insert.put("producedDate", producedDate);
insert.put("mid", map.get("mid")); insert.put("mid", map.get("mid"));
@ -402,24 +404,24 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
mapForYesterday.put("list", list); mapForYesterday.put("list", list);
// 查询今天目前为止的入库 // 查询今天目前为止的入库
List<ApplicationInRecordP> applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday); List<ApplicationInRecord> applicationInRecordPForToday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForToday);
// 查询昨天的入库 // 查询昨天的入库
List<ApplicationInRecordP> applicationInRecordPForYesterday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForYesterday); List<ApplicationInRecord> applicationInRecordPForYesterday = depositoryRecordMapper.findApplicationInRecordPForAPeriodOfTime(mapForYesterday);
// 今天的入库数量 // 今天的入库数量
int sumForToday = 0; double sumForToday = 0;
// 今天的入库额度 // 今天的入库额度
double priceForToday = 0.0; double priceForToday = 0.0;
// 昨天的入库数量 // 昨天的入库数量
int sumForYesterDay = 0; double sumForYesterDay = 0;
// 昨天的入库额度 // 昨天的入库额度
double priceForYesterDay = 0.0; double priceForYesterDay = 0.0;
for (ApplicationInRecordP applicationInRecordP : applicationInRecordPForToday) { for (ApplicationInRecord applicationInRecordP : applicationInRecordPForToday) {
// 获取当前入库类型(1物料2组合) // 获取当前入库类型(1物料2组合)
Integer flagForGroup = applicationInRecordP.getFlagForGroup(); Integer flagForGroup = applicationInRecordP.getFlagForGroup();
sumForToday += applicationInRecordP.getQuantity(); sumForToday += (double)applicationInRecordP.getQuantity() / 100;
if (applicationInRecordP.getPrice() != null) { if (applicationInRecordP.getPrice() != null) {
priceForToday += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity(); priceForToday += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100);
} else { } else {
priceForToday += 0; priceForToday += 0;
} }
@ -427,24 +429,23 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
for (int i = 0; i < applicationInRecordPForYesterday.size(); i++) { for (ApplicationInRecord applicationInRecordP : applicationInRecordPForYesterday) {
ApplicationInRecordP applicationInRecordP = applicationInRecordPForYesterday.get(i); sumForYesterDay += (double)applicationInRecordP.getQuantity() / 100;
sumForYesterDay += applicationInRecordP.getQuantity();
if (applicationInRecordP.getPrice() != null) { if (applicationInRecordP.getPrice() != null) {
priceForYesterDay += applicationInRecordP.getPrice() * applicationInRecordP.getQuantity(); priceForYesterDay += applicationInRecordP.getPrice() * (double)(applicationInRecordP.getQuantity() / 100);
} else { } else {
priceForYesterDay += 0; priceForYesterDay += 0;
} }
} }
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("total", sumForToday); result.put("total", sumForToday);
Double ratioForCount = 0.0; double ratioForCount = 0.0;
Double ratioForPrice = 0.0; double ratioForPrice = 0.0;
if (Double.compare(sumForYesterDay, 0.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) { 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 bgForSum = new BigDecimal(ratioForCount);
BigDecimal bgForPrice = new BigDecimal(ratioForPrice); BigDecimal bgForPrice = new BigDecimal(ratioForPrice);
@ -652,12 +653,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (placeId == null) { if (placeId == null) {
placeId = 0; placeId = 0;
} }
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); Double quantity = ObjectFormatUtil.toDouble(map.get("quantity"));
Place placeById = placeMapper.findPlaceById(placeId); Place placeById = placeMapper.findPlaceById(placeId);
// 获取当前物料基本信息 // 获取当前物料基本信息
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); Integer mid = ObjectFormatUtil.toInteger(map.get("mid"));
Material materialById = materialMapper.findMaterialById(mid); Material materialById = materialMapper.findMaterialById(mid);
map.put("mtId",materialById.getMaterialTypeId()); map.put("mtId", materialById.getMaterialTypeId());
String unit = (String) map.get("unit"); String unit = (String) map.get("unit");
if ("-1".equals(unit)) { if ("-1".equals(unit)) {
map.put("unit", materialById.getUnit()); map.put("unit", materialById.getUnit());
@ -709,7 +710,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @param placeById 入库库位 * @param placeById 入库库位
* @return * @return
*/ */
Integer updateInventoryInfoForApproval(Map<String, Object> map, Integer quantity, Material materialById, Place placeById) { Integer updateInventoryInfoForApproval(Map<String, Object> map, double quantity, Material materialById, Place placeById) {
// 获取当前入库的物料id // 获取当前入库的物料id
Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid")); Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid"));
// 获取当前入库记录id // 获取当前入库记录id
@ -731,13 +732,13 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
MaterialAndProducedDate materialAndProducedDateByMidAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(insertProducedDate); MaterialAndProducedDate materialAndProducedDateByMidAndProducedDate = materialMapper.findMaterialAndProducedDateByMidAndProducedDate(insertProducedDate);
if (materialAndProducedDateByMidAndProducedDate != null) { if (materialAndProducedDateByMidAndProducedDate != null) {
// 增加当前数量 // 增加当前数量
materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + quantity); materialAndProducedDateByMidAndProducedDate.setQuantity(materialAndProducedDateByMidAndProducedDate.getQuantity() + (int) quantity * 100);
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity); materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + (int) quantity * 100);
// 修改 // 修改
materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate); materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate);
} else { } else {
insertProducedDate.put("quantity", quantity); insertProducedDate.put("quantity", quantity * 100);
insertProducedDate.put("inventory", quantity); insertProducedDate.put("inventory", quantity * 100);
insertProducedDate.put("expendnum", 0); insertProducedDate.put("expendnum", 0);
insertProducedDate.put("barCode", map.get("barCode")); insertProducedDate.put("barCode", map.get("barCode"));
insertProducedDate.put("qrCode", map.get("qrCode")); insertProducedDate.put("qrCode", map.get("qrCode"));
@ -765,16 +766,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(insert); MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(insert);
if (placeAndMaterialByMidAndPid == null) { if (placeAndMaterialByMidAndPid == null) {
// 如果没有当前记录 // 如果没有当前记录
insert.put("quantity", quantity); insert.put("quantity", quantity * 100);
// 插入记录 // 插入记录
placeMapper.addMaterialOnPlace(insert); placeMapper.addMaterialOnPlace(insert);
} else { } else {
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity); placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) quantity * 100);
// 修改数量 // 修改数量
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
} }
// 修改当前库位数量 // 修改当前库位数量
placeById.setQuantity(placeById.getQuantity() + quantity); placeById.setQuantity(placeById.getQuantity() + (int) quantity * 100);
return placeMapper.UpdatePlace(placeById); return placeMapper.UpdatePlace(placeById);
} }
@ -813,7 +814,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 将库存还原 // 将库存还原
Material material = materialByCondition.get(0); Material material = materialByCondition.get(0);
Map<String, Object> update = new HashMap<>(); Map<String, Object> update = new HashMap<>();
update.put("quantity", material.getQuantity() - quantity); update.put("quantity", material.getQuantity() - quantity * 100);
update.put("price", oldPrice); update.put("price", oldPrice);
update.put("amounts", material.getAmounts() - quantity * price); update.put("amounts", material.getAmounts() - quantity * price);
update.put("id", material.getId()); update.put("id", material.getId());
@ -1053,8 +1054,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setData(""); restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));
} }
} } else {
else {
// 如果是拆单后的出库 // 如果是拆单后的出库
// 用于获取对应的拆单记录 // 用于获取对应的拆单记录
@ -1115,8 +1115,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功"));
} } else {
else {
// 如果不能满足需求 // 如果不能满足需求
// 获取对应的拆单记录 // 获取对应的拆单记录
@ -1160,8 +1159,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent);
} } else {
else {
// 如果当前拆单没有父级 // 如果当前拆单没有父级
@ -1246,8 +1244,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setData(""); restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));
} }
} } else {
else {
// 如果大于 // 如果大于
// 获取库存重要减少的数量 // 获取库存重要减少的数量
@ -1330,8 +1327,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
} }
} } else {
else {
// 如果拆单库存处理记录不存在 // 如果拆单库存处理记录不存在
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
@ -1397,8 +1393,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功"));
} } else {
else {
restResponse.setStatus(508); restResponse.setStatus(508);
restResponse.setData(""); restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));
@ -2096,57 +2091,57 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (!"".equals(sid) && flagForIn) { if (!"".equals(sid) && flagForIn) {
Integer id = ObjectFormatUtil.toInteger(sid.trim()); 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; continue;
} }
// 获取当前入库对应的物料 // 获取当前入库对应的物料
Material materialById = materialMapper.findMaterialById(recordP.getMid()); Material materialById = materialMapper.findMaterialById(record.getMid());
if (recordP.getAirtoGroupId() != null) { if (record.getAirtoGroupId() != null) {
// 如果该申请是组合入库下的申请 // 如果该申请是组合入库下的申请
flagForGroupInfoInDepository = true; flagForGroupInfoInDepository = true;
} }
// 用于调用入库方法而创建的 // 用于调用入库方法而创建的
Map<String, Object> paramForUpdateInventory = new HashMap<>(); Map<String, Object> paramForUpdateInventory = new HashMap<>();
paramForUpdateInventory.put("mid", recordP.getMid()); paramForUpdateInventory.put("mid", record.getMid());
paramForUpdateInventory.put("quantity", recordP.getQuantity()); paramForUpdateInventory.put("quantity", record.getQuantity());
paramForUpdateInventory.put("depositoryId", recordP.getDepositoryId()); paramForUpdateInventory.put("depositoryId", record.getDepositoryId());
paramForUpdateInventory.put("placeId", recordP.getPlaceId()); paramForUpdateInventory.put("placeId", record.getPlaceId());
if (materialById.getUnit().equals(recordP.getAirUnit())) { if (materialById.getUnit().equals(record.getAirUnit())) {
// 如果是基础单位 // 如果是基础单位
Map<String, Object> param = new HashMap<>(); Map<String, Object> param = new HashMap<>();
param.put("depositoryId", recordP.getDepositoryId()); param.put("depositoryId", record.getDepositoryId());
param.put("mcode", materialById.getCode()); param.put("mcode", materialById.getCode());
// 判断该仓库中有无该物物料 // 判断该仓库中有无该物物料
List<Inventory> materialByCondition = materialMapper.findInventory(param); List<Inventory> materialByCondition = materialMapper.findInventory(param);
// 修改仓库库存 // 修改仓库库存
Long mproducedDate = recordP.getMproducedDate(); Long mproducedDate = record.getMproducedDate();
if (mproducedDate == null) { if (mproducedDate == null) {
mproducedDate = 0L; mproducedDate = 0L;
} }
// 获取当前库存id // 获取当前库存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("newInMid", newMid);
paramForUpdateInventory.put("id", recordP.getId()); paramForUpdateInventory.put("id", record.getId());
paramForUpdateInventory.put("producedDate", recordP.getMproducedDate()); paramForUpdateInventory.put("producedDate", record.getMproducedDate());
Place placeById = placeMapper.findPlaceById(recordP.getPlaceId()); Place placeById = placeMapper.findPlaceById(record.getPlaceId());
// 修改当前库存容量 // 修改当前库存容量
updateInventoryInfoForApproval(paramForUpdateInventory, recordP.getQuantity(), materialById, placeById); updateInventoryInfoForApproval(paramForUpdateInventory, record.getQuantity(), materialById, placeById);
} else { } else {
// 如果是拆单单位 // 如果是拆单单位
// 查询拆单记录 // 查询拆单记录
Map<String, Object> paramForSplitInfo = new HashMap<>(); Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", recordP.getAirUnit()); paramForSplitInfo.put("newUnit", record.getAirUnit());
paramForSplitInfo.put("mid", recordP.getMid()); paramForSplitInfo.put("mid", record.getMid());
// 查询当前拆单是否存在 // 查询当前拆单是否存在
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
if (splitInfoForUnit != null) { if (splitInfoForUnit != null) {
@ -2163,8 +2158,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId()); paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId());
Map<String, Object> paramForInventory = new HashMap<>(); Map<String, Object> paramForInventory = new HashMap<>();
paramForInventory.put("depositoryId", recordP.getDepositoryId()); paramForInventory.put("depositoryId", record.getDepositoryId());
paramForInventory.put("mid", recordP.getMid()); paramForInventory.put("mid", record.getMid());
// 判断该仓库中有无该物物料 // 判断该仓库中有无该物物料
List<Inventory> inventoryList = materialMapper.findInventory(paramForInventory); List<Inventory> inventoryList = materialMapper.findInventory(paramForInventory);
@ -2173,7 +2168,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
// 用于查找该库存对应库位 // 用于查找该库存对应库位
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("pid", recordP.getPlaceId()); paramForInventoryToPlace.put("pid", record.getPlaceId());
paramForInventoryToPlace.put("mid", inventory.getId()); paramForInventoryToPlace.put("mid", inventory.getId());
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace); placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace);
@ -2184,7 +2179,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory); 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")) { if (paramForUpdateInventory.containsKey("applicationInId")) {
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForUpdateInventory.get("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"); String applyTime = (String) map.get("applyTime");
map.put("applicantTime", DateUtil.DateTimeByDayToTimeStamp(applyTime)); map.put("applicantTime", DateUtil.DateTimeByDayToTimeStamp(applyTime));
} }
List<ApplicationInRecordP> list = depositoryRecordMapper.findApplicationInRecordPByCondition(map); List<ApplicationInRecord> list = depositoryRecordMapper.findApplicationInRecordPByCondition(map);
for (ApplicationInRecordP applicationInRecordP : list) { List<ApplicationInRecordP> result = new ArrayList<>();
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecordP.getApplicantId(), userToken);
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecordP.getApplicantTime())); for (ApplicationInRecord applicationInRecord : list) {
applicationInRecordP.setApplicantName(userByPortById.getName()); UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userToken);
applicationInRecordP.setApplicantTime(time); String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime()));
applicationInRecordP.setApplyRemark(applicationInRecordP.getApplyRemark() == null ? "" : applicationInRecordP.getApplyRemark()); applicationInRecord.setApplicantName(userByPortById.getName());
if (Integer.compare(applicationInRecordP.getFlagForGroup(), 2) == 0) { applicationInRecord.setApplicantTime(time);
applicationInRecord.setApplyRemark(applicationInRecord.getApplyRemark() == null ? "" : applicationInRecord.getApplyRemark());
if (Integer.compare(applicationInRecord.getFlagForGroup(), 2) == 0) {
// 如果入库的是组合 // 如果入库的是组合
Group group = groupMapper.findGroupOnlyById(applicationInRecordP.getMid()); Group group = groupMapper.findGroupOnlyById(applicationInRecord.getMid());
applicationInRecordP.setMname(group.getGname()); applicationInRecord.setMname(group.getGname());
applicationInRecordP.setAirUnit(""); applicationInRecord.setAirUnit("");
applicationInRecordP.setMcode(group.getCode()); applicationInRecord.setMcode(group.getCode());
applicationInRecordP.setMversion("组合"); 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("depositoryIdList", depositoryIdList);
map.put("applicantId", userByPort.getId()); map.put("applicantId", userByPort.getId());
List<ApplicationInRecordP> list = depositoryRecordMapper.findApplicationInRecordPByUser(map); List<ApplicationInRecord> list = depositoryRecordMapper.findApplicationInRecordPByUser(map);
for (ApplicationInRecordP applicationInRecordP : list) { List<ApplicationInRecordP> result = new ArrayList<>();
UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecordP.getApplicantId(), userByPort); for (ApplicationInRecord applicationInRecord : list) {
String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecordP.getApplicantTime())); UserByPort userByPortById = LinkInterfaceUtil.FindUserById(applicationInRecord.getApplicantId(), userByPort);
applicationInRecordP.setApplicantName(userByPortById.getName()); String time = DateUtil.TimeStampToDateTime(Long.valueOf(applicationInRecord.getApplicantTime()));
applicationInRecordP.setApplicantTime(time); applicationInRecord.setApplicantName(userByPortById.getName());
applicationInRecordP.setApplyRemark(applicationInRecordP.getApplyRemark() == null ? "" : applicationInRecordP.getApplyRemark()); applicationInRecord.setApplicantTime(time);
if (Integer.compare(applicationInRecordP.getFlagForGroup(), 2) == 0) { applicationInRecord.setApplyRemark(applicationInRecord.getApplyRemark() == null ? "" : applicationInRecord.getApplyRemark());
if (Integer.compare(applicationInRecord.getFlagForGroup(), 2) == 0) {
// 如果入库的是组合 // 如果入库的是组合
Group group = groupMapper.findGroupOnlyById(applicationInRecordP.getMid()); Group group = groupMapper.findGroupOnlyById(applicationInRecord.getMid());
applicationInRecordP.setMname(group.getGname()); applicationInRecord.setMname(group.getGname());
applicationInRecordP.setAirUnit(""); applicationInRecord.setAirUnit("");
applicationInRecordP.setMcode(group.getCode()); applicationInRecord.setMcode(group.getCode());
applicationInRecordP.setMversion("组合"); applicationInRecord.setMversion("组合");
} }
ApplicationInRecordP arp = new ApplicationInRecordP(applicationInRecord);
result.add(arp);
} }
return list; return result;
} }
@Override @Override
@ -3584,7 +3585,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Override @Override
public List<ApplicationInRecordP> findApplicationInRecordByDepository(String depositoryId) { public List<ApplicationInRecordP> findApplicationInRecordByDepository(String depositoryId) {
return depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId); List<ApplicationInRecord> recordByDepository = depositoryRecordMapper.findApplicationInRecordByDepository(depositoryId);
List<ApplicationInRecordP> 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 @Override
public Map<String, Object> CalculateAllApplicationInAll(List<Integer> list) { public Map<String, Object> CalculateAllApplicationInAll(List<Integer> list) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
List<ApplicationInRecordP> applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPByDepositoryList(list); List<ApplicationInRecord> applicationInRecordPAll = depositoryRecordMapper.findApplicationInRecordPByDepositoryList(list);
Double sum = 0.0; double sum = 0.0;
Integer count = 0; double count = 0;
for (int i = 0; i < applicationInRecordPAll.size(); i++) { for (ApplicationInRecord applicationInRecordP : applicationInRecordPAll) {
ApplicationInRecordP applicationInRecordP = applicationInRecordPAll.get(i);
double price = 0.0; double price = 0.0;
if (applicationInRecordP.getPrice() != null) { if (applicationInRecordP.getPrice() != null) {
price = applicationInRecordP.getPrice(); price = applicationInRecordP.getPrice();
} }
sum += price * applicationInRecordP.getQuantity() / 100; sum += price * applicationInRecordP.getQuantity() / 10000;
count += applicationInRecordP.getQuantity(); count += (double)applicationInRecordP.getQuantity() / 100;
} }
BigDecimal bg = new BigDecimal(sum); BigDecimal bg = new BigDecimal(sum);
sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); sum = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
@ -3836,17 +3843,15 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
@Override @Override
public Double CalculateAllApplicationOutPrice(String state) { public Double CalculateAllApplicationOutPrice(String state) {
List<ApplicationOutRecordP> applicationOutRecordPAll = depositoryRecordMapper.findApplicationOutRecordPAll(); List<ApplicationOutRecordP> applicationOutRecordPAll = depositoryRecordMapper.findApplicationOutRecordPAll();
Double sum = 0.0; double sum = 0.0;
if (state.isEmpty()) { if (state.isEmpty()) {
// 如果要获取所有待出库的金额 // 如果要获取所有待出库的金额
for (int i = 0; i < applicationOutRecordPAll.size(); i++) { for (ApplicationOutRecordP applicationOutRecordP : applicationOutRecordPAll) {
ApplicationOutRecordP applicationOutRecordP = applicationOutRecordPAll.get(i);
// 获取所有子物料 // 获取所有子物料
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("parentId", applicationOutRecordP.getId()); map.put("parentId", applicationOutRecordP.getId());
List<ApplicationOutRecordMin> minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map); List<ApplicationOutRecordMin> minByCondition = depositoryRecordMapper.findApplicationOutMinByCondition(map);
for (int k = 0; k < minByCondition.size(); k++) { for (ApplicationOutRecordMin applicationOutRecordMin : minByCondition) {
ApplicationOutRecordMin applicationOutRecordMin = minByCondition.get(k);
Integer mid = applicationOutRecordMin.getMid(); Integer mid = applicationOutRecordMin.getMid();
Material materialById = materialMapper.findMaterialById(mid); Material materialById = materialMapper.findMaterialById(mid);
if (materialById.getPrice() != null) { if (materialById.getPrice() != null) {
@ -3911,16 +3916,19 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
* @return * @return
*/ */
@Override @Override
public Integer findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId) { public Double findApplicationRecordByDate(Long end, Long start, Integer type, Integer depositoryId) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("start", start); map.put("start", start);
map.put("end", end); map.put("end", end);
map.put("depositoryId", depositoryId); map.put("depositoryId", depositoryId);
double quantity = 0.0;
if (type == 1) { if (type == 1) {
return depositoryRecordMapper.findApplicationInRecordByDate(map); quantity = (double) depositoryRecordMapper.findApplicationInRecordByDate(map) / 100;
return quantity;
} else { } else {
map.put("state", "已出库"); map.put("state", "已出库");
return depositoryRecordMapper.findApplicationOutRecordByDate(map); quantity = (double) depositoryRecordMapper.findApplicationOutRecordByDate(map);
return quantity;
} }
} }
@ -4003,7 +4011,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} }
@Override @Override
public Integer findMaterialCountByMonth2(Map<String, Object> map) { public Double findMaterialCountByMonth2(Map<String, Object> map) {
Integer type = ObjectFormatUtil.toInteger(map.get("type")); Integer type = ObjectFormatUtil.toInteger(map.get("type"));
Object o = map.get("oldId"); Object o = map.get("oldId");
List<Long> allMtByParent = null; List<Long> allMtByParent = null;
@ -4013,10 +4021,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
allMtByParent = findChildForMaterialTypeByParent(mt); allMtByParent = findChildForMaterialTypeByParent(mt);
map.put("list", allMtByParent); map.put("list", allMtByParent);
} }
Integer sumCount = 0; double sumCount = 0;
if (type == 1) { if (type == 1) {
// 如果入库 // 如果入库
sumCount = depositoryRecordMapper.findApplicationInByMonthTest(map); sumCount = (double)depositoryRecordMapper.findApplicationInByMonthTest(map) / 100;
} else { } else {
// 如果出库 // 如果出库
sumCount = depositoryRecordMapper.findApplicationOutByMonth(map); sumCount = depositoryRecordMapper.findApplicationOutByMonth(map);
@ -4042,7 +4050,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Override @Override
public ApplicationInRecordP findApplicationInRecordPById(Integer id) { 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 @Override
public Integer deleteApplicationInRecordById(Integer id, UserByPort userToken, String userAgent) { public Integer deleteApplicationInRecordById(Integer id, UserByPort userToken, String userAgent) {
ApplicationInRecordP record = depositoryRecordMapper.findApplicationInRecordPById(id); ApplicationInRecord record = depositoryRecordMapper.findApplicationInRecordPById(id);
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -4074,11 +4083,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
*/ */
@Override @Override
public Integer deleteApplicationInRecordByIds(List<Integer> list, UserByPort userToken, String userAgent) { public Integer deleteApplicationInRecordByIds(List<Integer> list, UserByPort userToken, String userAgent) {
List<ApplicationInRecordP> applicationInRecordsByIds = depositoryRecordMapper.findApplicationInRecordsByIds(list); List<ApplicationInRecord> applicationInRecordsByIds = depositoryRecordMapper.findApplicationInRecordsByIds(list);
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
for (ApplicationInRecordP record : applicationInRecordsByIds for (ApplicationInRecord record : applicationInRecordsByIds
) { ) {
if (Integer.compare(record.getAirapproverPass(), 4) == 0 || Integer.compare(record.getAirapproverPass(), 1) == 0) { if (Integer.compare(record.getAirapproverPass(), 4) == 0 || Integer.compare(record.getAirapproverPass(), 1) == 0) {
updateInventoryForErrorInRecord(record.getMid(), record.getQuantity(), record.getAirUnit(), record.getPlaceId(), record.getDepositoryId()); 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)); placeAndMaterialByMidAndPid.setQuantity(Math.max(placeAndMaterialByMidAndPid.getQuantity() - quantity, 0));
place.setQuantity(Math.max(place.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); materialMapper.updateInventory(inventory);
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
placeMapper.UpdatePlace(place); placeMapper.UpdatePlace(place);
} }
} } else {
else {
// 如果不是基础单位 // 如果不是基础单位
Map<String, Object> paramForSplitInfo = new HashMap<>(); Map<String, Object> paramForSplitInfo = new HashMap<>();
paramForSplitInfo.put("newUnit", unit); paramForSplitInfo.put("newUnit", unit);
@ -4156,7 +4164,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (splitInventory.getSaveQuantity() >= quantity) { if (splitInventory.getSaveQuantity() >= quantity) {
// 如果当前待处理数目可以满足需求 // 如果当前待处理数目可以满足需求
splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity,0)); splitInventory.setSaveQuantity(Math.max(splitInventory.getSaveQuantity() - quantity, 0));
// 修改库存处理记录 // 修改库存处理记录
splitUnitMapper.updateSplitInventory(splitInventory); splitUnitMapper.updateSplitInventory(splitInventory);
@ -4213,7 +4221,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
if (inventory.getQuantity() >= 1 && flag) { if (inventory.getQuantity() >= 1 && flag) {
// 令库存-1 // 令库存-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); placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid);
// 修改库位数量 // 修改库位数量
Place placeById = placeMapper.findPlaceById(placeId); Place placeById = placeMapper.findPlaceById(placeId);
placeById.setQuantity(Math.max(placeById.getQuantity() - 1,0)); placeById.setQuantity(Math.max(placeById.getQuantity() - 1, 0));
placeMapper.UpdatePlace(placeById); placeMapper.UpdatePlace(placeById);
@ -4237,8 +4245,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + quantity); splitInventory.setOutQuantity(splitInventory.getOutQuantity() + quantity);
splitUnitMapper.updateSplitInventory(splitInventory); splitUnitMapper.updateSplitInventory(splitInventory);
} }
} } else {
else {
// 如果大于 // 如果大于
// 获取库存重要减少的数量 // 获取库存重要减少的数量

7
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryServiceImpl.java

@ -734,7 +734,12 @@ public class DepositoryServiceImpl implements DepositoryService {
*/ */
@Override @Override
public List<InventoryByDname> getToDayInventoryByDNameTest() { public List<InventoryByDname> getToDayInventoryByDNameTest() {
return depositoryMapper.getToDayInventoryByDNameTest(); List<InventoryByDname> toDayInventoryByDNameTest = depositoryMapper.getToDayInventoryByDNameTest();
for (InventoryByDname inventoryByDName:toDayInventoryByDNameTest
) {
inventoryByDName.setInventory(inventoryByDName.getInventory() / 100);
}
return toDayInventoryByDNameTest;
} }
private boolean hasDepository(List<Depository> list, Depository o) { private boolean hasDepository(List<Depository> list, Depository o) {

8
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"); // 主订单编号 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")); Integer approverPass = ObjectFormatUtil.toInteger(map.get("approverPass"));
map.put("approverId", userToken.getId()); map.put("approverId", userToken.getId());
map.put("approverTime", System.currentTimeMillis()); map.put("approverTime", System.currentTimeMillis());
// 根据当前主订单获取产生的对应子订单 // 根据当前主订单获取产生的对应子订单
List<ApplicationInRecordP> minInRecordList = depositoryRecordMapper.findApplicationInRecordPByToGroupId(mainRecordP.getId()); List<ApplicationInRecord> minInRecordList = depositoryRecordMapper.findApplicationInRecordPByToGroupId(mainRecordP.getId());
// 用于存储最终要删除的id列表 // 用于存储最终要删除的id列表
List<Integer> deleteIds = new ArrayList<>(); List<Integer> deleteIds = new ArrayList<>();
if (Integer.compare(approverPass, 1) == 0) { if (Integer.compare(approverPass, 1) == 0) {
for (ApplicationInRecordP minRecordP : for (ApplicationInRecord minRecordP :
minInRecordList) { minInRecordList) {
map.put("id", minRecordP.getId()); map.put("id", minRecordP.getId());
depositoryRecordService.reviewIn(map, userId, userToken, userAgent); depositoryRecordService.reviewIn(map, userId, userToken, userAgent);
@ -1117,7 +1117,7 @@ public class GroupServiceImpl implements GroupService {
} else { } else {
// 如果是要驳回 // 如果是要驳回
map.put("state", "驳回"); map.put("state", "驳回");
for (ApplicationInRecordP minRecordP : for (ApplicationInRecord minRecordP :
minInRecordList) { minInRecordList) {
deleteIds.add(minRecordP.getId()); deleteIds.add(minRecordP.getId());
} }

6
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<Integer> recordIdList, String QyWxUid) { public JSONObject sendApprovalTemplateIn(String userAgent, UserByPort userToken, List<Integer> recordIdList, String QyWxUid) {
// 获取当前出库明细 // 获取当前出库明细
List<ApplicationInRecordP> minRecordList = depositoryRecordMapper.findApplicationInRecordsByIds(recordIdList); List<ApplicationInRecord> minRecordList = depositoryRecordMapper.findApplicationInRecordsByIds(recordIdList);
if (minRecordList.size() <= 0) { if (minRecordList.size() <= 0) {
throw new MyException("参数错误"); throw new MyException("参数错误");
@ -1895,7 +1895,7 @@ public class QyWxOperationService {
approval_template_apply_data_contents_info.setId("Table-1668220735636"); approval_template_apply_data_contents_info.setId("Table-1668220735636");
// 定义明细列表 // 定义明细列表
List<Object> contents_detail = new ArrayList<>(); List<Object> contents_detail = new ArrayList<>();
for (ApplicationInRecordP recordMin : minRecordList) { for (ApplicationInRecord recordMin : minRecordList) {
// 获取明细信息 // 获取明细信息
// 获取当前出库物料 // 获取当前出库物料
Material materialById = materialMapper.findMaterialById(recordMin.getMid()); 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); detail_list_control_info_inNumber.put("title", detail_list_control_info_title_list_inNumber);
Map<String, String> detail_list_control_info_value_inNumber = new HashMap<>(); Map<String, String> 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); detail_list_control_info_inNumber.put("value", detail_list_control_info_value_inNumber);

77
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); SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo);
// 获取当前仓库是否有用户进行管理入库审批 // 获取当前仓库是否有用户进行管理入库审批
Map<String, Object> paramForMtRole = new HashMap<>(); Map<String, Object> paramForMtRole = new HashMap<>();
Material materialById = materialMapper.findMaterialById(ObjectFormatUtil.toInteger(map.get("mid"))); Material materialById = materialMapper.findMaterialById(ObjectFormatUtil.toInteger(map.get("mid")));
paramForMtRole.put("mtid",materialById.getMaterialTypeId()); paramForMtRole.put("mtid", materialById.getMaterialTypeId());
map.put("mtId",materialById.getMaterialTypeId()); map.put("mtId", materialById.getMaterialTypeId());
List<RoleAndMaterialType> roleAndMaterials = roleMapper.findRoleAndMaterialTypeByCondition(paramForMtRole); List<RoleAndMaterialType> roleAndMaterials = roleMapper.findRoleAndMaterialTypeByCondition(paramForMtRole);
// 用于标志该仓库是否需要进行审批 // 用于标志该仓库是否需要进行审批
boolean flagForApproval = false; // 默认不需要 boolean flagForApproval = false; // 默认不需要
if (roleAndMaterials.size() > 0) { if (roleAndMaterials.size() > 0) {
flagForApproval = true; flagForApproval = true;
} }
map.put("flagForApproval",flagForApproval); map.put("flagForApproval", flagForApproval);
// 用于存储最终计算结果 // 用于存储最终计算结果
Integer result = 0; Integer result = 0;
@ -168,13 +167,13 @@ public class SplitUnitServiceImpl implements SplitUnitService {
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); Double quantity = ObjectFormatUtil.toDouble(map.get("quantity"));
if ("in".equals(type) && !flagForApproval) { if ("in".equals(type) && !flagForApproval) {
// 如果是入库并且不需要审批 // 如果是入库并且不需要审批
result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid,false); result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid, false);
map.remove("applicationInId"); map.remove("applicationInId");
}else if("in".equals(type)){ } else if ("in".equals(type)) {
// 如果是入库且需要审批 // 如果是入库且需要审批
result = depositoryRecordService.applicationIn(map); result = depositoryRecordService.applicationIn(map);
map.put("applicationInId",map.get("id")); map.put("applicationInId", map.get("id"));
map.remove("id"); map.remove("id");
} }
@ -188,6 +187,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
/** /**
* 用于审批通过或无需审批时修改库存 * 用于审批通过或无需审批时修改库存
*
* @param quantity 库存数量 * @param quantity 库存数量
* @param splitInventory 拆单库存记录 * @param splitInventory 拆单库存记录
* @param map 调剂 * @param map 调剂
@ -196,7 +196,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
* @param flagForApprovalPass 用于标志是否为审批后调用该方法 * @param flagForApprovalPass 用于标志是否为审批后调用该方法
* @return * @return
*/ */
public Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid,boolean flagForApprovalPass) { public Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid, boolean flagForApprovalPass) {
Integer result = 0; Integer result = 0;
// 获取当前进制 // 获取当前进制
@ -218,14 +218,14 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 如果有过记录 // 如果有过记录
// 最终存储数量 // 最终存储数量
int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity(); int realQuantity = (int) saveQuantity * 100 + splitInventory.getSaveQuantity();
if (realQuantity >= scale) { 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; realQuantity = realQuantity - quantity_in * scale;
} }
@ -234,16 +234,16 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 设置当前计量单位的入库数目 // 设置当前计量单位的入库数目
if (splitInventory.getInQuantity() != null) { if (splitInventory.getInQuantity() != null) {
// 如果当前库存不为空 // 如果当前库存不为空
splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity)); splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity * 100));
} else { } else {
splitInventory.setInQuantity((int) Math.round(quantity)); splitInventory.setInQuantity((int) Math.round(quantity * 100));
} }
result += splitUnitMapper.updateSplitInventory(splitInventory); result += splitUnitMapper.updateSplitInventory(splitInventory);
if (disposeQuantity != 0) { if (disposeQuantity != 0) {
// 用于更改库存的数量 // 用于更改库存的数量
map.put("quantity", String.valueOf(disposeQuantity)); map.put("quantity", String.valueOf((double) disposeQuantity / 100));
} else { } else {
map.put("quantity", "0"); map.put("quantity", "0");
@ -252,10 +252,10 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("realQuantity", quantity.toString()); map.put("realQuantity", quantity.toString());
if (splitInfoForUnit.getParentId() != null) { if (splitInfoForUnit.getParentId() != null) {
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId()); 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 { } else {
map.put("price", Double.toString(0)); 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); updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), placeAndMaterialByMidAndPid.getId(), map, quantity.intValue(), splitInfoForUnit);
} else { } else {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
result += depositoryRecordService.applicationInPlace(map,flagForApprovalPass); result += depositoryRecordService.applicationInPlace(map, flagForApprovalPass);
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("mid", map.get("newInMid")); paramForInventoryToPlace.put("mid", map.get("newInMid"));
paramForInventoryToPlace.put("pid", map.get("placeId")); paramForInventoryToPlace.put("pid", map.get("placeId"));
@ -296,7 +296,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
} }
} else { } else {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
result += depositoryRecordService.applicationInPlace(map,flagForApprovalPass); result += depositoryRecordService.applicationInPlace(map, flagForApprovalPass);
} }
} else { } else {
// 如果不大于设置的进制数量 // 如果不大于设置的进制数量
@ -320,12 +320,12 @@ public class SplitUnitServiceImpl implements SplitUnitService {
// 先插入一条库存记录用于后续操作 // 先插入一条库存记录用于后续操作
map.put("quantity", "0"); map.put("quantity", "0");
depositoryRecordService.applicationInPlace(map,flagForApprovalPass); depositoryRecordService.applicationInPlace(map, flagForApprovalPass);
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("applicationInId"))); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("applicationInId")));
} else { } else {
// 如果没有父级 // 如果没有父级
depositoryRecordService.applicationInPlace(map,flagForApprovalPass); depositoryRecordService.applicationInPlace(map, flagForApprovalPass);
} }
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); Map<String, Object> paramForInventoryToPlace = new HashMap<>();
paramForInventoryToPlace.put("mid", map.get("newInMid")); paramForInventoryToPlace.put("mid", map.get("newInMid"));
@ -552,7 +552,7 @@ public class SplitUnitServiceImpl implements SplitUnitService {
* @param inQuantity 最终入库数量 * @param inQuantity 最终入库数量
* @param baseSplitInfo 基础拆单记录 * @param baseSplitInfo 基础拆单记录
*/ */
public void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity, SplitInfo baseSplitInfo) { public void updateSplitInfoSaveQuantity(SplitInfo splitInfo, double quantity, int iid, Map<String, Object> map, double inQuantity, SplitInfo baseSplitInfo) {
// 获取当前拆单记录的父级拆单记录 // 获取当前拆单记录的父级拆单记录
@ -577,19 +577,19 @@ public class SplitUnitServiceImpl implements SplitUnitService {
if (splitInventory != null) { 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 // 令计算处理数量+1
disposeQuantity += 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); splitUnitMapper.updateSplitInventory(splitInventory);
@ -606,41 +606,42 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
map.put("quantity", String.valueOf(disposeQuantity)); map.put("quantity", String.valueOf(disposeQuantity));
map.put("realQuantity", String.valueOf(inQuantity)); map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map,false); depositoryRecordService.applicationInPlace(map, false);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
} }
} else { } else {
// 当前库存拆单记录与新入库的数目不大于预设的进制 // 当前库存拆单记录与新入库的数目不大于预设的进制
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity); splitInventory.setSaveQuantity((int) (splitInventory.getSaveQuantity() + saveQuantity * 100));
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity); splitInventory.setInQuantity((int) (splitInventory.getInQuantity() + saveQuantity * 100));
splitUnitMapper.updateSplitInventory(splitInventory); splitUnitMapper.updateSplitInventory(splitInventory);
map.put("price", "0"); map.put("price", "0");
map.put("quantity", "0"); map.put("quantity", "0");
map.put("realQuantity", String.valueOf(inQuantity)); map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map,false); depositoryRecordService.applicationInPlace(map, false);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
} }
} else { }
else {
// 如果为空 // 如果为空
Map<String, Object> paramForInsertSplitInventory = new HashMap<>(); Map<String, Object> paramForInsertSplitInventory = new HashMap<>();
paramForInsertSplitInventory.put("sid", splitInfo.getId()); paramForInsertSplitInventory.put("sid", splitInfo.getId());
paramForInsertSplitInventory.put("inQuantity", quantity); paramForInsertSplitInventory.put("inQuantity", quantity * 100);
paramForInsertSplitInventory.put("outQuantity", 0); paramForInsertSplitInventory.put("outQuantity", 0);
paramForInsertSplitInventory.put("iid", iid); paramForInsertSplitInventory.put("iid", iid);
if (quantity > splitInfo.getQuantity()) { if (quantity > splitInfo.getQuantity()) {
// 如果当前处理数量大于当前设置的进制数量 // 如果当前处理数量大于当前设置的进制数量
// 计算需要进位的数量 // 计算需要进位的数量
int quantity_scale = quantity / splitInfo.getQuantity(); double quantity_scale = quantity / splitInfo.getQuantity();
// 计算剩余处理的数量 // 计算剩余处理的数量
int quantity_residue = quantity - quantity_scale * splitInfo.getQuantity(); double quantity_residue = quantity - quantity_scale * splitInfo.getQuantity();
paramForInsertSplitInventory.put("saveQuantity", quantity_residue); paramForInsertSplitInventory.put("saveQuantity", quantity_residue * 100);
splitUnitMapper.addSplitInventory(paramForInsertSplitInventory); splitUnitMapper.addSplitInventory(paramForInsertSplitInventory);
if (parentId != null) { if (parentId != null) {
@ -654,18 +655,18 @@ public class SplitUnitServiceImpl implements SplitUnitService {
map.put("price", Double.toString(0)); map.put("price", Double.toString(0));
map.put("quantity", String.valueOf(quantity_scale)); map.put("quantity", String.valueOf(quantity_scale));
map.put("realQuantity", String.valueOf(inQuantity)); map.put("realQuantity", String.valueOf(inQuantity));
depositoryRecordService.applicationInPlace(map,false); depositoryRecordService.applicationInPlace(map, false);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
} }
} else { } else {
// 如果不大于 // 如果不大于
paramForInsertSplitInventory.put("saveQuantity", String.valueOf(quantity)); paramForInsertSplitInventory.put("saveQuantity", String.valueOf(quantity * 100));
splitUnitMapper.addSplitInventory(paramForInsertSplitInventory); splitUnitMapper.addSplitInventory(paramForInsertSplitInventory);
map.put("quantity", "0"); map.put("quantity", "0");
map.put("realQuantity", String.valueOf(inQuantity)); map.put("realQuantity", String.valueOf(inQuantity));
map.put("price", "0"); map.put("price", "0");
depositoryRecordService.applicationInPlace(map,false); depositoryRecordService.applicationInPlace(map, false);
// 删除入库订单 // 删除入库订单
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); // depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));

114
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.DepositoryService;
import com.dreamchaser.depository_manage.service.PlaceService; import com.dreamchaser.depository_manage.service.PlaceService;
import com.dreamchaser.depository_manage.service.StockTakingService; 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.CreateQrCodeUtil;
import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil; import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil;
import com.dreamchaser.depository_manage.utils.ZipMultiFileUtil; import com.dreamchaser.depository_manage.utils.ZipMultiFileUtil;
@ -36,118 +37,19 @@ import java.util.concurrent.*;
public class TestForOther { public class TestForOther {
@Autowired
DepositoryRecordService depositoryRecordService;
@Test @Test
public void run() { public void run() {
UserByPort userByPort = LinkInterfaceUtil.FindUserById(78, null); ApprovalInfo_Details approvalInfo = new ApprovalInfo_Details();
List<Object> list = buildPostTree(userByPort); ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver();
System.out.println(JSONObject.toJSONString(list)); approver.setUserId("PangFuZhen");
approvalInfo.setApprover(approver);
depositoryRecordService.reviewByQyWxApprovalIn("[1]",approvalInfo,"460f46eaefb46bb0c171029f62e2cea6","2","202303170008");
} }
/**
* 用于构造当前用户可见的部门树
* @param userByPort 当前用户
* @return
*/
public List<Object> buildPostTree(UserByPort userByPort){
JSONArray postTree = LinkInterfaceUtil.getPostTree(userByPort);
// 定义线程数量
int threadSize = postTree.size();
// 开启对应数量的线程
ExecutorService exs = Executors.newFixedThreadPool(threadSize);
// 树结构结果集
List<Object> list = new ArrayList<>();
// 线程结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
for (Object o : postTree) {
JSONObject data = (JSONObject) o;
// 创建一个线程
Future<Object> 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<Object>{
private JSONObject jsonObject;
public PostTreeThreads(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
@Override
public Object call() throws Exception {
// 定义结果
Map<String,Object> result = new HashMap<>();
// 获取当前的子类
if (jsonObject.containsKey("child") && jsonObject.get("child") != null) {
// 如果存在子类
List<Object> list = buildChildNodes(jsonObject);
result = buildTree(jsonObject, list);
}else{
// 如果不存在子类
result = buildTree(jsonObject, null);
}
return result;
}
}
/**
* 用于构造子节点
* @param jsonObject 待构造父节点
* @return
*/
public List<Object> buildChildNodes (JSONObject jsonObject){
List<Object> 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<Object> list = buildChildNodes(data);
result.add(buildTree(data,list));
}else{
// 如果不存在子节点
result.add(buildTree(data,null));
}
}
return result;
}
/**
* 用于构造节点
* @param jsonObject 待构造节点数据
* @param children 当前节点子节点
* @return
*/
public Map<String,Object> buildTree(JSONObject jsonObject,List<Object> children){
Map<String,Object> 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;
}

4
target/classes/com/dreamchaser/depository_manage/mapper/DepositoryRecordMapper.xml

@ -53,7 +53,7 @@
</resultMap> </resultMap>
<!-- 插入入库记录--> <!-- 插入入库记录-->
<resultMap id="applicationInRecord" type="com.dreamchaser.depository_manage.pojo.ApplicationInRecordP"> <resultMap id="applicationInRecord" type="com.dreamchaser.depository_manage.entity.ApplicationInRecord">
<id column="airid" property="id" jdbcType="INTEGER"/> <id column="airid" property="id" jdbcType="INTEGER"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/> <result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="quantity" property="quantity" jdbcType="INTEGER"/> <result column="quantity" property="quantity" jdbcType="INTEGER"/>
@ -62,7 +62,7 @@
<result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/> <result column="flagForGroup" property="flagForGroup" jdbcType="INTEGER"/>
<result column="price" property="price" jdbcType="VARCHAR"/> <result column="price" property="price" jdbcType="VARCHAR"/>
<result column="tname" property="materialTypeName" jdbcType="VARCHAR"/> <result column="tname" property="materialTypeName" jdbcType="VARCHAR"/>
<result column="applicantTime" property="applicant_time" jdbcType="INTEGER"/> <result column="applicant_time" property="applicantTime" jdbcType="INTEGER"/>
<result column="airPlaceId" property="placeId" jdbcType="INTEGER"/> <result column="airPlaceId" property="placeId" jdbcType="INTEGER"/>
<result column="code" property="aircode" jdbcType="VARCHAR"/> <result column="code" property="aircode" jdbcType="VARCHAR"/>
<result column="dname" property="depositoryName" jdbcType="VARCHAR"/> <result column="dname" property="depositoryName" jdbcType="VARCHAR"/>

Loading…
Cancel
Save