Browse Source

修改本地移动端库存可视化页面

lwx_dev
erdanergou 3 years ago
parent
commit
b005bd25a5
  1. 501
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryController.java
  2. 6
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  3. 3
      src/main/resources/templates/pages/application/application-in.html
  4. 3
      src/main/resources/templates/pages/chart/chart-in_mobile.html
  5. 3
      src/main/resources/templates/pages/chart/chart-out_mobile.html
  6. 88
      src/main/resources/templates/pages/chart/chart-stock_mobile.html
  7. 2
      src/main/resources/templates/pages/material/selectDepositoryByCard.html
  8. 4
      src/main/resources/templates/pages/user/login.html
  9. 245
      src/test/java/com/dreamchaser/depository_manage/BarChartTest.java
  10. 33
      src/test/java/com/dreamchaser/depository_manage/InventoryLineChartTest.java
  11. 2
      src/test/java/com/dreamchaser/depository_manage/LineChartTest.java
  12. 44
      src/test/java/com/dreamchaser/depository_manage/OtherTest.java

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

@ -414,8 +414,7 @@ public class DepositoryController {
show_data.putAll((Map<?, ?>) result); show_data.putAll((Map<?, ?>) result);
} }
depository_data.put("data", show_data); depository_data.put("data", show_data);
} } else {
else{
// 定义线程 // 定义线程
ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size()); ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size());
// 结果集 // 结果集
@ -480,9 +479,9 @@ public class DepositoryController {
if ("0".equals(type)) { if ("0".equals(type)) {
// 如果是获取库存 // 如果是获取库存
Map<Object, Object> inventoryLineChartData = getInventoryLineChartData(depositoryAllNameAndId); Map<Object, Object> inventoryLineChartData = getInventoryLineChartData(depositoryAllNameAndId);
depository_data.put("data",inventoryLineChartData); depository_data.put("data", inventoryLineChartData);
} else { } else {
Map<Object, Object> lineChartData = getLineChartData(depositoryAllNameAndId, type); Map<Object, Object> lineChartData = getLineChartData(depositoryAllNameAndId, type, "line");
depository_data.put("data", lineChartData); depository_data.put("data", lineChartData);
} }
return depository_data; return depository_data;
@ -536,6 +535,8 @@ public class DepositoryController {
// 获取库存图 // 获取库存图
if ("0".equals(type)) { if ("0".equals(type)) {
// 获取库存旭日图 // 获取库存旭日图
Future<Object> futureForSunburstData = completionService.submit(new distributeTasks(depositoryAllNameAndId, type, 5, userByPort, depositoryName)); Future<Object> futureForSunburstData = completionService.submit(new distributeTasks(depositoryAllNameAndId, type, 5, userByPort, depositoryName));
futureList.add(futureForSunburstData); futureList.add(futureForSunburstData);
@ -547,6 +548,12 @@ public class DepositoryController {
taskNum += 1; taskNum += 1;
// 出入库对比图数据
Map<Object, Object> barChartData = new HashMap<>();
// 获取本周出入库对比图数据
Future<Object> futureForBarData = completionService.submit(new distributeTasks(depositoryAllNameAndId, type, 4, userByPort, depositoryName));
futureList.add(futureForBarData);
taskNum += 1;
for (int i = 0; i < taskNum; i++) { for (int i = 0; i < taskNum; i++) {
@ -562,11 +569,17 @@ public class DepositoryController {
if (lineChartData == null || lineChartData.size() == 0) { if (lineChartData == null || lineChartData.size() == 0) {
lineChartData = (Map<Object, Object>) ((Map<String, Object>) result).get("inventoryLineChartData"); lineChartData = (Map<Object, Object>) ((Map<String, Object>) result).get("inventoryLineChartData");
} }
if (barChartData == null || barChartData.size() == 0) {
barChartData = (Map<Object, Object>) ((Map<String, Object>) result).get("barChartData");
}
} }
if (barChartData != null && barChartData.size() > 0) {
depository_data.put("barChartData", barChartData);
} }
else {
} else {
// 获取本周至今仓库的入/出库数量 // 获取本周至今仓库的入/出库数量
Future<Object> futureForBarChartData = completionService.submit(new distributeTasks(depositoryAllNameAndId, type, 1, userByPort, depositoryName)); Future<Object> futureForBarChartData = completionService.submit(new distributeTasks(depositoryAllNameAndId, type, 1, userByPort, depositoryName));
@ -612,7 +625,7 @@ public class DepositoryController {
} }
// 获取面积图图数据 // 获取面积图图数据
public Map<Object, Object> getLineChartData(Map<String, Integer> depositoryAllNameAndId, String type) { public Map<Object, Object> getLineChartData(Map<String, Integer> depositoryAllNameAndId, String type, String barOrLine) {
// 获取遍历器 // 获取遍历器
Iterator it = depositoryAllNameAndId.keySet().iterator(); Iterator it = depositoryAllNameAndId.keySet().iterator();
@ -643,8 +656,14 @@ public class DepositoryController {
Map<Object, Object> show_data = new HashMap<>(); Map<Object, Object> show_data = new HashMap<>();
while (it.hasNext()) { while (it.hasNext()) {
Object next = it.next(); Object next = it.next();
Future<Object> future;
if ("line".equals(barOrLine)) {
getApplicationRecordByDate getApplicationRecordByDate = new getApplicationRecordByDate(type, next.toString(), days, depositoryAllNameAndId); getApplicationRecordByDate getApplicationRecordByDate = new getApplicationRecordByDate(type, next.toString(), days, depositoryAllNameAndId);
Future<Object> future = completionService.submit(getApplicationRecordByDate); future = completionService.submit(getApplicationRecordByDate);
} else {
getBarChartDataForApplicationRecord getApplicationRecordByDate = new getBarChartDataForApplicationRecord(type, next.toString(), days, depositoryAllNameAndId);
future = completionService.submit(getApplicationRecordByDate);
}
futureList.add(future); futureList.add(future);
} }
@ -660,7 +679,6 @@ public class DepositoryController {
return show_data; return show_data;
} }
// 用于获取旭日图数据
//获取本月及之前月份各种类别入/出库总量 //获取本月及之前月份各种类别入/出库总量
public List<Object> getSunburstChartData(String type) { public List<Object> getSunburstChartData(String type) {
@ -693,16 +711,15 @@ public class DepositoryController {
} }
return result; return result;
} }
// 用于获取旭日图数据
/** /**
* 用于获取当前用户所拥有的仓库库存及各类别的库存 * 用于获取当前用户所拥有的仓库库存及各类别的库存
*
* @param userByPort 带获取用户 * @param userByPort 带获取用户
* @return * @return
*/ */
public List<Object> getInventorySunburstData(UserByPort userByPort){ public List<Object> getInventorySunburstData(UserByPort userByPort) {
Map<String, Object> previousMonth = DateUtil.getPreviousMonth(); Map<String, Object> previousMonth = DateUtil.getPreviousMonth();
// 获取所有月份 // 获取所有月份
List<Object> months = (List<Object>) previousMonth.get("months"); List<Object> months = (List<Object>) previousMonth.get("months");
@ -757,9 +774,9 @@ public class DepositoryController {
obj = completionService.take().get(); obj = completionService.take().get();
Map<String, Object> objectMap = (Map<String, Object>) obj; Map<String, Object> objectMap = (Map<String, Object>) obj;
Integer id = ObjectFormatUtil.toInteger((objectMap).get("id")); Integer id = ObjectFormatUtil.toInteger((objectMap).get("id"));
List<InventoryByMTAndDepository> inventoryByMtAndD = (List<InventoryByMTAndDepository>)objectMap.get("inventoryByMtAndD"); List<InventoryByMTAndDepository> inventoryByMtAndD = (List<InventoryByMTAndDepository>) objectMap.get("inventoryByMtAndD");
value += ObjectFormatUtil.toDouble(objectMap.get("value")); value += ObjectFormatUtil.toDouble(objectMap.get("value"));
inventoryForMTAndDepository.put(id,inventoryByMtAndD); inventoryForMTAndDepository.put(id, inventoryByMtAndD);
(objectMap).remove("id"); (objectMap).remove("id");
(objectMap).remove("inventoryByMtAndD"); (objectMap).remove("inventoryByMtAndD");
@ -770,10 +787,10 @@ public class DepositoryController {
e.printStackTrace(); e.printStackTrace();
} }
} }
Map<String,Object> stringObjectMap = new HashMap<>(); Map<String, Object> stringObjectMap = new HashMap<>();
stringObjectMap.put("children",childItems); stringObjectMap.put("children", childItems);
stringObjectMap.put("name",month); stringObjectMap.put("name", month);
stringObjectMap.put("value",value); stringObjectMap.put("value", value);
Random random = new Random(); Random random = new Random();
int r = random.nextInt(256); int r = random.nextInt(256);
int g = random.nextInt(256); int g = random.nextInt(256);
@ -786,106 +803,6 @@ public class DepositoryController {
return result; return result;
} }
/**
* 用于计算当前时间段内当前仓库下各物料类型的库存
*/
class inventoryByMaterialTypeForMonth implements Callable<Object> {
// 开始时间
Object start;
// 结束时间
Object end;
// 查询仓库
Depository depository;
// 当前仓库各物料类型库存数
List<InventoryByMTAndDepository> todayInventoryInfoByDidAndMt;
public inventoryByMaterialTypeForMonth(Object start, Object end, Depository depository, List<InventoryByMTAndDepository> todayInventoryInfoByDidAndMt) {
this.start = start;
this.end = end;
this.depository = depository;
this.todayInventoryInfoByDidAndMt = todayInventoryInfoByDidAndMt;
}
@Override
public Object call() throws Exception {
// 定义当前返回结果
Map<String, Object> result = new HashMap<>();
// 定义当前仓库的总数
double inventorySum = 0.0;
for (InventoryByMTAndDepository item : todayInventoryInfoByDidAndMt
) {
inventorySum += item.getInventory();
}
result.put("name", depository.getDname());
result.put("id",depository.getId());
result.put("value", inventorySum);
// 用于生产随机的颜色
Random random = new Random();
int r = random.nextInt(256);
int g = random.nextInt(256);
int b = random.nextInt(256);
Map<String, String> itemStyle = new HashMap<>();
itemStyle.put("color", "rgb(" + r + "," + g + "," + b + ")");
result.put("itemStyle", itemStyle);
// 获取所有顶级物料类型
List<MaterialType> materialTypeNoParent = materialTypeService.findMaterialTypeNoParent();
Map<String, Object> paramIn = new HashMap<>();
Map<String, Object> paramOut = new HashMap<>();
// 获取每月入库总额
paramIn.put("type", 1);
paramIn.put("state", "已入库");
paramIn.put("depository_id", depository.getId());
paramIn.put("start", start);
paramIn.put("end", end);
// 获取每月出库总额
paramOut.put("type", 2);
paramOut.put("state", "已出库");
paramOut.put("depository_id", depository.getId());
paramOut.put("start", start);
paramOut.put("end", end);
List<Object> children = new ArrayList<>();
for (MaterialType materialType : materialTypeNoParent
) {
// 生成子数据
Map<String, Object> resultItem = new HashMap<>();
resultItem.put("name", materialType.getTname());
// 用于生产随机的颜色
Map<String, String> itemStyleItem = new HashMap<>();
int rt = random.nextInt(256);
int gt = random.nextInt(256);
int bt = random.nextInt(256);
itemStyleItem.put("color", "rgb(" + rt + "," + gt + "," + bt + ")");
result.put("itemStyle", itemStyleItem);
long oldId = materialType.getOldId();
paramIn.put("oldId", oldId);
paramOut.put("oldId", oldId);
// 获取当前类别在当前仓库下当前月份的入库总额
Double wareHouseInCountByMonth = depositoryRecordService.calMaterialTypeTopCount(paramIn);
// 获取当前类别在当前仓库下当前月份的出库总额
Double wareHouseOutCountByMonth = depositoryRecordService.calMaterialTypeTopCount(paramOut);
for (InventoryByMTAndDepository item : todayInventoryInfoByDidAndMt
) {
long mtId = item.getMtId();
// 如果是同一类型
if (mtId == oldId) {
// 计算上个月该类型库存数
Double wareHouseCount = item.getInventory() - wareHouseInCountByMonth + wareHouseOutCountByMonth;
// 修改库存记录
item.setInventory(wareHouseCount);
resultItem.put("value", wareHouseCount);
}
}
children.add(resultItem);
}
result.put("children", children);
result.put("inventoryByMtAndD",todayInventoryInfoByDidAndMt);
return result;
}
}
/** /**
* 根据物料编号查询所在仓库 * 根据物料编号查询所在仓库
* *
@ -1113,7 +1030,6 @@ public class DepositoryController {
return new RestResponse(list); return new RestResponse(list);
} }
// 构造库位树 // 构造库位树
@GetMapping("/treeMenus_Place") @GetMapping("/treeMenus_Place")
public RestResponse InitTreeMenus_Place(@RequestParam(value = "depositoryId") Integer depositoryId) { public RestResponse InitTreeMenus_Place(@RequestParam(value = "depositoryId") Integer depositoryId) {
@ -1262,7 +1178,6 @@ public class DepositoryController {
} }
} }
@PostMapping("/findWarehouseVisiblePermission") @PostMapping("/findWarehouseVisiblePermission")
public RestResponse findWarehouseVisiblePermission(@RequestBody Map<String, Object> map) { public RestResponse findWarehouseVisiblePermission(@RequestBody Map<String, Object> map) {
List<Integer> list = roleService.findDepositoryIdForWarehouseVisiblePermissionByCondition(map); List<Integer> list = roleService.findDepositoryIdForWarehouseVisiblePermissionByCondition(map);
@ -1309,6 +1224,115 @@ public class DepositoryController {
return false; return false;
} }
/**
* 用于获取出入库对照柱状图
*
* @param userByPort 待获取的当前用户
* @return
*/
Map<Object, Object> getBarChartData(UserByPort userByPort) {
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort);
ExecutorService exs = Executors.newFixedThreadPool(2);
// 结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
Future<Object> submitForIn = completionService.submit(new GetBarChartData(depositoryAllNameAndId, "1"));
Future<Object> submitForOut = completionService.submit(new GetBarChartData(depositoryAllNameAndId, "2"));
futureList.add(submitForOut);
futureList.add(submitForIn);
Map<Object, Object> result = new HashMap<>();
for (int i = 0; i < 2; i++) {
Object obj = null;
try {
obj = completionService.take().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
result.putAll((Map<?, ?>) obj);
}
return result;
}
/**
* 获取本周各仓库库存的折线图数据
*
* @param depositoryAllNameAndId 仓库与Id对应
* @return
*/
// 获取柱状图数据
public Map<Object, Object> getInventoryLineChartData(Map<String, Integer> depositoryAllNameAndId) {
// 每天各仓库入库数目
Map<Object, Object> show_data = new HashMap<>();
// 获取当前各仓库的库存数
List<InventoryByDname> toDayInventoryByDName = depositoryService.getToDayInventoryByDName();
// 获取遍历器
Iterator it = depositoryAllNameAndId.keySet().iterator();
//获取获取系统的当前日历对象
Calendar instance = Calendar.getInstance();
int weekDay = instance.get(Calendar.DAY_OF_WEEK);
weekDay = weekDay - 1;
if (weekDay == 1) {
while (it.hasNext()) {
String key = it.next().toString();
Integer val = depositoryAllNameAndId.get(key);
String dname = key.split(",")[0];
Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDName);
Map<String, Object> map = new HashMap<>();
map.put("type", "line");
Map<String, Object> areaStyleItem = new HashMap<>();
map.put("areaStyle", areaStyleItem);
List<Double> doubleList = new ArrayList<>();
doubleList.add(inventoryByDname);
map.put("data", doubleList);
show_data.put(val, map);
}
} else {
// 获取日期
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
int now = instance.get(Calendar.DAY_OF_WEEK) - 1 == 0 ? 7 : instance.get(Calendar.DAY_OF_WEEK) - 1;
List<Long> days = new ArrayList<>(); // 周一至今的每天
instance.add(Calendar.DATE, 1);
days.add(DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())));
instance.add(Calendar.DATE, -1);
days.add(DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())));
while (now - 1 > 0) {
now--;
instance.add(Calendar.DATE, -1);
Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime()));
days.add(format);
}
// 定义线程
ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size());
// 结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
while (it.hasNext()) {
Object next = it.next();
getInventoryByDate getApplicationRecordByDate = new getInventoryByDate(next.toString(), days, depositoryAllNameAndId, toDayInventoryByDName);
Future<Object> future = completionService.submit(getApplicationRecordByDate);
futureList.add(future);
}
for (int i = 0; i < depositoryAllNameAndId.size(); i++) {
Object result = null;
try {
result = completionService.take().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
show_data.putAll((Map<?, ?>) result);
}
}
return show_data;
}
// 用于分发任务 // 用于分发任务
@Data @Data
@ -1334,12 +1358,12 @@ public class DepositoryController {
@Override @Override
public Object call() throws Exception { public Object call() throws Exception {
// taskType 1为条形图2为旭日图3为库存可视化中的本周折线图4为库存可视化中上周折线图图5为库存可视化中的旭日图 // taskType 1为条形图2为旭日图3为库存可视化中的本周折线图4为库存可视化中出库入库对比图图5为库存可视化中的旭日图
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (1 == taskType) { if (1 == taskType) {
// 获取入库 // 获取入库
Map<Object, Object> lineChartData = getLineChartData(depositoryAllNameAndId, type); Map<Object, Object> lineChartData = getLineChartData(depositoryAllNameAndId, type, "line");
result.put("lineChartData", lineChartData); result.put("lineChartData", lineChartData);
} else if (2 == taskType) { } else if (2 == taskType) {
List<Object> sunburstChartData = getSunburstChartData(type); List<Object> sunburstChartData = getSunburstChartData(type);
@ -1348,15 +1372,116 @@ public class DepositoryController {
Map<Object, Object> inventoryLineChartData = getInventoryLineChartData(depositoryAllNameAndId); Map<Object, Object> inventoryLineChartData = getInventoryLineChartData(depositoryAllNameAndId);
result.put("inventoryLineChartData", inventoryLineChartData); result.put("inventoryLineChartData", inventoryLineChartData);
} else if (4 == taskType) { } else if (4 == taskType) {
Map<Object, Object> barChartData = getBarChartData(userByPort);
}else if(5 == taskType){ result.put("barChartData", barChartData);
} else if (5 == taskType) {
List<Object> inventorySunburstData = getInventorySunburstData(userByPort); List<Object> inventorySunburstData = getInventorySunburstData(userByPort);
result.put("sunburstChartDataForInventory",inventorySunburstData); result.put("sunburstChartDataForInventory", inventorySunburstData);
}
return result;
}
}
/**
* 用于计算当前时间段内当前仓库下各物料类型的库存
*/
class inventoryByMaterialTypeForMonth implements Callable<Object> {
// 开始时间
Object start;
// 结束时间
Object end;
// 查询仓库
Depository depository;
// 当前仓库各物料类型库存数
List<InventoryByMTAndDepository> todayInventoryInfoByDidAndMt;
public inventoryByMaterialTypeForMonth(Object start, Object end, Depository depository, List<InventoryByMTAndDepository> todayInventoryInfoByDidAndMt) {
this.start = start;
this.end = end;
this.depository = depository;
this.todayInventoryInfoByDidAndMt = todayInventoryInfoByDidAndMt;
}
@Override
public Object call() throws Exception {
// 定义当前返回结果
Map<String, Object> result = new HashMap<>();
// 定义当前仓库的总数
double inventorySum = 0.0;
for (InventoryByMTAndDepository item : todayInventoryInfoByDidAndMt
) {
inventorySum += item.getInventory();
}
result.put("name", depository.getDname());
result.put("id", depository.getId());
result.put("value", inventorySum);
// 用于生产随机的颜色
Random random = new Random();
int r = random.nextInt(256);
int g = random.nextInt(256);
int b = random.nextInt(256);
Map<String, String> itemStyle = new HashMap<>();
itemStyle.put("color", "rgb(" + r + "," + g + "," + b + ")");
result.put("itemStyle", itemStyle);
// 获取所有顶级物料类型
List<MaterialType> materialTypeNoParent = materialTypeService.findMaterialTypeNoParent();
Map<String, Object> paramIn = new HashMap<>();
Map<String, Object> paramOut = new HashMap<>();
// 获取每月入库总额
paramIn.put("type", 1);
paramIn.put("state", "已入库");
paramIn.put("depository_id", depository.getId());
paramIn.put("start", start);
paramIn.put("end", end);
// 获取每月出库总额
paramOut.put("type", 2);
paramOut.put("state", "已出库");
paramOut.put("depository_id", depository.getId());
paramOut.put("start", start);
paramOut.put("end", end);
List<Object> children = new ArrayList<>();
for (MaterialType materialType : materialTypeNoParent
) {
// 生成子数据
Map<String, Object> resultItem = new HashMap<>();
resultItem.put("name", materialType.getTname());
// 用于生产随机的颜色
Map<String, String> itemStyleItem = new HashMap<>();
int rt = random.nextInt(256);
int gt = random.nextInt(256);
int bt = random.nextInt(256);
itemStyleItem.put("color", "rgb(" + rt + "," + gt + "," + bt + ")");
result.put("itemStyle", itemStyleItem);
long oldId = materialType.getOldId();
paramIn.put("oldId", oldId);
paramOut.put("oldId", oldId);
// 获取当前类别在当前仓库下当前月份的入库总额
Double wareHouseInCountByMonth = depositoryRecordService.calMaterialTypeTopCount(paramIn);
// 获取当前类别在当前仓库下当前月份的出库总额
Double wareHouseOutCountByMonth = depositoryRecordService.calMaterialTypeTopCount(paramOut);
for (InventoryByMTAndDepository item : todayInventoryInfoByDidAndMt
) {
long mtId = item.getMtId();
// 如果是同一类型
if (mtId == oldId) {
// 计算上个月该类型库存数
Double wareHouseCount = item.getInventory() - wareHouseInCountByMonth + wareHouseOutCountByMonth;
// 修改库存记录
item.setInventory(wareHouseCount);
resultItem.put("value", wareHouseCount);
}
} }
children.add(resultItem);
}
result.put("children", children);
result.put("inventoryByMtAndD", todayInventoryInfoByDidAndMt);
return result; return result;
} }
} }
/** /**
* 根据日期获取出入库的数量 * 根据日期获取出入库的数量
*/ */
@ -1389,7 +1514,7 @@ public class DepositoryController {
for (i = days.size() - 1; i > 0; i--) { for (i = days.size() - 1; i > 0; i--) {
// 遍历 Map并计算各仓库的入库数 // 遍历 Map并计算各仓库的入库数
// 获取一段时间内的库存额度 // 获取一段时间内的库存额度
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i), days.get(i - 1), 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);
} }
map.put("data", drCountbyDrName); map.put("data", drCountbyDrName);
@ -1398,64 +1523,92 @@ public class DepositoryController {
} }
} }
/** /**
* 获取本周各仓库库存的折线图数据 * 用于执行柱状图线程
* @param depositoryAllNameAndId 仓库与Id对应
* @return
*/ */
// 获取柱状图数据 class GetBarChartData implements Callable<Object> {
public Map<Object, Object> getInventoryLineChartData(Map<String, Integer> depositoryAllNameAndId) {
// 获取遍历器 // 仓库名称与id对应
Iterator it = depositoryAllNameAndId.keySet().iterator(); Map<String, Integer> depositoryAllNameAndId;
//获取获取系统的当前日历对象 // 要查询的类型
Calendar instance = Calendar.getInstance(); String type;
// 获取日期
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
int now = instance.get(Calendar.DAY_OF_WEEK) - 1 == 0 ? 7 : instance.get(Calendar.DAY_OF_WEEK) - 1;
List<Long> days = new ArrayList<>(); // 周一至今的每天
instance.add(Calendar.DATE, 1);
days.add(DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())));
instance.add(Calendar.DATE, -1);
days.add(DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())));
while (now - 1 > 0) {
now--;
instance.add(Calendar.DATE, -1);
Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime()));
days.add(format);
}
// 获取当前各仓库的库存数
List<InventoryByDname> toDayInventoryByDName = depositoryService.getToDayInventoryByDName();
// 定义线程
ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size());
// 结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
// 每天各仓库库存数目 public GetBarChartData(Map<String, Integer> depositoryAllNameAndId, String type) {
Map<Object, Object> show_data = new HashMap<>(); this.depositoryAllNameAndId = depositoryAllNameAndId;
while (it.hasNext()) { this.type = type;
Object next = it.next();
getInventoryByDate getApplicationRecordByDate = new getInventoryByDate(next.toString(), days, depositoryAllNameAndId, toDayInventoryByDName);
Future<Object> future = completionService.submit(getApplicationRecordByDate);
futureList.add(future);
} }
for (int i = 0; i < depositoryAllNameAndId.size(); i++) { @Override
Object result = null; public Object call() throws Exception {
try { Map<Object, Object> lineChartData = getLineChartData(depositoryAllNameAndId, type, "bar");
result = completionService.take().get(); Map<String, Object> result = new HashMap<>();
} catch (InterruptedException | ExecutionException e) { if ("1".equals(type)) {
e.printStackTrace(); // 如果是入库
result.put("in", lineChartData);
} else if ("2".equals(type)) {
// 如果是出库
result.put("out", lineChartData);
}
return result;
} }
show_data.putAll((Map<?, ?>) result);
} }
return show_data; /**
* 根据日期获取出入库的数量(用于柱状图)
*/
@Data
class getBarChartDataForApplicationRecord implements Callable<Object> {
String key;
List<Long> days;
Map<String, Integer> depositoryAllNameAndId;
String type;
getBarChartDataForApplicationRecord(String type, String key, List<Long> days, Map<String, Integer> depositoryAllNameAndId) {
this.key = key;
this.depositoryAllNameAndId = depositoryAllNameAndId;
this.days = days;
this.type = type;
}
@Override
public Object call() throws Exception {
Map<Integer, Object> result = new HashMap<>();
Map<String, Object> map = new HashMap<>();
map.put("type", "bar");
Map<String, Object> emphasisItem = new HashMap<>();
emphasisItem.put("focus", "series");
map.put("emphasis", emphasisItem);
Map<String, Object> labelItem = new HashMap<>();
labelItem.put("show", true);
labelItem.put("position", "inside");
map.put("label", labelItem);
if ("1".equals(type)) {
map.put("name", "入库");
} else {
map.put("name", "出库");
} }
int i;
List<Double> drCountbyDrName = new ArrayList<>();
Integer val = depositoryAllNameAndId.get(key);
for (i = days.size() - 1; i > 0; i--) {
// 遍历 Map并计算各仓库的入库数
// 获取一段时间内的库存额度
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val);
if ("2".equals(type)) {
depositoryRecordByDate1 = -depositoryRecordByDate1;
}
drCountbyDrName.add(depositoryRecordByDate1);
}
map.put("data", drCountbyDrName);
result.put(val, map);
return result;
}
}
/** /**
* 根据日期获取各仓库库存的数量 * 根据日期获取各仓库库存的数量

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

@ -564,7 +564,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
e.printStackTrace(); e.printStackTrace();
} }
countForToday += ObjectFormatUtil.toDouble(((Map<String, Object>) o).get("count")); countForToday += ObjectFormatUtil.toDouble(((Map<String, Object>) o).get("count"));
priceForToday += Double.parseDouble(((Map<String, Object>) o).get("price").toString()); priceForToday += ObjectFormatUtil.toDouble(((Map<String, Object>) o).get("price"));
} }
} }
if (yesterdaySize > 0) { if (yesterdaySize > 0) {
@ -590,8 +590,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
} catch (ExecutionException e) { } catch (ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
} }
countForYesterday += ObjectFormatUtil.toInteger(((Map<String, Object>) o).get("count")); countForYesterday += ObjectFormatUtil.toDouble(((Map<String, Object>) o).get("count"));
priceForYesterday += Double.parseDouble(((Map<String, Object>) o).get("price").toString()); priceForYesterday += ObjectFormatUtil.toDouble(((Map<String, Object>) o).get("price"));
} }
} }
// 设置今天的额度 // 设置今天的额度

3
src/main/resources/templates/pages/application/application-in.html

@ -728,14 +728,13 @@
contentType: "application/json;charset=utf-8", contentType: "application/json;charset=utf-8",
success: function (d) { success: function (d) {
var d = d.data; var d = d.data;
console.log(materialId)
var idNumber = materialId.name.split("mid")[1]; var idNumber = materialId.name.split("mid")[1];
if (d == null) { if (d == null) {
layer.msg("没有该编码,请确认是否输入正确", { layer.msg("没有该编码,请确认是否输入正确", {
icon: 0, icon: 0,
time: 500 time: 500
}, function () { }, function () {
layer.close(loading2) layer.close(loading2);
materialName.value = ""; materialName.value = "";
materialId.value = ""; materialId.value = "";
obj.value = ""; obj.value = "";

3
src/main/resources/templates/pages/chart/chart-in_mobile.html

@ -191,6 +191,9 @@
yAxis: { yAxis: {
type: 'value' type: 'value'
}, },
tooltip:{
trigger:"axis",
},
series: [] series: []
}; };

3
src/main/resources/templates/pages/chart/chart-out_mobile.html

@ -189,6 +189,9 @@
yAxis: { yAxis: {
type: 'value' type: 'value'
}, },
tooltip:{
trigger:"axis",
},
series: [] series: []
}; };

88
src/main/resources/templates/pages/chart/chart-stock_mobile.html

@ -46,7 +46,7 @@
<button class="layui-btn" lay-submit lay-filter="lastWeek"> <button class="layui-btn" lay-submit lay-filter="lastWeek">
&emsp;上周&emsp; &emsp;上周&emsp;
</button> </button>
<select id="selectDepositoryForChart" class="form-control"> <select id="selectDepositoryForLineChart" class="form-control">
</select> </select>
<div id="echarts-line" style="background-color:#ffffff;padding: 10px;height: 400px"> <div id="echarts-line" style="background-color:#ffffff;padding: 10px;height: 400px">
@ -61,6 +61,17 @@
</div> </div>
</div> </div>
<div class="layui-colla-item">
<h2 class="layui-colla-title">出入库对比</h2>
<div class="layui-colla-content layui-show">
<select id="selectDepositoryForBarChart" class="form-control">
</select>
<div id="echarts-bar-chart" style="background-color:#ffffff;padding: 10px;height:400px;"></div>
</div>
</div>
</div> </div>
</div> </div>
@ -133,8 +144,10 @@
let LineChartData = {}; let LineChartData = {};
let inBarChartData = {};
let outBarChartData = {};
// 柱状图 // 面积
var echartLineChart = echarts.init(document.getElementById('echarts-line')); var echartLineChart = echarts.init(document.getElementById('echarts-line'));
var optionLineChart = { var optionLineChart = {
xAxis: { xAxis: {
@ -145,11 +158,47 @@
yAxis: { yAxis: {
type: 'value' type: 'value'
}, },
tooltip:{
trigger:"axis",
},
series: [] series: []
}; };
// 柱状图
var echartBarChart = echarts.init(document.getElementById('echarts-bar-chart'));
var optionBarChart = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
data: []
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'value'
}
],
yAxis: [
{
type: 'category',
axisTick: {
show: false
},
data: []
}
],
series: []
};
//动态加载相关数据 //动态加载相关数据
$.ajax({ $.ajax({
@ -175,18 +224,31 @@
let keys = Object.keys(depositoryItem); let keys = Object.keys(depositoryItem);
for (let i = 0; i < keys.length; i++) { for (let i = 0; i < keys.length; i++) {
let key = keys[i]; let key = keys[i];
$("#selectDepositoryForChart").append(new Option(key,depositoryItem[key])); $("#selectDepositoryForLineChart").append(new Option(key, depositoryItem[key]));
$("#selectDepositoryForBarChart").append(new Option(key, depositoryItem[key]));
} }
let depositoryKey = depositoryItem[keys[0]];
let week = data.depository_data.week;
optionSunburstChart.series.data =data.depository_data.sunburstChartData; optionSunburstChart.series.data = data.depository_data.sunburstChartData;
echartSunburstChart.setOption(optionSunburstChart); echartSunburstChart.setOption(optionSunburstChart);
LineChartData = data.depository_data.lineChartData; LineChartData = data.depository_data.lineChartData;
optionLineChart.series = LineChartData[depositoryItem[keys[0]]]; optionLineChart.series = LineChartData[depositoryKey];
optionLineChart.xAxis.data = data.depository_data.week; optionLineChart.xAxis.data = week;
echartLineChart.setOption(optionLineChart); echartLineChart.setOption(optionLineChart);
optionBarChart.legend.data = ["入库","出库"];
optionBarChart.yAxis[0].data = week;
inBarChartData = data.depository_data.barChartData["in"];
outBarChartData = data.depository_data.barChartData["out"];
optionBarChart.series=[inBarChartData[depositoryKey],outBarChartData[depositoryKey]];
echartBarChart.setOption(optionBarChart)
} }
} }
@ -210,7 +272,7 @@
success: function (result) { success: function (result) {
layer.close(this.layerIndex); layer.close(this.layerIndex);
LineChartData = result.data; LineChartData = result.data;
let value = $("#selectDepositoryForChart").val(); let value = $("#selectDepositoryForLineChart").val();
optionLineChart.series = LineChartData[value]; optionLineChart.series = LineChartData[value];
echartLineChart.setOption(optionLineChart); echartLineChart.setOption(optionLineChart);
} }
@ -234,20 +296,26 @@
success: function (result) { success: function (result) {
layer.close(this.layerIndex); layer.close(this.layerIndex);
LineChartData = result.data; LineChartData = result.data;
let value = $("#selectDepositoryForChart").val(); let value = $("#selectDepositoryForLineChart").val();
optionLineChart.series = LineChartData[value]; optionLineChart.series = LineChartData[value];
echartLineChart.setOption(optionLineChart); echartLineChart.setOption(optionLineChart);
} }
}) })
}); });
$('#selectDepositoryForChart').on('change', function (obj) { $('#selectDepositoryForLineChart').on('change', function (obj) {
let value = obj.target.value; let value = obj.target.value;
optionLineChart.series = LineChartData[value]; optionLineChart.series = LineChartData[value];
echartLineChart.setOption(optionLineChart); echartLineChart.setOption(optionLineChart);
}); });
$('#selectDepositoryForBarChart').on('change', function (obj) {
let value = obj.target.value;
optionBarChart.series=[inBarChartData[value],outBarChartData[value]];
echartBarChart.setOption(optionBarChart);
});
}); });

2
src/main/resources/templates/pages/material/selectDepositoryByCard.html

@ -53,8 +53,6 @@
// 物料查询跳转入库 // 物料查询跳转入库
depositoryChildren = windowParent.childNodes[15]; depositoryChildren = windowParent.childNodes[15];
} }
console.log(windowParent.childNodes)
console.log(depositoryChildren)
}else{ }else{
depositoryChildren = windowParent.childNodes[11]; depositoryChildren = windowParent.childNodes[11];
} }

4
src/main/resources/templates/pages/user/login.html

@ -298,9 +298,7 @@
$("#login_panle").hide(); $("#login_panle").hide();
}) })
$('body').on('click', '[data-refresh]', function () {
location.reload();
})
// 卸载 // 卸载

245
src/test/java/com/dreamchaser/depository_manage/BarChartTest.java

@ -0,0 +1,245 @@
package com.dreamchaser.depository_manage;
import com.alibaba.fastjson.JSONObject;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.service.DepositoryRecordService;
import com.dreamchaser.depository_manage.service.DepositoryService;
import com.dreamchaser.depository_manage.service.MaterialService;
import com.dreamchaser.depository_manage.service.MaterialTypeService;
import com.dreamchaser.depository_manage.utils.DateUtil;
import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil;
import lombok.Data;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.*;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
public class BarChartTest {
@Autowired
MaterialTypeService materialTypeService;
@Autowired
DepositoryRecordService depositoryRecordService;
@Autowired
MaterialService materialService;
@Autowired
DepositoryService depositoryService;
/**
* 获取本月之前的月份
*
* @return
*/
public static Map<String, Object> getPreviousMonth() {
Calendar instance = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
Map<String, Object> source = new HashMap<>();
List<Object> sourceList = new ArrayList<>();
int month = instance.get(Calendar.MONTH) + 1;
// 获取下个月
instance.add(Calendar.MONTH, 1);
Long nextMonth = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime()));
ArrayList<Object> months = new ArrayList<>();
months.add(nextMonth);
instance.add(Calendar.MONTH, -1);
while (month > 0) {
instance.set(Calendar.MONTH, month);
instance.set(Calendar.DAY_OF_MONTH, -1);
source.put("month", month + "月");
months.add(DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())));
month--;
sourceList.add(((HashMap<String, Object>) source).clone());
}
instance.set(Calendar.MONTH, month);
instance.add(Calendar.MONTH, 1);
Map<String, Object> map = new HashMap<>();
map.put("months", months);
map.put("sourceList", sourceList);
return map;
}
@Test
public void main() {
UserByPort userByPort = LinkInterfaceUtil.FindUserById(87, null);
}
/**
* 用于获取出入库对照柱状图
* @param userByPort 待获取的当前用户
* @return
*/
List<Object> getBarChartData( UserByPort userByPort){
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort);
ExecutorService exs = Executors.newFixedThreadPool(2);
// 结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
Future<Object> submitForIn = completionService.submit(new GetBarChartData(depositoryAllNameAndId, "1"));
Future<Object> submitForOut = completionService.submit(new GetBarChartData(depositoryAllNameAndId, "2"));
futureList.add(submitForOut);
futureList.add(submitForIn);
List<Object> result = new ArrayList<>();
for (int i = 0; i < 2; i++) {
Object obj = null;
try {
obj = completionService.take().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
result.add(obj);
}
return result;
}
/**
* 用于执行柱状图线程
*/
class GetBarChartData implements Callable<Object> {
// 仓库名称与id对应
Map<String, Integer> depositoryAllNameAndId;
// 要查询的类型
String type;
public GetBarChartData(Map<String, Integer> depositoryAllNameAndId, String type) {
this.depositoryAllNameAndId = depositoryAllNameAndId;
this.type = type;
}
@Override
public Object call() throws Exception {
Map<Object, Object> lineChartData = getLineChartData(depositoryAllNameAndId, type);
Map<String,Object> result = new HashMap<>();
if("1".equals(type)){
// 如果是入库
result.put("in",lineChartData);
}else if("2".equals(type)){
// 如果是出库
result.put("out",lineChartData);
}
return result;
}
}
/**
* 获取入库或出库数据
* @param depositoryAllNameAndId 仓库名称与id对应
* @param type 类型1入库2出库
* @return
*/
public Map<Object,Object> getLineChartData(Map<String, Integer> depositoryAllNameAndId, String type) {
// 获取遍历器
Iterator it = depositoryAllNameAndId.keySet().iterator();
//获取获取系统的当前日历对象
Calendar instance = Calendar.getInstance();
// 获取日期
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
int now = instance.get(Calendar.DAY_OF_WEEK) - 1 == 0 ? 7 : instance.get(Calendar.DAY_OF_WEEK) - 1;
List<Long> days = new ArrayList<>(); // 周一至今的每天
instance.add(Calendar.DATE, 1);
days.add(DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())));
instance.add(Calendar.DATE, -1);
days.add(DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())));
while (now - 1 > 0) {
now--;
instance.add(Calendar.DATE, -1);
Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime()));
days.add(format);
}
// 定义线程
ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size());
// 结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
// 每天各仓库入库数目
Map<Object,Object> show_data = new HashMap<>();
while (it.hasNext()) {
Object next = it.next();
getBarChartDataForApplicationRecord getApplicationRecordByDate = new getBarChartDataForApplicationRecord(type, next.toString(), days, depositoryAllNameAndId);
Future<Object> future = completionService.submit(getApplicationRecordByDate);
futureList.add(future);
}
for (int i = 0; i < depositoryAllNameAndId.size(); i++) {
Object result = null;
try {
result = completionService.take().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
show_data.putAll((Map<?, ?>) result);
}
return show_data;
}
/**
* 根据日期获取出入库的数量(用于柱状图)
*/
@Data
class getBarChartDataForApplicationRecord implements Callable<Object> {
String key;
List<Long> days;
Map<String, Integer> depositoryAllNameAndId;
String type;
getBarChartDataForApplicationRecord(String type, String key, List<Long> days, Map<String, Integer> depositoryAllNameAndId) {
this.key = key;
this.depositoryAllNameAndId = depositoryAllNameAndId;
this.days = days;
this.type = type;
}
@Override
public Object call() throws Exception {
Map<Integer, Object> result = new HashMap<>();
Map<String, Object> map = new HashMap<>();
map.put("type", "bar");
Map<String, Object> emphasisItem = new HashMap<>();
emphasisItem.put("focus","series");
map.put("emphasis", emphasisItem);
Map<String, Object> labelItem = new HashMap<>();
labelItem.put("show",true);
labelItem.put("position","inside");
map.put("label", labelItem);
int i;
List<Double> drCountbyDrName = new ArrayList<>();
Integer val = depositoryAllNameAndId.get(key);
for (i = days.size() - 1; i > 0; i--) {
// 遍历 Map并计算各仓库的入库数
// 获取一段时间内的库存额度
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val);
if("2".equals(type)){
depositoryRecordByDate1 = -depositoryRecordByDate1;
}
drCountbyDrName.add(depositoryRecordByDate1);
}
map.put("data", drCountbyDrName);
result.put(val,map);
return result;
}
}
}

