|
@@ -0,0 +1,131 @@
|
|
|
+package com.fdkk.sxz.other.listener;
|
|
|
+
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fdkk.sxz.entity.RenovationPartsDetailEntity;
|
|
|
+import com.fdkk.sxz.entity.custuom.CustomComponentEntity;
|
|
|
+import com.fdkk.sxz.entity.custuom.CustomProductEntity;
|
|
|
+import com.fdkk.sxz.other.mq.TopicRabbitConfig;
|
|
|
+import com.fdkk.sxz.util.OkHttpUtils;
|
|
|
+import com.fdkk.sxz.webApi.service.IRenovationPartsDetailService;
|
|
|
+import com.fdkk.sxz.webApi.service.custom.ICustomComponentService;
|
|
|
+import com.fdkk.sxz.webApi.service.custom.ICustomProductService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Xiewj
|
|
|
+ * @date 2021/11/12
|
|
|
+ */
|
|
|
+
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class SnycBuild {
|
|
|
+
|
|
|
+ @Value("${build.url}")
|
|
|
+ private String buildUrl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IRenovationPartsDetailService renovationPartsDetailService;
|
|
|
+ @Autowired
|
|
|
+ private ICustomProductService customProductService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICustomComponentService customComponentService;
|
|
|
+
|
|
|
+
|
|
|
+ @RabbitHandler
|
|
|
+ @RabbitListener(queues = TopicRabbitConfig.SYNCMODEL)
|
|
|
+ public void syncModel(String str) {
|
|
|
+ SnycBuild.log.info("模型syncmodel:" + str + ",开始同步");
|
|
|
+ syncModelHandler(str);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void syncModelHandler(String str) {
|
|
|
+ String[] datas = str.split(":;");
|
|
|
+ String id = datas[0].trim();
|
|
|
+ String type = datas[1].trim();
|
|
|
+ String json = datas[2].trim();
|
|
|
+ RenovationPartsDetailEntity renovationPartsDetailEntity = null;
|
|
|
+ CustomProductEntity customProductEntity = null;
|
|
|
+ CustomComponentEntity componentEntity = null;
|
|
|
+ try {
|
|
|
+ SnycBuild.log.info("更新模型库,syncmodel开始:" + json);
|
|
|
+ String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", json);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(resultData);
|
|
|
+ SnycBuild.log.info("更新模型库,syncmodel结束:" + resultData.toString());
|
|
|
+ if ("error".equals(resultJson.getString("state"))) {
|
|
|
+ SnycBuild.log.info("更新模型库,syncmodel接口失败:" + resultData);
|
|
|
+ throw new RuntimeException(id + ":更新模型库,syncmodel接口失败");
|
|
|
+ }
|
|
|
+ switch (type) {
|
|
|
+ case "1":
|
|
|
+ //普通
|
|
|
+ renovationPartsDetailEntity = renovationPartsDetailService.findById(id);
|
|
|
+ if (ObjectUtil.isNotNull(renovationPartsDetailEntity)) {
|
|
|
+ renovationPartsDetailEntity.setExamine(1);
|
|
|
+ renovationPartsDetailEntity.setExamineTime(new Date());
|
|
|
+ renovationPartsDetailService.updateById(renovationPartsDetailEntity);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ //定制
|
|
|
+ customProductEntity = customProductService.findById(id);
|
|
|
+ if (ObjectUtil.isNotNull(customProductEntity)) {
|
|
|
+ customProductEntity.setExamine(1);
|
|
|
+ customProductEntity.setExamineTime(new Date());
|
|
|
+ customProductService.updateById(customProductEntity);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ //组件
|
|
|
+ componentEntity = customComponentService.findById(id);
|
|
|
+ if (ObjectUtil.isNotNull(componentEntity)) {
|
|
|
+ componentEntity.setExamine(1);
|
|
|
+ componentEntity.setExamineTime(new Date());
|
|
|
+ customComponentService.updateById(componentEntity);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ SnycBuild.log.error("同步模型报错-{}", e.getMessage());
|
|
|
+ switch (type) {
|
|
|
+ case "1":
|
|
|
+ //普通
|
|
|
+ renovationPartsDetailEntity = renovationPartsDetailService.findById(id);
|
|
|
+ if (ObjectUtil.isNotNull(renovationPartsDetailEntity)) {
|
|
|
+ renovationPartsDetailEntity.setExamine(-1);
|
|
|
+ renovationPartsDetailEntity.setExamineTime(new Date());
|
|
|
+ renovationPartsDetailService.updateById(renovationPartsDetailEntity);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ //定制
|
|
|
+ customProductEntity = customProductService.findById(id);
|
|
|
+ if (ObjectUtil.isNotNull(customProductEntity)) {
|
|
|
+ customProductEntity.setExamine(-1);
|
|
|
+ customProductEntity.setExamineTime(new Date());
|
|
|
+ customProductService.updateById(customProductEntity);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ //组件
|
|
|
+ componentEntity = customComponentService.findById(id);
|
|
|
+ if (ObjectUtil.isNotNull(componentEntity)) {
|
|
|
+ componentEntity.setExamine(-1);
|
|
|
+ componentEntity.setExamineTime(new Date());
|
|
|
+ customComponentService.updateById(componentEntity);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|