Browse Source

feat:"部分功能更换为MQTT协议"

soobin 1 week ago
parent
commit
ea4698b651
46 changed files with 1349 additions and 921 deletions
  1. 8 1
      src/main/java/com/szwl/constant/OperationType.java
  2. 2 2
      src/main/java/com/szwl/constant/ResponseCodesEnum.java
  3. 31 28
      src/main/java/com/szwl/controller/RabbitMqController.java
  4. 3 43
      src/main/java/com/szwl/controller/ReturnCoinRecordController.java
  5. 3 16
      src/main/java/com/szwl/controller/ScheduledService.java
  6. 8 62
      src/main/java/com/szwl/controller/SugarDoOrderController.java
  7. 18 14
      src/main/java/com/szwl/controller/SysRoleMenuController.java
  8. 42 35
      src/main/java/com/szwl/controller/TAdController.java
  9. 57 0
      src/main/java/com/szwl/controller/TAdminController.java
  10. 0 21
      src/main/java/com/szwl/controller/TAdminEquipmentController.java
  11. 0 4
      src/main/java/com/szwl/controller/TAlarmClockController.java
  12. 0 24
      src/main/java/com/szwl/controller/TAlarmClockItemController.java
  13. 0 2
      src/main/java/com/szwl/controller/TAlarmRecordController.java
  14. 253 142
      src/main/java/com/szwl/controller/TEquipmentController.java
  15. 1 4
      src/main/java/com/szwl/controller/TEquipmentDeletedController.java
  16. 0 28
      src/main/java/com/szwl/controller/THotUpdateController.java
  17. 60 60
      src/main/java/com/szwl/controller/TJoinpayMchCheckController.java
  18. 3 1
      src/main/java/com/szwl/controller/TJoinpayMchController.java
  19. 57 120
      src/main/java/com/szwl/controller/TLabelController.java
  20. 156 167
      src/main/java/com/szwl/controller/TLocationCheckController.java
  21. 0 5
      src/main/java/com/szwl/controller/TMessageCodeController.java
  22. 2 0
      src/main/java/com/szwl/controller/TNoticeController.java
  23. 2 0
      src/main/java/com/szwl/controller/TPriceController.java
  24. 7 13
      src/main/java/com/szwl/controller/TPromoCodeController.java
  25. 5 0
      src/main/java/com/szwl/controller/TProportionCheckController.java
  26. 0 65
      src/main/java/com/szwl/controller/TProportionController.java
  27. 4 0
      src/main/java/com/szwl/controller/TShandeMchCheckController.java
  28. 0 1
      src/main/java/com/szwl/controller/TShandeMchController.java
  29. 47 35
      src/main/java/com/szwl/controller/TTimeRuleController.java
  30. 7 11
      src/main/java/com/szwl/controller/TWechatController.java
  31. 41 0
      src/main/java/com/szwl/handle/response/BlockProcessor.java
  32. 69 0
      src/main/java/com/szwl/handle/response/FlowersProcessor.java
  33. 41 0
      src/main/java/com/szwl/handle/response/OfflineProcessor.java
  34. 54 0
      src/main/java/com/szwl/handle/response/PhoneProcessor.java
  35. 54 0
      src/main/java/com/szwl/handle/response/SleepDescProcessor.java
  36. 6 0
      src/main/java/com/szwl/model/param/EquipmentDescParam.java
  37. 15 0
      src/main/java/com/szwl/model/param/EquipmentParam.java
  38. 4 0
      src/main/java/com/szwl/model/param/LoginParam.java
  39. 9 0
      src/main/java/com/szwl/model/vo/EquipmentVO.java
  40. 3 0
      src/main/java/com/szwl/model/vo/MachineVo.java
  41. 9 0
      src/main/java/com/szwl/service/TGoodsDataService.java
  42. 11 0
      src/main/java/com/szwl/service/TMessageCodeService.java
  43. 38 2
      src/main/java/com/szwl/service/impl/TGoodsDataServiceImpl.java
  44. 49 1
      src/main/java/com/szwl/service/impl/TMessageCodeServiceImpl.java
  45. 60 2
      src/main/java/com/szwl/util/MqttUtils.java
  46. 110 12
      src/main/java/com/szwl/util/TimezoneFmtUtil.java

+ 8 - 1
src/main/java/com/szwl/constant/OperationType.java