33
src/test/java/com/dreamchaser/depository_manage/InventoryLineChartTest.java

@ -81,10 +81,34 @@ public class InventoryLineChartTest {
// 获取柱状图数据 // 获取柱状图数据
public Map<Object, Object> getInventoryLineChartData(Map<String, Integer> depositoryAllNameAndId) { public Map<Object, Object> getInventoryLineChartData(Map<String, Integer> depositoryAllNameAndId) {
// 每天各仓库入库数目
Map<Object, Object> show_data = new HashMap<>();
// 获取当前各仓库的库存数
List<InventoryByDname> toDayInventoryByDName = depositoryService.getToDayInventoryByDName();
// 获取遍历器 // 获取遍历器
Iterator it = depositoryAllNameAndId.keySet().iterator(); Iterator it = depositoryAllNameAndId.keySet().iterator();
//获取获取系统的当前日历对象 //获取获取系统的当前日历对象
Calendar instance = Calendar.getInstance(); Calendar instance = Calendar.getInstance();
int weekDay = instance.get(Calendar.DAY_OF_WEEK);
weekDay = weekDay - 1;
if (weekDay == 1) {
while (it.hasNext()) {
List<Object> objectList = new ArrayList<>();
String key = it.next().toString();
String dname = key.split(",")[0];
Double inventoryByDname = getInventoryByDname(dname, toDayInventoryByDName);
Map<String, Object> map = new HashMap<>();
map.put("type", "line");
Map<String, Object> areaStyleItem = new HashMap<>();
map.put("areaStyle", areaStyleItem);
List<Double> doubleList = new ArrayList<>();
doubleList.add(inventoryByDname);
map.put("data", doubleList);
objectList.add(map);
show_data.put(key,objectList);
}
}else{
// 获取日期 // 获取日期
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
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;
@ -99,17 +123,13 @@ public class InventoryLineChartTest {
Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime())); Long format = DateUtil.DateTimeByDayToTimeStamp(formatter.format(instance.getTime()));
days.add(format); days.add(format);
} }
// 获取当前各仓库的库存数
List<InventoryByDname> toDayInventoryByDName = depositoryService.getToDayInventoryByDName();
// 定义线程 // 定义线程
ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size()); ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size());
// 结果集 // 结果集
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); List<Future<Object>> futureList = new ArrayList<Future<Object>>();
// 1.定义CompletionService // 1.定义CompletionService
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs);
// 每天各仓库入库数目
Map<Object, Object> show_data = new HashMap<>();
while (it.hasNext()) { while (it.hasNext()) {
Object next = it.next(); Object next = it.next();
getInventoryByDate getApplicationRecordByDate = new getInventoryByDate(next.toString(), days, depositoryAllNameAndId, toDayInventoryByDName); getInventoryByDate getApplicationRecordByDate = new getInventoryByDate(next.toString(), days, depositoryAllNameAndId, toDayInventoryByDName);
@ -126,6 +146,9 @@ public class InventoryLineChartTest {
} }
show_data.putAll((Map<?, ?>) result); show_data.putAll((Map<?, ?>) result);
} }
}
return show_data; return show_data;
} }

