From deb8a2c32ba0cb7a88819b54d720418cdc2f7ebb Mon Sep 17 00:00:00 2001
From: sgj <1442489573@qq.com>
Date: 星期二, 24 三月 2026 16:58:53 +0800
Subject: [PATCH] 粮情报表,数量监测报表,库区回显错误纠正
---
fzzy-igdss-web/src/main/java/com/fzzy/common/manager/CommonManager.java | 265 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 234 insertions(+), 31 deletions(-)
diff --git a/fzzy-igdss-web/src/main/java/com/fzzy/common/manager/CommonManager.java b/fzzy-igdss-web/src/main/java/com/fzzy/common/manager/CommonManager.java
index e99201a..bc79e57 100644
--- a/fzzy-igdss-web/src/main/java/com/fzzy/common/manager/CommonManager.java
+++ b/fzzy-igdss-web/src/main/java/com/fzzy/common/manager/CommonManager.java
@@ -2,20 +2,27 @@
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.constant.DepotType;
+import com.fzzy.igds.data.IgdsBaseParam;
+import com.fzzy.igds.data.InoutParam;
+import com.fzzy.igds.data.MainData;
import com.fzzy.igds.domain.*;
import com.fzzy.igds.service.*;
import com.fzzy.igds.utils.ContextUtil;
+import com.fzzy.igds.utils.DateUtil;
+import com.fzzy.work.service.WorkOrderService;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
-import com.ruoyi.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
+import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.List;
/**
@@ -33,10 +40,8 @@
private DicService dicService;
@Resource
private CoreDeptService coreDeptService;
- @Autowired
- private SecCameraService secCameraService;
@Resource
- private ISysUserService userService;
+ private SecCameraService secCameraService;
@Resource
private ISysDeptService iSysDeptService;
@Resource
@@ -45,6 +50,30 @@
private CoreCompanyService coreCompanyService;
@Resource
private SloganService sloganService;
+ @Resource
+ private WorkOrderService workOrderService;
+ @Resource
+ private InoutRecordService inoutRecordService;
+ @Resource
+ private EventInfoService eventInfoService;
+ @Resource
+ private SnapRecordService snapRecordService;
+ @Resource
+ private GatewaySerService gatewaySerService;
+
+ /**
+ * 鏍规嵁搴撳尯缂栫爜鑾峰彇搴撳尯缃戝叧淇℃伅
+ *
+ * @param deptId
+ * @return
+ */
+ public GatewaySer getGatewaySerByDeptId(String deptId) {
+ if (StringUtils.isBlank(deptId)) {
+ deptId = ContextUtil.subDeptId(null);
+ }
+
+ return gatewaySerService.getCacheSerByDeptId(deptId);
+ }
/**
* 鏍规嵁搴撳尯缂栫爜鑾峰彇搴撳尯涓嬫墍鏈変粨搴撳垪琛�
@@ -59,6 +88,7 @@
/**
* 鑾峰彇搴撳尯楦熺灠鍥�
+ *
* @param deptId
* @return
*/
@@ -72,6 +102,7 @@
/**
* 鍒ゆ柇璺緞涓嬫枃浠舵槸鍚﹀瓨鍦紝涓嶅瓨鍦ㄥ垯缁欓粯璁�
+ *
* @param imgPath
* @param tag
* @return
@@ -98,12 +129,39 @@
* @return
*/
public List<Depot> listDepotByDeptId(String deptId) {
+ try {
+ if (StringUtils.isEmpty(deptId)) {
+ deptId = ContextUtil.subDeptId(null);
+ }
- if (StringUtils.isEmpty(deptId)) {
- deptId = ContextUtil.subDeptId(null);
+ return depotService.getCacheDepotList(ContextUtil.getCompanyId(), deptId);
+
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * 鏍规嵁浠撳簱绫诲瀷鑾峰彇搴撳尯涓嬩粨搴撳垪琛�
+ *
+ * @param deptId
+ * @param depotTypes 绫诲瀷澶氫釜锛岀敤閫楀彿闅斿紑
+ * @return
+ */
+ public List<Depot> listAllDepot(String deptId, String depotTypes) {
+
+ List<Depot> depots = this.listDepotByDeptId(deptId);
+ if (null == depots || depots.isEmpty()) {
+ return null;
}
- return depotService.getCacheDepotList(ContextUtil.getCompanyId(), deptId);
+ List<Depot> result = new ArrayList<>();
+ for (Depot depot : depots) {
+ if (depotTypes.contains(depot.getDepotType())) {
+ result.add(depot);
+ }
+ }
+ return result;
}
/**
@@ -115,13 +173,13 @@
/**
- * 鑾峰彇鍒嗗簱鍒楄〃
+ * 鏍规嵁鍏徃ID鑾峰彇鍏徃涓嬬殑鍒嗗簱鍒楄〃
*
* @author sgj
* @date 2025/12/12
*/
- public List<Dept> listDeptData() {
- return coreDeptService.getDeptData();
+ public List<Dept> listDeptData(String parentId) {
+ return coreDeptService.getDeptByUserType(parentId);
}
/**
@@ -142,27 +200,13 @@
}
/**
- * 鑾峰彇鐢ㄦ埛鍒楄〃
- *
- * @author sgj
- * @date 2025/12/12
- */
- public List<SysUser> listUserData() {
- SysUser user = new SysUser() ;
- user.setCompanyId(ContextUtil.getCompanyId());
- user.setDeptId(Long.valueOf(ContextUtil.subDeptId(null)));
- return userService.selectUserList(user);
- }
-
-
- /**
* 鑾峰彇璁惧鍒楄〃
*
* @author sgj
* @date 2025/12/12
*/
- public List<Camera> listCameraData() {
- return secCameraService.listCamera(ContextUtil.getCompanyId(),ContextUtil.subDeptId(null));
+ public List<Camera> listCameraData() {
+ return secCameraService.listCamera(ContextUtil.getCompanyId(), ContextUtil.subDeptId(null));
}
/**
@@ -171,21 +215,180 @@
* @author sgj
* @date 2025/12/17
*/
- public List<Company> listCompanyData() {
- SysUser user = ContextUtil.getLoginUser();
- return coreCompanyService.listCompany(null, null, user.getDeptId() + "");
+ public List<Company> listCompanyData() {
+ return coreCompanyService.getCompanyByUserType();
}
/**
* 鑾峰彇鍚敤鐨勫ぇ灞忔爣璇�
+ *
* @return
*/
public Slogan getDicSlogan() {
List<Slogan> slogans = sloganService.listData(Constant.YN_Y);
- if(null == slogans || slogans.isEmpty()){
+ if (null == slogans || slogans.isEmpty()) {
return null;
}
return slogans.get(0);
}
+
+
+ /**
+ * 鑾峰彇鍚敤鐨勫ぇ灞忔爣璇�
+ *
+ * @return
+ */
+ public MainData getIndexData(SysUser user) {
+
+ MainData mainData = new MainData();
+
+ //寰呭姙宸ュ崟鏁�
+ Integer orderNum = workOrderService.getTodoNumByUser(user);
+ mainData.setOrderNum(orderNum);
+
+ //缁熻鍑哄叆搴撲俊鎭�
+ Double inSum = 0.0;
+ Double outSum = 0.0;
+ LinkedHashMap<String, Integer> mapWeekInNum = new LinkedHashMap<>();
+ LinkedHashMap<String, Integer> mapWeekOutNum = new LinkedHashMap<>();
+ LinkedHashMap<String, Integer> mapMonthInNum = new LinkedHashMap<>();
+ LinkedHashMap<String, Integer> mapMonthOutNum = new LinkedHashMap<>();
+ LinkedHashMap<String, Integer> mapWeekAiNum = new LinkedHashMap<>();
+ LinkedHashMap<String, Integer> mapWeekSnapNum = new LinkedHashMap<>();
+ LinkedHashMap<String, Double> mapWeekMaizeNum = new LinkedHashMap<>();
+ String key;
+ for (int i = -29; i <= 0; i++) {
+ mapMonthInNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
+ mapMonthOutNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
+ if (i >= -6) {
+ mapWeekInNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
+ mapWeekOutNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
+ mapWeekAiNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
+ mapWeekSnapNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0);
+ mapWeekMaizeNum.put(DateFormatUtils.format(DateUtil.getNewByDay(new Date(), i), "MM-dd"), 0.0);
+ }
+ }
+
+ //杩�7澶〢I浜嬩欢鏁�
+ IgdsBaseParam param = new IgdsBaseParam();
+ param.setDeptId(user.getDeptId() + "");
+ param.setStart(DateUtil.getNewByDay(new Date(), -6));
+ param.setEnd(new Date());
+ List<EventInfo> listEvent = eventInfoService.getListByParam(param);
+ if (null != listEvent && !listEvent.isEmpty()) {
+ mainData.setAiNum(listEvent.size());
+ for (EventInfo event : listEvent) {
+ key = DateFormatUtils.format(event.getTime(), "MM-dd");
+ if (null != mapWeekAiNum.get(key)) {
+ mapWeekAiNum.put(key, mapWeekAiNum.get(key) + 1);
+ }
+ }
+ }
+ for (String mapKey : mapWeekAiNum.keySet()) {
+ mainData.getWeekAiDateList().add(mapKey);
+ mainData.getWeekAiNumList().add(mapWeekAiNum.get(mapKey));
+ }
+
+ //杩�7澶╂姄鎷嶄俊鎭粺璁�
+ List<SnapRecord> listSnap = snapRecordService.getListByParam(param);
+ if (null != listSnap && !listSnap.isEmpty()) {
+ for (SnapRecord snap : listSnap) {
+ key = DateFormatUtils.format(snap.getSnapTime(), "MM-dd");
+ if (null != mapWeekSnapNum.get(key)) {
+ mapWeekSnapNum.put(key, mapWeekSnapNum.get(key) + 1);
+ }
+ }
+ }
+ for (String mapKey : mapWeekSnapNum.keySet()) {
+ mainData.getWeekSnapDateList().add(mapKey);
+ mainData.getWeekSnapNumList().add(mapWeekSnapNum.get(mapKey));
+ }
+ //杩戜竷澶╃帀绫冲嚭搴撲环鏍肩粺璁�
+
+ InoutParam inoutParamOfMaize = new InoutParam();
+ inoutParamOfMaize.setDeptId(user.getDeptId() + "");
+ //绮鍝佺鐜夌背
+ inoutParamOfMaize.setFoodVariety("1120000");
+ inoutParamOfMaize.setType(Constant.TYPE_OUT);
+ inoutParamOfMaize.setStart(DateUtil.getNewByDay(new Date(), -6));
+ inoutParamOfMaize.setEnd(new Date());
+ List<InoutRecord> inoutRecordsOfMaize = inoutRecordService.listInout(inoutParamOfMaize);
+ if (null != inoutRecordsOfMaize && !inoutRecordsOfMaize.isEmpty()) {
+ for (InoutRecord record : inoutRecordsOfMaize) {
+ key = DateFormatUtils.format(record.getRegisterTime(), "MM-dd");
+ if (null != mapWeekMaizeNum.get(key)) {
+ Double nowPrice = mapWeekMaizeNum.get(key);
+ Double newPrice = record.getPrice();
+ if (nowPrice > newPrice || nowPrice == 0) {
+ nowPrice = newPrice;
+ }
+ mapWeekMaizeNum.put(key, nowPrice);
+
+ }
+ }
+ }
+ for (String mapKey : mapWeekMaizeNum.keySet()) {
+ mainData.getWeekMaizeDateList().add(mapKey);
+ mainData.getWeekMaizeNumList().add(mapWeekMaizeNum.get(mapKey));
+ }
+
+ //鏌ヨ杩�30澶╂墍鏈夊嚭鍏ュ簱淇℃伅
+ InoutParam inoutParam = new InoutParam();
+ inoutParam.setDeptId(user.getDeptId() + "");
+ inoutParam.setStart(DateUtil.getNewByDay(new Date(), -29));
+ inoutParam.setEnd(new Date());
+ List<InoutRecord> inoutRecords = inoutRecordService.listInout(inoutParam);
+ if (null != inoutRecords && !inoutRecords.isEmpty()) {
+ for (InoutRecord record : inoutRecords) {
+ key = DateFormatUtils.format(record.getRegisterTime(), "MM-dd");
+ if (Constant.TYPE_IN.equals(record.getType())) {
+ if (null != mapWeekInNum.get(key)) {
+ mapWeekInNum.put(key, mapWeekInNum.get(key) + 1);
+ }
+ if (null != mapMonthInNum.get(key)) {
+ mapMonthInNum.put(key, mapMonthInNum.get(key) + 1);
+ }
+ if (key.equals(DateFormatUtils.format(new Date(), "MM-dd"))) {
+ mainData.setInNumDay(mainData.getInNumDay() + 1);
+ inSum += record.getRecordWeight();
+ }
+ }
+ if (Constant.TYPE_OUT.equals(record.getType())) {
+ if (null != mapWeekOutNum.get(key)) {
+ mapWeekOutNum.put(key, mapWeekOutNum.get(key) + 1);
+ }
+ if (null != mapMonthOutNum.get(key)) {
+ mapMonthOutNum.put(key, mapMonthOutNum.get(key) + 1);
+ }
+ if (key.equals(DateFormatUtils.format(new Date(), "MM-dd"))) {
+ mainData.setOutNumDay(mainData.getOutNumDay() + 1);
+ outSum += record.getRecordWeight();
+ }
+ }
+ }
+ }
+
+ for (String mapKey : mapWeekInNum.keySet()) {
+ mainData.getWeekDateList().add(mapKey);
+ mainData.getWeekInNumList().add(mapWeekInNum.get(mapKey));
+ }
+
+ for (String mapKey : mapWeekOutNum.keySet()) {
+ mainData.getWeekOutNumList().add(mapWeekOutNum.get(mapKey));
+ }
+
+ for (String mapKey : mapMonthInNum.keySet()) {
+ mainData.getMonthDateList().add(mapKey);
+ mainData.getMonthInNumList().add(mapMonthInNum.get(mapKey));
+ }
+
+ for (String mapKey : mapMonthOutNum.keySet()) {
+ mainData.getMonthOutNumList().add(mapMonthOutNum.get(mapKey));
+ }
+ mainData.setInSum(inSum / 1000);
+ mainData.setOutSum(outSum / 1000);
+ return mainData;
+ }
+
}
--
Gitblit v1.9.3