Selaa lähdekoodia

fix:“修复远程屏蔽花型失效问题“

soobin 1 vuosi sitten
vanhempi
commit
37fc4dce40

+ 19 - 19
src/main/java/com/szwl/controller/IndexController.java

@@ -2311,28 +2311,28 @@ public class IndexController {
                 return "fail";
             }
             TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
-            if (equipmentDesc.getLanguage() == null || !(equipmentDesc.getLanguage().equals(language))) {
-                equipmentDesc.setLanguage(language);
-                equipmentDescService.updateById(equipmentDesc);
-                LambdaQueryWrapper<TProduct> wrapper = Wrappers.lambdaQuery();
-                wrapper.eq(TProduct::getEquipmentId, equipment.getId());
-                List<TProduct> products = productService.list(wrapper);
-                for (TProduct product : products) {
-                    String no = product.getNo();
-                    // 如果没改过名才更改
-                    if (StringUtils.isEmpty(product.getName())) {
-                        LambdaQueryWrapper<TNameDictionary> lambdaQueryWrapper = Wrappers.lambdaQuery();
-                        lambdaQueryWrapper.eq(TNameDictionary::getLanguage, language);
-                        lambdaQueryWrapper.eq(TNameDictionary::getNo, no);
-                        TNameDictionary nameDictionary = nameDictionaryService.getOne(lambdaQueryWrapper);
-                        if (nameDictionary != null) {
-                            product.setModifyDate(new Date());
-                            product.setProductName(nameDictionary.getName());
-                            productService.updateById(product);
-                        }
+            equipmentDesc.setLanguage(language);
+            equipmentDescService.updateById(equipmentDesc);
+            LambdaQueryWrapper<TProduct> wrapper = Wrappers.lambdaQuery();
+            wrapper.eq(TProduct::getEquipmentId, equipment.getId());
+            List<TProduct> products = productService.list(wrapper);
+            for (TProduct product : products) {
+                String no = product.getNo();
+                // 如果没改过名才更改
+                if (StringUtils.isEmpty(product.getName())) {
+                    LambdaQueryWrapper<TNameDictionary> lambdaQueryWrapper = Wrappers.lambdaQuery();
+                    lambdaQueryWrapper.eq(TNameDictionary::getLanguage, language);
+                    lambdaQueryWrapper.eq(TNameDictionary::getNo, no);
+                    TNameDictionary nameDictionary = nameDictionaryService.getOne(lambdaQueryWrapper);
+                    if (nameDictionary != null) {
+                        product.setModifyDate(new Date());
+                        product.setProductName(nameDictionary.getName());
+                        productService.updateById(product);
                     }
                 }
             }
+//            if (equipmentDesc.getLanguage() == null || !(equipmentDesc.getLanguage().equals(language))) {
+//            }
             return "success";
         }
         return "fail";

+ 12 - 4
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -1763,34 +1763,42 @@ public class TEquipmentController {
     /**
      * 上传日志
      *
-     * @param equipmentId
-     * @param day
+     * @param equipmentId 设备ID,用于标识上传日志的设备
+     * @param day 日期,指定要上传日志的日期
+     * @return 返回操作结果,成功则返回成功信息,失败则返回失败原因
      */
     @ApiOperation(value = "上传日志")
     @GetMapping("/uploadLog")
     public ResponseModel<?> uploadLog(String equipmentId, String day) {
+        // 检查设备ID是否为空
         if (StringUtils.isEmpty(equipmentId)) {
             return R.fail(A0001);
         }
+        // 根据设备ID查询设备信息
         TEquipment tEquipment = tEquipmentService.getById(equipmentId);
+        // 检查设备信息是否存在
         if (tEquipment == null) {
             return R.fail(A0001, "该设备不存在");
         }
+        // 组装日志信息的标识
         String clientId = tEquipment.getClientId();
         String kind = day + "-" + clientId;
+        // 获取设备的渠道号和类型
         String channel = tEquipment.getChannel();
         String equimentType = tEquipment.getEquimentType();
+        // 如果渠道号为空或为"1",或设备类型为空,则使用个推推送日志
         if (StringUtils.isEmpty(channel) || channel.equals("1") || StringUtils.isEmpty(equimentType)) {
-            //用个推
             PushUtils.push(tEquipment.getGtClientId(), "", "", PushUtils.buildJson("log", kind).toString());
         }
+        // 如果渠道号为"2"且设备类型不为空,则使用MQ发送日志
         if (StringUtils.isNotEmpty(channel) && channel.equals("2") && StringUtils.isNotEmpty(equimentType)) {
-            //用Mq
             tEquipmentService.sentMessage(tEquipment.getClientId(), PushUtils.buildJson("log", kind).toString());
         }
+        // 返回操作成功信息
         return R.ok();
     }
 
+
     /**
      * 查询指定设备在指定日期的日志是否已上传至七牛云。
      *

+ 17 - 1
src/main/java/com/szwl/controller/TProductController.java

@@ -15,12 +15,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TNameDictionary;
 import com.szwl.model.entity.TProduct;
 
 import com.szwl.model.query.TEquipmentParam;
 import com.szwl.model.utils.PushUtils;
 import com.szwl.service.TAdminService;
 import com.szwl.service.TEquipmentService;
+import com.szwl.service.TNameDictionaryService;
 import com.szwl.service.TProductService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -47,13 +49,19 @@ import java.util.List;
 @RestController
 @RequestMapping("/tProduct")
 public class TProductController {
+
     @Autowired
     TEquipmentService tEquipmentService;
+
     @Autowired
     TProductService tProductService;
+
     @Autowired
     TAdminService tAdminService;
 
+    @Autowired
+    TNameDictionaryService nameDictionaryService;
+
     @ApiOperation(value = "查询商品列表信息")
     @GetMapping("/selectProducts")
     public ResponseEntity<?> selectProducts(String equipmentId){
@@ -93,7 +101,15 @@ public class TProductController {
                 if(StringUtils.isEmpty(product.getShowType())){
                     productBean.setShowType("0");
                 }
-                productBean.setProductName(product.getProductName());
+                if (StringUtils.isNotEmpty(product.getName())) {
+                    productBean.setProductName(product.getProductName());
+                } else {
+                    LambdaQueryWrapper<TNameDictionary> wrapper = Wrappers.lambdaQuery();
+                    wrapper.eq(TNameDictionary::getNo, product.getNo());
+                    wrapper.eq(TNameDictionary::getLanguage, "zh");
+                    TNameDictionary nameDictionary = nameDictionaryService.getOne(wrapper);
+                    productBean.setProductName(nameDictionary.getName());
+                }
                 list.add(productBean);
             }
         }