From 918eb3afde4886ab9d87e9f2fafbde1bf9e83587 Mon Sep 17 00:00:00 2001
From: huangjiayang <5265313@qq.com>
Date: 星期四, 15 五月 2025 16:30:26 +0800
Subject: [PATCH] 【ADD】新增将钣金子单数据存到redis中定时任务
---
aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml | 4 ++
aps-api/aps-api-system/src/main/java/com/aps/system/api/factory/RemoteCoreFallbackFactory.java | 6 +++
aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsPlatePlanController.java | 15 +++++++
aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java | 8 ++++
aps-modules/aps-job/src/main/java/com/aps/job/task/RyTask.java | 6 +++
aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java | 35 ++++++++++++++++-
aps-api/aps-api-system/src/main/java/com/aps/system/api/RemoteCoreService.java | 9 ++++
aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlatePlanService.java | 3 +
8 files changed, 82 insertions(+), 4 deletions(-)
diff --git a/aps-api/aps-api-system/src/main/java/com/aps/system/api/RemoteCoreService.java b/aps-api/aps-api-system/src/main/java/com/aps/system/api/RemoteCoreService.java
index 150131b..6f63d24 100644
--- a/aps-api/aps-api-system/src/main/java/com/aps/system/api/RemoteCoreService.java
+++ b/aps-api/aps-api-system/src/main/java/com/aps/system/api/RemoteCoreService.java
@@ -3,6 +3,7 @@
import com.aps.common.core.constant.SecurityConstants;
import com.aps.common.core.constant.ServiceNameConstants;
import com.aps.common.core.domain.R;
+import com.aps.common.core.web.domain.AjaxResult;
import com.aps.system.api.factory.RemoteCoreFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@@ -42,4 +43,12 @@
@PostMapping("/materialStorageManagement/setStorageDataToRedis")
R<Boolean> setStorageDataToRedis(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+ /**
+ * 鍒锋柊閽i噾瀛愬崟鏁版嵁鍒癛edis
+ * @param source
+ * @return
+ */
+ @PostMapping("/apsPlatePlan/setPlateSubPlansToRedis")
+ R<AjaxResult> setPlateSubPlansToRedis(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
+
}
diff --git a/aps-api/aps-api-system/src/main/java/com/aps/system/api/factory/RemoteCoreFallbackFactory.java b/aps-api/aps-api-system/src/main/java/com/aps/system/api/factory/RemoteCoreFallbackFactory.java
index ca6e0bd..1802a8c 100644
--- a/aps-api/aps-api-system/src/main/java/com/aps/system/api/factory/RemoteCoreFallbackFactory.java
+++ b/aps-api/aps-api-system/src/main/java/com/aps/system/api/factory/RemoteCoreFallbackFactory.java
@@ -1,6 +1,7 @@
package com.aps.system.api.factory;
import com.aps.common.core.domain.R;
+import com.aps.common.core.web.domain.AjaxResult;
import com.aps.system.api.RemoteCoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,6 +41,11 @@
{
return R.fail("搴撳瓨鏁版嵁瀛樺偍鍒癛edis涓け璐�:" + throwable.getMessage());
}
+
+ @Override
+ public R<AjaxResult> setPlateSubPlansToRedis(String source) {
+ return R.fail("閽i噾瀛愬崟璁″垝鏁版嵁瀛樺偍鍒癛edis涓け璐�:" + throwable.getMessage());
+ }
};
}
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsPlatePlanController.java b/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsPlatePlanController.java
index ad84a51..6be84ee 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsPlatePlanController.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsPlatePlanController.java
@@ -214,4 +214,19 @@
util.exportExcel(response, planListExport, "閽i噾鍐椾綑宸ュ崟鎶ヨ〃鏁版嵁");
}
+ /**
+ * 灏嗛挘閲戝瓙鍗曟暟鎹瓨鍒皉edis涓�
+ * @return
+ */
+ @PostMapping("/setPlateSubPlansToRedis")
+ public AjaxResult setPlateSubPlansToRedis() {
+ try {
+ apsPlatePlanService.setSubPlansToRedis();
+ return success();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return error();
+ }
+ }
+
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java
index ded9061..6590c9e 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/mapper/ApsPlatePlanMapper.java
@@ -1,7 +1,9 @@
package com.aps.core.mapper;
+import com.alibaba.fastjson2.JSONObject;
import com.aps.core.domain.ApsPlatePlan;
import org.apache.ibatis.annotations.Mapper;
+
import java.util.List;
/**
@@ -97,4 +99,10 @@
* 鏇存柊瀛愪欢宸ュ崟鏈尮閰嶆暟閲忓拰鐗堟湰
* */
int updatePlanUnMatchQtyAndVersion(ApsPlatePlan plan);
+
+ /**
+ * 鏌ヨ閽i噾瀛愬崟鏁版嵁
+ * @return
+ */
+ List<JSONObject> selectApsSubPlatePlan();
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlatePlanService.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlatePlanService.java
index a923079..a3c655a 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlatePlanService.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlatePlanService.java
@@ -2,7 +2,6 @@
import com.aps.core.domain.ApsPlatePlan;
import com.aps.core.domain.ApsPlatePlanTemp;
-import com.aps.core.domain.ApsPlateStandardRequire;
import java.util.Hashtable;
import java.util.List;
@@ -85,4 +84,6 @@
ApsPlatePlan selectUnMatchPlateSubPlan(String plant, String itemNumber, Hashtable<String, List<ApsPlatePlan>> subPlans);
// ApsPlatePlan selectUnMatchPlateSubPlan(ApsPlateStandardRequire require);
+
+ boolean setSubPlansToRedis();
}
diff --git a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
index 15d21c4..3792967 100644
--- a/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
+++ b/aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
@@ -1,6 +1,7 @@
package com.aps.core.service.impl;
import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson2.JSONObject;
import com.aps.common.core.utils.DateUtils;
import com.aps.common.core.utils.uuid.IdUtils;
import com.aps.common.security.utils.DictUtils;
@@ -14,12 +15,12 @@
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* 閽i噾璁″垝绠$悊Service涓氬姟灞傚鐞�
@@ -35,8 +36,12 @@
@Autowired
private ApsPartPlanTempMapper apsPartPlanTempMapper;
+
@Autowired
private ApsPlatePlanTempMapper apsPlatePlanTempMapper;
+
+ @Autowired
+ public RedisTemplate redisTemplate;
/**
* 鏌ヨ閽i噾璁″垝绠$悊
@@ -211,4 +216,28 @@
}
}
}
+
+ @Override
+ public boolean setSubPlansToRedis() {
+ try {
+ Set<String> keys = redisTemplate.keys("PLATE_SUB_PLAN:*");
+ if (keys != null && !keys.isEmpty()) {
+ redisTemplate.delete(keys);
+ }
+ List<JSONObject> subPlans = apsPlatePlanMapper.selectApsSubPlatePlan();
+// ApsPlatePlan a = JSONObject.parseObject(String.valueOf(subPlans.get(0)), ApsPlatePlan.class);
+ Map<String, List<JSONObject>> groupByItemNumber = subPlans.stream().collect(Collectors.groupingBy(obj -> obj.getString("itemNumber")));
+ Map<String, Object> bulkData = new HashMap<>();
+ for (Map.Entry<String, List<JSONObject>> entry : groupByItemNumber.entrySet()) {
+ String key = entry.getKey();
+ List<JSONObject> value = entry.getValue();
+ bulkData.put("PLATE_SUB_PLAN:"+key, value);
+ }
+ redisTemplate.opsForValue().multiSet(bulkData);
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
}
diff --git a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
index c0db9f6..028dff5 100644
--- a/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
+++ b/aps-modules/aps-core/src/main/resources/mapper/core/ApsPlatePlanMapper.xml
@@ -334,4 +334,8 @@
set unmatched_quantity=#{unmatchedQuantity},version=#{version},update_time=now()
where id=#{id}
</update>
+
+ <select id="selectApsSubPlatePlan" resultType="com.alibaba.fastjson2.JSONObject">
+ SELECT id,item_number as "itemNumber",document_number as "documentNumber",production_quantity as "unmatchedQuantity" FROM aps_plate_plan WHERE item_number in (SELECT item_number FROM aps_plate_plan WHERE professional_affiliation='sub' GROUP BY item_number) order by item_number
+ </select>
</mapper>
\ No newline at end of file
diff --git a/aps-modules/aps-job/src/main/java/com/aps/job/task/RyTask.java b/aps-modules/aps-job/src/main/java/com/aps/job/task/RyTask.java
index 3ba5dee..ed72422 100644
--- a/aps-modules/aps-job/src/main/java/com/aps/job/task/RyTask.java
+++ b/aps-modules/aps-job/src/main/java/com/aps/job/task/RyTask.java
@@ -191,5 +191,11 @@
apsMaterialManagementJobService.syncApsMaterialDataJob(pageIndex, pageSize, orgCode, itemCodeList);
}
+ /**
+ * 鍒锋柊閽i噾瀛愬崟鏁版嵁鍒癛edis
+ */
+ public void setPlateSubPlansToRedis(){
+ remoteCoreService.setPlateSubPlansToRedis(SecurityConstants.INNER);
+ }
}
--
Gitblit v1.9.3