2
src/test/java/com/dreamchaser/depository_manage/LineChartTest.java

@ -74,7 +74,7 @@ public class LineChartTest {
@Test @Test
public void main() { public void main() {
UserByPort userByPort = LinkInterfaceUtil.FindUserById(1257, null); UserByPort userByPort = LinkInterfaceUtil.FindUserById(87, null);
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort); Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort);
Map<Object, Object> barChartData = getBarChartData(depositoryAllNameAndId, "1"); Map<Object, Object> barChartData = getBarChartData(depositoryAllNameAndId, "1");
System.out.println(JSONObject.toJSONString(barChartData)); System.out.println(JSONObject.toJSONString(barChartData));

44
src/test/java/com/dreamchaser/depository_manage/OtherTest.java

@ -0,0 +1,44 @@
package com.dreamchaser.depository_manage;
import com.alibaba.fastjson.JSONObject;
import com.dreamchaser.depository_manage.config.QyWx_approval_template.Approval_template_approver;
import com.dreamchaser.depository_manage.entity.UserByPort;
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details;
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver;
import com.dreamchaser.depository_manage.service.DepositoryRecordService;
import com.dreamchaser.depository_manage.service.DepositoryService;
import com.dreamchaser.depository_manage.service.MaterialService;
import com.dreamchaser.depository_manage.service.MaterialTypeService;
import com.dreamchaser.depository_manage.utils.DateUtil;
import com.dreamchaser.depository_manage.utils.LinkInterfaceUtil;
import lombok.Data;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.*;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
public class OtherTest {
@Autowired
DepositoryRecordService depositoryRecordService;
@Test
public void main() {
UserByPort userByPort = LinkInterfaceUtil.FindUserById(87, null);
ApprovalInfo_Details approvalInfo = new ApprovalInfo_Details();
ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver();
approver.setUserId("PangFuZhen");
approvalInfo.setApprover(approver);
depositoryRecordService.reviewByQyWxApprovalIn("[8]",approvalInfo,"42156e781cdc727e7d5deac872be45a9","2","202304240010");
}
}
Loading…
Cancel
Save