|
|
|
@ -14,6 +14,7 @@ import com.dreamchaser.depository_manage.utils.CrudUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.HttpUtils; |
|
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
|
import lombok.Data; |
|
|
|
import org.apache.http.protocol.HTTP; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
@ -101,8 +102,8 @@ public class DepositoryController { |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String, Object> getBeforeInventoryByDName(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort user) { |
|
|
|
List<Double> result = new ArrayList<>(); |
|
|
|
public Map<String, Object> getBeforeInventoryByDName(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort user) { |
|
|
|
List<Integer> result = new ArrayList<>(); |
|
|
|
List<Long> days = getLastTimeInterval(); |
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user); |
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
@ -112,24 +113,24 @@ public class DepositoryController { |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
Double thisDayInventory = 0.0; |
|
|
|
Integer thisDayInventory = 0; |
|
|
|
// 本周周一的总量
|
|
|
|
thisDayInventory = ((List<Double>) thisWeekInventoryByDName.get(key.toString())).get(0); |
|
|
|
thisDayInventory = ((List<Integer>) thisWeekInventoryByDName.get(key.toString())).get(0); |
|
|
|
result.add(thisDayInventory); |
|
|
|
int j = 0; |
|
|
|
for (i = days.size() - 1; i > 0; i--) { |
|
|
|
// 遍历 Map并计算各仓库的入库数
|
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的入库额度
|
|
|
|
Double depositoryRecordByDateByIn1 = depositoryRecordService.findApplicationInRecordByDate(days.get(i), days.get(i - 1), val); |
|
|
|
Integer depositoryRecordByDateByIn1 = depositoryRecordService.findApplicationInRecordByDate(days.get(i), days.get(i - 1), val); |
|
|
|
// 获取一段时间内的出库库额度
|
|
|
|
Double depositoryRecordByDateByOut1 = depositoryRecordService.findApplicationOutRecordByDate(days.get(i), days.get(i - 1), val); |
|
|
|
Double wareHouseCount1 = result.get(j++) - depositoryRecordByDateByIn1 + depositoryRecordByDateByOut1; |
|
|
|
Integer depositoryRecordByDateByOut1 = depositoryRecordService.findApplicationOutRecordByDate(days.get(i), days.get(i - 1), val); |
|
|
|
Integer wareHouseCount1 = result.get(j++) - depositoryRecordByDateByIn1 + depositoryRecordByDateByOut1; |
|
|
|
result.add(wareHouseCount1); |
|
|
|
} |
|
|
|
result.remove(0); |
|
|
|
Collections.reverse(result); |
|
|
|
map.put(key.toString(), ((ArrayList<Double>) result).clone()); |
|
|
|
map.put(key.toString(), ((ArrayList<Integer>) result).clone()); |
|
|
|
result.clear(); |
|
|
|
} |
|
|
|
return map; |
|
|
|
@ -142,7 +143,7 @@ public class DepositoryController { |
|
|
|
* @param depositoryRecordService |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String, Object> getThisWeekInventoryByDName(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort user) { |
|
|
|
public Map<String, Object> getThisWeekInventoryByDName(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort user) { |
|
|
|
Calendar instance = Calendar.getInstance(); |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
int weekDay = instance.get(Calendar.DAY_OF_WEEK); |
|
|
|
@ -151,17 +152,20 @@ public class DepositoryController { |
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(user); |
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
//result用来接收每个仓库每天的库存
|
|
|
|
List<Double> result = new ArrayList<>(); |
|
|
|
List<Integer> result = new ArrayList<>(); |
|
|
|
// map用来存储仓库与库存的映射
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
// 只获取当天
|
|
|
|
List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); |
|
|
|
System.out.println("当前仓库中的库存记录为:"+JSONObject.toJSONString(toDayInventoryByDNameTest)); |
|
|
|
if (weekDay == 1) { |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
result.add(toDayInventoryByDName); |
|
|
|
map.put(key.toString(), ((ArrayList<Double>) result).clone()); |
|
|
|
String key = it.next().toString(); |
|
|
|
String dname = key.split(",")[0]; |
|
|
|
Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); |
|
|
|
result.add(inventoryByDname); |
|
|
|
map.put(key, ((ArrayList<Integer>) result).clone()); |
|
|
|
result.clear(); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -177,18 +181,23 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
String key = it.next().toString(); |
|
|
|
int j = 0; |
|
|
|
|
|
|
|
// 获取今天容量
|
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
result.add(toDayInventoryByDName); |
|
|
|
String dname = key.split(",")[0]; |
|
|
|
Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); |
|
|
|
result.add(inventoryByDname); |
|
|
|
// 判断当天是否有出入口记录
|
|
|
|
System.out.println("当前进行运算的仓库:"+key+"此时的库存为"+inventoryByDname); |
|
|
|
|
|
|
|
Calendar IsInOut = Calendar.getInstance(); |
|
|
|
Long start = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(IsInOut.getTime())); |
|
|
|
IsInOut.add(Calendar.DATE, 1); |
|
|
|
Long end = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(IsInOut.getTime())); |
|
|
|
Double inCount = depositoryRecordService.findApplicationInRecordByDate(end, start, null); |
|
|
|
Double OutCount = depositoryRecordService.findApplicationOutRecordByDate(end, start, null); |
|
|
|
// 判断今天是否有出入库记录
|
|
|
|
Integer inCount = depositoryRecordService.findApplicationInRecordByDate(end, start, null); |
|
|
|
Integer OutCount = depositoryRecordService.findApplicationOutRecordByDate(end, start, null); |
|
|
|
if (inCount > 0 || OutCount > 0) { |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
@ -199,26 +208,27 @@ public class DepositoryController { |
|
|
|
break; |
|
|
|
} |
|
|
|
// 当前日期额度
|
|
|
|
Double aDouble = result.get(j++); |
|
|
|
Integer aDouble = result.get(j++); |
|
|
|
// 获取当前仓库
|
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 如果今天有出入库记录
|
|
|
|
if (flag) { |
|
|
|
Double inRecordByDate = depositoryRecordService.findApplicationInRecordByDate(end, start, val); |
|
|
|
Double OutRecordByDate = depositoryRecordService.findApplicationOutRecordByDate(end, start, val); |
|
|
|
Integer inRecordByDate = depositoryRecordService.findApplicationInRecordByDate(end, start, val); |
|
|
|
Integer OutRecordByDate = depositoryRecordService.findApplicationOutRecordByDate(end, start, val); |
|
|
|
aDouble = aDouble - inRecordByDate + OutRecordByDate; |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
// 获取一段时间内的入库额度
|
|
|
|
//测试
|
|
|
|
Double depositoryRecordByDateByIn1 = depositoryRecordService.findApplicationInRecordByDate(days.get(i), days.get(i + 1), val); |
|
|
|
Integer depositoryRecordByDateByIn1 = depositoryRecordService.findApplicationInRecordByDate(days.get(i), days.get(i + 1), val); |
|
|
|
// 获取一段时间内的出库额度
|
|
|
|
Double depositoryRecordByDateByOut1 = depositoryRecordService.findApplicationOutRecordByDate(days.get(i), days.get(i + 1), val); |
|
|
|
Double warehouserCount1 = aDouble - depositoryRecordByDateByIn1 + depositoryRecordByDateByOut1; |
|
|
|
Integer depositoryRecordByDateByOut1 = depositoryRecordService.findApplicationOutRecordByDate(days.get(i), days.get(i + 1), val); |
|
|
|
Integer warehouserCount1 = (int)aDouble - depositoryRecordByDateByIn1 + depositoryRecordByDateByOut1; |
|
|
|
result.add(warehouserCount1); |
|
|
|
} |
|
|
|
System.out.println("当前仓库本周的库存"+result); |
|
|
|
Collections.reverse(result); |
|
|
|
map.put(key.toString(), ((ArrayList<Double>) result).clone()); |
|
|
|
map.put(key.toString(), ((ArrayList<Integer>) result).clone()); |
|
|
|
result.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -232,7 +242,7 @@ public class DepositoryController { |
|
|
|
* @param depositoryRecordService |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static List<Object> getBeforeInventoryByMonth(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort userByPort) { |
|
|
|
public List<Object> getBeforeInventoryByMonth(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort userByPort) { |
|
|
|
List<Depository> depositoryAll = depositoryService.findDepositoryByAdminorgAndUser(userByPort); |
|
|
|
// 获取该用户管理的仓库
|
|
|
|
Map<String, Object> previousMonth = getPreviousMonth(); |
|
|
|
@ -242,13 +252,15 @@ public class DepositoryController { |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
instance.add(Calendar.MONTH, 1); |
|
|
|
instance.set(Calendar.DATE, 1); |
|
|
|
List<Double> result = new ArrayList<>(); |
|
|
|
List<Integer> result = new ArrayList<>(); |
|
|
|
String month = formatter.format(instance.getTime()); |
|
|
|
List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); |
|
|
|
for (int i = 0; i < depositoryAll.size(); i++) { |
|
|
|
result.add(depositoryService.getToDayInventoryByDName(depositoryAll.get(i).getDname())); |
|
|
|
((Map<String, Object>) sourceList.get(0)).put(depositoryAll.get(i).getDname(), result.get(i)); |
|
|
|
String dname = depositoryAll.get(i).getDname(); |
|
|
|
Integer todayDepositoryInventory = getInventoryByDname(dname,toDayInventoryByDNameTest); |
|
|
|
result.add(todayDepositoryInventory); |
|
|
|
((Map<String, Object>) sourceList.get(0)).put(dname, result.get(i)); |
|
|
|
} |
|
|
|
|
|
|
|
for (int num = 0; num < months.size() - 1; num++) { |
|
|
|
int k = 0; |
|
|
|
for (int j = 0; j < depositoryAll.size(); j++) { |
|
|
|
@ -275,7 +287,7 @@ public class DepositoryController { |
|
|
|
Integer wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); |
|
|
|
// 获取当前月库存容量
|
|
|
|
// 测试
|
|
|
|
Double wareHouseCount1 = result.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; |
|
|
|
Integer wareHouseCount1 = result.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; |
|
|
|
result.add(wareHouseCount1); |
|
|
|
((Map<String, Object>) sourceList.get(num)).put(depositoryAll.get(j).getDname(), wareHouseCount1); |
|
|
|
} |
|
|
|
@ -283,9 +295,11 @@ public class DepositoryController { |
|
|
|
result.remove(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < depositoryAll.size(); i++) { |
|
|
|
((Map<String, Object>) sourceList.get(0)).put(depositoryAll.get(i).getDname(), depositoryService.getToDayInventoryByDName(depositoryAll.get(i).getDname())); |
|
|
|
String dname = depositoryAll.get(i).getDname(); |
|
|
|
Integer todayDepositoryInventory = getInventoryByDname(dname,toDayInventoryByDNameTest); |
|
|
|
result.add(todayDepositoryInventory); |
|
|
|
((Map<String, Object>) sourceList.get(0)).put(dname, result.get(i)); |
|
|
|
} |
|
|
|
List<String> barSource = new ArrayList<>(); |
|
|
|
barSource.add("month"); |
|
|
|
@ -296,6 +310,22 @@ public class DepositoryController { |
|
|
|
return sourceList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取当前仓库下的库存 |
|
|
|
* @param dname |
|
|
|
* @param list |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public Integer getInventoryByDname(String dname,List<InventoryByDname> list){ |
|
|
|
for (InventoryByDname inventoryByDname : list) { |
|
|
|
if (dname.equals(inventoryByDname.getDname())) { |
|
|
|
return inventoryByDname.getInventory(); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取之前个月的库存给地图数据 |
|
|
|
* |
|
|
|
@ -303,7 +333,7 @@ public class DepositoryController { |
|
|
|
* @param depositoryRecordService |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String, Object> getBeforeInventoryOnMap(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort userByPort) { |
|
|
|
public Map<String, Object> getBeforeInventoryOnMap(DepositoryService depositoryService, DepositoryRecordService depositoryRecordService, UserByPort userByPort) { |
|
|
|
// 中国地图数据
|
|
|
|
// ['product', '3月', '4月', '5月', '6月', '7月', '8月'],
|
|
|
|
// ['电子产品类', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
|
|
|
|
@ -318,16 +348,14 @@ public class DepositoryController { |
|
|
|
for (int i = sourceList.size() - 1; i >= 0; i--) { |
|
|
|
title.add(((Map<String, Object>) sourceList.get(i)).get("month")); |
|
|
|
} |
|
|
|
Calendar instance1 = Calendar.getInstance(); |
|
|
|
instance1.add(Calendar.MONTH, 1); |
|
|
|
instance1.set(Calendar.DATE, 1); |
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String month = formatter.format(instance1.getTime()); |
|
|
|
mapDataList.add(title); |
|
|
|
List<InventoryByDname> toDayInventoryByDNameTest = depositoryService.getToDayInventoryByDNameTest(); |
|
|
|
for (int i = 0; i < depositoryAll.size(); i++) { |
|
|
|
List<Object> productData = new ArrayList<>(); |
|
|
|
productData.add(depositoryAll.get(i).getDname()); |
|
|
|
productData.add(depositoryService.getToDayInventoryByDName(depositoryAll.get(i).getDname())); |
|
|
|
String dname = depositoryAll.get(i).getDname(); |
|
|
|
productData.add(dname); |
|
|
|
Integer inventoryByDname = getInventoryByDname(dname, toDayInventoryByDNameTest); |
|
|
|
productData.add(inventoryByDname); |
|
|
|
int k = 1; |
|
|
|
for (int j = 0; j < months.size() - 1; j++) { |
|
|
|
Map<String, Object> parmIn = new HashMap<>(); |
|
|
|
@ -348,7 +376,7 @@ public class DepositoryController { |
|
|
|
// 获取某个月某物料出库总额
|
|
|
|
// 测试
|
|
|
|
Integer wareHouseOutCountByMonth1 = depositoryRecordService.findMaterialCountByMonth2(parmOut); |
|
|
|
Double wareHouseCount1 = (Double) productData.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; |
|
|
|
Integer wareHouseCount1 = (int)productData.get(k++) - wareHouseInCountByMonth1 + wareHouseOutCountByMonth1; |
|
|
|
productData.add(wareHouseCount1); |
|
|
|
} |
|
|
|
List<Object> result = new ArrayList<>(); |
|
|
|
@ -363,7 +391,6 @@ public class DepositoryController { |
|
|
|
return mapData; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询仓库 |
|
|
|
* |
|
|
|
@ -722,14 +749,14 @@ public class DepositoryController { |
|
|
|
List<String> depositoryName = new ArrayList<>(); |
|
|
|
|
|
|
|
// 各仓库对应入库数目
|
|
|
|
Map<String, Double> yesterdayData = new HashMap<>(); |
|
|
|
Map<String, Integer> yesterdayData = new HashMap<>(); |
|
|
|
// 获取昨天数据标志位
|
|
|
|
boolean flag = true; |
|
|
|
|
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
List<Long> days = getLastTimeInterval(); |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
List<Integer> drCountbyDrName = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
while (it.hasNext()) { |
|
|
|
@ -743,14 +770,14 @@ public class DepositoryController { |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
// 测试
|
|
|
|
Double depositoryRecordByDateAndType1 = depositoryRecordService.findApplicationRecordByDate(days.get(i), days.get(i - 1), Integer.parseInt(type), val); |
|
|
|
Integer depositoryRecordByDateAndType1 = depositoryRecordService.findApplicationRecordByDate(days.get(i), days.get(i - 1), Integer.parseInt(type), val); |
|
|
|
drCountbyDrName.add(depositoryRecordByDateAndType1); |
|
|
|
if (i == 2 && flag) { |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDateAndType1); |
|
|
|
} |
|
|
|
} |
|
|
|
Collections.reverse(drCountbyDrName); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); |
|
|
|
drCountbyDrName.clear(); |
|
|
|
} |
|
|
|
Map<String, Object> depository_data = new HashMap<>(); |
|
|
|
@ -795,7 +822,7 @@ public class DepositoryController { |
|
|
|
// 仓库名称列表
|
|
|
|
List<String> depositoryName = new ArrayList<>(); |
|
|
|
// 各仓库对应入库数目
|
|
|
|
Map<String, Double> yesterdayData = new HashMap<>(); |
|
|
|
Map<String, Integer> yesterdayData = new HashMap<>(); |
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
// 各仓库当前库存数目
|
|
|
|
@ -822,13 +849,13 @@ public class DepositoryController { |
|
|
|
depositoryName.add(key.toString()); |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); |
|
|
|
Integer toDayInventoryByDName = ObjectFormatUtil.toInteger(depositoryService.getToDayInventoryByDName(key.toString())); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
List<Integer> drCountbyDrName = new ArrayList<>(); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
int now = instance.get(Calendar.DAY_OF_WEEK) - 1; |
|
|
|
@ -843,7 +870,7 @@ public class DepositoryController { |
|
|
|
Long format = DateUtil.DateTimeByMonthToTimeStamp(formatter.format(instance.getTime())); |
|
|
|
days.add(format); |
|
|
|
} |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
List<Integer> drCountbyDrName = new ArrayList<>(); |
|
|
|
while (it.hasNext()) { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
@ -857,13 +884,13 @@ public class DepositoryController { |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); |
|
|
|
Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
if (i == 2 && flag) { |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
} |
|
|
|
} |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); |
|
|
|
drCountbyDrName.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -915,7 +942,7 @@ public class DepositoryController { |
|
|
|
// 仓库名称列表
|
|
|
|
List<String> depositoryName = new ArrayList<>(); |
|
|
|
// 各仓库对应入库数目
|
|
|
|
Map<String, Double> yesterdayData = new HashMap<>(); |
|
|
|
Map<String, Integer> yesterdayData = new HashMap<>(); |
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
// 各仓库当前库存数目
|
|
|
|
@ -947,13 +974,13 @@ public class DepositoryController { |
|
|
|
depositoryName.add(key.toString()); |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(tomorrow, now, Integer.parseInt(type), val); |
|
|
|
Integer toDayInventoryByDName =ObjectFormatUtil.toInteger(depositoryService.getToDayInventoryByDName(key.toString())); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
List<Integer> drCountbyDrName = new ArrayList<>(); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
show_data.put(key.toString(), ((ArrayList<Integer>) drCountbyDrName).clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
@ -1005,10 +1032,45 @@ public class DepositoryController { |
|
|
|
if ("0".equals(type)) { |
|
|
|
// 如果是获取库存
|
|
|
|
depository_data.put("todayInventory", todayInventory); |
|
|
|
depository_data.put("sourceListByMonth", getBeforeInventoryByMonth(depositoryService, depositoryRecordService, userByPort)); |
|
|
|
depository_data.put("ThisWeekInventory", getThisWeekInventoryByDName(depositoryService, depositoryRecordService, userByPort)); |
|
|
|
depository_data.put("BeforeInventory", getBeforeInventoryByDName(depositoryService, depositoryRecordService, userByPort)); |
|
|
|
depository_data.put("MapInventory", getBeforeInventoryOnMap(depositoryService, depositoryRecordService, userByPort)); |
|
|
|
distributeTasks distributeTasks1 = new distributeTasks(type, 5, userByPort, yesterdayData, depositoryName); |
|
|
|
distributeTasks1.setDepositoryService(depositoryService); |
|
|
|
distributeTasks1.setDepositoryRecordService(depositoryRecordService); |
|
|
|
distributeTasks distributeTasks2 = new distributeTasks(type, 6, userByPort, yesterdayData, depositoryName); |
|
|
|
distributeTasks2.setDepositoryService(depositoryService); |
|
|
|
distributeTasks2.setDepositoryRecordService(depositoryRecordService); |
|
|
|
distributeTasks distributeTasks3 = new distributeTasks(type, 7, userByPort, yesterdayData, depositoryName); |
|
|
|
distributeTasks3.setDepositoryService(depositoryService); |
|
|
|
distributeTasks3.setDepositoryRecordService(depositoryRecordService); |
|
|
|
Future<Object> future1 = completionService.submit(distributeTasks1); |
|
|
|
Future<Object> future2 = completionService.submit(distributeTasks2); |
|
|
|
Future<Object> future3 = completionService.submit(distributeTasks3); |
|
|
|
futureList.add(future1); |
|
|
|
futureList.add(future2); |
|
|
|
futureList.add(future3); |
|
|
|
List<Object> beforeInventoryByMonth = null; |
|
|
|
Map<String, Object> thisWeekInventoryByDName = null; |
|
|
|
Map<String, Object> beforeInventoryOnMap = null; |
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
Object result = null; |
|
|
|
try { |
|
|
|
result = completionService.take().get(); |
|
|
|
} catch (InterruptedException | ExecutionException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
if(beforeInventoryByMonth == null || beforeInventoryByMonth.size() == 0) { |
|
|
|
beforeInventoryByMonth = (List<Object>) ((Map<String, Object>) result).get("sourceListByMonth"); |
|
|
|
} |
|
|
|
if(thisWeekInventoryByDName == null || thisWeekInventoryByDName.size() == 0) { |
|
|
|
thisWeekInventoryByDName = (Map<String, Object>) ((Map<String, Object>) result).get("ThisWeekInventory"); |
|
|
|
} |
|
|
|
if(beforeInventoryOnMap == null || beforeInventoryOnMap.size() == 0){ |
|
|
|
beforeInventoryOnMap = (Map<String, Object>) ((Map<String, Object>) result).get("MapInventory"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
depository_data.put("sourceListByMonth", beforeInventoryByMonth); |
|
|
|
depository_data.put("ThisWeekInventory", thisWeekInventoryByDName); |
|
|
|
depository_data.put("MapInventory", beforeInventoryOnMap); |
|
|
|
} |
|
|
|
else { |
|
|
|
// 如果不是
|
|
|
|
@ -1028,16 +1090,19 @@ public class DepositoryController { |
|
|
|
return resMap; |
|
|
|
} |
|
|
|
|
|
|
|
// 用于
|
|
|
|
// 用于分发任务
|
|
|
|
@Data |
|
|
|
class distributeTasks implements Callable<Object>{ |
|
|
|
|
|
|
|
String type; |
|
|
|
int taskType; |
|
|
|
UserByPort userByPort; |
|
|
|
Map<String,Double> yesterdayData; |
|
|
|
Map<String,Integer> yesterdayData; |
|
|
|
List<String> depositoryName; |
|
|
|
DepositoryService depositoryService; |
|
|
|
DepositoryRecordService depositoryRecordService; |
|
|
|
|
|
|
|
distributeTasks(String type ,int taskType,UserByPort userByPort,Map<String,Double> yesterdayData,List<String> depositoryName){ |
|
|
|
distributeTasks(String type ,int taskType,UserByPort userByPort,Map<String,Integer> yesterdayData,List<String> depositoryName){ |
|
|
|
this.taskType = taskType; |
|
|
|
this.type = type; |
|
|
|
this.userByPort = userByPort; |
|
|
|
@ -1047,7 +1112,7 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
@Override |
|
|
|
public Object call() throws Exception { |
|
|
|
// taskType 1为折线图2为饼图3为柱状图4为中国地图
|
|
|
|
// taskType 1为折线图2为饼图3为柱状图4为中国地图5为库存可视化中的折线图6为库存可视化中中国地图7为库存可视化中柱状图
|
|
|
|
|
|
|
|
Map<String,Object> result = new HashMap<>(); |
|
|
|
if(1 == taskType){ |
|
|
|
@ -1061,6 +1126,15 @@ public class DepositoryController { |
|
|
|
}else if(4 == taskType){ |
|
|
|
Map<String, Object> mapData = getMapData(type); |
|
|
|
result.put("mapData",mapData); |
|
|
|
}else if(5 == taskType){ |
|
|
|
List<Object> beforeInventoryByMonth = getBeforeInventoryByMonth(depositoryService, depositoryRecordService, userByPort); |
|
|
|
result.put("sourceListByMonth",beforeInventoryByMonth); |
|
|
|
}else if(6 == taskType){ |
|
|
|
Map<String, Object> thisWeekInventoryByDName = getThisWeekInventoryByDName(depositoryService, depositoryRecordService, userByPort); |
|
|
|
result.put("ThisWeekInventory",thisWeekInventoryByDName); |
|
|
|
}else if(7 == taskType){ |
|
|
|
Map<String, Object> beforeInventoryOnMap = getBeforeInventoryOnMap(depositoryService, depositoryRecordService, userByPort); |
|
|
|
result.put("MapInventory",beforeInventoryOnMap); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
@ -1068,12 +1142,10 @@ public class DepositoryController { |
|
|
|
|
|
|
|
|
|
|
|
// 用于获取折线图
|
|
|
|
public Map<String,Object> getShowData(String type,UserByPort userByPort,Map<String,Double> yesterdayData,List<String> depositoryName){ |
|
|
|
public Map<String,Object> getShowData(String type,UserByPort userByPort,Map<String,Integer> yesterdayData,List<String> depositoryName){ |
|
|
|
// 获取各仓库名称以及id
|
|
|
|
Map<String, Integer> depositoryAllNameAndId = depositoryService.findDepositoryAllNameAndId(userByPort); |
|
|
|
|
|
|
|
// 各仓库当前库存数目
|
|
|
|
Map<String, Object> todayInventory = new HashMap<>(); |
|
|
|
|
|
|
|
Iterator it = depositoryAllNameAndId.keySet().iterator(); |
|
|
|
|
|
|
|
@ -1095,15 +1167,58 @@ public class DepositoryController { |
|
|
|
days.add(format); |
|
|
|
} |
|
|
|
List<Double> drCountbyDrName = new ArrayList<>(); |
|
|
|
// 获取昨天数据标志位
|
|
|
|
boolean flag = true; |
|
|
|
|
|
|
|
// 定义线程
|
|
|
|
ExecutorService exs = Executors.newFixedThreadPool(depositoryAllNameAndId.size()); |
|
|
|
// 结果集
|
|
|
|
List<Future<Object>> futureList = new ArrayList<Future<Object>>(); |
|
|
|
// 1.定义CompletionService
|
|
|
|
CompletionService<Object> completionService = new ExecutorCompletionService<Object>(exs); |
|
|
|
|
|
|
|
// 每天各仓库入库数目
|
|
|
|
Map<String, Object> show_data = new HashMap<>(); |
|
|
|
while (it.hasNext()) { |
|
|
|
Object next = it.next(); |
|
|
|
getApplicationRecordByDate getApplicationRecordByDate = new getApplicationRecordByDate(type, next, days, depositoryAllNameAndId); |
|
|
|
getApplicationRecordByDate.setShow_data(show_data); |
|
|
|
getApplicationRecordByDate.setDepositoryName(depositoryName); |
|
|
|
getApplicationRecordByDate.setYesterdayData(yesterdayData); |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return show_data; |
|
|
|
} |
|
|
|
|
|
|
|
@Data |
|
|
|
class getApplicationRecordByDate implements Callable<Object>{ |
|
|
|
Object key; |
|
|
|
List<Long> days; |
|
|
|
Map<String, Integer> depositoryAllNameAndId; |
|
|
|
List<String> depositoryName; |
|
|
|
Map<String,Integer> yesterdayData; |
|
|
|
String type; |
|
|
|
Map<String, Object> show_data; |
|
|
|
getApplicationRecordByDate(String type,Object 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 { |
|
|
|
int i; |
|
|
|
Object key = it.next(); |
|
|
|
Double toDayInventoryByDName = depositoryService.getToDayInventoryByDName(key.toString()); |
|
|
|
todayInventory.put(key.toString(), toDayInventoryByDName); |
|
|
|
List<Integer> drCountbyDrName = new ArrayList<>(); |
|
|
|
for (i = days.size() - 1; i > 0; i--) { |
|
|
|
// 遍历 Map并计算各仓库的入库数
|
|
|
|
if (i == days.size() - 1) { |
|
|
|
@ -1111,20 +1226,16 @@ public class DepositoryController { |
|
|
|
} |
|
|
|
Integer val = (Integer) depositoryAllNameAndId.get(key); |
|
|
|
// 获取一段时间内的库存额度
|
|
|
|
|
|
|
|
Double depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); |
|
|
|
Integer depositoryRecordByDate1 = depositoryRecordService.findApplicationRecordByDate(days.get(i - 1), days.get(i), Integer.parseInt(type), val); |
|
|
|
drCountbyDrName.add(depositoryRecordByDate1); |
|
|
|
if (i == 2 && flag) { |
|
|
|
if (i == 2) { |
|
|
|
yesterdayData.put(key.toString(), depositoryRecordByDate1); |
|
|
|
} |
|
|
|
} |
|
|
|
show_data.put(key.toString(), ((ArrayList<Double>) drCountbyDrName).clone()); |
|
|
|
drCountbyDrName.clear(); |
|
|
|
show_data.put(key.toString(),drCountbyDrName); |
|
|
|
return null; |
|
|
|
} |
|
|
|
return show_data; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取本月及之前月份各种类别入/出库总量
|
|
|
|
public List<Object> getSourceList(String type){ |
|
|
|
List<MaterialType> materialTypeAll = materialTypeService.findMaterialTypeNoParent(); |
|
|
|
|