@@ -29,7 +29,14 @@ public enum OperationType implements IEnum<String> {
     PASSWORD("password","修改密码"),
     RESTART_ANDROID("restartAndroid","重启屏幕"),
     SLEEP("sleep","休眠"),
-    EQE_STATUS("eqeStatus", "开关机");
+    EQE_STATUS("eqeStatus", "开关机"),
+    BLOCK("block","锁屏"),
+    PHONE("phone","联系方式"),
+    FLOWERS("flowers","推送商品"),
+    OFFLINE("tuoji","脱机"),
+    SLEEP_DESC("sleepDesc","修改睡眠描述"),
+    UPDATE_LOGO("updateLogo","修改logo"),
+    PUSH_TIME_RULE("pushTimeRule","推送广告规则");
 
     private String code;
 

+ 2 - 2
src/main/java/com/szwl/constant/ResponseCodesEnum.java

@@ -67,8 +67,8 @@ public enum ResponseCodesEnum {
     R0007("R0007","验证码不存在"),
     R0008("R0008","请勿频繁发送,10分钟后再试"),
     R0009("R0009","手机号或邮箱为空"),
-    R0010("R0010","登录名或手机号出错"),
-    R0011("R0011","登录名或邮箱出错");
+    R0010("R0010","手机号不存在"),
+    R0011("R0011","邮箱不存在");
 
 
     private final String errorCode;

+ 31 - 28
src/main/java/com/szwl/controller/RabbitMqController.java

@@ -22,84 +22,86 @@ import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 @Api(value = "/api/app_mq/rabbitMq", tags = {"MQ"})
 @RestController
 @RequestMapping("/api/app_mq/rabbitMq")
-//@RequestMapping("/rabbitMqController")
 public class RabbitMqController {
+
     @Autowired
     TEquipmentService tEquipmentService;
+
     @Autowired
     TAdminService tAdminService;
-//    @Autowired
-//    private RabbitAdmin rabbitAdmin;
+
     @Autowired
     private AmqpAdmin amqpAdmin;
-//    @Autowired
-//    private RabbitTemplate rabbitTemplate;
+
     /**
-     *添加交换机
+     * 添加交换机
+     *
      * @param
      * @return
      */
     @GetMapping(value = "/addExchange.htm")
     @ResponseBody
-    public String addExchange(String exchange,String type,Boolean durable){
-        if(StringUtils.isEmpty(type)){
+    public String addExchange(String exchange, String type, Boolean durable) {
+        if (StringUtils.isEmpty(type)) {
             return "type is null";
         }
-        if(type.equals("Direct")){
+        if (type.equals("Direct")) {
             amqpAdmin.declareExchange(new DirectExchange(exchange, durable, false));
 
         }
-        if(type.equals("Topic")){
+        if (type.equals("Topic")) {
             amqpAdmin.declareExchange(new TopicExchange(exchange, durable, false));
         }
-        if(type.equals("Fanout")){
+        if (type.equals("Fanout")) {
             amqpAdmin.declareExchange(new FanoutExchange(exchange, durable, false));
         }
         return "success";
-//        return JsonMessage.success("成功");
     }
+
     /**
-     *添加队列并绑定
+     * 添加队列并绑定
+     *
      * @param
      * @return
      */
     @GetMapping(value = "/addQueue.htm")
     @ResponseBody
-    public String addQueue(String exchange,String queue,String routingKey,Boolean durable){
-        Map<String,Object> arg = new HashMap<>();
-        arg.put("x-message-ttl",1800000);
+    public String addQueue(String exchange, String queue, String routingKey, Boolean durable) {
+        Map<String, Object> arg = new HashMap<>();
+        arg.put("x-message-ttl", 1800000);
         String queue1 = amqpAdmin.declareQueue(new Queue(queue, durable, false, false, arg));
         HashMap<String, Object> objectObjectHashMap = new HashMap<>();
         amqpAdmin.declareBinding(new Binding(queue,
                 Binding.DestinationType.QUEUE,
                 exchange, routingKey, objectObjectHashMap));
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,routingKey);
+        query.eq(TEquipment::getClientId, routingKey);
         List<TEquipment> list = tEquipmentService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             TEquipment equipment = list.get(0);
             equipment.setEquimentType(exchange);
             tEquipmentService.updateById(equipment);
         }
-
-//        return JsonMessage.success("成功");
         return "success";
     }
+
     /**
-     *修改信道
+     * 修改信道
+     *
      * @param
      * @return
      */
     @GetMapping(value = "/updateChannel.htm")
     @ResponseBody
-    public String updateChannel(String clientId,String type){
+    public String updateChannel(String clientId, String type) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getClientId,clientId);
+        query.eq(TEquipment::getClientId, clientId);
         List<TEquipment> list = tEquipmentService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             TEquipment equipment = list.get(0);
             equipment.setChannel(type);
             tEquipmentService.updateById(equipment);
@@ -109,18 +111,19 @@ public class RabbitMqController {
 
     /**
      * 修改机型重新创建MQ队列
+     *
      * @param
      * @return
      */
     @GetMapping(value = "/updateEquipmentType")
     @ResponseBody
-    public String updateEquipmentType(String clientId, String equipmentType){
+    public String updateEquipmentType(String clientId, String equipmentType) {
         if (StringUtils.isNotEmpty(clientId) && StringUtils.isNotEmpty(equipmentType)) {
             // 删除MQ队列
             amqpAdmin.deleteQueue(clientId);
             // 重新创建队列
-            Map<String,Object> arg = new HashMap<>();
-            arg.put("x-message-ttl",1800000);
+            Map<String, Object> arg = new HashMap<>();
+            arg.put("x-message-ttl", 1800000);
             amqpAdmin.declareQueue(new Queue(clientId, true, false, false, arg));
             HashMap<String, Object> objectObjectHashMap = new HashMap<>();
             amqpAdmin.declareBinding(new Binding(clientId,
@@ -129,7 +132,7 @@ public class RabbitMqController {
             LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
             query.eq(TEquipment::getClientId, clientId);
             TEquipment equipment = tEquipmentService.getOne(query);
-            if(equipment != null){
+            if (equipment != null) {
                 equipment.setEquimentType(equipmentType);
                 tEquipmentService.updateById(equipment);
                 return "success";

+ 3 - 43
src/main/java/com/szwl/controller/ReturnCoinRecordController.java

@@ -38,6 +38,7 @@ import java.util.List;
 @RestController
 @RequestMapping("/returnCoinRecord")
 public class ReturnCoinRecordController {
+
     @Autowired
     ReturnCoinRecordService returnCoinRecordService;
 
@@ -46,7 +47,7 @@ public class ReturnCoinRecordController {
 
     @ApiOperation("获取当天远程退币申请列表")
     @GetMapping("/list")
-    public ResponseModel<?> list(Long equipmentId){
+    public ResponseModel<?> list(Long equipmentId) {
         // 获取当天的 0 点时间
         LocalDateTime startTime = LocalDate.now().atStartOfDay();
 
@@ -83,49 +84,8 @@ public class ReturnCoinRecordController {
     }
 
     @ApiOperation("远程退币申请")
-    @PostMapping("/apply")
-    public ResponseModel<?> apply(@RequestBody ReturnCoinRecord returnCoinRecord){
-        // 设备ID
-        Long equipmentId = returnCoinRecord.getEquipmentId();
-        // 用户ID
-        Long adminId = returnCoinRecord.getAdminId();
-        // 退币数量
-        Integer amount = returnCoinRecord.getAmount();
-        if (equipmentId == null || adminId == null || amount == null) {
-            return R.fail("参数错误");
-        }
-        if (amount <= 0) {
-            return R.fail("参数错误");
-        }
-        TEquipment equipment = tEquipmentService.getById(equipmentId);
-        if (equipment == null || equipment.getId() == null) {
-            return R.fail("找不到设备");
-        }
-        String clientId = equipment.getClientId();
-        String name = equipment.getName();
-        ReturnCoinRecord record = new ReturnCoinRecord();
-        long commonId = IDGenerator.commonID();
-        record.setId(commonId);
-        record.setCreateDate(new Date());
-        record.setModifyDate(new Date());
-        record.setAdminId(adminId);
-        record.setEquipmentId(equipmentId);
-        record.setAmount(amount);
-        record.setClientId(clientId);
-        if (StringUtils.isEmpty(name)) {
-            record.setName(clientId.substring(clientId.length() - 6));
-        } else {
-            record.setName(name);
-        }
-        record.setStatus(0);
-        returnCoinRecordService.save(record);
-        tEquipmentService.sentMessage(clientId, PushUtils.buildJson("returnCoin", commonId + ":" + amount).toString());
-        return R.ok();
-    }
-
-    @ApiOperation("远程退币申请")
     @PostMapping("/applyReturn")
-    public ResponseModel<?> applyReturn(@RequestBody ReturnCoinRecord returnCoinRecord){
+    public ResponseModel<?> applyReturn(@RequestBody ReturnCoinRecord returnCoinRecord) {
         // 设备ID
         Long equipmentId = returnCoinRecord.getEquipmentId();
         // 用户ID

+ 3 - 16
src/main/java/com/szwl/controller/ScheduledService.java

@@ -23,7 +23,6 @@ import java.util.Date;
 import java.util.List;
 
 
-
 @Configuration //1.主要用于标记配置类,兼备Component的效果。
 @Component
 @EnableScheduling // 2.开启定时任务
@@ -63,16 +62,13 @@ public class ScheduledService {
     @Scheduled(cron = "0 10 8 ? * TUE")
     public void equipmentLocCheck() throws IOException {
         if (isDo()) {
-//            List<TLocationCheck> locationChecks = locationCheckMapper.selectNotNullIp();
             List<TLocationCheck> locationChecks = locationCheckMapper.selectNotNullAddr();
-//            String locErrorEq = null;
             StringBuilder locErrorEq = new StringBuilder();
             for (TLocationCheck locationChc : locationChecks) {
                 String clientId = locationChc.getClientId();
                 String addr = locationChc.getAddr();
 
                 // 这里不需要更新ip,只需要校验有ip的设备位置对不对
-//                locationCheckService.locCheckMsg(locationChc, clientId, addr);
                 String check = locationCheckService.schLocCheck(locationChc, clientId, addr);
                 locErrorEq.append(check);
             }
@@ -80,15 +76,6 @@ public class ScheduledService {
                 locationCheckService.schSendMsg(locErrorEq.toString());
             }
 
-//            Optional.ofNullable(locErrorEq)
-//                    .filter(stringBuilder -> stringBuilder.length() > 0)
-//                    .ifPresent(stringBuilder -> {
-//                        try {
-//                            locationCheckService.schSendMsg(locErrorEq.toString());
-//                        } catch (IOException e) {
-//                            throw new RuntimeException(e);
-//                        }
-//                    });
         }
     }
 
@@ -168,7 +155,7 @@ public class ScheduledService {
     }
 
     /**
-     *  定时更新access_token
+     * 定时更新access_token
      */
     @Scheduled(cron = "0 20 * * * ?")
     public void updateAccessToken() {
@@ -179,7 +166,7 @@ public class ScheduledService {
     }
 
     /**
-     *  每日0点重置收钱吧的签到状态
+     * 每日0点重置收钱吧的签到状态
      */
     @Scheduled(cron = "0 0 0 * * ?")
     public void resetSignIn() {
@@ -189,7 +176,7 @@ public class ScheduledService {
     }
 
     /**
-     *  定时月末汇付提现申泽公账
+     * 定时月末汇付提现申泽公账
      */
     @Scheduled(cron = "0 0 6 28-31 * *")
     public void regularWithdrawal() {

+ 8 - 62
src/main/java/com/szwl/controller/SugarDoOrderController.java

@@ -35,80 +35,26 @@ public class SugarDoOrderController {
     //远程做糖状态回返
     @RequestMapping(value = "/updateSugarDoStatus.htm", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
     @ResponseBody
-    public String updateSugarDoStatus(String clientId,  String status, String no, String note) {
-        if(!StringUtils.isEmpty(no)&&!StringUtils.isEmpty(status)){
+    public String updateSugarDoStatus(String clientId, String status, String no, String note) {
+        if (!StringUtils.isEmpty(no) && !StringUtils.isEmpty(status)) {
             LambdaQueryWrapper<TSugarDo> query = Wrappers.lambdaQuery();
-            query.eq(TSugarDo::getNo,no);
-            query.eq(TSugarDo::getClientId,clientId);
+            query.eq(TSugarDo::getNo, no);
+            query.eq(TSugarDo::getClientId, clientId);
             List<TSugarDo> list = sugarDoService.list(query);
             TSugarDo sugarDo = list.get(0);
-            if(sugarDo.getClientId().equals(clientId)){
+            if (sugarDo.getClientId().equals(clientId)) {
                 sugarDo.setStatus(status);
-                if(status.equals("2")){
+                if (status.equals("2")) {
                     sugarDo.setNote(note);
                 }
                 sugarDoService.updateById(sugarDo);
-            }else {
+            } else {
                 return "error";
             }
-        }else {
+        } else {
             return "error";
         }
         return "success";
     }
 
-    /**
-     * 远程做糖
-     */
-//    @RequestMapping(value = "/doSugar", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
-//    @ResponseBody
-//    public Object getProductions(String adminId,String clientId,String productName) {
-////        productName = "夏日倾城";
-//        JSONObject jsonObject = new JSONObject();
-//        if(StringUtils.isEmpty(adminId)){
-//            jsonObject.put("code", 1);
-//            jsonObject.put("errmsg", "adminId为空");
-//            return jsonObject;
-//        }
-//        if(StringUtils.isEmpty(clientId)){
-//            jsonObject.put("code", 1);
-//            jsonObject.put("errmsg", "clientId为空");
-//            return jsonObject;
-//        }
-//        Admin admin = adminService.find(Long.valueOf(adminId));
-//        Equipment equipment = equipmentService.findByClientId(clientId);
-//        if(!equipment.getAdminId().toString().equals(admin.getId().toString())){
-//            jsonObject.put("code", 1);
-//            jsonObject.put("errmsg", "clientId与adminId不匹配");
-//            return jsonObject;
-//        }
-//        int j =0;
-//        ArrayList<Filter> filters = new ArrayList<>();
-//        filters.add(Filter.eq("equipmentId", equipment.getId()));
-//        List<Product> products = productService.findList(null, filters, null);
-//        for (Product product:products){
-//            if(product.getProductName().equals(productName)){
-//                j++;
-//            }
-//        }
-//        if(j==0){
-//            jsonObject.put("code", 1);
-//            jsonObject.put("errmsg", "商品未找到");
-//            return jsonObject;
-//        }
-//        StringBuilder number = new StringBuilder();
-//        Random random = new Random();
-//        number.append(String.valueOf(adminId)).append("-");
-//        for (int i = 0; i < 6; i++) {
-//            number.append(String.valueOf(random.nextInt(10)));
-//        }
-//        JSONObject kindData = new JSONObject();
-//        kindData.put("productName" , productName);
-//        kindData.put("no" , number.toString());
-//        equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("dosugar", kindData.toString()).toString());
-//
-//        jsonObject.put("code", 0);
-//        jsonObject.put("errmsg", "发送成功!");
-//        return jsonObject;
-//    }
 }

+ 18 - 14
src/main/java/com/szwl/controller/SysRoleMenuController.java

@@ -34,6 +34,7 @@ import java.util.stream.Collectors;
 @RequestMapping("/sysRoleMenu")
 @Api(value = "/sysRoleMenu", tags = {"角色权限菜单"})
 public class SysRoleMenuController {
+
     @Autowired
     SysRoleService sysRoleService;
 
@@ -50,11 +51,11 @@ public class SysRoleMenuController {
     @GetMapping("/listRoleOption")
     @ApiOperation("获取所有角色下拉框")
     public ResponseModel<List<OptionDTO>> listRoleOption(String adminId) {
-        if(org.apache.commons.lang.StringUtils.isEmpty(adminId)){
+        if (org.apache.commons.lang.StringUtils.isEmpty(adminId)) {
             return R.fail(ResponseCodesEnum.A0100);
         }
         LambdaQueryWrapper<SysRole> query = Wrappers.lambdaQuery();
-        query.eq(SysRole::getAdminId,adminId);
+        query.eq(SysRole::getAdminId, adminId);
         List<OptionDTO> list = sysRoleService.list(query)
                 .stream()
                 .map(e -> new OptionDTO()
@@ -63,39 +64,42 @@ public class SysRoleMenuController {
                 ).collect(Collectors.toList());
         return R.ok(list);
     }
+
     @GetMapping("/pageRoleOption")
     @ApiOperation("获取所有角色")
     public ResponseModel<List<SysRole>> pageRoleOption(String adminId) {
-        if(org.apache.commons.lang.StringUtils.isEmpty(adminId)){
+        if (org.apache.commons.lang.StringUtils.isEmpty(adminId)) {
             return R.fail(ResponseCodesEnum.A0100);
         }
         LambdaQueryWrapper<SysRole> query = Wrappers.lambdaQuery();
-        query.eq(SysRole::getAdminId,adminId);
-        if(!adminId.equals("1")){
-            query.ne(SysRole::getRoleName,"商家");
+        query.eq(SysRole::getAdminId, adminId);
+        if (!adminId.equals("1")) {
+            query.ne(SysRole::getRoleName, "商家");
         }
         List<SysRole> list = sysRoleService.list(query);
         return R.ok(list);
     }
+
     @GetMapping("/deleteRoleOption")
     @ApiOperation("删除角色")
-    public ResponseModel<?> deleteRoleOption(String roleId,String adminId) {
+    public ResponseModel<?> deleteRoleOption(String roleId, String adminId) {
         // 需要查询是否有账号在使用这个角色
         LambdaQueryWrapper<SysUserRole> query = Wrappers.lambdaQuery();
-        query.eq(SysUserRole::getRoleId,roleId);
+        query.eq(SysUserRole::getRoleId, roleId);
         List<SysUserRole> list = sysUserRoleService.list(query);
-        if(list.size()>0){
-            return R.fail(ResponseCodesEnum.A0001,"角色正在使用中,不能删除");
+        if (list.size() > 0) {
+            return R.fail(ResponseCodesEnum.A0001, "角色正在使用中,不能删除");
         }
         sysRoleService.removeById(roleId);
         return R.ok();
     }
+
     @PostMapping("/addSysRole")
     @ApiOperation("新增角色及权限菜单")
-    @Audit(type = AuditEnum.INSERT,content = "#loginUser.name + '新增角色及权限菜单'")
+    @Audit(type = AuditEnum.INSERT, content = "#loginUser.name + '新增角色及权限菜单'")
     public ResponseModel<?> addSysRole(@RequestBody @Valid AddSysRoleParam param) {
-        if(param.getRoleName().equals("商家")&&param.getAdminId().equals("1")){
-            return R.fail(ResponseCodesEnum.A0001,"不能起商家这个名称");
+        if (param.getRoleName().equals("商家") && param.getAdminId().equals("1")) {
+            return R.fail(ResponseCodesEnum.A0001, "不能起商家这个名称");
         }
         sysRoleService.addSysRole(param);
         return R.ok();
@@ -103,7 +107,7 @@ public class SysRoleMenuController {
 
     @PostMapping("/updateSysRole")
     @ApiOperation("修改角色及权限菜单")
-    @Audit(type = AuditEnum.UPDATE,content = "#loginUser.name + '修改角色及权限菜单'")
+    @Audit(type = AuditEnum.UPDATE, content = "#loginUser.name + '修改角色及权限菜单'")
     public ResponseModel<?> updateSysRole(@RequestBody @Valid UpdateSysRoleParam param) {
         sysRoleService.updateSysRole(param);
         return R.ok();

+ 42 - 35
src/main/java/com/szwl/controller/TAdController.java

@@ -23,7 +23,7 @@ import java.util.List;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author wuhs
@@ -32,22 +32,25 @@ import java.util.List;
 @RestController
 @RequestMapping("/tAd")
 public class TAdController {
+
     @Autowired
     TAdService adService;
+
     @Autowired
     TAdminService adminService;
+
     @GetMapping("/pageAd")
-    public ResponseModel<IPage<?>> pageAd(long current, long size ) {
+    public ResponseModel<IPage<?>> pageAd(long current, long size) {
         LambdaQueryWrapper<TAd> query = Wrappers.lambdaQuery();
         query.orderByDesc(TAd::getCreateDate);
         Page<TAd> page = new Page<>(current, size, true);
         IPage<TAd> iPage = adService.page(page, query);
         List<TAd> records = iPage.getRecords();
-        if(records.size()>0){
-            for(TAd ad:records){
-                if(StringUtils.isNotEmpty(ad.getAdminId())){
+        if (records.size() > 0) {
+            for (TAd ad : records) {
+                if (StringUtils.isNotEmpty(ad.getAdminId())) {
                     TAdmin admin = adminService.getById(ad.getAdminId());
-                    if(admin!=null&&admin.getId()!=null){
+                    if (admin != null && admin.getId() != null) {
                         ad.setUsername(admin.getUsername());
                     }
                 }
@@ -55,6 +58,7 @@ public class TAdController {
         }
         return R.ok(iPage);
     }
+
     @GetMapping("/listAd")
     public ResponseModel<?> listAd() {
         LambdaQueryWrapper<TAd> query = Wrappers.lambdaQuery();
@@ -63,34 +67,36 @@ public class TAdController {
 
         return R.ok(list);
     }
+
     @GetMapping("/getAdList")
-    public ResponseModel<?> getAdList(String type,String userName,String name,String screenType) {
+    public ResponseModel<?> getAdList(String type, String userName, String name, String screenType) {
         LambdaQueryWrapper<TAd> query = Wrappers.lambdaQuery();
-        if(StringUtils.isNotEmpty(type)){
-            query.eq(TAd::getEquipmentType,type);
+        if (StringUtils.isNotEmpty(type)) {
+            query.eq(TAd::getEquipmentType, type);
         }
-        if(StringUtils.isNotEmpty(userName)){
-            query.like(TAd::getUsername,userName);
+        if (StringUtils.isNotEmpty(userName)) {
+            query.like(TAd::getUsername, userName);
         }
-        if(StringUtils.isNotEmpty(name)){
-            query.like(TAd::getName,name);
+        if (StringUtils.isNotEmpty(name)) {
+            query.like(TAd::getName, name);
         }
-        if(StringUtils.isNotEmpty(screenType)){
-            query.eq(TAd::getScreenType,screenType);
+        if (StringUtils.isNotEmpty(screenType)) {
+            query.eq(TAd::getScreenType, screenType);
         }
         query.orderByDesc(TAd::getCreateDate);
         List<TAd> list = adService.list(query);
         return R.ok(list);
     }
+
     @ApiOperation(value = "添加")
     @PostMapping("/add")
     public ResponseModel<?> add(@RequestBody TAd ad) {
-        if(StringUtils.isEmpty(ad.getStatus())&&StringUtils.isEmpty(ad.getUrl())){
+        if (StringUtils.isEmpty(ad.getStatus()) && StringUtils.isEmpty(ad.getUrl())) {
             return R.fail(ResponseCodesEnum.A0001);
         }
-        if(StringUtils.isNotEmpty(ad.getUsername())){
+        if (StringUtils.isNotEmpty(ad.getUsername())) {
             LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
-            query.eq(TAdmin::getUsername,ad.getUsername());
+            query.eq(TAdmin::getUsername, ad.getUsername());
             List<TAdmin> list = adminService.list(query);
             TAdmin tAdmin = list.get(0);
             ad.setAdminId(String.valueOf(tAdmin.getId()));
@@ -98,46 +104,48 @@ public class TAdController {
         ad.setCreateDate(new Date());
         ad.setModifyDate(new Date());
         adService.save(ad);
-        return R.ok(ad,"添加成功");
+        return R.ok(ad, "添加成功");
     }
+
     @ApiOperation(value = "添加")
     @GetMapping("/getOne")
     public ResponseModel<?> getOne(Long id) {
-        if(id==null){
+        if (id == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         TAd ad = adService.getById(id);
         return R.ok(ad);
     }
+
     @ApiOperation(value = "修改")
     @PostMapping("/update")
     public ResponseModel<?> update(@RequestBody TAd ad) {
-        if(StringUtils.isEmpty(ad.getUrl())){
+        if (StringUtils.isEmpty(ad.getUrl())) {
             return R.fail(ResponseCodesEnum.A0001);
         }
 
         ad.setModifyDate(new Date());
         TAd oldAd = adService.getById(ad.getId());
-        if(StringUtils.isNotEmpty(ad.getUrl())){
+        if (StringUtils.isNotEmpty(ad.getUrl())) {
             oldAd.setUrl(ad.getUrl());
         }
-        if(StringUtils.isNotEmpty(ad.getName())){
+        if (StringUtils.isNotEmpty(ad.getName())) {
             oldAd.setName(ad.getName());
         }
         oldAd.setEquipmentType(ad.getEquipmentType());
-        if(StringUtils.isNotEmpty(ad.getStatus())){
+        if (StringUtils.isNotEmpty(ad.getStatus())) {
             oldAd.setStatus(ad.getStatus());
         }
-        if(StringUtils.isNotEmpty(ad.getMediaPreview())){
+        if (StringUtils.isNotEmpty(ad.getMediaPreview())) {
             oldAd.setMediaPreview(ad.getMediaPreview());
         }
-        if(StringUtils.isNotEmpty(ad.getUsername())){
+        if (StringUtils.isNotEmpty(ad.getUsername())) {
             LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
-            query.eq(TAdmin::getUsername,ad.getUsername());
+            query.eq(TAdmin::getUsername, ad.getUsername());
             List<TAdmin> list = adminService.list(query);
             TAdmin tAdmin = list.get(0);
             oldAd.setAdminId(String.valueOf(tAdmin.getId()));
-        }else {
+        } else {
             oldAd.setAdminId(ad.getAdminId());
         }
         oldAd.setAdType(ad.getAdType());
@@ -150,26 +158,25 @@ public class TAdController {
         oldAd.setType(ad.getType());
         oldAd.setPlayTimeStatus(ad.getPlayTimeStatus());
         adService.updateById(oldAd);
-        return R.ok(oldAd,"修改成功");
+        return R.ok(oldAd, "修改成功");
     }
+
     /**
-     *
-     *
      * @param
      * @return
      */
     @GetMapping(value = "/deletes")
     @ResponseBody
     public ResponseModel<?> deletes(int[] ids) {
-        if(ids==null){
+        if (ids == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
-        if(ids.length>0){
-            for(int i=0;i<ids.length;i++){
+        if (ids.length > 0) {
+            for (int i = 0; i < ids.length; i++) {
                 adService.removeById(ids[i]);
             }
         }
-        return  R.ok(null,"删除成功");
+        return R.ok(null, "删除成功");
     }
 }
 

+ 57 - 0
src/main/java/com/szwl/controller/TAdminController.java

@@ -1440,6 +1440,63 @@ public class TAdminController {
         return R.ok();
     }
 
+    @ApiOperation(value = "发送忘记密码验证码")
+    @PostMapping("/sentForgetCode")
+    public ResponseModel<?> sentForgetCode(@RequestBody LoginParam param) {
+        String phoneOrEmail = param.getPhoneOrEmail();
+        // 定义国内手机号和邮箱的正则表达式
+        String phoneReg = "^1[3-9]\\d{9}$";
+        String emailReg = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
+
+        // 判断 phoneOrEmail 是手机号还是邮箱
+        if (Pattern.matches(phoneReg, phoneOrEmail)) {
+            //检测是否已有手机号注册
+            LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
+            query.eq(TAdmin::getPhone, phoneOrEmail);
+            TAdmin admin = tAdminService.getOne(query);
+            if (admin == null) {
+                // 说明手机未注册
+                return R.fail(ResponseCodesEnum.R0010);
+            }
+            //国内发送短信
+            String result = tMessageCodeService.sentMessage("1", phoneOrEmail, admin.getCompanyType(), admin.getId());
+            return R.ok(result);
+        } else if (Pattern.matches(emailReg, phoneOrEmail)) {
+            //检测是否已有邮箱注册
+            LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
+            query.eq(TAdmin::getEmail, phoneOrEmail);
+            TAdmin admin = tAdminService.getOne(query);
+            if (admin == null) {
+                // 邮箱未注册
+                return R.fail(ResponseCodesEnum.R0011);
+            }
+            // 发邮件
+            String result = tMessageCodeService.sentEmail("1", phoneOrEmail, admin.getId());
+            return R.ok(result);
+        }
+        return R.fail(ResponseCodesEnum.R0004);
+    }
+
+    @ApiOperation(value = "校验验证码")
+    @PostMapping("/checkForgetCode")
+    public ResponseModel<?> checkForgetCode(@RequestBody LoginParam param) {
+        String phoneOrEmail = param.getPhoneOrEmail();
+        String code = param.getCode();
+        LambdaQueryWrapper<TMessageCode> query = Wrappers.lambdaQuery();
+        query.eq(TMessageCode::getPhone, phoneOrEmail);
+        query.eq(TMessageCode::getCode, code);
+        query.eq(TMessageCode::getType, "1");
+        query.eq(TMessageCode::getStatus, "0");
+        TMessageCode messageCode = tMessageCodeService.getOne(query);
+        if (messageCode != null) {
+            messageCode.setStatus("1");
+            messageCode.setModifyDate(new Date());
+            tMessageCodeService.updateById(messageCode);
+            TAdmin admin = tAdminService.getById(messageCode.getAdminId());
+            return R.ok(admin.getUsername());
+        }
+        return R.fail(ResponseCodesEnum.R0007);
+    }
 
 }
 

+ 0 - 21
src/main/java/com/szwl/controller/TAdminEquipmentController.java

@@ -1,21 +0,0 @@
-package com.szwl.controller;
-
-
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- *  前端控制器
- * </p>
- *
- * @author wuhs
- * @since 2022-07-04
- */
-@RestController
-@RequestMapping("/tAdminEquipment")
-public class TAdminEquipmentController {
-
-}
-

+ 0 - 4
src/main/java/com/szwl/controller/TAlarmClockController.java

@@ -81,9 +81,7 @@ public class TAlarmClockController {
         alarmClock.setWeek(alarmClock.getWeek()+",");
         alarmClock.setHour(alarmClock.getHour()+":00");
         tAlarmClockService.save(alarmClock);
-//		sentMessageToEquiment(alarmClock.getType(),alarmClock.getEquipmentIds(),alarmClock.getAdminId());
         //避免返回大量数据
-//		alarmClock.setEquipmentIds(null);
         Long alarmClockItemId = alarmClock.getId();
         String equipmentIds = alarmClock.getEquipmentIds();
         String[] eids = equipmentIds.split(",");
@@ -97,7 +95,6 @@ public class TAlarmClockController {
             alarmClockItem.setWeek(alarmClock.getWeek());
             alarmClockItem.setStatus(alarmClock.getStatus());
             alarmClockItem.setType(alarmClock.getType());
-//                alarmClockItem.setIsCirculate(alarmClocka1.getIsCirculate());
             alarmClockItem.setModifyDate(alarmClock.getModifyDate());
             alarmClockItem.setCreateDate(alarmClock.getCreateDate());
             tAlarmClockItemService.save(alarmClockItem);
@@ -120,7 +117,6 @@ public class TAlarmClockController {
                 kindData.put("type" ,alarmClock.getType());
                 kindData.put("data" , list);
                 tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("alarmClock", kindData.toString()).toString());
-//                    PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("alarmClock", kindData.toString()).toString());
             }
         }
         return ResponseEntity.status(HttpStatus.OK)

+ 0 - 24
src/main/java/com/szwl/controller/TAlarmClockItemController.java

@@ -1,24 +0,0 @@
-package com.szwl.controller;
-
-
-import io.swagger.annotations.Api;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 闹钟列表详情 前端控制器
- * </p>
- *
- * @author wuhs
- * @since 2022-06-02
- */
-@Api(value = "/tAlarmClock", tags = {"闹钟详情"})
-
-@RestController
-@RequestMapping("/tAlarmClockItem")
-public class TAlarmClockItemController {
-
-}
-

+ 0 - 2
src/main/java/com/szwl/controller/TAlarmRecordController.java

@@ -54,9 +54,7 @@ public class TAlarmRecordController {
         JSONObject kindData = new JSONObject();
         kindData.put("id" , param.getId());
         kindData.put("content" , tAlarmRecord.getAlarmContent());
-//        equipment.getGtClientId();
         tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("eliminate", kindData.toString()).toString());
-//        PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("eliminate", kindData.toString()).toString());
         return ResponseEntity.status(HttpStatus.OK)
                 .body(new ResultMessage().setCode(true).setData("0").setMessage("已发送"));
     }

+ 253 - 142
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -498,13 +498,14 @@ public class TEquipmentController {
             equipmentDTO.setCouponStatus(equipmentDesc.getCouponStatus());
             equipmentDTO.setInDoor(equipmentDesc.getInDoor());
             equipmentDTO.setOutDoor(equipmentDesc.getOutDoor());
-            if (equipmentDesc.getFlowers() != null) {
+            if (StringUtils.isNotEmpty(equipmentDesc.getFlowers())) {
                 equipmentDTO.setFlowers(equipmentDesc.getFlowers());
             }
             equipmentDTO.setNumberOne(equipmentDesc.getNumberOne());
             equipmentDTO.setCandyGeneratorTm(equipmentDesc.getCandyGeneratorTm());
             equipmentDTO.setOutsideHd(equipmentDesc.getOutsideHd());
             equipmentDTO.setOutsideTm(equipmentDesc.getOutsideTm());
+            equipmentDTO.setIsMaterialUse(equipmentDesc.getIsMaterialUse());
             equipmentDTO.setDiyFlowerStatus(equipmentDesc.getDiyFlowerStatus());
             equipmentDTO.setCleanFunction(equipmentDesc.getCleanFunction());
             equipmentDTO.setTaxStatus(equipmentDesc.getTaxStatus());
@@ -673,18 +674,12 @@ public class TEquipmentController {
         return R.ok(tEquipment);
     }
 
-    /**
-     * 更新
-     */
     @ApiOperation(value = "更新机器")
     @RequestMapping(value = "/update", method = RequestMethod.POST)
     public ResponseModel<?> update(@RequestBody TEquipmentDTO equipment) {
         //获取修改前的设备
         TEquipment oldEquipment = tEquipmentService.getById(equipment.getId());
         TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
-        if (StringUtils.isNotEmpty(equipment.getSn())) {
-            oldEquipment.setSn(equipment.getSn());
-        }
         String name = equipment.getName();
         if (StringUtils.isNotEmpty(name) && !name.equals(oldEquipment.getName())) {
             LambdaQueryWrapper<TEquipment> queryWrapper = new LambdaQueryWrapper<>();
@@ -699,9 +694,6 @@ public class TEquipmentController {
         if (StringUtils.isNotEmpty(equipment.getSelfName())) {
             oldEquipment.setSelfName(equipment.getSelfName());
         }
-        if (equipment.getAreaId() != null) {
-            oldEquipment.setAreaId(equipment.getAreaId());
-        }
         if (StringUtils.isNotEmpty(equipment.getContactName())) {
             oldEquipment.setContactName(equipment.getContactName());
         }
@@ -714,24 +706,12 @@ public class TEquipmentController {
         if (StringUtils.isNotEmpty(equipment.getOperationalPhone())) {
             oldEquipment.setOperationalPhone(equipment.getOperationalPhone());
         }
-        if (StringUtils.isNotEmpty(equipment.getOperator())) {
-            oldEquipment.setOperator(equipment.getOperator());
-        }
-        if (StringUtils.isNotEmpty(equipment.getSimNo())) {
-            oldEquipment.setSimNo(equipment.getSimNo());
-        }
         if (equipment.getTimeRuleId() != null) {
             oldEquipment.setTimeRuleId(equipment.getTimeRuleId());
         }
-        if (StringUtils.isNotEmpty(equipment.getPlcVersion())) {
-            oldEquipment.setPlcVersion(equipment.getPlcVersion());
-        }
         if (StringUtils.isNotEmpty(equipment.getChannel())) {
             oldEquipment.setChannel(equipment.getChannel());
         }
-        if (equipment.getPayType() != null) {
-            oldEquipment.setPayType(equipment.getPayType());
-        }
         if (equipment.getEndDate() != null) {
             oldEquipment.setEndDate(equipment.getEndDate());
         }
@@ -764,28 +744,13 @@ public class TEquipmentController {
             oldEquipment.setMessageReceiver(message[0] + "," + message[1] + "," + message[2]);
         }
         tEquipmentService.updateById(oldEquipment);
-        if (equipment.getPayType() != null) {
-            tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("payType", oldEquipment.getPayType().toString() + ":" + oldEquipment.getTimeRuleId()).toString());
-        }
         if (StringUtils.isNotEmpty(oldEquipment.getContactName()) && StringUtils.isNotEmpty(oldEquipment.getContactPhone())) {
+            // MQ消息
             tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("phone", oldEquipment.getContactName() + ":" + oldEquipment.getContactPhone()).toString());
         }
-        if (StringUtils.isNotEmpty(oldEquipment.getCompanyPhone())) {
-            tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("companyPhone", oldEquipment.getCompanyPhone()).toString());
-        }
-        if (StringUtils.isNotEmpty(oldEquipment.getPlcVersion())) {
-            tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("plcVersion", oldEquipment.getPlcVersion()).toString());
-        }
-        if (StringUtils.isNotEmpty(oldEquipment.getSelfName())) {
-            tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("selfName", oldEquipment.getSelfName()).toString());
-        }
         if (oldEquipment.getTimeRuleId() != null) {
             tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("pushTimeRule", oldEquipment.getTimeRuleId() + "").toString());
         }
-        if (StringUtils.isNotEmpty(oldEquipment.getOperationalName())) {
-            tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("operational", oldEquipment.getOperationalName() + ":" + oldEquipment.getOperationalPhone()).toString());
-        }
-
         return R.ok("null", "更新成功!");
     }
 
@@ -895,41 +860,6 @@ public class TEquipmentController {
 
     }
 
-    @ApiOperation(value = "消除报警")
-    @PostMapping("/eliminate")
-    public ResponseModel<?> eliminate(@RequestBody TAlarmRecord param) {
-        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
-                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
-        Long adminId = userDetailBO.getId();
-        TAlarmRecord tAlarmRecord = tAlarmRecordService.getById(param.getId());
-        TEquipment equipment = tEquipmentService.getById(tAlarmRecord.getEquipmentId());
-        if (equipment == null) {
-            return R.fail(A0001, "设备不存在");
-        }
-        String machineType = equipment.getMachineType();
-        if (StringUtils.isNotEmpty(machineType) && "2".equals(machineType)) {
-            // 消除过往的报警
-            LambdaUpdateWrapper<TAlarmRecord> wrapper = Wrappers.lambdaUpdate();
-            wrapper.eq(TAlarmRecord::getClientId, tAlarmRecord.getClientId());
-            wrapper.eq(TAlarmRecord::getIsEliminate, 0);
-            wrapper.le(TAlarmRecord::getCreateDate, new Date());
-            wrapper.set(TAlarmRecord::getIsEliminate, 1);
-            tAlarmRecordService.update(wrapper);
-            // 更改机器状态
-            equipment.setIsAlarm(false);
-            tEquipmentService.updateById(equipment);
-        } else {
-            JSONObject kindData = new JSONObject();
-            kindData.put("id", param.getId());
-            kindData.put("content", tAlarmRecord.getAlarmContent());
-            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("eliminate", kindData.toString()).toString());
-            // MQTT
-            String message = PushUtils.buildJson(OperationType.ELIMINATE.getCode(), "1").toString();
-            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.ELIMINATE, message, adminId);
-        }
-        return R.ok();
-    }
-
     @ApiOperation(value = "修改机器音量")
     @PostMapping("/updateVolume")
     public ResponseEntity<?> updateVolume(@RequestBody TEquipment equipment) {
@@ -943,52 +873,6 @@ public class TEquipmentController {
 
     }
 
-    @ApiOperation(value = "修改机器信息")
-    @PostMapping("/updateEquipment")
-    public ResponseEntity<?> updateEquipment(@RequestBody TEquipment equipment) {
-        TEquipment equipment1 = tEquipmentService.getById(equipment.getId());
-        Integer type = equipment.getType();
-        //修改基本信息
-        if (type == 0) {
-            equipment1.setName(equipment.getName());
-            equipment1.setSimNo(equipment.getSimNo());
-            equipment1.setOperator(equipment.getOperator());
-        }
-        //修改后台密码
-        if (type == 1) {
-            equipment1.setAdminPwd(equipment.getAdminPwd());
-            equipment1.setGuestPwd(equipment.getGuestPwd());
-            tEquipmentService.sentMessage(equipment1.getClientId(), PushUtils.buildJson("guestPwd", equipment1.getGuestPwd()).toString());
-            tEquipmentService.sentMessage(equipment1.getClientId(), PushUtils.buildJson("adminPwd", equipment1.getAdminPwd()).toString());
-//            PushUtils.push(equipment1.getGtClientId(), "【棉花糖】设备管理-更改密码", "修改guest密码", PushUtils.buildJson("guestPwd", equipment1.getGuestPwd()).toString());
-//            PushUtils.push(equipment1.getGtClientId(), "【棉花糖】设备管理-更改密码", "修改admin密码", PushUtils.buildJson("adminPwd", equipment1.getAdminPwd()).toString());
-        }
-        //定时开机
-//        if (type == 3) {
-//            equipment1.setBootTime(equipment.getBootTime());
-//            tEquipmentService.sentMessage(equipment1.getClientId(),PushUtils.buildJson("updateBootTime", equipment.getBootTime()).toString());
-//            PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("updateBootTime", equipment.getBootTime()).toString());
-//        }
-        //定时关机
-//        if (type == 4) {
-//            equipment1.setOffTime(equipment.getOffTime());
-//            tEquipmentService.sentMessage(equipment1.getClientId(), PushUtils.buildJson("updateOffTime", equipment.getBootTime()).toString());
-//            PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("updateOffTime", equipment.getBootTime()).toString());
-//        }
-        if (type == 5) {
-            equipment1.setMessageReceiver(equipment.getMessageReceiver());
-        }
-        Boolean t = tEquipmentService.updateById(equipment1);
-        if (t) {
-            return ResponseEntity.status(HttpStatus.OK)
-                    .body(new ResultMessage().setCode(true).setData(equipment1).setMessage("修改成功"));
-        } else {
-            return ResponseEntity.status(HttpStatus.OK)
-                    .body(new ResultMessage().setCode(false).setData(t).setMessage("修改失败"));
-        }
-
-    }
-
     @ApiOperation(value = "根据机器id获取用户信息")
     @PostMapping("/findByEquipment")
     public ResponseEntity<?> findByEquipment(@RequestBody TEquipment equipment) {
@@ -1699,13 +1583,6 @@ public class TEquipmentController {
         return R.ok();
     }
 
-    /**
-     * 下载日志
-     *
-     * @param equipmentId 设备id
-     * @param day         日期
-     * @param response    响应
-     */
     @ApiOperation(value = "下载日志")
     @GetMapping("/downloadLog")
     public ResponseModel<?> downloadLog(String equipmentId, String day, HttpServletResponse response) throws IOException, InterruptedException {
@@ -1854,13 +1731,6 @@ public class TEquipmentController {
         return R.ok();
     }
 
-    /**
-     * 上传日志
-     *
-     * @param equipmentId 设备ID,用于标识上传日志的设备
-     * @param day         日期,指定要上传日志的日期
-     * @return 返回操作结果,成功则返回成功信息,失败则返回失败原因
-     */
     @ApiOperation(value = "上传日志")
     @GetMapping("/uploadLog")
     public ResponseModel<?> uploadLog(String equipmentId, String day) {
@@ -2147,7 +2017,7 @@ public class TEquipmentController {
         return R.ok();
     }
 
-    @ApiOperation(value = "制作商品")
+    @ApiOperation("制作商品")
     @PostMapping("/produceGoods")
     public ResponseModel<?> produceGoods(@RequestBody DoSugarParam param) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2195,7 +2065,7 @@ public class TEquipmentController {
         return R.fail(ResponseCodesEnum.A0001);
     }
 
-    @ApiOperation(value = "上传日志")
+    @ApiOperation("上传日志")
     @GetMapping("/newUploadLog")
     public ResponseModel<?> newUploadLog(String equipmentId, String day) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2225,7 +2095,7 @@ public class TEquipmentController {
         return R.ok();
     }
 
-    @ApiOperation(value = "修改音量")
+    @ApiOperation("修改音量")
     @PostMapping("/changeVolume")
     public ResponseModel<?> changeVolume(@RequestBody TEquipment param) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2244,7 +2114,7 @@ public class TEquipmentController {
         return R.fail(ResponseCodesEnum.A0001);
     }
 
-    @ApiOperation(value = "修改机器密码")
+    @ApiOperation("修改机器密码")
     @PostMapping("/changePassword")
     public ResponseModel<?> changePassword(@RequestBody EquipmentParam param) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2258,7 +2128,7 @@ public class TEquipmentController {
             String guestPwd = param.getGuestPwd();
             JSONObject kindData = new JSONObject();
             if (StringUtils.isNotEmpty(guestPwd)) {
-                kindData.put("type", "0");
+                kindData.put("type", "1");
                 kindData.put("password", guestPwd);
                 String message = PushUtils.buildJson(OperationType.PASSWORD.getCode(), kindData.toString()).toString();
                 // MQTT消息
@@ -2267,7 +2137,7 @@ public class TEquipmentController {
                 tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("guestPwd", guestPwd).toString());
             }
             if (StringUtils.isNotEmpty(adminPwd)) {
-                kindData.put("type", "1");
+                kindData.put("type", "0");
                 kindData.put("password", adminPwd);
                 String message = PushUtils.buildJson(OperationType.PASSWORD.getCode(), kindData.toString()).toString();
                 // MQTT消息
@@ -2309,7 +2179,7 @@ public class TEquipmentController {
         return R.fail(ResponseCodesEnum.A0001);
     }
 
-    @ApiOperation(value = "重启触摸屏")
+    @ApiOperation("重启触摸屏")
     @GetMapping("/restartScreen")
     public ResponseModel<?> restartScreen(String equipmentId) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2329,7 +2199,7 @@ public class TEquipmentController {
         return R.fail(ResponseCodesEnum.A0001);
     }
 
-    @ApiOperation(value = "机器睡眠")
+    @ApiOperation("机器睡眠")
     @PostMapping("/switchSleep")
     public ResponseModel<?> switchSleep(@RequestBody EquipmentParam param) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2350,7 +2220,7 @@ public class TEquipmentController {
         return R.fail(ResponseCodesEnum.A0001);
     }
 
-    @ApiOperation(value = "机器开关机")
+    @ApiOperation("机器开关机")
     @PostMapping("/powerOnOff")
     public ResponseModel<?> powerOnOff(@RequestBody EquipmentParam param) {
         UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
@@ -2375,5 +2245,246 @@ public class TEquipmentController {
         return R.fail(ResponseCodesEnum.A0001);
     }
 
+    @ApiOperation("消除报警")
+    @PostMapping("/eliminate")
+    public ResponseModel<?> eliminate(@RequestBody TAlarmRecord param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+        TAlarmRecord tAlarmRecord = tAlarmRecordService.getById(param.getId());
+        TEquipment equipment = tEquipmentService.getById(tAlarmRecord.getEquipmentId());
+        if (equipment == null) {
+            return R.fail(A0001, "设备不存在");
+        }
+        String machineType = equipment.getMachineType();
+        if (StringUtils.isNotEmpty(machineType) && "2".equals(machineType)) {
+            // 消除过往的报警
+            LambdaUpdateWrapper<TAlarmRecord> wrapper = Wrappers.lambdaUpdate();
+            wrapper.eq(TAlarmRecord::getClientId, tAlarmRecord.getClientId());
+            wrapper.eq(TAlarmRecord::getIsEliminate, 0);
+            wrapper.le(TAlarmRecord::getCreateDate, new Date());
+            wrapper.set(TAlarmRecord::getIsEliminate, 1);
+            tAlarmRecordService.update(wrapper);
+            // 更改机器状态
+            equipment.setIsAlarm(false);
+            tEquipmentService.updateById(equipment);
+        } else {
+            JSONObject kindData = new JSONObject();
+            kindData.put("id", param.getId());
+            kindData.put("content", tAlarmRecord.getAlarmContent());
+            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("eliminate", kindData.toString()).toString());
+            // MQTT
+            String message = PushUtils.buildJson(OperationType.ELIMINATE.getCode(), "1").toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.ELIMINATE, message, adminId);
+        }
+        return R.ok();
+    }
+
+    @ApiOperation("锁机")
+    @PostMapping("/block")
+    public ResponseModel<?> block(@RequestBody EquipmentParam param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+
+        Long equipmentId = param.getId();
+        TEquipment equipment = tEquipmentService.getById(equipmentId);
+        if (equipment != null) {
+            // MQTT消息
+            String clientId = equipment.getClientId();
+            String status = param.getStatus();
+            String message = PushUtils.buildJson(OperationType.BLOCK.getCode(), status).toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.BLOCK, message, adminId);
+            // MQ消息
+            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("block", status).toString());
+            return R.ok();
+        }
+        return R.fail(ResponseCodesEnum.A0001);
+    }
+
+    @ApiOperation("更新机器")
+    @PostMapping("/updateInfo")
+    public ResponseModel<?> updateInfo(@RequestBody TEquipmentDTO equipment) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+
+        //获取修改前的设备
+        TEquipment oldEquipment = tEquipmentService.getById(equipment.getId());
+        TEquipmentDesc equipmentDesc = equipmentDescService.getById(equipment.getId());
+        String name = equipment.getName();
+        if (StringUtils.isNotEmpty(name) && !name.equals(oldEquipment.getName())) {
+            LambdaQueryWrapper<TEquipment> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(TEquipment::getAdminId, oldEquipment.getAdminId());
+            queryWrapper.eq(TEquipment::getName, name);
+            TEquipment tEquipment = tEquipmentService.getOne(queryWrapper);
+            if (tEquipment != null) {
+                return R.fail(A0001);
+            }
+            oldEquipment.setName(equipment.getName());
+        }
+        if (StringUtils.isNotEmpty(equipment.getSelfName())) {
+            oldEquipment.setSelfName(equipment.getSelfName());
+        }
+        if (StringUtils.isNotEmpty(equipment.getContactName())) {
+            oldEquipment.setContactName(equipment.getContactName());
+        }
+        if (StringUtils.isNotEmpty(equipment.getContactPhone())) {
+            oldEquipment.setContactPhone(equipment.getContactPhone());
+        }
+        if (StringUtils.isNotEmpty(equipment.getOperationalName())) {
+            oldEquipment.setOperationalName(equipment.getOperationalName());
+        }
+        if (StringUtils.isNotEmpty(equipment.getOperationalPhone())) {
+            oldEquipment.setOperationalPhone(equipment.getOperationalPhone());
+        }
+        if (equipment.getTimeRuleId() != null) {
+            oldEquipment.setTimeRuleId(equipment.getTimeRuleId());
+        }
+        if (StringUtils.isNotEmpty(equipment.getChannel())) {
+            oldEquipment.setChannel(equipment.getChannel());
+        }
+        if (equipment.getAreaId() != null) {
+            oldEquipment.setFullName(tAreaService.getById(equipment.getAreaId()).getFullName());
+        }
+        String[] message = new String[3];
+        message[0] = equipment.getMessageReceiver1();
+        message[1] = equipment.getMessageReceiver2();
+        message[2] = equipment.getMessageReceiver3();
+        if (message.length > 0) {
+            oldEquipment.setMessageReceiver(message[0] + "," + message[1] + "," + message[2]);
+        }
+        tEquipmentService.updateById(oldEquipment);
+        if (StringUtils.isNotEmpty(oldEquipment.getContactName()) && StringUtils.isNotEmpty(oldEquipment.getContactPhone())) {
+            // MQ消息
+            tEquipmentService.sentMessage(oldEquipment.getClientId(), PushUtils.buildJson("phone",
+                    oldEquipment.getContactName() + ":" + oldEquipment.getContactPhone()).toString());
+
+            JSONObject kindData = new JSONObject();
+            kindData.put("contactName", oldEquipment.getContactName());
+            kindData.put("contactPhone", oldEquipment.getContactPhone());
+            // MQTT消息
+            String mqMessage = PushUtils.buildJson(OperationType.PHONE.getCode(), kindData.toString()).toString();
+            tEquipmentService.sendRemoteMessage(oldEquipment.getClientId(), OperationType.PHONE, mqMessage, adminId);
+        }
+        return R.ok();
+    }
+
+    @ApiOperation("推送商品")
+    @PostMapping("/pushGoods")
+    public ResponseModel<?> pushGoods(@RequestBody EquipmentDescParam param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+
+        Long equipmentId = param.getId();
+        TEquipment equipment = tEquipmentService.getById(equipmentId);
+        if (equipment != null) {
+            // MQTT消息
+            String clientId = equipment.getClientId();
+            String flowers = param.getFlowers();
+            String message = PushUtils.buildJson(OperationType.FLOWERS.getCode(), flowers).toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.FLOWERS, message, adminId);
+            // MQ消息
+            tEquipmentService.sentMessage(clientId, PushUtils.buildJson("flowers", equipment.getFlowers()).toString());
+            // 通知客户
+            tEquipmentService.informClient(equipment.getAdminId(), clientId);
+            return R.ok();
+        }
+
+        return R.fail(ResponseCodesEnum.A0001);
+    }
+
+    @ApiOperation("推送LOGO")
+    @PostMapping("/pushLogo")
+    public ResponseModel<?> pushLogo(@RequestBody EquipmentParam param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+        TEquipment equipment = tEquipmentService.getById(param.getId());
+
+        if (equipment != null) {
+            String clientId = equipment.getClientId();
+            String logoNumber = param.getLogoNumber();
+            // MQTT消息
+            String message = PushUtils.buildJson(OperationType.UPDATE_LOGO.getCode(), logoNumber).toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.UPDATE_LOGO, message, adminId);
+            // MQ消息
+            tEquipmentService.sentMessage(clientId, PushUtils.buildJson("updateLogo", logoNumber).toString());
+            return R.ok();
+        }
+        return R.fail(ResponseCodesEnum.A0001);
+    }
+
+    @ApiOperation("脱机")
+    @PostMapping("/offline")
+    public ResponseModel<?> offline(@RequestBody EquipmentParam param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+
+        TEquipment equipment = tEquipmentService.getById(param.getId());
+        if (equipment != null) {
+            if ("xxx".equals(equipment.getClientId().substring(equipment.getClientId().length() - 3))) {
+                return R.fail("该设备已脱机");
+            }
+            // MQTT消息
+            String clientId = equipment.getClientId();
+            String message = PushUtils.buildJson(OperationType.OFFLINE.getCode(), "0").toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.OFFLINE, message, adminId);
+            // MQ消息
+            tEquipmentService.sentMessage(clientId, PushUtils.buildJson("tuoji", "0").toString());
+            return R.ok();
+        }
+        return R.fail(ResponseCodesEnum.A0001);
+    }
+
+    @ApiOperation("睡眠描述")
+    @PostMapping("/sleepDesc")
+    public ResponseModel<?> sleepDesc(@RequestBody EquipmentDescParam param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+        TEquipment equipment = tEquipmentService.getById(param.getId());
+        if (equipment != null) {
+            // MQTT消息
+            String clientId = equipment.getClientId();
+            String sleepDesc = param.getSleepDesc();
+            String message = PushUtils.buildJson(OperationType.SLEEP_DESC.getCode(), sleepDesc).toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.SLEEP_DESC, message, adminId);
+            // MQ消息
+            tEquipmentService.sentMessage(clientId, PushUtils.buildJson("sleepDesc", sleepDesc).toString());
+            return R.ok();
+        }
+        return R.fail(ResponseCodesEnum.A0001);
+    }
+
+    @ApiOperation("推送广告规则")
+    @PostMapping("/pushAdRule")
+    public ResponseModel<?> pushAdRule(@RequestBody EquipmentParam param) {
+        UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
+                .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
+        Long adminId = userDetailBO.getId();
+        Long equipmentId = param.getId();
+
+        TEquipment equipment = tEquipmentService.getById(param.getId());
+        if (equipment != null) {
+            String clientId = equipment.getClientId();
+            String timeRuleId = param.getTimeRuleId();
+
+            equipment.setTimeRuleId(Long.valueOf(timeRuleId));
+            tEquipmentService.updateById(equipment);
+
+            // MQTT消息
+            String message = PushUtils.buildJson(OperationType.PUSH_TIME_RULE.getCode(), timeRuleId).toString();
+            tEquipmentService.sendRemoteMessage(equipment.getClientId(), OperationType.PUSH_TIME_RULE, message, adminId);
+
+            // MQ消息
+            tEquipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pushTimeRule", timeRuleId).toString());
+            return R.ok();
+        }
+        return R.fail(ResponseCodesEnum.A0001);
+    }
+
 }
 

+ 1 - 4
src/main/java/com/szwl/controller/TEquipmentDeletedController.java

@@ -50,9 +50,6 @@ public class TEquipmentDeletedController {
 
     @Autowired
     TProductService tProductService;
-//
-//    @Resource
-//    TokenManager tokenManager;
 
 
     @ApiOperation(value = "删除设备")
@@ -76,7 +73,7 @@ public class TEquipmentDeletedController {
                 BeanUtils.copyProperties(tEquipment, tEquipmentDeleted);
                 tEquipmentDeletedService.save(tEquipmentDeleted);
                 LambdaQueryWrapper<TProduct> wrapper = new LambdaQueryWrapper<>();
-                wrapper.eq(TProduct::getEquipmentId,equipmentId);
+                wrapper.eq(TProduct::getEquipmentId, equipmentId);
                 tProductService.remove(wrapper);
                 // 删除设备
                 tEquipmentService.removeById(equipmentId);

+ 0 - 28
src/main/java/com/szwl/controller/THotUpdateController.java

@@ -119,10 +119,6 @@ public class THotUpdateController {
     public ResponseModel<?> getPatchList1(String clientId, String ifForeign) {
         List<THotUpdate> lastTen = new ArrayList<THotUpdate>();
         String area;
-//        if (StringUtils.isNotEmpty(clientId)) {
-//            // 部分设备 targetAreas = 0
-//            area = "0";
-//        } else
         if ("0".equals(ifForeign)) {
             // 国内 targetAreas = 1
             area = "1";
@@ -280,18 +276,11 @@ public class THotUpdateController {
                 if (equipmentIdList.isEmpty()) {
                     return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
                 }
-//                if (CollectionUtils.isEmpty(equipmentIdList)) {
-//                    return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
-//                }
-//                equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList, hotUpdateId);
                 tHotUpdate.setShouldUpdateNum(equipmentIdList.size());
                 break;
             case "1":
                 // 推送国内
                 // 查询所有的国内用户
-//                LambdaQueryWrapper<TAdmin> wrapper1 = Wrappers.lambdaQuery();
-//                wrapper1.eq(TAdmin::getIfForeign, "0");
-//                List<TAdmin> domesticAdminList = adminService.list(wrapper1);
                 List<TAdmin> domesticAdminList = adminService.lambdaQuery().eq(TAdmin::getIfForeign, "0").list();
 
                 ArrayList<Long> equipmentIdList1 = new ArrayList<>();
@@ -307,9 +296,6 @@ public class THotUpdateController {
                 if (equipmentIdList1.isEmpty()) {
                     return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
                 }
-//                if (!equipmentIdList1.isEmpty()) {
-//                    equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
-//                }
                 tHotUpdate.setShouldUpdateNum(equipmentIdList1.size());
 
                 break;
@@ -322,9 +308,6 @@ public class THotUpdateController {
                 if (equipmentIdList2.isEmpty()) {
                     return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
                 }
-//                if (!equipmentIdList2.isEmpty()) {
-//                    equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList2, hotUpdateId);
-//                }
                 tHotUpdate.setShouldUpdateNum(equipmentIdList2.size());
                 break;
             case "3":
@@ -334,11 +317,6 @@ public class THotUpdateController {
                 if (equipmentIdList3.isEmpty()) {
                     return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
                 }
-//                equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList3, hotUpdateId);
-
-//                List<TEquipmentDesc> equipmentDescList = equipmentDescService.list();
-//                equipmentDescList.forEach(d -> d.setPatchId(hotUpdateId));
-//                equipmentDescService.saveOrUpdateBatch(equipmentDescList);
                 tHotUpdate.setShouldUpdateNum(equipmentIdList3.size());
                 break;
             default:
@@ -362,10 +340,6 @@ public class THotUpdateController {
         String clientIdS = hotUpdate.getClientId(); // 设备编号
         String note = hotUpdate.getNote(); // 更新内容
 
-//        if (StringUtils.isEmpty(patchVersion) || StringUtils.isEmpty(patchStatus) || StringUtils.isEmpty(patchLink) || StringUtils.isEmpty(note)) {
-//            return R.fail(ResponseCodesEnum.A0001,"参数不完整");
-//        }
-
         assert StringUtils.isNotEmpty(patchVersion) : R.fail(ResponseCodesEnum.B0001, "补丁版本号不能为空");
         assert StringUtils.isNotEmpty(patchStatus) : R.fail(ResponseCodesEnum.B0001, "补丁状态不能为空");
         assert StringUtils.isNotEmpty(patchLink) : R.fail(ResponseCodesEnum.B0001, "补丁外链不能为空");
@@ -389,7 +363,6 @@ public class THotUpdateController {
         tHotUpdate.setNote(note);
         tHotUpdate.setOriginalVersion(originalVersion);
         tHotUpdate.setHaveUpdateNum(0);
-//        tHotUpdate.setShouldUpdateNum(0);
 
         switch (targetAreas) {
             case "0":
@@ -425,7 +398,6 @@ public class THotUpdateController {
                     }
                 }
                 if (!equipmentIdList1.isEmpty()) {
-//                    saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
                     equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
                 }
 

+ 60 - 60
src/main/java/com/szwl/controller/TJoinpayMchCheckController.java

@@ -52,27 +52,23 @@ public class TJoinpayMchCheckController {
 
     @ApiOperation(value = "平台查找审核信息列表")
     @GetMapping("/pageMch")
-    public ResponseModel<?> pageMch(String adminId,String username, String type,long current, long size) {
-        if(StringUtils.isEmpty(type)||StringUtils.isEmpty(adminId)){
+    public ResponseModel<?> pageMch(String adminId, String username, String type, long current, long size) {
+        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(adminId)) {
             return R.fail(ResponseCodesEnum.A0100);
         }
         TAdmin admin = adminService.getById(adminId);
-        if(admin.getType()>1){
-            // todo
-//            return R.fail(ResponseCodesEnum.A0100);
-        }
-        if(type.equals("0")){
+        if (type.equals("0")) {
             //汇聚的审核信息
             LambdaQueryWrapper<TJoinpayMchCheck> query = Wrappers.lambdaQuery();
-            if(admin.getType()>1){
-                query.eq(TJoinpayMchCheck::getAdminId,admin.getId());
+            if (admin.getType() > 1) {
+                query.eq(TJoinpayMchCheck::getAdminId, admin.getId());
             }
-            if(StringUtils.isNotEmpty(username)){
+            if (StringUtils.isNotEmpty(username)) {
                 LambdaQueryWrapper<TAdmin> query1 = Wrappers.lambdaQuery();
-                query1.eq(TAdmin::getUsername,username);
+                query1.eq(TAdmin::getUsername, username);
                 List<TAdmin> list1 = adminService.list(query1);
-                if(list1.size()>0){
-                    query.eq(TJoinpayMchCheck::getAdminId,list1.get(0).getId());
+                if (list1.size() > 0) {
+                    query.eq(TJoinpayMchCheck::getAdminId, list1.get(0).getId());
                 }
             }
             if (admin.getId() == 2738) {
@@ -81,7 +77,7 @@ public class TJoinpayMchCheckController {
                         .eq(TAdmin::getCompanyType, "0");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(TJoinpayMchCheck::getAdminId,adminIds);
+                query.in(TJoinpayMchCheck::getAdminId, adminIds);
             }
             // 七云平台管理员
             if (admin.getId() == 2739) {
@@ -89,26 +85,26 @@ public class TJoinpayMchCheckController {
                 adminQuery.eq(TAdmin::getCompanyType, "1");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(TJoinpayMchCheck::getAdminId,adminIds);
+                query.in(TJoinpayMchCheck::getAdminId, adminIds);
             }
             query.orderByDesc(TJoinpayMchCheck::getCreateDate);
-            query.eq(TJoinpayMchCheck::getType,"0");
+            query.eq(TJoinpayMchCheck::getType, "0");
             Page<TJoinpayMchCheck> page = new Page<>(current, size, true);
             IPage<TJoinpayMchCheck> iPage = tJoinpayMchCheckService.page(page, query);
             return R.ok(iPage);
         }
-        if(type.equals("1")) {
+        if (type.equals("1")) {
             //杉德的审核信息
             LambdaQueryWrapper<THuifuMchCheck> query = Wrappers.lambdaQuery();
-            if(admin.getType()>1){
-                query.eq(THuifuMchCheck::getAdminId,admin.getId());
+            if (admin.getType() > 1) {
+                query.eq(THuifuMchCheck::getAdminId, admin.getId());
             }
-            if(StringUtils.isNotEmpty(username)){
+            if (StringUtils.isNotEmpty(username)) {
                 LambdaQueryWrapper<TAdmin> query1 = Wrappers.lambdaQuery();
-                query1.eq(TAdmin::getUsername,username);
+                query1.eq(TAdmin::getUsername, username);
                 List<TAdmin> list1 = adminService.list(query1);
-                if(list1.size()>0){
-                    query.eq(THuifuMchCheck::getAdminId,list1.get(0).getId());
+                if (list1.size() > 0) {
+                    query.eq(THuifuMchCheck::getAdminId, list1.get(0).getId());
                 }
             }
             if (admin.getId() == 2738) {
@@ -117,7 +113,7 @@ public class TJoinpayMchCheckController {
                         .eq(TAdmin::getCompanyType, "0");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(THuifuMchCheck::getAdminId,adminIds);
+                query.in(THuifuMchCheck::getAdminId, adminIds);
             }
             // 七云平台管理员
             if (admin.getId() == 2739) {
@@ -125,7 +121,7 @@ public class TJoinpayMchCheckController {
                 adminQuery.eq(TAdmin::getCompanyType, "1");
                 List<Long> adminIds = adminService.list(adminQuery).stream()
                         .map(TAdmin::getId).collect(Collectors.toList());
-                query.in(THuifuMchCheck::getAdminId,adminIds);
+                query.in(THuifuMchCheck::getAdminId, adminIds);
             }
             query.orderByDesc(THuifuMchCheck::getCreateDate);
 //            query.eq(THuifuMchCheck::getStatus,"1").or().eq(THuifuMchCheck::getStatus,"4");
@@ -140,28 +136,29 @@ public class TJoinpayMchCheckController {
     @PostMapping("/getOne")
     public ResponseModel<?> findById(Long id, String username) {
         TAdmin admin = adminService.getById(id);
-        if(!admin.getUsername().equals(username)){
+        if (!admin.getUsername().equals(username)) {
             return R.fail("username不符合!");
         }
         LambdaQueryWrapper<TJoinpayMchCheck> query = Wrappers.lambdaQuery();
-        query.eq(TJoinpayMchCheck::getAdminId,id);
-        query.eq(TJoinpayMchCheck::getType,"0");
+        query.eq(TJoinpayMchCheck::getAdminId, id);
+        query.eq(TJoinpayMchCheck::getType, "0");
         List<TJoinpayMchCheck> list = tJoinpayMchCheckService.list(query);
-        if(list.size()>0){
-            return R.ok(list.get(list.size()-1));
-        }else {
+        if (list.size() > 0) {
+            return R.ok(list.get(list.size() - 1));
+        } else {
             return R.fail("没有审核信息");
         }
     }
+
     @GetMapping("/selectOne")
     public ResponseModel<?> selectOne(Long id, String type) {
-        if(StringUtils.isNotEmpty(type)){
-            if(type.equals("0")){
+        if (StringUtils.isNotEmpty(type)) {
+            if (type.equals("0")) {
                 //汇聚
                 TJoinpayMchCheck joinpayMchCheck = tJoinpayMchCheckService.getById(id);
                 return R.ok(joinpayMchCheck);
             }
-            if(type.equals("1")){
+            if (type.equals("1")) {
                 //汇付
                 THuifuMchCheck huifuMchCheck = tHuifuMchCheckService.getById(id);
                 return R.ok(huifuMchCheck);
@@ -169,58 +166,60 @@ public class TJoinpayMchCheckController {
         }
         return R.ok();
     }
+
     @ApiOperation(value = "撤销申请")
     @GetMapping("/update")
     public ResponseModel<?> update(Long id) {
         LambdaQueryWrapper<TJoinpayMchCheck> query = Wrappers.lambdaQuery();
-        query.eq(TJoinpayMchCheck::getId,id);
+        query.eq(TJoinpayMchCheck::getId, id);
         List<TJoinpayMchCheck> list = tJoinpayMchCheckService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             TJoinpayMchCheck tJoinpayMchCheck = list.get(0);
             tJoinpayMchCheck.setType("2");
             tJoinpayMchCheck.setModifyDate(new Date());
             tJoinpayMchCheckService.updateById(tJoinpayMchCheck);
             return R.ok();
-        }else {
+        } else {
             return R.fail("撤销失败");
         }
     }
+
     @ApiOperation(value = "平台查找汇聚收款账户在审核信息")
     @PostMapping("/getList")
     public ResponseModel<?> getList(String username, String type) {
         LambdaQueryWrapper<TJoinpayMchCheck> query = Wrappers.lambdaQuery();
-        if(StringUtils.isNotEmpty(username)){
+        if (StringUtils.isNotEmpty(username)) {
             LambdaQueryWrapper<TAdmin> query1 = Wrappers.lambdaQuery();
-            query1.eq(TAdmin::getUsername,username);
+            query1.eq(TAdmin::getUsername, username);
             List<TAdmin> list1 = adminService.list(query1);
-            if(list1.size()>0){
-                query.eq(TJoinpayMchCheck::getAdminId,list1.get(0).getId());
+            if (list1.size() > 0) {
+                query.eq(TJoinpayMchCheck::getAdminId, list1.get(0).getId());
             }
         }
-        if(StringUtils.isNotEmpty(type)){
-            query.eq(TJoinpayMchCheck::getType,type);
+        if (StringUtils.isNotEmpty(type)) {
+            query.eq(TJoinpayMchCheck::getType, type);
         }
         List<TJoinpayMchCheck> list = tJoinpayMchCheckService.list(query);
-        if(list.size()>0){
+        if (list.size() > 0) {
             return R.ok(list);
-        }else {
+        } else {
             return R.fail("没有审核信息");
         }
     }
 
     @ApiOperation(value = "平台审核是否通过")
     @GetMapping("/shenhe")
-    public ResponseModel<?> shenhe(Long id,String type,String status) {
-        if(type.equals("0")){
+    public ResponseModel<?> shenhe(Long id, String type, String status) {
+        if (type.equals("0")) {
             //汇聚
-            if(status.equals("1")){
+            if (status.equals("1")) {
                 //通过
                 TJoinpayMchCheck joinpayMchCheck = tJoinpayMchCheckService.getById(id);
                 joinpayMchCheck.setType("1");
                 LambdaQueryWrapper<TJoinpayMch> query1 = Wrappers.lambdaQuery();
-                query1.eq(TJoinpayMch::getAdminId,joinpayMchCheck.getAdminId());
+                query1.eq(TJoinpayMch::getAdminId, joinpayMchCheck.getAdminId());
                 List<TJoinpayMch> list1 = tJoinpayMchService.list(query1);
-                if(list1.size()>0){
+                if (list1.size() > 0) {
                     TJoinpayMch mch = list1.get(0);
                     mch.setModifyDate(new Date());
                     mch.setAltMerchantType(joinpayMchCheck.getAltMerchantType());
@@ -239,15 +238,15 @@ public class TJoinpayMchCheckController {
                     mch.setStep("0");
                     //修改的数据发送到汇聚
                     String result = tJoinpayMchService.updateMch(mch);
-                    if(result.equals("ok")){
+                    if (result.equals("ok")) {
                         tJoinpayMchService.updateById(mch);
                         joinpayMchCheck.setModifyDate(new Date());
                         tJoinpayMchCheckService.updateById(joinpayMchCheck);
-                    }else{
+                    } else {
                         return R.fail(result);
                     }
                 }
-            }else {
+            } else {
                 //拒绝
                 TJoinpayMchCheck tJoinpayMchCheck = tJoinpayMchCheckService.getById(id);
                 tJoinpayMchCheck.setModifyDate(new Date());
@@ -255,27 +254,28 @@ public class TJoinpayMchCheckController {
                 tJoinpayMchCheckService.updateById(tJoinpayMchCheck);
             }
 
-        }if(type.equals("1")) {
+        }
+        if (type.equals("1")) {
             //杉德
-            if(status.equals("1")){
+            if (status.equals("1")) {
                 //通过
                 TShandeMchCheck shandeMchCheck = tShandeMchCheckService.getById(id);
                 LambdaQueryWrapper<TShandeMch> query = Wrappers.lambdaQuery();
-                query.eq(TShandeMch::getAdminId,shandeMchCheck.getAdminId());
+                query.eq(TShandeMch::getAdminId, shandeMchCheck.getAdminId());
                 List<TShandeMch> list = tShandeMchService.list(query);
-                if(list.size()>0){
+                if (list.size() > 0) {
                     TShandeMch mch = list.get(0);
                     mch.setModifyDate(new Date());
                     mch.setBankName(shandeMchCheck.getBankName());
                     mch.setType(shandeMchCheck.getType());
                     mch.setBankNo(shandeMchCheck.getBankNo());
                     //企业
-                    if(shandeMchCheck.getType().equals("0")){
+                    if (shandeMchCheck.getType().equals("0")) {
                         mch.setBankChannelNo(shandeMchCheck.getBankChannelNo());
                         mch.setBankChannelName(shandeMchCheck.getBankChannelName());
                     }
                     //个人
-                    if(shandeMchCheck.getType().equals("1")){
+                    if (shandeMchCheck.getType().equals("1")) {
                         mch.setBankChannelNo(null);
                         mch.setBankChannelName(null);
                     }
@@ -284,7 +284,7 @@ public class TJoinpayMchCheckController {
                     shandeMchCheck.setModifyDate(new Date());
                     tShandeMchCheckService.updateById(shandeMchCheck);
                 }
-            }else {
+            } else {
                 //拒绝
                 TShandeMchCheck tShandeMchCheck = tShandeMchCheckService.getById(id);
                 tShandeMchCheck.setModifyDate(new Date());

+ 3 - 1
src/main/java/com/szwl/controller/TJoinpayMchController.java

@@ -306,7 +306,9 @@ public class TJoinpayMchController {
     public ResponseModel<?> uploadPhotos(@RequestBody TJoinpayMch tJoinpayMch) {
         UserLicense userLicense = userLicenseService.getById(tJoinpayMch.getAdminId());
         Integer altMerchantType = tJoinpayMch.getAltMerchantType();
-        TJoinpayMch mch = tJoinpayMchService.getById(tJoinpayMch.getId());
+        LambdaQueryWrapper<TJoinpayMch> query = Wrappers.lambdaQuery();
+        query.eq(TJoinpayMch::getAdminId, tJoinpayMch.getAdminId());
+        TJoinpayMch mch = tJoinpayMchService.getOne(query);
         String cardNegative = Base64Util.imgToBase64(userLicense.getIdCardFront());
         String cardPositive = Base64Util.imgToBase64(userLicense.getIdCardBack());
         if (JoinpayConstant.ALT_MERCHANT_TYPE_ENTERPRISE == altMerchantType) {

+ 57 - 120
src/main/java/com/szwl/controller/TLabelController.java

@@ -50,24 +50,25 @@ public class TLabelController {
     @ApiOperation(value = "添加标签")
     @PostMapping("/add")
     public ResponseModel<?> add(@RequestBody TLabel label) {
-        if(StringUtils.isNotEmpty(label.getName())&&StringUtils.isNotEmpty(label.getType())&&label.getAdminId()!=null){
+        if (StringUtils.isNotEmpty(label.getName()) && StringUtils.isNotEmpty(label.getType()) && label.getAdminId() != null) {
             label.setCreateDate(new Date());
             label.setModifyDate(new Date());
             labelService.save(label);
             return R.ok();
-        }else {
+        } else {
             return R.fail(ResponseCodesEnum.A0001);
         }
     }
+
     @ApiOperation(value = "批量删除分组标签")
     @PostMapping("/delete")
     public ResponseModel<?> delete(@RequestBody Long[] ids) {
-        if(ids==null){
+        if (ids == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
-        if(ids.length > 0){
+        if (ids.length > 0) {
             ArrayList<Long> idList = new ArrayList<>();
-            for(int i = 0;i < ids.length; i++){
+            for (int i = 0; i < ids.length; i++) {
                 idList.add(ids[i]);
             }
             labelService.removeByIds(idList);
@@ -75,10 +76,12 @@ public class TLabelController {
         return R.ok();
 
     }
+
     /**
      * 获取分组列表
+     *
      * @param adminId 管理员ID
-     * @param type 分组类型
+     * @param type    分组类型
      * @return 分组列表
      */
     @GetMapping("/list")
@@ -94,83 +97,21 @@ public class TLabelController {
         // 返回分组列表
         return R.ok(list);
     }
+
     @ApiOperation(value = "获取标签详情")
     @GetMapping("/getOne")
     public ResponseModel<?> getOne(String id) {
         TLabel label = labelService.getById(id);
-//        List<String> ids = new ArrayList<>();
-//        if(label.getType().equals("0")){
-//            String adminNames = label.getAdminNames();
-//            if(StringUtils.isNotEmpty(adminNames)){
-//                List<String> adminNamelist = JSON.parseArray(adminNames, String.class);
-//                for(String username:adminNamelist){
-//                    LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
-//                    query.like(TAdmin::getUsername,username);
-//                    List<TAdmin> list = adminService.list(query);
-//                    TAdmin tAdmin = list.get(0);
-//                    ids.add(String.valueOf(tAdmin.getUsername()));
-//                }
-//            }
-//        }
-//        if(label.getType().equals("1")){
-//            String equipmentNames = label.getEquipmentNames();
-//            if(StringUtils.isNotEmpty(equipmentNames)){
-//                List<String> equipmentNamelist = JSON.parseArray(equipmentNames, String.class);
-//                for(String name:equipmentNamelist){
-//                    LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-//                    query.like(TEquipment::getName,name);
-//                    List<TEquipment> list = equipmentService.list(query);
-//                    TEquipment equipment = list.get(0);
-//                    ids.add(String.valueOf(equipment.getId()));
-//                }
-//
-//            }
-//        }
         return R.ok(label);
     }
+
     @ApiOperation(value = "修改标签")
     @PostMapping("/update")
     public ResponseModel<?> update(@RequestBody TLabel label) {
-        if(StringUtils.isNotEmpty(label.getName())&&StringUtils.isNotEmpty(label.getType())&&label.getAdminId()!=null){
+        if (StringUtils.isNotEmpty(label.getName()) && StringUtils.isNotEmpty(label.getType()) && label.getAdminId() != null) {
             label.setModifyDate(new Date());
             labelService.updateById(label);
-//            List<String> ids = new ArrayList<>();
-//            if(label.getType().equals("0")){
-//                String adminNames = label.getAdminNames();
-//                if(StringUtils.isNotEmpty(adminNames)){
-//                    List<String> adminNamelist = JSON.parseArray(adminNames, String.class);
-//                    for(String username:adminNamelist){
-//                        LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
-//                        query.like(TAdmin::getUsername,username);
-//                        List<TAdmin> list = adminService.list(query);
-//                        TAdmin tAdmin = list.get(0);
-//                        ids.add(String.valueOf(tAdmin.getId()));
-//                    }
-//                }
-//            }
-//            if(label.getType().equals("1")){
-//                String equipmentNames = label.getEquipmentNames();
-//                if(StringUtils.isNotEmpty(equipmentNames)){
-//                    List<String> equipmentNamelist = JSON.parseArray(equipmentNames, String.class);
-//                    for(String name:equipmentNamelist){
-//                        LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-//                        query.like(TEquipment::getName,name);
-//                        List<TEquipment> list = equipmentService.list(query);
-//                        TEquipment equipment = list.get(0);
-//                        ids.add(String.valueOf(equipment.getId()));
-//                    }
-//                }
-
-//            }
-//            if(ids.size()>0){
-//                if(label.getType().equals("0")){
-//                    label.setAdminIds(ids.toString());
-//                }
-//                if(label.getType().equals("1")){
-//                    label.setEquipmentIds(ids.toString());
-//                }
-//            }
-        }else {
+        } else {
             return R.fail(ResponseCodesEnum.A0001);
         }
         return R.ok();
@@ -178,47 +119,42 @@ public class TLabelController {
 
     @ApiOperation(value = "单个机器绑定标签")
     @GetMapping("/equipmentToLabel")
-    public ResponseModel<?> equipmentToLabel(String equipmentId,String labelIds) {
+    public ResponseModel<?> equipmentToLabel(String equipmentId, String labelIds) {
         TEquipment tEquipment = equipmentService.getById(equipmentId);
-        if(tEquipment==null||tEquipment.getId()==null||StringUtils.isEmpty(labelIds)){
+        if (tEquipment == null || tEquipment.getId() == null || StringUtils.isEmpty(labelIds)) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         String[] split = labelIds.split(",");
         List<String> labelIdList = Arrays.asList(split);
-//        List<String> labelIdList = JSON.parseArray(labelIds, String.class);
-        if(labelIdList.size()>0){
-            for(String id:labelIdList){
+        if (labelIdList.size() > 0) {
+            for (String id : labelIdList) {
                 TLabel label = labelService.getById(id);
-                if(label.getType().equals("1")){
+                if (label.getType().equals("1")) {
                     String ids = label.getEquipmentIds();
                     List<String> list = JSON.parseArray(ids, String.class);
-                    int i = 0 ;
-                    if(list.size()>0){
-                        for(String eid:list){
-                            if(eid.equals(equipmentId)){
+                    int i = 0;
+                    if (list.size() > 0) {
+                        for (String eid : list) {
+                            if (eid.equals(equipmentId)) {
                                 i++;
                             }
                         }
                     }
-                    if(i==0){
+                    if (i == 0) {
                         list.add(equipmentId);
                         label.setModifyDate(new Date());
                         label.setEquipmentIds(JSON.toJSON(list).toString());
                         String equipmentNames = label.getEquipmentNames();
                         List<String> stringList = new ArrayList<>();
-//                        stringList = JSON.parseArray(equipmentNames, String.class);
-                        for(String eid:list){
+                        for (String eid : list) {
                             TEquipment byId = equipmentService.getById(eid);
                             stringList.add(byId.getName());
                         }
-//                        if(StringUtils.isNotEmpty(tEquipment.getName())){
-//                            stringList.add(tEquipment.getName());
-//                        }
                         label.setEquipmentNames(JSON.toJSON(stringList).toString());
                         labelService.updateById(label);
                     }
                     List<String> stringList = new ArrayList<>();
-                    for(String eid:list){
+                    for (String eid : list) {
                         TEquipment byId = equipmentService.getById(eid);
                         stringList.add(byId.getName());
                     }
@@ -229,19 +165,19 @@ public class TLabelController {
         }
         //清空没有的标签
         LambdaQueryWrapper<TLabel> query = Wrappers.lambdaQuery();
-        query.eq(TLabel::getAdminId,tEquipment.getAdminId());
-        query.eq(TLabel::getType,1);
+        query.eq(TLabel::getAdminId, tEquipment.getAdminId());
+        query.eq(TLabel::getType, 1);
         List<TLabel> list = labelService.list(query);
         List<TLabel> returnList = new ArrayList<>();
-        if(list.size()>0){
-            for(TLabel tLabel:list){
+        if (list.size() > 0) {
+            for (TLabel tLabel : list) {
                 int i = 0;
                 String equipmentIds = tLabel.getEquipmentIds();
-                equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
+                equipmentIds = equipmentIds.replace("\"", "").replace("[", "").replace("]", "");
                 String[] split1 = equipmentIds.split(",");
-                if(split1.length>0){
-                    for(int j=0;j<split1.length;j++){
-                        if(split1[j].equals(equipmentId)){
+                if (split1.length > 0) {
+                    for (int j = 0; j < split1.length; j++) {
+                        if (split1[j].equals(equipmentId)) {
                             i++;
                         }
                     }
@@ -249,22 +185,22 @@ public class TLabelController {
                 returnList.add(tLabel);
             }
         }
-        if(returnList.size()>0){
-            if(labelIdList.size()!=returnList.size()){
-                for(TLabel tLabel:list){
+        if (returnList.size() > 0) {
+            if (labelIdList.size() != returnList.size()) {
+                for (TLabel tLabel : list) {
                     int i = 0;
-                    for(String id:labelIdList){
-                        if(id.equals(tLabel.getId().toString())){
+                    for (String id : labelIdList) {
+                        if (id.equals(tLabel.getId().toString())) {
                             i++;
                         }
                     }
-                    if(i==0){
+                    if (i == 0) {
                         String equipmentIds = tLabel.getEquipmentIds();
-                        equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
+                        equipmentIds = equipmentIds.replace("\"", "").replace("[", "").replace("]", "");
                         String[] split1 = equipmentIds.split(",");
                         List<String> stringList = new ArrayList<>();
-                        for(int j=0;j<split1.length;j++){
-                            if(!split1[j].equals(equipmentId)){
+                        for (int j = 0; j < split1.length; j++) {
+                            if (!split1[j].equals(equipmentId)) {
                                 stringList.add(split1[j]);
                             }
                         }
@@ -272,8 +208,8 @@ public class TLabelController {
                         List<String> nameList = new ArrayList<>();
                         String equipmentNames = tLabel.getEquipmentNames();
                         nameList = JSON.parseArray(equipmentNames, String.class);
-                        for(String name : nameList){
-                            if(!name.equals(tEquipment.getName())){
+                        for (String name : nameList) {
+                            if (!name.equals(tEquipment.getName())) {
                                 newNames.add(name);
                             }
                         }
@@ -284,39 +220,40 @@ public class TLabelController {
                 }
             }
         }
-        return R.ok(null,"绑定成功");
+        return R.ok(null, "绑定成功");
     }
+
     @ApiOperation(value = "单个机器标签")
     @GetMapping("/getEquipmentToLabel")
     public ResponseModel<?> getEquipmentToLabel(String equipmentId) {
         TEquipment tEquipment = equipmentService.getById(equipmentId);
-        if(tEquipment==null||tEquipment.getId()==null){
+        if (tEquipment == null || tEquipment.getId() == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         LambdaQueryWrapper<TLabel> query = Wrappers.lambdaQuery();
-        query.eq(TLabel::getAdminId,tEquipment.getAdminId());
-        query.eq(TLabel::getType,1);
+        query.eq(TLabel::getAdminId, tEquipment.getAdminId());
+        query.eq(TLabel::getType, 1);
         List<TLabel> list = labelService.list(query);
         List<TLabel> returnList = new ArrayList<>();
-        if(list.size()>0){
-            for(TLabel tLabel:list){
+        if (list.size() > 0) {
+            for (TLabel tLabel : list) {
                 int i = 0;
                 String equipmentIds = tLabel.getEquipmentIds();
-                equipmentIds = equipmentIds.replace("\"", "").replace("[","").replace("]","");
+                equipmentIds = equipmentIds.replace("\"", "").replace("[", "").replace("]", "");
                 String[] split = equipmentIds.split(",");
-                if(split.length>0){
-                    for(int j=0;j<split.length;j++){
-                        if(split[j].equals(equipmentId)){
+                if (split.length > 0) {
+                    for (int j = 0; j < split.length; j++) {
+                        if (split[j].equals(equipmentId)) {
                             i++;
                         }
                     }
                 }
-                if(i>0){
+                if (i > 0) {
                     returnList.add(tLabel);
                 }
             }
             return R.ok(returnList);
-        }else {
+        } else {
             return R.ok(returnList);
         }
 

+ 156 - 167
src/main/java/com/szwl/controller/TLocationCheckController.java

@@ -29,183 +29,172 @@ import java.util.*;
 @RequestMapping("/tLocationCheck")
 public class TLocationCheckController {
 
-  TLocationCheckService locationCheckService;
-  TAdminService adminService;
-
-  public TLocationCheckController(TLocationCheckService locationCheckService,
-      TAdminService adminService) {
-    this.locationCheckService = locationCheckService;
-    this.adminService = adminService;
-  }
-
-  @ApiOperation(value = "获取定位信息")
-  @GetMapping("/getLocInfo")
-  public ResponseModel<?> getLocInfo(String clientId) {
-    if (StringUtils.isEmpty(clientId)) {
-      return R.fail("设备id不能为空");
-    }
-    // 根据设备id查询位置信息
-    LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
-    lqw.eq(TLocationCheck::getClientId, clientId);
-    TLocationCheck locationCheck = locationCheckService.getOne(lqw);
-    if (Objects.nonNull(locationCheck)) {
-      HashMap<String, String> locationMap = new HashMap<>();
-      String country = locationCheck.getCountry();
-      String username = locationCheck.getUsername();
-      String name = locationCheck.getName();
-      String phone = locationCheck.getPhone();
-      String longitude = locationCheck.getLongitude();
-      String latitude = locationCheck.getLatitude();
-      String addr = locationCheck.getAddr();
-      String modUsername = locationCheck.getModUsername();
-      String modName = locationCheck.getModName();
-      String modPhone = locationCheck.getModPhone();
-      String message = locationCheck.getMessage();
-
-      locationMap.put("country", country); // 录入国家
-      locationMap.put("username", username); // 账号用户名
-      locationMap.put("name", name); // 录入人姓名
-      locationMap.put("phone", phone); // 录入人电话
-      locationMap.put("longitude", longitude); // 经度
-      locationMap.put("latitude", latitude); // 纬度
-      locationMap.put("address", addr); // 反编译的地址
-      locationMap.put("modUsername", modUsername); // 修改人账号
-      locationMap.put("modName", modName); // 修改人姓名
-      locationMap.put("modPhone", modPhone); // 修改人电话
-      locationMap.put("message", message); // 修改原因
-
-//            if (country.equals("中国")) {
-//                String location = locationCheck.getLocation();
-//                return R.ok(country + location);
-//            } else {
-//                return R.ok(country);
-//            }
-      return R.ok(locationMap);
-    }
-    return R.fail("地区信息未录入");
-  }
-
-  @ApiOperation(value = "根据ip校验clientId设备定位")
-  @PostMapping("/ipCheck")
-  public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip){
-    if (StringUtils.isBlank(clientId) || StringUtils.isBlank(ip)) {
-      return R.fail("参数不能为空");
-    }
-    // 根据 clientId 查设备的 location,country
-    LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
-    lqw.eq(TLocationCheck::getClientId, clientId);
-    TLocationCheck locationCheck = locationCheckService.getOne(lqw);
-    if (Objects.isNull(locationCheck)) {
-      return R.fail("生产部未录入改设备的位置信息");
-    }
-
-    locationCheck.setIp(ip);
-    locationCheck.setModifyTime(new Date());
+    TLocationCheckService locationCheckService;
+    TAdminService adminService;
 
-    String addr = WhoIsUtil.getLocByIp(ip);
-
-//        String result = locationCheckService.locCheckMsg(locationCheck, clientId, addr);
-    String result = locationCheckService.locCheckNoMsg(locationCheck, clientId, addr);
-
-    if ("fail".equals(result)) {
-      locationCheck.setErr("不匹配");
-    }
-    locationCheckService.updateById(locationCheck);
-    return R.ok(result);
-  }
-
-  @ApiOperation(value = "修改定位信息")
-  @PostMapping("/updateLocInfo")
-  public ResponseModel<?> updateLocInfo(@RequestBody TLocationCheck locationCheck) {
-    if (Objects.isNull(locationCheck)) {
-      return R.fail("参数不能为空");
+    public TLocationCheckController(TLocationCheckService locationCheckService,
+                                    TAdminService adminService) {
+        this.locationCheckService = locationCheckService;
+        this.adminService = adminService;
     }
 
-    // 售后部同事修改的信息:姓名,电话,username,clientId,国家
-    String modUsername = locationCheck.getModUsername();
-
-    Set<String> allowedUsernames = new HashSet<>(
-        Arrays.asList("shouhoumi", "sysMgtAcc", "jiang123", "ethan"));
-    if (!allowedUsernames.contains(modUsername)) {
-      return R.fail("该账号无权修改");
-    }
-    String modName = locationCheck.getModName();
-    String modPhone = locationCheck.getModPhone();
-    String clientId = locationCheck.getClientId();
-//        String location = locationCheck.getLocation();
-    String country = locationCheck.getCountry();
-    String message = locationCheck.getMessage();
-
-    if (Objects.isNull(clientId)) {
-      return R.fail("设备唯一码不能为空");
+    @ApiOperation(value = "获取定位信息")
+    @GetMapping("/getLocInfo")
+    public ResponseModel<?> getLocInfo(String clientId) {
+        if (StringUtils.isEmpty(clientId)) {
+            return R.fail("设备id不能为空");
+        }
+        // 根据设备id查询位置信息
+        LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
+        lqw.eq(TLocationCheck::getClientId, clientId);
+        TLocationCheck locationCheck = locationCheckService.getOne(lqw);
+        if (Objects.nonNull(locationCheck)) {
+            HashMap<String, String> locationMap = new HashMap<>();
+            String country = locationCheck.getCountry();
+            String username = locationCheck.getUsername();
+            String name = locationCheck.getName();
+            String phone = locationCheck.getPhone();
+            String longitude = locationCheck.getLongitude();
+            String latitude = locationCheck.getLatitude();
+            String addr = locationCheck.getAddr();
+            String modUsername = locationCheck.getModUsername();
+            String modName = locationCheck.getModName();
+            String modPhone = locationCheck.getModPhone();
+            String message = locationCheck.getMessage();
+
+            locationMap.put("country", country); // 录入国家
+            locationMap.put("username", username); // 账号用户名
+            locationMap.put("name", name); // 录入人姓名
+            locationMap.put("phone", phone); // 录入人电话
+            locationMap.put("longitude", longitude); // 经度
+            locationMap.put("latitude", latitude); // 纬度
+            locationMap.put("address", addr); // 反编译的地址
+            locationMap.put("modUsername", modUsername); // 修改人账号
+            locationMap.put("modName", modName); // 修改人姓名
+            locationMap.put("modPhone", modPhone); // 修改人电话
+            locationMap.put("message", message); // 修改原因
+
+            return R.ok(locationMap);
+        }
+        return R.fail("地区信息未录入");
     }
 
-    LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
-    wrapper.eq(TLocationCheck::getClientId, clientId);
-    List<TLocationCheck> checks = locationCheckService.list(wrapper);
-    TLocationCheck tLocationCheck = checks.get(0);
-
-    tLocationCheck.setModifyTime(new Date());
-    tLocationCheck.setModName(modName);
-//        tLocationCheck.setModAdminId(modAdminId);
-    tLocationCheck.setModPhone(modPhone);
-    tLocationCheck.setModUsername(modUsername);
-//        tLocationCheck.setLocation(location);
-    tLocationCheck.setClientId(clientId);
-    tLocationCheck.setCountry(country);
-    tLocationCheck.setMessage(message);
-
-    locationCheckService.updateById(tLocationCheck);
-
-    return R.ok("修改成功");
-  }
-
-
-  @ApiOperation(value = "录入定位信息")
-  @PostMapping("/inputLocInfo")
-  public ResponseModel<?> inputLocInfo(@RequestBody TLocationCheck locationCheck) {
-    if (Objects.isNull(locationCheck)) {
-      return R.fail("参数不能为空");
+    @ApiOperation(value = "根据ip校验clientId设备定位")
+    @PostMapping("/ipCheck")
+    public ResponseModel<?> ipCheck(@RequestParam String clientId, @RequestParam String ip) {
+        if (StringUtils.isBlank(clientId) || StringUtils.isBlank(ip)) {
+            return R.fail("参数不能为空");
+        }
+        // 根据 clientId 查设备的 location,country
+        LambdaQueryWrapper<TLocationCheck> lqw = Wrappers.lambdaQuery();
+        lqw.eq(TLocationCheck::getClientId, clientId);
+        TLocationCheck locationCheck = locationCheckService.getOne(lqw);
+        if (Objects.isNull(locationCheck)) {
+            return R.fail("生产部未录入改设备的位置信息");
+        }
+
+        locationCheck.setIp(ip);
+        locationCheck.setModifyTime(new Date());
+
+        String addr = WhoIsUtil.getLocByIp(ip);
+
+        String result = locationCheckService.locCheckNoMsg(locationCheck, clientId, addr);
+
+        if ("fail".equals(result)) {
+            locationCheck.setErr("不匹配");
+        }
+        locationCheckService.updateById(locationCheck);
+        return R.ok(result);
     }
 
-    String name = locationCheck.getName();
-    String phone = locationCheck.getPhone();
-    String username = locationCheck.getUsername();
-    String clientId = locationCheck.getClientId();
-    String country = locationCheck.getCountry(); // 国家
-
-    if (Objects.isNull(clientId)) {
-      return R.fail("设备唯一码不能为空");
-    }
-    LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
-    wrapper.eq(TLocationCheck::getClientId, clientId);
-    List<TLocationCheck> checks = locationCheckService.list(wrapper);
-    if (checks.size() > 0) {
-      return R.fail("此设备信息已录入");
+    @ApiOperation(value = "修改定位信息")
+    @PostMapping("/updateLocInfo")
+    public ResponseModel<?> updateLocInfo(@RequestBody TLocationCheck locationCheck) {
+        if (Objects.isNull(locationCheck)) {
+            return R.fail("参数不能为空");
+        }
+
+        // 售后部同事修改的信息:姓名,电话,username,clientId,国家
+        String modUsername = locationCheck.getModUsername();
+
+        Set<String> allowedUsernames = new HashSet<>(
+                Arrays.asList("shouhoumi", "sysMgtAcc", "jiang123", "ethan"));
+        if (!allowedUsernames.contains(modUsername)) {
+            return R.fail("该账号无权修改");
+        }
+        String modName = locationCheck.getModName();
+        String modPhone = locationCheck.getModPhone();
+        String clientId = locationCheck.getClientId();
+        String country = locationCheck.getCountry();
+        String message = locationCheck.getMessage();
+
+        if (Objects.isNull(clientId)) {
+            return R.fail("设备唯一码不能为空");
+        }
+
+        LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TLocationCheck::getClientId, clientId);
+        List<TLocationCheck> checks = locationCheckService.list(wrapper);
+        TLocationCheck tLocationCheck = checks.get(0);
+
+        tLocationCheck.setModifyTime(new Date());
+        tLocationCheck.setModName(modName);
+        tLocationCheck.setModPhone(modPhone);
+        tLocationCheck.setModUsername(modUsername);
+        tLocationCheck.setClientId(clientId);
+        tLocationCheck.setCountry(country);
+        tLocationCheck.setMessage(message);
+
+        locationCheckService.updateById(tLocationCheck);
+
+        return R.ok("修改成功");
     }
 
-    Set<String> allowedUsers = new HashSet<>(
-        Arrays.asList("sysMgtAcc", "jiang123", "shouhou121", "shouhou369", "shouhou397",
-            "shouhoumi", "zhl123", "ethan", "debugUser"));
-    if (!allowedUsers.contains(username)) {
-      return R.fail("该账号无权操作");
-    }
 
-    TLocationCheck tLocationCheck = new TLocationCheck();
-    String uuid = IdUtil.simpleUUID();
-    tLocationCheck.setId(uuid);
-    tLocationCheck.setCreateTime(new Date());
-    tLocationCheck.setName(name);
-    tLocationCheck.setPhone(phone);
-    tLocationCheck.setUsername(username);
-    tLocationCheck.setClientId(clientId);
-    tLocationCheck.setCountry(country);
-//        tLocationCheck.setLocation(location);
-
-    locationCheckService.save(tLocationCheck);
-
-    return R.ok("设备出厂信息录入成功");
-  }
+    @ApiOperation(value = "录入定位信息")
+    @PostMapping("/inputLocInfo")
+    public ResponseModel<?> inputLocInfo(@RequestBody TLocationCheck locationCheck) {
+        if (Objects.isNull(locationCheck)) {
+            return R.fail("参数不能为空");
+        }
+
+        String name = locationCheck.getName();
+        String phone = locationCheck.getPhone();
+        String username = locationCheck.getUsername();
+        String clientId = locationCheck.getClientId();
+        String country = locationCheck.getCountry(); // 国家
+
+        if (Objects.isNull(clientId)) {
+            return R.fail("设备唯一码不能为空");
+        }
+        LambdaQueryWrapper<TLocationCheck> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TLocationCheck::getClientId, clientId);
+        List<TLocationCheck> checks = locationCheckService.list(wrapper);
+        if (checks.size() > 0) {
+            return R.fail("此设备信息已录入");
+        }
+
+        Set<String> allowedUsers = new HashSet<>(
+                Arrays.asList("sysMgtAcc", "jiang123", "shouhou121", "shouhou369", "shouhou397",
+                        "shouhoumi", "zhl123", "ethan", "debugUser"));
+        if (!allowedUsers.contains(username)) {
+            return R.fail("该账号无权操作");
+        }
+
+        TLocationCheck tLocationCheck = new TLocationCheck();
+        String uuid = IdUtil.simpleUUID();
+        tLocationCheck.setId(uuid);
+        tLocationCheck.setCreateTime(new Date());
+        tLocationCheck.setName(name);
+        tLocationCheck.setPhone(phone);
+        tLocationCheck.setUsername(username);
+        tLocationCheck.setClientId(clientId);
+        tLocationCheck.setCountry(country);
+
+        locationCheckService.save(tLocationCheck);
+
+        return R.ok("设备出厂信息录入成功");
+    }
 
 }
 

+ 0 - 5
src/main/java/com/szwl/controller/TMessageCodeController.java

@@ -48,9 +48,6 @@ public class TMessageCodeController {
         }
         // 查询该 手机号/邮箱 最后一次发送验证码的时间
         Date lastSendTime = tMessageCodeService.getLastSendTime(phoneOrEmail);
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//        String format = sdf.format(lastSendTime);
-//        return R.ok(format);
         return R.ok(lastSendTime); // 返回时间戳
     }
 
@@ -69,7 +66,6 @@ public class TMessageCodeController {
         if (currentTime - lastTime < 10 * 60 * 1000) {
             return R.fail(ResponseCodesEnum.R0008);
         }
-//        String SZ = "Sunzee";
         String SC = "Sevencloud";
         String AETI = "Portalmcc";
         String companyType;
@@ -238,6 +234,5 @@ public class TMessageCodeController {
         }
     }
 
-
 }
 

+ 2 - 0
src/main/java/com/szwl/controller/TNoticeController.java

@@ -32,8 +32,10 @@ import java.util.List;
 @RestController
 @RequestMapping("/tNotice")
 public class TNoticeController {
+
     @Autowired
     TAdminService tAdminService;
+
     @Autowired
     TNoticeService noticeService;
 

+ 2 - 0
src/main/java/com/szwl/controller/TPriceController.java

@@ -30,8 +30,10 @@ import java.util.List;
 @RestController
 @RequestMapping("/tPrice")
 public class TPriceController {
+
     @Autowired
     TPriceService priceService;
+
     @ApiOperation(value = "获取价格")
     @GetMapping("/getPrice")
     public ResponseModel<TPrice> getPrice(@RequestParam String name) {

+ 7 - 13
src/main/java/com/szwl/controller/TPromoCodeController.java

@@ -56,18 +56,25 @@ import static com.szwl.model.utils.DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss;
 @RestController
 @RequestMapping("/tPromoCode")
 public class TPromoCodeController {
+
     @Autowired
     TEquipmentService tEquipmentService;
+
     @Autowired
     TPromoCodeService promoCodeService;
+
     @Autowired
     TPriceService priceService;
+
     @Autowired
     TAdminService adminService;
+
     @Autowired
     TOrderService orderService;
+
     @Autowired
     TJoinpayMchService joinpayMchService;
+
     @Autowired
     PayFeign payFeign;
 
@@ -145,8 +152,6 @@ public class TPromoCodeController {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
         query.eq(TEquipment::getClientId, clientId);
         TEquipment equipment = tEquipmentService.getOne(query);
-//        List<TEquipment> list = tEquipmentService.list(query);
-//        TEquipment equipment = list.get(0);
         LambdaQueryWrapper<TPromoCode> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.eq(TPromoCode::getCode, code);
         queryWrapper.eq(TPromoCode::getAdminId, equipment.getAdminId());
@@ -207,7 +212,6 @@ public class TPromoCodeController {
             promoCode.setIsUse("0");
             promoCode.setDiscount(0f);
             promoCode.setLastUseDate(lastUseDate);
-//                promoCode.setCreateDate(new Date());
             promoCode.setType("0");
             promoCode.setUserName(admin.getUsername());
             promoCodeService.save(promoCode);
@@ -314,15 +318,6 @@ public class TPromoCodeController {
         List<TPromoCode> list = promoCodeService.list(query);
         if (list.size() > 0) {
             TPromoCode tPromoCode = list.get(0);
-//            String isUse = tPromoCode.getIsUse();
-//            if(isUse.equals("1")){
-//                return R.fail(A0002,"已使用");
-//            }
-//            Date lastUseDate = tPromoCode.getLastUseDate();
-//            Date date = new Date();
-//            if(date.getTime()>lastUseDate.getTime()){
-//                return R.fail(A0002,"已过期");
-//            }
             return R.ok(tPromoCode);
         }
         return R.ok();
@@ -445,7 +440,6 @@ public class TPromoCodeController {
                 String altType = null;
                 String altUrl = null;
                 BigDecimal marketingAmount = null;
-//                frpCode = "WEIXIN_NATIVE";
                 TOrder order1 = new TOrder();
                 order1.setId(IDGenerator.orderID());
                 order1.setSn(sn);

+ 5 - 0
src/main/java/com/szwl/controller/TProportionCheckController.java

@@ -37,14 +37,19 @@ import java.util.List;
 @RestController
 @RequestMapping("/tProportionCheck")
 public class TProportionCheckController {
+
     @Autowired
     TProportionCheckService tProportionCheckService;
+
     @Autowired
     TProportionService tProportionService;
+
     @Autowired
     TEquipmentService tEquipmentService;
+
     @Autowired
     TAdminService adminService;
+
     @ApiOperation(value = "分销审核信息详情")
     @PostMapping("/getOne")
     public ResponseModel<?> findById(Long id) {

+ 0 - 65
src/main/java/com/szwl/controller/TProportionController.java

@@ -221,40 +221,6 @@ public class TProportionController {
         List<TProportion> list = tProportionService.list(query);
         if (list.size() > 0) {
             //已经注册,就要查看是否有提交审核的
-//            LambdaQueryWrapper<TProportionCheck> query1 = Wrappers.lambdaQuery();
-//            query1.eq(TProportionCheck::getAdminId,adminid);
-//            query1.eq(TProportionCheck::getClientId,clientId);
-//            List<TProportionCheck> list1 = tProportionCheckService.list(query1);
-//            if(list1.size()>0){
-//                int i = 0;
-//                for(TProportionCheck tProportionCheck:list1){
-//                    if(tProportionCheck.getCheckType().equals("0")||tProportionCheck.getCheckType().equals("3")){
-//                        i++;
-//                    }
-//                }
-//                if(i==0){
-//                    return R.ok(list.get(0));
-//                }else {
-//                    for(int j=list1.size()-1;j>=0;j--){
-//                        if(!list1.get(j).getCheckType().equals("2")&!list1.get(j).getCheckType().equals("1")){
-//                            if(list1.get(j).getCheckType().equals("3")){
-//                                Date data = new Date();
-//                                long time = data.getTime();
-//                                long updateTime = list1.get(j).getModifyDate().getTime();
-//                                if(3*24*60*60*1000l>time-updateTime){
-//                                    //拒绝的审核,超过3天后不显示
-//                                    return R.ok(list.get(0));
-//                                }else {
-//                                    return R.ok(list.get(j));
-//                                }
-//                            }
-//                            return R.ok(list.get(j));
-//                        }
-//                    }
-//                }
-//            }else {
-//                return R.ok(list.get(0));
-//            }
             TProportion tProportion = list.get(0);
             if (tProportion.getAgencyId() != null) {
                 TAdmin admin1 = adminService.getById(tProportion.getAgencyId());
@@ -280,12 +246,10 @@ public class TProportionController {
         if (tProportion.getAdminId() == null || StringUtils.isEmpty(tProportion.getClientId())) {
             R.fail("信息有空!");
         }
-//        TAdmin admin = adminService.getById(tProportion.getAdminId());
         //查找机器,看改商家是否有该机器
         LambdaQueryWrapper<TEquipment> query1 = Wrappers.lambdaQuery();
         query1.eq(TEquipment::getAdminId, tProportion.getAdminId());
         query1.eq(TEquipment::getClientId, tProportion.getClientId());
-//        List<TEquipment> equipmentList = tEquipmentService.list(query1);
         TEquipment equipment = tEquipmentService.getOne(query1);
         if (equipment == null) {
             return R.fail("找不到该机器!");
@@ -444,8 +408,6 @@ public class TProportionController {
     public ResponseModel<TProportion> getProportion(@RequestParam String equipmentId) {
         LambdaQueryWrapper<TProportion> query = Wrappers.lambdaQuery();
         query.eq(TProportion::getEquipmentId, Long.valueOf(equipmentId));
-//        List<TProportion> list = tProportionService.list(query);
-//        TProportion tProportion = list.get(0);
         TProportion proportion = tProportionService.getOne(query);
         return R.ok(proportion);
     }
@@ -492,18 +454,6 @@ public class TProportionController {
                     } else {
                         //没有,需要创建
                         //1,判断是否新机器
-//                    Date createDate = equipment.getCreateDate();
-//                    long time = createDate.getTime();
-//                    DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//                    String  day= "2022-09-21 23:59:59";
-//                    try {
-//                        Date parse = simpleDateFormat.parse(day);
-//                        if(time>parse.getTime()){
-//                            return "新机器,不能已此方式生成分销!";
-//                        }
-//                    } catch (ParseException e) {
-//                        e.printStackTrace();
-//                    }
                         //先找到原账户的分销
                         LambdaQueryWrapper<TProportion> query3 = Wrappers.lambdaQuery();
                         query3.eq(TProportion::getAdminId, admin.getId());
@@ -531,11 +481,6 @@ public class TProportionController {
                                         case 2:
                                             equipmentProportion.setProportion(adminProportion.getMerchantProportion());
                                             equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
-//                                    if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
-//                                        equipmentProportion.setAgencyId(admin.getAgencyId());
-//                                        TAdmin byId = adminService.getById(admin.getAgencyId());
-//                                        equipmentProportion.setAgencyName(byId.getUsername());
-//                                    }
                                             equipmentProportion.setAgencyId(admin.getAgencyId());
                                             TAdmin byId = adminService.getById(admin.getAgencyId());
                                             equipmentProportion.setAgencyName(byId.getUsername());
@@ -546,20 +491,10 @@ public class TProportionController {
                                         case 3:
                                             equipmentProportion.setProportion(adminProportion.getPersonageProportion());
                                             equipmentProportion.setAgencyProportion(adminProportion.getAgencyProportion());
-//                                    if(adminProportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))!=0){
-//                                        equipmentProportion.setAgencyId(admin.getAgencyId());
-//                                        TAdmin byId = adminService.getById(admin.getAgencyId());
-//                                        equipmentProportion.setAgencyName(byId.getUsername());
-//                                    }
                                             equipmentProportion.setAgencyId(admin.getAgencyId());
                                             TAdmin byId1 = adminService.getById(admin.getAgencyId());
                                             equipmentProportion.setAgencyName(byId1.getUsername());
                                             equipmentProportion.setMerchantProportion(adminProportion.getMerchantProportion());
-//                                    if(adminProportion.getMerchantProportion().compareTo(new BigDecimal("0.00"))!=0){
-//                                        equipmentProportion.setMerchantId(admin.getMerchantId());
-//                                        TAdmin byId = adminService.getById(admin.getMerchantId());
-//                                        equipmentProportion.setMerchantName(byId.getUsername());
-//                                    }
                                             equipmentProportion.setMerchantId(admin.getMerchantId());
                                             TAdmin byId2 = adminService.getById(admin.getMerchantId());
                                             equipmentProportion.setMerchantName(byId2.getUsername());

+ 4 - 0
src/main/java/com/szwl/controller/TShandeMchCheckController.java

@@ -34,12 +34,16 @@ import java.util.List;
 @RestController
 @RequestMapping("/tShandeMchCheck")
 public class TShandeMchCheckController {
+
     @Autowired
     TShandeMchCheckService tShandeMchCheckService;
+
     @Autowired
     TShandeMchService tShandeMchService;
+
     @Autowired
     TAdminService adminService;
+
     @ApiOperation(value = "商家查找杉德收款账户在审核信息")
     @PostMapping("/getOne")
     public ResponseModel<?> findById(Long id, String username) {

+ 0 - 1
src/main/java/com/szwl/controller/TShandeMchController.java

@@ -292,7 +292,6 @@ public class TShandeMchController {
                 }else {
                     response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("个人账号" + format.format(new Date()) + ".xls", "UTF-8"));
                 }
-//                    response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
                 workbook.write(os);
                 return  R.ok("导出成功");
             } catch (Exception e) {

+ 47 - 35
src/main/java/com/szwl/controller/TTimeRuleController.java

@@ -41,42 +41,50 @@ import java.util.List;
 @RestController
 @RequestMapping("/tTimeRule")
 public class TTimeRuleController {
+
     @Autowired
     TAdService adService;
+
     @Autowired
     TAdminService adminService;
+
     @Autowired
     TTimeRuleService timeRuleService;
+
     @Autowired
     TEquipmentService equipmentService;
 
+
     private static final String[] times = {"0-1", "1-2", "2-3", "3-4", "4-5", "5-6", "6-7", "7-8",
             "8-9", "9-10", "10-11", "11-12", "12-13", "13-14", "14-15", "15-16", "16-17", "17-18", "18-19", "19-20"
             , "20-21", "21-22", "22-23", "23-24"};
+
     @GetMapping("/pageTimeRule")
-    public ResponseModel<IPage<?>> pageTimeRule(long current, long size ) {
+    public ResponseModel<IPage<?>> pageTimeRule(long current, long size) {
         LambdaQueryWrapper<TTimeRule> query = Wrappers.lambdaQuery();
         query.orderByDesc(TTimeRule::getCreateDate);
         Page<TTimeRule> page = new Page<>(current, size, true);
         IPage<TTimeRule> iPage = timeRuleService.page(page, query);
         return R.ok(iPage);
     }
+
     @ApiOperation(value = "添加")
     @PostMapping("/add")
     public ResponseModel<?> add(@RequestBody TTimeRule timeRule) {
-        if(StringUtils.isEmpty(timeRule.getName())&&StringUtils.isEmpty(timeRule.getRule())){
+        if (StringUtils.isEmpty(timeRule.getName()) && StringUtils.isEmpty(timeRule.getRule())) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         timeRule.setCreateDate(new Date());
         timeRule.setModifyDate(new Date());
         timeRule.setType("1");
         timeRuleService.save(timeRule);
-        return R.ok(timeRule,"添加成功");
+        return R.ok(timeRule, "添加成功");
     }
+
     @ApiOperation(value = "修改")
     @PostMapping("/update")
     public ResponseModel<?> update(@RequestBody TTimeRule timeRule) {
-        if(StringUtils.isEmpty(timeRule.getName())&&StringUtils.isEmpty(timeRule.getRule())){
+        if (StringUtils.isEmpty(timeRule.getName()) && StringUtils.isEmpty(timeRule.getRule())) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         TTimeRule oldTimeRule = timeRuleService.getById(timeRule.getId());
@@ -85,58 +93,61 @@ public class TTimeRuleController {
         oldTimeRule.setUserNames(timeRule.getUserNames());
         oldTimeRule.setModifyDate(new Date());
         timeRuleService.updateById(oldTimeRule);
-        return R.ok(oldTimeRule,"修改成功");
+        return R.ok(oldTimeRule, "修改成功");
     }
 
     @GetMapping("/getList")
     public ResponseModel<?> getList(String name) {
         LambdaQueryWrapper<TTimeRule> query = Wrappers.lambdaQuery();
-        if(StringUtils.isNotEmpty(name)){
-            query.like(TTimeRule::getName,name);
+        if (StringUtils.isNotEmpty(name)) {
+            query.like(TTimeRule::getName, name);
         }
         query.orderByDesc(TTimeRule::getCreateDate);
         List<TTimeRule> list = timeRuleService.list(query);
         return R.ok(list);
     }
+
     @GetMapping("/getAdListByTimeRule")
     public ResponseModel<?> getAdListByTimeRule(String id) {
         List<TAd> adList = new ArrayList<>();
         TTimeRule timeRule = timeRuleService.getById(id);
-        if(StringUtils.isEmpty(timeRule.getType())){
+        if (StringUtils.isEmpty(timeRule.getType())) {
             List<TimeRuleVo> timeRuleVos = JSON.parseArray(timeRule.getRule(), TimeRuleVo.class);
-            for(TimeRuleVo timeRuleVo:timeRuleVos){
+            for (TimeRuleVo timeRuleVo : timeRuleVos) {
                 List<String> ads = timeRuleVo.getAd();
-                for (String aid:ads){
+                for (String aid : ads) {
                     TAd ad = adService.getById(aid);
-                    if(ad!=null&&ad.getId()!=null){
+                    if (ad != null && ad.getId() != null) {
                         adList.add(ad);
                     }
-                 }
+                }
                 break;
             }
-        }else if(timeRule.getType().equals("1")){
+        } else if (timeRule.getType().equals("1")) {
             String rule = timeRule.getRule();
-            rule= rule.substring(1, rule.length() - 1);
+            rule = rule.substring(1, rule.length() - 1);
             List<String> result = Arrays.asList(rule.split(","));
-            for (String aid:result){
+            for (String aid : result) {
                 TAd ad = adService.getById(aid);
-                if(ad!=null&&ad.getId()!=null){
+                if (ad != null && ad.getId() != null) {
                     adList.add(ad);
                 }
             }
         }
         return R.ok(adList);
     }
+
     @GetMapping("/updateEquimentpTimeRule")
-    public ResponseModel<?> updateEquimentpTimeRule(String equipmentId,String timeRuleId) {
+    public ResponseModel<?> updateEquimentpTimeRule(String equipmentId, String timeRuleId) {
         TEquipment equipment = equipmentService.getById(equipmentId);
-        if(equipment!=null&&equipment.getId()!=null){
+        if (equipment != null && equipment.getId() != null) {
             equipment.setTimeRuleId(Long.valueOf(timeRuleId));
             equipmentService.updateById(equipment);
             equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pushTimeRule", timeRuleId + "").toString());
         }
         return R.ok();
     }
+
     /**
      * 获取时间规则
      *
@@ -146,12 +157,13 @@ public class TTimeRuleController {
     @GetMapping(value = "/getOne")
     @ResponseBody
     public ResponseModel<?> getOne(Long id) {
-        if(id==null){
+        if (id == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         TTimeRule timeRule = timeRuleService.getById(id);
-        return  R.ok(timeRule);
+        return R.ok(timeRule);
     }
+
     /**
      * 删除时间规则
      *
@@ -161,16 +173,17 @@ public class TTimeRuleController {
     @GetMapping(value = "/deletes")
     @ResponseBody
     public ResponseModel<?> deletes(int[] ids) {
-        if(ids==null){
+        if (ids == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
-        if(ids.length>0){
-            for(int i=0;i<ids.length;i++){
+        if (ids.length > 0) {
+            for (int i = 0; i < ids.length; i++) {
                 timeRuleService.removeById(ids[i]);
             }
         }
-        return  R.ok(null,"删除成功");
+        return R.ok(null, "删除成功");
     }
+
     /**
      * 推送时间规则广告id
      *
@@ -181,27 +194,26 @@ public class TTimeRuleController {
     @ResponseBody
     public ResponseModel<?> pullTimeRule(Long id) {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
-        query.eq(TEquipment::getTimeRuleId,id);
+        query.eq(TEquipment::getTimeRuleId, id);
         List<TEquipment> list = equipmentService.list(query);
         //查询出用这个广告规则的设备
         for (TEquipment equipment : list) {
             equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pushTimeRule", id + "").toString());
-//            PushUtils.push(equipment.getGtClientId(), "", "", PushUtils.buildJson("pushTimeRule", id + "").toString());
         }
         TTimeRule timeRule = timeRuleService.getById(id);
-        if(StringUtils.isNotEmpty(timeRule.getUserNames())){
+        if (StringUtils.isNotEmpty(timeRule.getUserNames())) {
             String[] nameUsers = timeRule.getUserNames().split(",");
-            if(nameUsers.length>0){
-                for(int i=0;i<nameUsers.length;i++){
+            if (nameUsers.length > 0) {
+                for (int i = 0; i < nameUsers.length; i++) {
                     LambdaQueryWrapper<TAdmin> query1 = Wrappers.lambdaQuery();
-                    query1.eq(TAdmin::getUsername,nameUsers[i]);
+                    query1.eq(TAdmin::getUsername, nameUsers[i]);
                     List<TAdmin> list1 = adminService.list(query1);
-                    if(list1.size()>0){
-                        for(TAdmin admin:list1){
+                    if (list1.size() > 0) {
+                        for (TAdmin admin : list1) {
                             LambdaQueryWrapper<TEquipment> query2 = Wrappers.lambdaQuery();
-                            query2.eq(TEquipment::getAdminId,admin.getId());
+                            query2.eq(TEquipment::getAdminId, admin.getId());
                             List<TEquipment> list2 = equipmentService.list(query2);
-                            for(TEquipment equipment:list2){
+                            for (TEquipment equipment : list2) {
                                 equipmentService.sentMessage(equipment.getClientId(), PushUtils.buildJson("pushTimeRule", id + "").toString());
                             }
                         }
@@ -209,7 +221,7 @@ public class TTimeRuleController {
                 }
             }
         }
-        return  R.ok(null,"推送成功");
+        return R.ok(null, "推送成功");
     }
 }
 

+ 7 - 11
src/main/java/com/szwl/controller/TWechatController.java

@@ -32,7 +32,7 @@ import java.util.*;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author wuhs
@@ -50,14 +50,10 @@ public class TWechatController {
     @Autowired
     private TWechatService tWechatService;
 
-    // 从 yml 文件中获取
-//    @Value("${oauth.wx.appid}")
     private String appid;
 
-//    @Value("${oauth.wx.appsecret}")
     private String appsecret;
 
-//    @Value("${oauth.callback.http}")
     private String http;
 
     @ApiOperation(value = "绑定微信")
@@ -75,7 +71,7 @@ public class TWechatController {
 
         if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
             path = ConfigConsts.SC_RETURN_URL + "/SZWL-SERVER/tWechat/callback";
-            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            appId = ConfigConsts.SC_WX_SUB_APP_ID;
             head = ConfigConsts.SC_RETURN_URL;
         } else {
             path = ConfigConsts.SZ_RETURN_URL + "/SZWL-SERVER/tWechat/callback";
@@ -115,7 +111,7 @@ public class TWechatController {
         String appSecret = "";
         String redirectUrl = "";
         if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
-            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            appId = ConfigConsts.SC_WX_SUB_APP_ID;
             appSecret = ConfigConsts.SC_WX_APP_SECRET;
             redirectUrl = ConfigConsts.SC_RETURN_URL + "/sc/#/user";
         } else {
@@ -227,7 +223,7 @@ public class TWechatController {
         String appId = "";
         String appSecret = "";
         if (StringUtils.isNotEmpty(companyType) && companyType.equals("1")) {
-            appId =  ConfigConsts.SC_WX_SUB_APP_ID;
+            appId = ConfigConsts.SC_WX_SUB_APP_ID;
             appSecret = ConfigConsts.SC_WX_APP_SECRET;
         } else {
             appId = ConfigConsts.SZ_WX_SUB_APP_ID;
@@ -299,13 +295,13 @@ public class TWechatController {
     @ApiOperation(value = "获取微信授权openId")
     @GetMapping("/getOpenId")
     public ResponseModel<?> getOpenId(@RequestParam("adminId") Long adminId) {
-        if(adminId == null) {
+        if (adminId == null) {
             return R.fail(ResponseCodesEnum.A0001);
         }
         LambdaQueryWrapper<TWechat> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(TWechat::getAdminId, adminId);
         TWechat wechat = tWechatService.getOne(queryWrapper);
-        if(wechat != null && StringUtils.isNotEmpty(wechat.getOpenId())) {
+        if (wechat != null && StringUtils.isNotEmpty(wechat.getOpenId())) {
             return R.ok(wechat.getOpenId());
         }
         return R.ok();
@@ -355,7 +351,7 @@ public class TWechatController {
         LambdaQueryWrapper<TWechat> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(TWechat::getAdminId, adminId);
         TWechat wechat = tWechatService.getOne(queryWrapper);
-        if(wechat != null) {
+        if (wechat != null) {
             tWechatService.removeById(wechat);
         }
         return R.ok();

+ 41 - 0
src/main/java/com/szwl/handle/response/BlockProcessor.java

@@ -0,0 +1,41 @@
+package com.szwl.handle.response;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.constant.OperationType;
+import com.szwl.model.entity.MessageLog;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.service.TEquipmentService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class BlockProcessor implements ResponseProcessor {
+
+    @Resource
+    private TEquipmentService tEquipmentService;
+
+    @Override
+    public void process(MessageLog messageLog) {
+        Integer statusCode = messageLog.getStatusCode();
+        if (statusCode == 200) {
+            Integer direction = messageLog.getDirection();
+            String clientId = messageLog.getClientId();
+            String responseContent = messageLog.getResponseContent();
+
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = tEquipmentService.getOne(query);
+            if (equipment != null) {
+                equipment.setIsBlocked(responseContent.equals("1"));
+                tEquipmentService.updateById(equipment);
+            }
+        }
+    }
+
+    @Override
+    public String getSupportedOperationType() {
+        return OperationType.BLOCK.getCode();
+    }
+}

+ 69 - 0
src/main/java/com/szwl/handle/response/FlowersProcessor.java

@@ -0,0 +1,69 @@
+package com.szwl.handle.response;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.constant.OperationType;
+import com.szwl.model.entity.MessageLog;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TProduct;
+import com.szwl.service.TEquipmentService;
+import com.szwl.service.TGoodsDataService;
+import com.szwl.service.TProductService;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Component
+public class FlowersProcessor implements ResponseProcessor {
+
+    @Resource
+    private TEquipmentService tEquipmentService;
+
+    @Resource
+    private TProductService productService;
+
+    @Resource
+    private TGoodsDataService goodsDataService;
+
+    @Override
+    public void process(MessageLog messageLog) {
+        Integer statusCode = messageLog.getStatusCode();
+        if (statusCode == 200) {
+            String clientId = messageLog.getClientId();
+            String responseContent = messageLog.getResponseContent();
+
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = tEquipmentService.getOne(query);
+            if (equipment != null) {
+                Long id = equipment.getId();
+                equipment.setFlowers(responseContent);
+
+                //删除旧商品
+                LambdaQueryWrapper<TProduct> queryProduct = Wrappers.lambdaQuery();
+                queryProduct.eq(TProduct::getEquipmentId, equipment.getId());
+                List<TProduct> productList = productService.list(queryProduct);
+                for (TProduct product : productList) {
+                    productService.removeById(product.getId());
+                }
+
+                // 机器类型
+                String machineType = equipment.getMachineType();
+                if (StringUtils.isEmpty(equipment.getMachineType())) {
+                    machineType = "0";
+                }
+                String equipmentType = equipment.getEquimentType();
+                //创建花型
+                goodsDataService.saveGoodsData(id, machineType, Integer.parseInt(responseContent), equipmentType);
+                tEquipmentService.updateById(equipment);
+            }
+        }
+    }
+
+    @Override
+    public String getSupportedOperationType() {
+        return OperationType.FLOWERS.getCode();
+    }
+}

+ 41 - 0
src/main/java/com/szwl/handle/response/OfflineProcessor.java

@@ -0,0 +1,41 @@
+package com.szwl.handle.response;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.constant.OperationType;
+import com.szwl.model.entity.MessageLog;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.service.TEquipmentService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class OfflineProcessor implements ResponseProcessor {
+
+    @Resource
+    private TEquipmentService tEquipmentService;
+
+    @Override
+    public void process(MessageLog messageLog) {
+        Integer statusCode = messageLog.getStatusCode();
+        if (statusCode == 200) {
+            Integer direction = messageLog.getDirection();
+            String clientId = messageLog.getClientId();
+            String responseContent = messageLog.getResponseContent();
+
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = tEquipmentService.getOne(query);
+            if (equipment != null) {
+                equipment.setClientId(equipment.getClientId() + "xxx");
+                tEquipmentService.updateById(equipment);
+            }
+        }
+    }
+
+    @Override
+    public String getSupportedOperationType() {
+        return OperationType.OFFLINE.getCode();
+    }
+}

+ 54 - 0
src/main/java/com/szwl/handle/response/PhoneProcessor.java

@@ -0,0 +1,54 @@
+package com.szwl.handle.response;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.constant.OperationType;
+import com.szwl.model.entity.MessageLog;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.param.EquipmentDescParam;
+import com.szwl.model.param.EquipmentParam;
+import com.szwl.model.vo.EquipmentVO;
+import com.szwl.service.TEquipmentService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class PhoneProcessor implements ResponseProcessor {
+
+    @Resource
+    private TEquipmentService tEquipmentService;
+
+    @Override
+    public void process(MessageLog messageLog) {
+        Integer statusCode = messageLog.getStatusCode();
+        if (statusCode == 200) {
+            String clientId = messageLog.getClientId();
+            String responseContent = messageLog.getResponseContent();
+
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment equipment = tEquipmentService.getOne(query);
+            if (equipment != null) {
+                try {
+                    EquipmentVO equipmentVO = JSON.parseObject(responseContent, EquipmentVO.class);
+                    if (equipmentVO != null) {
+                        String contactName = equipmentVO.getContactName();
+                        String contactPhone = equipmentVO.getContactPhone();
+                        equipment.setContactName(contactName);
+                        equipment.setContactPhone(contactPhone);
+                        tEquipmentService.updateById(equipment);
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    @Override
+    public String getSupportedOperationType() {
+        return OperationType.PHONE.getCode();
+    }
+}

+ 54 - 0
src/main/java/com/szwl/handle/response/SleepDescProcessor.java

@@ -0,0 +1,54 @@
+package com.szwl.handle.response;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.szwl.constant.OperationType;
+import com.szwl.model.entity.MessageLog;
+import com.szwl.model.entity.TEquipment;
+import com.szwl.model.entity.TEquipmentDesc;
+import com.szwl.model.vo.EquipmentVO;
+import com.szwl.service.TEquipmentDescService;
+import com.szwl.service.TEquipmentService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+public class SleepDescProcessor implements ResponseProcessor {
+
+    @Resource
+    private TEquipmentService tEquipmentService;
+
+    @Resource
+    private TEquipmentDescService tEquipmentDescService;
+
+    @Override
+    public void process(MessageLog messageLog) {
+        Integer statusCode = messageLog.getStatusCode();
+        if (statusCode == 200) {
+            String clientId = messageLog.getClientId();
+            String responseContent = messageLog.getResponseContent();
+            LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
+            query.eq(TEquipment::getClientId, clientId);
+            TEquipment tEquipment = tEquipmentService.getOne(query);
+            if (tEquipment != null) {
+                try {
+                    // 转换为对象
+                    EquipmentVO equipmentVO = JSON.parseObject(responseContent, EquipmentVO.class);
+                    String sleepDesc = equipmentVO.getSleepDesc();
+                    TEquipmentDesc equipmentDesc = tEquipmentDescService.getById(tEquipment.getId());
+                    equipmentDesc.setSleepDesc(sleepDesc);
+                    tEquipmentDescService.updateById(equipmentDesc);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    @Override
+    public String getSupportedOperationType() {
+        return OperationType.SLEEP_DESC.getCode();
+    }
+}

+ 6 - 0
src/main/java/com/szwl/model/param/EquipmentDescParam.java

@@ -11,6 +11,12 @@ public class EquipmentDescParam {
     @ApiModelProperty(value = "设备唯一ID")
     private Long id;
 
+    @ApiModelProperty(value = "花型数量")
+    private String flowers;
+
+    @ApiModelProperty(value = "休眠描述")
+    private String sleepDesc;
+
     @ApiModelProperty(value = "开门状态;0:关闭,1:开门")
     private String status;
 

+ 15 - 0
src/main/java/com/szwl/model/param/EquipmentParam.java

@@ -53,9 +53,24 @@ public class EquipmentParam {
     @ApiModelProperty(value = "今天日期")
     private String todayDate;
 
+    @ApiModelProperty(value = "机器联系人名称")
+    private String contactName;
+
+    @ApiModelProperty(value = "联系人电话")
+    private String contactPhone;
+
     @ApiModelProperty(value = "是否海外机器,0:国内,1:海外")
     private Boolean isAbroad;
 
+    @ApiModelProperty(value = "logo编号")
+    private String logoNumber;
+
+    @ApiModelProperty(value = "广告规则ID")
+    private String timeRuleId;
+
+    @ApiModelProperty(value = "状态")
+    private String status;
+
     @ApiModelProperty(value = "app链接")
     private String url;
 

+ 4 - 0
src/main/java/com/szwl/model/param/LoginParam.java

@@ -9,6 +9,10 @@ public class LoginParam {
 
     private String password;
 
+    private String phoneOrEmail;
+
+    private String code;
+
     private String hostName;
 
 }

+ 9 - 0
src/main/java/com/szwl/model/vo/EquipmentVO.java

@@ -15,6 +15,15 @@ public class EquipmentVO {
     @ApiModelProperty(value = "机器名称")
     private String name;
 
+    @ApiModelProperty(value = "机器联系人名称")
+    private String contactName;
+
+    @ApiModelProperty(value = "联系人电话")
+    private String contactPhone;
+
+    @ApiModelProperty(value = "休眠描述")
+    private String sleepDesc;
+
     @ApiModelProperty(value = "类型,0:管理员密码,1:游客密码")
     private Integer type;
 

+ 3 - 0
src/main/java/com/szwl/model/vo/MachineVo.java

@@ -52,4 +52,7 @@ public class MachineVo {
 
     @ApiModelProperty(value = "废水")
     private String wasteWater;
+
+    @ApiModelProperty(value = "机器状态;0:空闲,1:制作中")
+    private String status;
 }

+ 9 - 0
src/main/java/com/szwl/service/TGoodsDataService.java

@@ -13,4 +13,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface TGoodsDataService extends IService<TGoodsData> {
 
+    /**
+     * 添加商品数据
+     * @param id
+     * @param machineType
+     * @param number
+     * @param equipmentType
+     */
+    void saveGoodsData(Long id, String machineType, Integer number, String equipmentType);
+
 }

+ 11 - 0
src/main/java/com/szwl/service/TMessageCodeService.java

@@ -19,11 +19,22 @@ public interface TMessageCodeService extends MyIService<TMessageCode> {
     * 发送短信验证码
     * */
     String sentMessage(String type, String phone, String companyType);
+
+    /*
+     * 发送忘记密码短信验证码
+     * */
+    String sentMessage(String type, String phone, String companyType, Long adminId);
+
     /*
      * 发送邮箱验证码
      * */
     String sentEmail(String type, String email);
 
+    /*
+     * 发送忘记密码邮箱验证码
+     * */
+    String sentEmail(String type, String email, Long adminId);
+
     String sendEmailAbroad(String type, String email);
 
     Date getLastSendTime(String phoneOrEmail);

+ 38 - 2
src/main/java/com/szwl/service/impl/TGoodsDataServiceImpl.java

@@ -1,11 +1,19 @@
 package com.szwl.service.impl;
 
-import com.szwl.model.entity.TGoodsData;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.szwl.mapper.TGoodsDataMapper;
+import com.szwl.model.entity.TGoodsData;
+import com.szwl.model.entity.TProduct;
 import com.szwl.service.TGoodsDataService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.szwl.service.TProductService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.Date;
+
 /**
  * <p>
  * 商品数据表 服务实现类
@@ -17,4 +25,32 @@ import org.springframework.stereotype.Service;
 @Service
 public class TGoodsDataServiceImpl extends ServiceImpl<TGoodsDataMapper, TGoodsData> implements TGoodsDataService {
 
+    @Autowired
+    private TProductService productService;
+
+    @Override
+    public void saveGoodsData(Long id, String machineType, Integer number, String equipmentType) {
+        LambdaQueryWrapper<TGoodsData> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(TGoodsData::getNumber, number);
+        wrapper.eq(TGoodsData::getMachineType, machineType);
+        if (!machineType.equals("0")) {
+            wrapper.eq(TGoodsData::getEquipmentType, equipmentType);
+        }
+        TGoodsData goodsData = this.getOne(wrapper);
+        String goods = goodsData.getGoods();
+        String[] str = goods.split(",");
+
+        for (int i = 0; i < str.length; i++) {
+            TProduct product = new TProduct();
+            product.setCreateDate(new Date());
+            product.setModifyDate(new Date());
+            product.setEquipmentId(id);
+            String[] split = str[i].split("-");
+            product.setProductName(split[0]);
+            product.setNo(split[1]);
+            product.setRmbPrice(new BigDecimal(0.01));
+            product.setCodePrice(new BigDecimal(0.01));
+            productService.save(product);
+        }
+    }
 }

+ 49 - 1
src/main/java/com/szwl/service/impl/TMessageCodeServiceImpl.java

@@ -63,13 +63,42 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
         return retu;
     }
 
+    @Override
+    public String sentMessage(String type, String phone, String companyType, Long adminId) {
+        String result = null;
+        String retu = null;
+        try {
+            String code = addCode();
+            result = YunPianSms.sendSms(appid, getMessage(companyType, code), phone);
+            JSONObject sult = JSONObject.parseObject(result);
+            Object msg = sult.get("msg");
+            Object mobile = sult.get("mobile");
+            retu = msg + ":" + phone;
+            if (mobile != null) {
+                TMessageCode tMessageCode = new TMessageCode();
+                tMessageCode.setType(type);
+                tMessageCode.setCode(code);
+                tMessageCode.setPhone(phone);
+                tMessageCode.setAdminId(adminId);
+                tMessageCode.setModifyDate(new Date());
+                tMessageCode.setCreateDate(new Date());
+                tMessageCode.setStatus("0");
+                int insert = tMessageCodeMapper.insert(tMessageCode);
+            }
+            int a = 0;
+        } catch (Exception e) {
+
+        }
+
+        return retu;
+    }
+
     /*
      * 发送邮箱验证码
      * */
     @Override
     public String sentEmail(String type, String email) {
         String code = addCode();
-//        String subject = "Verification code message";
         String subject = getSubject(type);
         String contnet = "";
         contnet = getContent(type, code);
@@ -86,6 +115,25 @@ public class TMessageCodeServiceImpl extends ServiceImpl<TMessageCodeMapper, TMe
     }
 
     @Override
+    public String sentEmail(String type, String email, Long adminId) {
+        String code = addCode();
+        String subject = getSubject(type);
+        String contnet = "";
+        contnet = getContent(type, code);
+        new MailUtil().send(email, subject, contnet);
+        TMessageCode tMessageCode = new TMessageCode();
+        tMessageCode.setType(type);
+        tMessageCode.setCode(code);
+        tMessageCode.setPhone(email);
+        tMessageCode.setAdminId(adminId);
+        tMessageCode.setModifyDate(new Date());
+        tMessageCode.setCreateDate(new Date());
+        tMessageCode.setStatus("0");
+        tMessageCodeMapper.insert(tMessageCode);
+        return "发送成功";
+    }
+
+    @Override
     public String sendEmailAbroad(String type, String email) {
         String code = addCode();
         String content;

+ 60 - 2
src/main/java/com/szwl/util/MqttUtils.java

@@ -1,8 +1,13 @@
 package com.szwl.util;
 
+import com.szwl.model.dto.MqttReturnVo;
 import okhttp3.*;
+import org.apache.commons.lang.StringUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
 
 import java.io.IOException;
+import java.util.ArrayList;
 
 public class MqttUtils {
 
@@ -14,15 +19,23 @@ public class MqttUtils {
         try {
 
             OkHttpClient client = new OkHttpClient();
-
             // 构建 URL,添加查询参数
             HttpUrl url = HttpUrl.parse("http://112.74.63.148:18083/api/v5/clients")
                     .newBuilder()
                     .addQueryParameter("page", page)
                     .addQueryParameter("limit", limit)
-                    .addQueryParameter("like_clientid", clientId)
                     .build();
 
+            if (StringUtils.isNotEmpty(clientId)) {
+                url = HttpUrl.parse("http://112.74.63.148:18083/api/v5/clients")
+                        .newBuilder()
+                        .addQueryParameter("page", page)
+                        .addQueryParameter("limit", limit)
+                        .addQueryParameter("like_clientid", clientId)
+                        .build();
+            }
+
+
             Request request = new Request.Builder()
                     .url(url)
                     .header("Content-Type", "application/json")
@@ -36,4 +49,49 @@ public class MqttUtils {
         }
         return result;
     }
+
+
+    public static boolean onlineStatus(String clientId) {
+        String result = "";
+        try {
+
+            OkHttpClient client = new OkHttpClient();
+            // 构建 URL,添加查询参数
+            HttpUrl url = HttpUrl.parse("http://112.74.63.148:18083/api/v5/clients")
+                    .newBuilder()
+                    .addQueryParameter("page", "1")
+                    .addQueryParameter("limit", "1")
+                    .addQueryParameter("like_clientid", clientId)
+                    .build();
+
+            Request request = new Request.Builder()
+                    .url(url)
+                    .header("Content-Type", "application/json")
+                    .header("Authorization", Credentials.basic(USERNAME, PASSWORD))
+                    .build();
+
+            Response response = client.newCall(request).execute();
+            result = response.body().string();
+
+            JSONObject jsonObject = new JSONObject(result);
+            JSONArray data = jsonObject.getJSONArray("data");
+            if (data.length() == 0) {
+                return false;
+            } else {
+                // 获取设备编号和连接状态
+                boolean connected = false;
+                for (int i = 0; i < data.length(); i++) {
+                    JSONObject jsonObject1 = data.getJSONObject(i);
+                    String clientid = jsonObject1.getString("clientid");
+                    connected = (boolean)jsonObject1.get("connected");
+                    
+                }
+                return connected;
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+
 }

+ 110 - 12
src/main/java/com/szwl/util/TimezoneFmtUtil.java

@@ -1,34 +1,88 @@
 package com.szwl.util;
 
 import cn.hutool.core.util.RandomUtil;
-
+import cn.hutool.crypto.digest.DigestUtil;
+import cn.hutool.crypto.digest.HmacAlgorithm;
+import com.alibaba.fastjson.JSON;
+import okhttp3.*;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
+import java.text.SimpleDateFormat;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.Base64;
+import java.util.Date;
 
 public class TimezoneFmtUtil {
 
 
     public static void main(String[] args) {
-//        String timeZoneByID = getTimeByZoneID("Asia/Shanghai");  // America/New_York, Asia/Shanghai
-//        System.out.println(timeZoneByID);
-
-//        String nowDateUTC = getNowDateUTC();
-//        System.out.println("nowDateUTC >>> " + nowDateUTC);
 
-        // 生成一个24字节长度的随机密钥
-        String key = generateKey(24);
-
-        // 输出生成的密钥
-        System.out.println("Generated Key: " + key);
+        // 获取当前时间
+        Date currentDate = new Date();
+        // 创建SimpleDateFormat对象,用于格式化日期
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+        // 格式化日期为yyyyMMdd格式的字符串
+        String dateString = dateFormat.format(currentDate);
+
+        // 生成6位随机数
+        String numbers = RandomUtil.randomNumbers(6);
+
+        // 将yyyyMMdd格式的日期字符串和6位随机数拼接在一起
+        String result = dateString + numbers;
+
+        final String secretCode = "dRjWjM4LdjVls7KhQCiIZJiY7L2uBaz8";
+        final String bodyContent = "{\n" +
+                "    \"product_number\": \"SERVICE_PROVIDER\",\n" +
+                "    \"product_ability_code\": \"DuitNow\",\n" +
+                "    \"area_code\": \"MY\",\n" +
+                "    \"out_trade_number\": \""+ result +"\",\n" +
+                "    \"introduction\": \"123123\",\n" +
+                "    \"payment_amount\": 0.1,\n" +
+                "    \"expired_time_expression\": \"30s\",\n" +
+                "    \"equipment_code\" : \"G0002501\",\n" +
+                "    \"subscription\": {\n" +
+                "        \"notification_method\": \"HTTP\",\n" +
+                "        \"notification_address\": \"https://sz.sunzee.com.cn/SZWL-SERVER/callback/openPay\",\n" +
+                "        \"notification_payload\":\"167944687746597219764736\"\n" +
+                "    }\n" +
+                "}";
+//        final String bodyContent = "{   \n    \"out_trade_number\": \"123211113112321\"\n}";
+        final String signature = DigestUtil.hmac(HmacAlgorithm.HmacSHA512, secretCode.getBytes()).digestHex(bodyContent);
+        System.out.println("signature:" + signature);
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        MediaType mediaType = MediaType.parse("application/json");
+        RequestBody body = RequestBody.create(mediaType, bodyContent);
+        Request request = new Request.Builder()
+                .url("https://gpayment.starthing.com/open/apis/gateway.do")
+                .method("POST", body)
+                .addHeader("RESOURCE_MERCHANT", "1238431130069229568")
+                .addHeader("RESOURCE_VERSION", "v1.0")
+                .addHeader("RESOURCE_CODE", "unified.pay.creation")
+//                .addHeader("RESOURCE_CODE", "unified.pay.query")
+                .addHeader("AUTHORIZATION", signature)
+                .addHeader("Content-Type", "application/json")
+                .build();
+        try {
+            Response response = client.newCall(request).execute();
+            System.out.println(response);
+            System.out.println(response.body().string());
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
     }
 
 
     /**
      * 获取 zoneID 时区的时间
-     *
      */
     public static String getTimeByZoneID(String zoneID) {
         String formatted = null;
@@ -57,6 +111,50 @@ public class TimezoneFmtUtil {
         return Base64.getEncoder().encodeToString(randomBytes);
     }
 
+    /**
+     * 生成 HMAC-SHA512 签名 (16进制小写格式)
+     *
+     * @param secretKey 共享密钥
+     * @param message   待签名的消息内容
+     * @return 128字符的16进制签名
+     */
+    public static String generateHmacSha512(String secretKey, String message)
+            throws NoSuchAlgorithmException, InvalidKeyException {
+
+        // 1. 获取 HmacSHA512 的 Mac 实例
+        Mac hmac = Mac.getInstance("HmacSHA512");
+
+        // 2. 将密钥转换为字节并初始化
+        SecretKeySpec secretKeySpec = new SecretKeySpec(
+                secretKey.getBytes(StandardCharsets.UTF_8),
+                "HmacSHA512"
+        );
+        hmac.init(secretKeySpec);
+
+        // 3. 计算消息的哈希值
+        byte[] hashedBytes = hmac.doFinal(
+                message.getBytes(StandardCharsets.UTF_8)
+        );
+
+        // 4. 将哈希字节数组转为16进制小写字符串
+        return bytesToHex(hashedBytes).toLowerCase();
+    }
+
+    /**
+     * 将字节数组转换为16进制字符串
+     */
+    private static String bytesToHex(byte[] bytes) {
+        StringBuilder hexString = new StringBuilder(128); // 预分配大小
+        for (byte b : bytes) {
+            String hex = Integer.toHexString(0xff & b);
+            if (hex.length() == 1) {
+                hexString.append('0'); // 补零
+            }
+            hexString.append(hex);
+        }
+        return hexString.toString();
+    }
+
 
     /**
      * 获取中国时区的UTC格式