|
|
@@ -12,9 +12,9 @@ import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.Hashtable;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
|
* 平台消息、任务快照
|
|
|
@@ -98,8 +98,15 @@ public class SnapshotController {
|
|
|
@ResponseBody
|
|
|
@ResponseStatus(value = HttpStatus.OK)
|
|
|
public ModelMap getUnreadCount() {
|
|
|
- // Hashtable 防止HashMap的put方法在多线程并发的情况下数据丢失
|
|
|
- final Hashtable<String, Integer> hashtable = new Hashtable<>();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Hashtable 防止HashMap的put方法在多线程并发的情况下数据丢失
|
|
|
+ *
|
|
|
+ * @modify-author hejq
|
|
|
+ * @modify-date 2018-07-28 10:26
|
|
|
+ * @modify-desc Hashtable 已过时,不需要要再使用,采用ConcurrentHashMap编写
|
|
|
+ */
|
|
|
+ final ConcurrentHashMap<String, Integer> hashMap = new ConcurrentHashMap<>();
|
|
|
final User user = SystemSession.getUser();
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
//并行处理
|
|
|
@@ -114,7 +121,7 @@ public class SnapshotController {
|
|
|
for (Object[] objects : list){
|
|
|
count = count + Integer.valueOf(objects[0].toString());
|
|
|
}
|
|
|
- hashtable.put("customer", count);
|
|
|
+ hashMap.put("customer", count);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -128,7 +135,7 @@ public class SnapshotController {
|
|
|
for (Object[] objects : list){
|
|
|
count = count + Integer.valueOf(objects[0].toString());
|
|
|
}
|
|
|
- hashtable.put("vendorPerformanceAssess", count);
|
|
|
+ hashMap.put("vendorPerformanceAssess", count);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -138,7 +145,7 @@ public class SnapshotController {
|
|
|
//客户采购询价
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> map = purchaseInquiryService.getInquiryCount("sale");
|
|
|
- hashtable.put("inquiry", map.containsKey("all")?map.get("all"):0);
|
|
|
+ hashMap.put("inquiry", map.containsKey("all") ? map.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -148,18 +155,9 @@ public class SnapshotController {
|
|
|
//客户模具询价
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = purchaseInquiryMouldService.getInquiryMouldCount("sale");
|
|
|
- hashtable.put("mould", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("mould", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //主动报价
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("quotation", saleQuotationService.getQuotationUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
}).task(new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
@@ -167,7 +165,7 @@ public class SnapshotController {
|
|
|
//客户招标
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = tenderService.getTenderCount("sale");
|
|
|
- hashtable.put("tender", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("tender", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -177,7 +175,7 @@ public class SnapshotController {
|
|
|
//客户采购订单
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = purchaseOrderService.getOrderCount("sale");
|
|
|
- hashtable.put("order", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("order", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -187,7 +185,7 @@ public class SnapshotController {
|
|
|
//客户采购变更单
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> map = purchaseOrderChangeService.getChangeCount("sale");
|
|
|
- hashtable.put("change", map.containsKey("all")?map.get("all"):0);
|
|
|
+ hashMap.put("change", map.containsKey("all") ? map.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -197,24 +195,9 @@ public class SnapshotController {
|
|
|
//客户委外单
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = makeOrderService.getMakeOrderCount("sale");
|
|
|
- hashtable.put("makeOrder", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("makeOrder", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //委外变更单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// int count = 0;
|
|
|
-// List<Object[]> list = makeOrderChangeService.getMakeChangeCount();
|
|
|
-// for (Object[] objects : list){
|
|
|
-// count = count + Integer.valueOf(objects[0].toString());
|
|
|
-// }
|
|
|
-// System.out.println(count);
|
|
|
-// hashtable.put("makeChange", count);
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
}).task(new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
@@ -222,18 +205,9 @@ public class SnapshotController {
|
|
|
//客户发货提醒
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = purchaseNoticeService.getNoticeCount("sale");
|
|
|
- hashtable.put("notice", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("notice", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //发货单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("send", purchaseNoticeService.getSendUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
}).task(new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
@@ -241,81 +215,9 @@ public class SnapshotController {
|
|
|
//客户打样申请
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = purchaseProofingService.getProofingCount("sale");
|
|
|
- hashtable.put("sample", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("sample", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //客户认定单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("approval", purchaseProofingService.getApprovalUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //MRB单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("MRB", purchaseMRBService.getMRBUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //不良品出库单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("badOut", purchaseBadOutService.getBadOutUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //不良品入库单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("badIn", purchaseBadInService.getBadInUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //客户采购验收单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("accept", purchaseAcceptService.getAcceptUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //客户采购验退单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("returns", purchaseReturnService.getReturnUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //客户委外验收单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("makeAccept", makeAcceptService.getAcceptUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //客户委外验退单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("makeReturns", makeReturnService.getReturnUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
}).task(new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
@@ -327,7 +229,7 @@ public class SnapshotController {
|
|
|
for(Object[] objects : list){
|
|
|
count = count + Integer.valueOf(objects[0].toString());
|
|
|
}
|
|
|
- hashtable.put("purcVendor", count);
|
|
|
+ hashMap.put("purcVendor", count);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -337,7 +239,7 @@ public class SnapshotController {
|
|
|
//采购招标
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = tenderService.getTenderCount("purc");
|
|
|
- hashtable.put("tender", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("tender", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -347,7 +249,7 @@ public class SnapshotController {
|
|
|
//采购询价
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> map = purchaseInquiryService.getInquiryCount("purc");
|
|
|
- hashtable.put("purcInquiry", map.containsKey("all")?map.get("all"):0);
|
|
|
+ hashMap.put("purcInquiry", map.containsKey("all") ? map.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
}).task(new Runnable() {
|
|
|
@@ -357,36 +259,9 @@ public class SnapshotController {
|
|
|
//采购订单
|
|
|
SystemSession.setUser(user);
|
|
|
Map<String, Integer> count = purchaseOrderService.getOrderCount("purc");
|
|
|
- hashtable.put("purcOrder", count.containsKey("all")?count.get("all"):0);
|
|
|
+ hashMap.put("purcOrder", count.containsKey("all") ? count.get("all") : 0);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //代采订单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("purcDeputy", deputyOrderService.getPurchaseDeputyUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //委外订单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("purcMakeOrder", makeOrderService.getPurchaseOrderUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //发票
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("apBill", purchaseApBillService.getApBillUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
}).task(new Runnable() {
|
|
|
|
|
|
@Override
|
|
|
@@ -401,20 +276,11 @@ public class SnapshotController {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- hashtable.put("apCheck", count);
|
|
|
+ hashMap.put("apCheck", count);
|
|
|
SystemSession.clear();
|
|
|
}
|
|
|
-// }).task(new Runnable() {
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// //应付对账单
|
|
|
-// SystemSession.setUser(user);
|
|
|
-// hashtable.put("arCheck", saleARCheckService.getArCheckUnreadCount());
|
|
|
-// SystemSession.clear();
|
|
|
-// }
|
|
|
}).run();
|
|
|
- modelMap.addAllAttributes(hashtable);
|
|
|
+ modelMap.addAllAttributes(hashMap);
|
|
|
return modelMap;
|
|
|
}
|
|
|
|