Просмотр исходного кода

Merge branch 'master' of http://192.168.1.43:3000/git/sass-lab-distributed-java

zhuchangxue лет назад: 3
Родитель
Сommit
60c3fd7a66
21 измененных файлов с 285 добавлено и 82 удалено
  1. 1 0
      docker/mysql/update/hxp-update.sql
  2. 4 4
      zd-api/zd-api-system/src/main/java/com/zd/system/api/chemical/RemoteStockService.java
  3. 17 4
      zd-auth/src/main/java/com/zd/auth/controller/TokenController.java
  4. 1 1
      zd-common/zd-common-core/src/main/java/com/zd/common/core/constant/Constants.java
  5. 6 0
      zd-modules/zd-bottle-parent/zd-bottle-api/src/main/java/com/zd/bottle/domain/RfidTag.java
  6. 4 4
      zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/controller/RfidTagController.java
  7. 9 0
      zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/RfidTagService.java
  8. 21 0
      zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/impl/RfidTagServiceImpl.java
  9. 7 6
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/controller/HxpStockController.java
  10. 10 0
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/domain/HxpAlarmRecord.java
  11. 2 0
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/mapper/HxpAlarmRecordMapper.java
  12. 15 3
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpAlarmRecordServiceImpl.java
  13. 58 34
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpStockServiceImpl.java
  14. 17 16
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/util/SmsSydUtil.java
  15. 6 0
      zd-modules/zd-chemical/src/main/resources/mapper/chemical/HxpAlarmRecordMapper.xml
  16. 3 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/socket/runner/TCPServer.java
  17. 19 2
      zd-modules/zd-modules-system/src/main/java/com/zd/system/controller/SysUserController.java
  18. 23 1
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDClientImpl.java
  19. 53 2
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDServerImpl.java
  20. 7 2
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/WuYuanRFIDServiceImpl.java
  21. 2 2
      zd-modules/zd-speaker/src/main/java/com/zd/speaker/service/impl/SpeakerServiceImpl.java

+ 1 - 0
docker/mysql/update/hxp-update.sql

@@ -0,0 +1 @@
+ALTER TABLE `hxp_alarm_record` ADD COLUMN `parent_id` bigint(20) NULL DEFAULT NULL COMMENT '父级ID' AFTER `userecord_id`;

+ 4 - 4
zd-api/zd-api-system/src/main/java/com/zd/system/api/chemical/RemoteStockService.java

@@ -35,10 +35,10 @@ public interface RemoteStockService {
     public void queryUplinkResult();
 
     @GetMapping(value = "/hxpStock/sendSydSms")
-    public R sendSydSms(@RequestParam(value = "content", required = true) String content,
-                        @RequestParam(value = "purpose", required = true) Integer purpose,
-                        @RequestParam(value = "lockApplyId") Long lockApplyId,
-                        @RequestParam(value = "phones", required = true) @NotNull String... phones);
+    public R sendSydSms(@RequestParam(value = "content") String content,
+                        @RequestParam(value = "purpose") Integer purpose,
+                        @RequestParam(value = "lockApplyId", required = false) Long lockApplyId,
+                        @RequestParam(value = "phones") @NotNull String... phones);
 
     /**
      * 四医大短信告警方案阶梯式通知流程

+ 17 - 4
zd-auth/src/main/java/com/zd/auth/controller/TokenController.java

@@ -78,7 +78,7 @@ public class TokenController {
                     throw new ServiceException("系统异常");
                 }
             }else {
-                throw new CaptchaException("验证码不正确");
+                throw new ServiceException("验证码不正确",503);
             }
         }else {
             userInfo = sysLoginService.login(form.getUsername(), UserConstants.USER_LOGIN_PC, form.getPassword());
@@ -183,8 +183,21 @@ public class TokenController {
         String code = RandomUtil.randomNumbers(6);
         redisTemplate.opsForValue().set(key,code,CODE_EXPIRATION,TimeUnit.MINUTES);
         logger.info("========================>{}<=========================",code);
-        return R.ok(code);
-//        return stockService.sendSydSms(code, 2, null, form.getUsername());
+        String countKey=Constants.DEFAULT_CODE_KEY + "@" + username+"_COUNT";
+        String count = redisTemplate.opsForValue().get(countKey);
+        if (StringUtils.isEmpty(count)){
+            redisTemplate.opsForValue().set(countKey,"1",60,TimeUnit.MINUTES);
+        }else {
+            if (count!=null){
+                int i=Integer.parseInt(count);
+                if (i>=5){
+                    throw new ServiceException("验证码发送超过限制,请一小时后再试",530);
+                }
+                i++;
+                redisTemplate.opsForValue().set(countKey,i+"",60,TimeUnit.MINUTES);
+            }
+        }
+        return stockService.sendSydSms(code, 2, null, form.getUsername());
     }
 
     /**
@@ -227,7 +240,7 @@ public class TokenController {
         if (R.FAIL == user.getCode()) {
             throw new ServiceException(user.getMsg());
         }
-        if (StringUtils.isNull(user) || StringUtils.isNull(user.getData())) {
+        if (StringUtils.isNull(user.getData())) {
             return R.fail("登录用户不存在!");
         }
 

+ 1 - 1
zd-common/zd-common-core/src/main/java/com/zd/common/core/constant/Constants.java

@@ -181,5 +181,5 @@ public class Constants {
     /**
      * 手机登录验证码有效期(分钟)
      */
-    public static final long CODE_EXPIRATION = 15;
+    public static final long CODE_EXPIRATION = 5;
 }

+ 6 - 0
zd-modules/zd-bottle-parent/zd-bottle-api/src/main/java/com/zd/bottle/domain/RfidTag.java

@@ -39,4 +39,10 @@ public class RfidTag extends BaseBean {
     @Excel(name = "是否绑定 1绑定  0未绑定")
     @ApiModelProperty("是否绑定 1绑定  0未绑定")
     private Short isBind;
+
+    @ApiModelProperty(value = "开始时间")
+    private transient String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private transient String endTime;
 }

+ 4 - 4
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/controller/RfidTagController.java

@@ -3,6 +3,7 @@ package com.zd.bottle.controller;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.zd.bottle.domain.RfidTag;
+import com.zd.bottle.domain.UseRecord;
 import com.zd.bottle.service.RfidTagService;
 import com.zd.common.core.domain.per.PerFun;
 import com.zd.common.core.domain.per.PerPrefix;
@@ -16,6 +17,7 @@ import com.zd.common.response.ResultData;
 import com.zd.common.security.annotation.PreAuthorize;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -50,10 +52,8 @@ public class RfidTagController extends BaseController<RfidTag> {
     @GetMapping("/list")
     @ApiOperation(value = "查询RFID标签管理列表")
     public TableDataInfo<RfidTag> list(RfidTag rfidTag) {
-        startPage();
-        LambdaQueryWrapper<RfidTag> wrapper = Wrappers.lambdaQuery();
-        wrapper.setEntity(rfidTag);
-        List<RfidTag> list = service.list(wrapper);
+        startPage("create_time","descending");
+        List<RfidTag> list = service.list(rfidTag);
         return getDataTable(list);
     }
 

+ 9 - 0
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/RfidTagService.java

@@ -3,6 +3,8 @@ package com.zd.bottle.service;
 import com.zd.bottle.domain.RfidTag;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * RFID标签管理 服务类
@@ -33,4 +35,11 @@ public interface RfidTagService extends IService<RfidTag> {
      * @return
      */
     int updateQpRfidTag(RfidTag rfidTag);
+
+    /***
+     * 列表查询
+     * @param rfidTag
+     * @return
+     */
+    List<RfidTag> list(RfidTag rfidTag);
 }

+ 21 - 0
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/impl/RfidTagServiceImpl.java

@@ -12,9 +12,11 @@ import com.zd.common.security.service.TokenService;
 import com.zd.system.api.domain.SysUser;
 import com.zd.system.api.model.LoginUser;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.text.DecimalFormat;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -83,5 +85,24 @@ public class RfidTagServiceImpl extends ServiceImpl<RfidTagMapper, RfidTag> impl
         return updateById(rfidTag) ?1:0;
     }
 
+    @Override
+    public List<RfidTag> list(RfidTag rfidTag) {
+        LambdaQueryWrapper<RfidTag> wrapper = Wrappers.lambdaQuery();
+        //时间
+        String startTime = rfidTag.getStartTime();
+        String endTime = rfidTag.getEndTime();
+        wrapper.apply(StringUtils.hasLength(startTime), "DATE_FORMAT(create_time,'%Y-%m-%d') >=date_format('" + startTime + "','%Y-%m-%d')")
+                .apply(StringUtils.hasLength(endTime), "DATE_FORMAT(create_time,'%Y-%m-%d') <=date_format('" + endTime + "','%Y-%m-%d')");
+
+        //搜索值
+        String searchValue = rfidTag.getSearchValue();
+        if (StringUtils.hasLength(searchValue)) {
+            wrapper.like(RfidTag::getAuthCode, searchValue)
+                    .or()
+                    .like(RfidTag::getTagCode, searchValue);
+        }
+        return list(wrapper);
+    }
+
 
 }

+ 7 - 6
zd-modules/zd-chemical/src/main/java/com/zd/chemical/controller/HxpStockController.java

@@ -231,16 +231,17 @@ public class HxpStockController extends BaseController {
      * @return 发送结果
      */
     @GetMapping(value = "/sendSydSms")
-    public R sendSydSms(@RequestParam(value = "content", required = true) String content,
-                        @RequestParam(value = "purpose", required = true) Integer purpose,
-                        @RequestParam(value = "lockApplyId") Long lockApplyId,
-                        @RequestParam(value = "phones", required = true) @NotNull String... phones){
+    public R sendSydSms(@RequestParam(value = "content") String content,
+                        @RequestParam(value = "purpose") Integer purpose,
+                        @RequestParam(value = "lockApplyId", required = false) Long lockApplyId,
+                        @RequestParam(value = "phones") @NotNull String... phones){
 
         try {
             return smsSydUtil.sendSydSms(content, purpose, lockApplyId, phones);
         } catch (Exception e) {
-            logger.error("四医大短信调用发生异常!");
-           return R.fail("调用发生异常");
+            e.printStackTrace();
+            logger.error("四医大短信调用发生异常!" + e.getMessage());
+           return R.fail("短信发送失败:" + e.getMessage());
         }
     }
 }

+ 10 - 0
zd-modules/zd-chemical/src/main/java/com/zd/chemical/domain/HxpAlarmRecord.java

@@ -106,6 +106,8 @@ public class HxpAlarmRecord extends BaseEntity {
     @ApiModelProperty(value = "使用记录ID")
     private Long userecordId;
 
+    private Long parentId;
+
     public void setId(Long id) {
         this.id = id;
     }
@@ -225,4 +227,12 @@ public class HxpAlarmRecord extends BaseEntity {
     public void setUserecordId(Long userecordId) {
         this.userecordId = userecordId;
     }
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
 }

+ 2 - 0
zd-modules/zd-chemical/src/main/java/com/zd/chemical/mapper/HxpAlarmRecordMapper.java

@@ -72,4 +72,6 @@ public interface HxpAlarmRecordMapper
     int updateByReturnUserecord(Long userecordId);
 
     List<HxpAlarmRecord> queryListByNOValid(HxpAlarmRecord alarmRecord);
+
+    int updateOtherByParentId(Long parentId);
 }

+ 15 - 3
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpAlarmRecordServiceImpl.java

@@ -88,7 +88,13 @@ public class HxpAlarmRecordServiceImpl implements IHxpAlarmRecordService {
         }
         hxpAlarmRecord.setHandlingTime(DateUtils.getNowDate());
         hxpAlarmRecord.setHandlingUserId(SecurityUtils.getUserId());
-        return hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord);
+        int count = hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord);
+
+        if(hxpAlarmRecord.getHandlingStatus() == 2){
+            hxpAlarmRecordMapper.updateOtherByParentId(hxpAlarmRecord.getId());
+        }
+
+        return count;
     }
 
     /**
@@ -137,7 +143,13 @@ public class HxpAlarmRecordServiceImpl implements IHxpAlarmRecordService {
         }
         hxpAlarmRecord.setHandlingTime(DateUtils.getNowDate());
         hxpAlarmRecord.setHandlingUserId(SecurityUtils.getUserId());
-        return hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord);
+
+        int count = hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord);
+
+        if(hxpAlarmRecord.getHandlingStatus() == 2){
+            hxpAlarmRecordMapper.updateOtherByParentId(hxpAlarmRecord.getId());
+        }
+        return count;
     }
 
     @Override
@@ -160,7 +172,7 @@ public class HxpAlarmRecordServiceImpl implements IHxpAlarmRecordService {
                 subName = subInfo.get("name")==null?"":String.valueOf(subInfo.get("name"));
                 content = "【实验室安全系统】" + subName + "-实验人员未领用即携带化学品离开房间,发生时间:"
                         + DateUtil.format(DateUtil.date(), DateUtils.YYYY_MM_DD_HH_MM_SS)
-                        + ",请尽快确认。短信回复“CL”确认已处理。";
+                        + ",请尽快确认。";// 短信回复“CL”确认已处理。
                 try {
                     smsSydUtil.sendSydSms(content, 1, null, new String[]{hxpAlarmRecord.getLiableUserIds()});
                 } catch (Exception e) {

+ 58 - 34
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpStockServiceImpl.java

@@ -309,7 +309,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
      * @return
      */
     @Override
-    public boolean RFIDCheck(InventoryTag tag) {
+    public synchronized boolean RFIDCheck(InventoryTag tag) {
         String rfidCode = tag.getEpc();
         if(StringUtils.isBlank(rfidCode)){
             return false;
@@ -394,7 +394,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
             }
 
             // 报警通知演示临时通知给实验室管理员  phones
-            sendPhoneAlarm(hxpStock.getSubId(), subName, hxpStock.getChemicalName(), subInfo.get("phones") + "");
+            Long recordId = sendPhoneAlarm(hxpStock.getId(),hxpStock.getSubId(), subName, hxpStock.getChemicalName(), subInfo.get("phones") + "");
 
             cacheMap.put(rfidCode, DateUtils.getNowDate());
 
@@ -420,51 +420,72 @@ public class HxpStockServiceImpl implements IHxpStockService {
                 remoteMessageContentService.addDynamicMessage(msgData);
             }
 
-            // 1.查询标签所属实验室院系报警配置流程处理
-            List<HxpAlarmConfig> hxpAlarmConfigList = hxpAlarmConfigMapper.selectBySubId(3, hxpStock.getSubId());
-            // 2.最多五个步骤分别执行
-            if(CollectionUtils.isNotEmpty(hxpAlarmConfigList)){
-                logger.error("实验室【"+subName+"】ID" + hxpStock.getSubId() +"执行用户短信通知!");
-
-                Date date = DateUtil.offsetMinute(DateUtils.getNowDate(), Optional.ofNullable(dealTime).orElse(1));
-
-                for (HxpAlarmConfig hxpAlarmConfig : hxpAlarmConfigList) {
-                    hxpAlarmRecord = new HxpAlarmRecord();
-                    hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+hxpStock.getChemicalName()+"),请尽快确认!");
-                    hxpAlarmRecord.setAlarmType(2);
-                    hxpAlarmRecord.setAlarmMode(3);
-                    hxpAlarmRecord.setHasValid(0);
-                    hxpAlarmRecord.setAlarmTime(date);
-                    hxpAlarmRecord.setSubId(hxpStock.getSubId());
-                    //hxpAlarmRecord.setTerminalNum();
-                    hxpAlarmRecord.setHandlingStatus(1);
-                    hxpAlarmRecord.setLiableUserIds(hxpAlarmConfig.getAlarmPhone());
-
-                    //执行时间 - 报警时间计算
-                    date = DateUtil.offsetMinute(date, Optional.ofNullable(hxpAlarmConfig.getTimeInterval()).orElse(1));
-                    // TODO 短信阶梯通知触发流程控制
-                    hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
+            // 需求变动内容:未领用即携带化学品离开房间报警时,如实验室安全责任人通过化学品终端或PC管理后台操作处理,状态更改为已处理,报警流程终止
+            // 保证逻辑严谨,数据必须进行强关联
+            if(recordId != null){
+                // 1.查询标签所属实验室院系报警配置流程处理
+                List<HxpAlarmConfig> hxpAlarmConfigList = hxpAlarmConfigMapper.selectBySubId(3, hxpStock.getSubId());
+                // 2.最多五个步骤分别执行
+                if(CollectionUtils.isNotEmpty(hxpAlarmConfigList)){
+                    logger.error("实验室【"+subName+"】ID" + hxpStock.getSubId() +"执行用户短信通知!");
+
+                    Date date = DateUtil.offsetMinute(DateUtils.getNowDate(), Optional.ofNullable(dealTime).orElse(1));
+
+                    for (HxpAlarmConfig hxpAlarmConfig : hxpAlarmConfigList) {
+                        hxpAlarmRecord = new HxpAlarmRecord();
+                        hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+hxpStock.getChemicalName()+"),请尽快确认!");
+                        hxpAlarmRecord.setAlarmType(2);
+                        hxpAlarmRecord.setAlarmMode(3);
+                        hxpAlarmRecord.setHasValid(0);
+                        hxpAlarmRecord.setAlarmTime(date);
+                        hxpAlarmRecord.setSubId(hxpStock.getSubId());
+                        hxpAlarmRecord.setStockId(hxpStock.getId());
+                        hxpAlarmRecord.setParentId(recordId);
+                        //hxpAlarmRecord.setTerminalNum();
+                        hxpAlarmRecord.setHandlingStatus(1);
+                        hxpAlarmRecord.setLiableUserIds(hxpAlarmConfig.getAlarmPhone());
+
+                        //执行时间 - 报警时间计算
+                        date = DateUtil.offsetMinute(date, Optional.ofNullable(hxpAlarmConfig.getTimeInterval()).orElse(1));
+                        // TODO 短信阶梯通知触发流程控制
+                        hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
+                    }
                 }
+            }else {
+                logger.error("");
             }
+
             return true;
         }
     }
 
-    private void sendPhoneAlarm(Long subId, String subName, String chemicalName, String phones) {
+    private Long sendPhoneAlarm(Long stockId, Long subId, String subName, String chemicalName, String phones) {
 
         try {
             String[] to = phones.split(",");
             if(to == null && to.length == 0){
                 logger.error("RFID触发电话报警失败:实验室【"+subName+"】管理员未配置手机号!");
-                return;
+                return null;
             }
             to = Arrays.stream(to).distinct().toArray(String[]::new);
 
+            HxpAlarmRecord hxpAlarmRecord = new HxpAlarmRecord();
+            hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+chemicalName+"),请尽快确认!");
+            hxpAlarmRecord.setAlarmType(2);
+            hxpAlarmRecord.setAlarmMode(3);
+            hxpAlarmRecord.setHasValid(1);
+            hxpAlarmRecord.setAlarmTime(DateUtils.getNowDate());
+            hxpAlarmRecord.setSubId(subId);
+            hxpAlarmRecord.setHandlingStatus(1);
+            hxpAlarmRecord.setLiableUserIds(phones);
+            hxpAlarmRecord.setStockId(stockId);
+
+            hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
 
             // 判断四医大还是其他学校短信方案
             String content;
             if(phoneMode == 0){
-                HxpAlarmRecord hxpAlarmRecord = new HxpAlarmRecord();
+                /*HxpAlarmRecord hxpAlarmRecord = new HxpAlarmRecord();
                 hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+chemicalName+"),请尽快确认!");
                 hxpAlarmRecord.setAlarmType(2);
                 hxpAlarmRecord.setAlarmMode(3);
@@ -474,7 +495,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
                 hxpAlarmRecord.setHandlingStatus(1);
                 hxpAlarmRecord.setLiableUserIds(phones);
 
-                hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
+                hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);*/
 
                 content = "电话报警:" + subName + "的化学品" + chemicalName + "违规带离实验室,请尽快确认!";
                 AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, to, content);
@@ -482,7 +503,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
 
                 logger.error(JSONUtil.toJsonStr(result));
             }else if(phoneMode == 1){
-                for (String s : to) {
+                /*for (String s : to) {
                     HxpAlarmRecord hxpAlarmRecord = new HxpAlarmRecord();
                     hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+chemicalName+"),请尽快确认!");
                     hxpAlarmRecord.setAlarmType(2);
@@ -494,11 +515,11 @@ public class HxpStockServiceImpl implements IHxpStockService {
                     hxpAlarmRecord.setLiableUserIds(s);
 
                     hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
-                }
+                }*/
 
                 content = "【实验室安全系统】" + subName + "-实验人员未领用即携带化学品离开房间,发生时间:"
                         + DateUtil.format(DateUtil.date(), DateUtils.YYYY_MM_DD_HH_MM_SS)
-                        + ",请尽快确认。短信回复“CL”确认已处理。";
+                        + ",请尽快确认。";//短信回复“CL”确认已处理。
                 try {
                     smsSydUtil.sendSydSms(content, 1, null, to);
                 } catch (Exception e) {
@@ -506,11 +527,14 @@ public class HxpStockServiceImpl implements IHxpStockService {
                 }
             }
 
-
+            return hxpAlarmRecord.getId();
         }catch (Exception e){
             e.printStackTrace();
             logger.error("【"+subName+"】RFID触发报警器进行电话通知失败:" + e.getMessage());
+            return null;
         }
+
+
     }
 
     @Override

+ 17 - 16
zd-modules/zd-chemical/src/main/java/com/zd/chemical/util/SmsSydUtil.java

@@ -26,23 +26,23 @@ import java.util.stream.Stream;
 @Component
 public class SmsSydUtil {
 
-    private static MTPack mtPack;
+    private MTPack mtPack;
 
     // 证号 djjx
     // 登录密码 6B1aQety
     // 发送密码 yfhzfGSJ
-    private static Account account = new Account("djjx", "yfhzfGSJ");
+    private Account account = new Account("djjx", "yfhzfGSJ");
 
     @Value("${sms-syd.ip:127.0.0.1}")
-    private static String SMS_IP =  "127.0.0.1";
+    private String SMS_IP =  "127.0.0.1";
     @Value("${sms-syd.down-port:8090}")
-    public static int DOWN_PORT = 8090;
+    public int DOWN_PORT = 8090;
     @Value("${sms-syd.up-port:8188}")
-    public static int UP_PORT = 8188;
+    public int UP_PORT = 8188;
 
     // 8090  下发端口   8188 拉取状态报告和上行
-    private static PostMsg DOWN_PM = new PostMsg(SMS_IP, DOWN_PORT);
-    private static PostMsg UP_PM = new PostMsg(SMS_IP, UP_PORT);
+    private PostMsg DOWN_PM = new PostMsg(SMS_IP, DOWN_PORT);
+    private PostMsg UP_PM = new PostMsg(SMS_IP, UP_PORT);
 
     private static Map<Integer, String> DOWN_MAP;
 
@@ -64,14 +64,14 @@ public class SmsSydUtil {
 
     }
 
-    private static MTPack buildDefaultSMSPack() {
-        if(SmsSydUtil.mtPack == null){
-            MTPack mtPack = new MTPack();
+    private MTPack buildDefaultSMSPack() {
+        if(this.mtPack == null){
+            this.mtPack = new MTPack();
             mtPack.setSendType(MTPack.SendType.MASS);
             mtPack.setMsgType(MTPack.MsgType.SMS);
             mtPack.setBizType(1);
         }
-        return SmsSydUtil.mtPack;
+        return this.mtPack;
     }
 
     /**
@@ -114,14 +114,14 @@ public class SmsSydUtil {
     /**
      * 短信下发范例 每个话单,一个扩展码
      */
-    private synchronized static R singleTicketMsgId(@NotNull String content, UUID uuid, @NotNull String... phones) throws Exception {
+    private synchronized R singleTicketMsgId(@NotNull String content, UUID uuid, @NotNull String... phones) throws Exception {
 
         MTPack pack = buildDefaultSMSPack();
 
         // 批次号
         pack.setBatchID(uuid);
 
-        log.info("四医大短信下发参数:UUID," + pack.getBatchID() + "手机号:" + phones.toString() + "内容:" + content);
+        log.info("四医大短信下发参数:UUID," + pack.getBatchID() + "手机号:" + JSONUtil.toJsonStr(phones) + ",内容:" + content);
 
         List<MessageData> msgs = new ArrayList<>();
         for (String phone : phones) {
@@ -133,7 +133,7 @@ public class SmsSydUtil {
         log.info("四医大短信下发返回结果:" + resp.toString());
         if(resp.getResult() == 0){
 
-            return R.ok(resp.getResult()+"", resp.getResult());
+            return R.ok(resp.getResult()+"", DOWN_MAP.get(resp.getResult()));
         }else {
             return R.fail(resp.getResult()+"", DOWN_MAP.get(resp.getResult()));
         }
@@ -151,9 +151,10 @@ public class SmsSydUtil {
         sydSmsLog.setReply(0);
         List<SydSmsLog> list = sydSmsLogService.selectSydSmsLogList(sydSmsLog);
 
-        if(list.size() == 0){
+        // TODO 测试原因,咱注释掉
+        /*if(list.size() == 0){
             return;
-        }
+        }*/
 
         MOMsg[] mos = UP_PM.getMOMsgs(account, 10);
 

+ 6 - 0
zd-modules/zd-chemical/src/main/resources/mapper/chemical/HxpAlarmRecordMapper.xml

@@ -198,6 +198,8 @@
 
             <if test="userecordId != null">userecord_id,</if>
 
+            <if test="parentId != null">parent_id,</if>
+
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="alarmContent != null">#{alarmContent},</if>
@@ -215,6 +217,7 @@
 
             <if test="stockId != null">#{stockId},</if>
             <if test="userecordId != null">#{userecordId},</if>
+            <if test="parentId != null">#{parentId},</if>
         </trim>
     </insert>
 
@@ -244,6 +247,9 @@
     <update id="updateByReturnUserecord">
         update hxp_alarm_record set handling_status = 2 where handling_status = 1 and userecord_id = #{userecordId}
     </update>
+    <update id="updateOtherByParentId">
+        update hxp_alarm_record set handling_status = 2 where has_valid = 0 and handling_status = 1 and parent_id = #{parentId}
+    </update>
 
     <delete id="deleteHxpAlarmRecordById" parameterType="Long">
         delete

+ 3 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/socket/runner/TCPServer.java

@@ -227,7 +227,9 @@ public class TCPServer implements Runnable {
 //
 //        System.out.println(TCPServer.byte2hex(b));
 
-        TransmissionVo transmissionVo = new TransmissionVo("fe dc 01 6b 55 65 61 6a 67 00 00 1f a0 03 00 10 00 00 01 2d 00 00 02 3a 00 01 88 08 00 00 00 00 00");
+        String str = "fe dc 01 78 99 4c 6c 61 88 00 02 64 30 03 00 34 00 00 00 00 00 00 00 00 00 00 01 2d 00 00 01 55 00 01 88 f6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00";
+
+        TransmissionVo transmissionVo = new TransmissionVo(str);
 
         System.out.println(JSONUtil.toJsonStr(transmissionVo));
     }

+ 19 - 2
zd-modules/zd-modules-system/src/main/java/com/zd/system/controller/SysUserController.java

@@ -19,6 +19,7 @@ import com.zd.common.core.utils.file.ImageUtils;
 import com.zd.common.security.utils.DictUtils;
 import com.zd.system.api.RemoteDeptService;
 import com.zd.system.api.RemoteFileService;
+import com.zd.system.api.chemical.RemoteStockService;
 import com.zd.system.api.domain.*;
 import com.zd.system.api.laboratory.RemoteSubQueryService;
 import com.zd.system.api.model.SimpleUserVO;
@@ -86,6 +87,9 @@ public class SysUserController extends BaseController {
     @Resource
     private RedisTemplate<String, String> redisTemplate;
 
+    @Resource
+    private RemoteStockService stockService;
+
 
     /**
      * 获取用户列表 "system:user:list"
@@ -728,8 +732,21 @@ public class SysUserController extends BaseController {
         String code = RandomUtil.randomNumbers(6);
         redisTemplate.opsForValue().set(key, code, CODE_EXPIRATION, TimeUnit.MINUTES);
         logger.info("========================>{}<=========================", code);
-        return R.ok(code);
-//        return stockService.sendSydSms(code, 2, null, form.getUsername());
+        String countKey=Constants.DEFAULT_CODE_KEY + "@" + phone+"_COUNT";
+        String count = redisTemplate.opsForValue().get(countKey);
+        if (StringUtils.isEmpty(count)){
+            redisTemplate.opsForValue().set(countKey,"1",60,TimeUnit.MINUTES);
+        }else {
+            if (count!=null){
+                int i=Integer.parseInt(count);
+                if (i>=5){
+                    throw new ServiceException("验证码发送超过限制,请一小时后再试",530);
+                }
+                i++;
+                redisTemplate.opsForValue().set(countKey,i+"",60,TimeUnit.MINUTES);
+            }
+        }
+        return stockService.sendSydSms(code, 2, null, phone);
     }
 
     /**

+ 23 - 1
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDClientImpl.java

@@ -8,7 +8,6 @@ import com.gg.reader.api.protocol.gx.MsgBaseSetPower;
 import com.zd.common.core.enums.HardwareOperate;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.SpringUtils;
-import com.zd.common.redis.service.RedisService;
 import com.zd.netty.service.IService;
 import com.zd.system.api.laboratory.RemoteLaboratoryService;
 import com.zd.system.api.laboratory.domain.RemoteLabHardware;
@@ -100,11 +99,29 @@ public class DeJuRFIDClientImpl implements IService {
             client.setPrint(true);
             reSet(hardware, client);
             service.subscribeHandler(client, hardware);
+            subscribeHandlerTagEpcOver(client);
             remoteLaboratoryService.update(HardwareOperate.OPEN, hardware.getIpAddress());
             log.info(client.getName() + "---监听成功");
         };
     }
 
+    /**
+     * 订阅6c标签信息上报停止事件
+     *
+     * @param client   客户端
+     */
+    public void subscribeHandlerTagEpcOver(GClient client) {
+        client.onTagEpcOver= (s, logBaseEpcInfo) -> {
+            log.info("HandlerTagEpcOver:"+s);
+            RemoteLabHardware labHardware = redisTemplate.opsForValue().get(client.getSerialNumber());
+            if (labHardware==null){
+                return;
+            }
+            disconnect(labHardware);
+            start(labHardware);
+        };
+    }
+
     private void reSet(RemoteLabHardware hardware, GClient client) {
         MsgBaseSetBaseband msgBaseSetBaseband = DeJuRFIDServerImpl.setSession(hardware, client);
         if (0 != msgBaseSetBaseband.getRtCode()) {
@@ -122,6 +139,11 @@ public class DeJuRFIDClientImpl implements IService {
         if (0 != msgBaseInventoryEpc.getRtCode()) {
             log.error("Inventory epc error.");
             reConnect(hardware, client);
+            return;
+        }
+        boolean changeGpi = DeJuRFIDServerImpl.setGpi(client);
+        if (!changeGpi){
+            reConnect(hardware,client);
         }
     }
 

+ 53 - 2
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDServerImpl.java

@@ -21,7 +21,6 @@ import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * @author Administrator
@@ -70,6 +69,13 @@ public class DeJuRFIDServerImpl implements IService {
         }
         if (client.openTcp(ipAddress, TIME_OUT)) {
             stopMsg(client);
+            boolean change = setGpi(client);
+            if (!change){
+                log.info("GPI epc error.");
+                close(hardware);
+                open(hardware);
+                return;
+            }
             MsgBaseSetBaseband msgBaseSetBaseband = setSession(hardware, client);
             if (0 != msgBaseSetBaseband.getRtCode()) {
                 log.info("Session epc error.");
@@ -96,6 +102,7 @@ public class DeJuRFIDServerImpl implements IService {
 
             // 订阅标签上报事件
             subscribeHandler(client, hardware);
+            subscribeHandlerTagEpcOver(client,hardware);
             String serialNumber = client.getSerialNumber();
             if (StringUtils.hasLength(serialNumber)){
                 redisTemplate.opsForValue().set(serialNumber, hardware);
@@ -213,6 +220,37 @@ public class DeJuRFIDServerImpl implements IService {
         return msgBaseSetBaseband;
     }
 
+    public static boolean setGpi(GClient client) {
+        MsgAppGetGpiState gpiState=new MsgAppGetGpiState();
+        client.sendSynMsg(gpiState);
+        HashMap<Integer, Integer> hashMap = gpiState.getHpGpiState();
+        boolean change=true;
+        for (Map.Entry<Integer,Integer> entry:hashMap.entrySet()) {
+            Integer k = entry.getKey();
+            MsgAppGetGpiTrigger getGpiTrigger = new MsgAppGetGpiTrigger();
+            getGpiTrigger.setGpiPort(k-1);
+            client.sendSynMsg(getGpiTrigger);
+            if (getGpiTrigger.getRtCode()==0){
+                int triggerOver = getGpiTrigger.getTriggerOver();
+                int triggerStart = getGpiTrigger.getTriggerStart();
+                if (triggerStart!=0|| triggerOver!=0){
+                    MsgAppSetGpiTrigger gpiTrigger = new MsgAppSetGpiTrigger();
+                    gpiTrigger.setGpiPort(getGpiTrigger.getGpiPort());
+                    gpiTrigger.setTriggerOver(0);
+                    gpiTrigger.setTriggerStart(0);
+                    client.sendSynMsg(gpiTrigger);
+                    if (0 != gpiTrigger.getRtCode()) {
+                        log.info("GPI epc error.");
+                        change=false;
+                    } else {
+                        log.info("GPI epc success.");
+                    }
+                }
+            }
+        }
+        return change;
+    }
+
     @Override
     public void disconnect(RemoteLabHardware hardware) {
         close(hardware);
@@ -333,6 +371,19 @@ public class DeJuRFIDServerImpl implements IService {
                 }
             }
         };
-        client.onTagEpcOver = (s, logBaseEpcOver) -> log.info("HandlerTagEpcOver");
+    }
+
+    /**
+     * 订阅6c标签信息上报停止事件
+     *
+     * @param client   客户端
+     * @param hardware 设备数据
+     */
+    public void subscribeHandlerTagEpcOver(GClient client, RemoteLabHardware hardware) {
+        client.onTagEpcOver= (s, logBaseEpcInfo) -> {
+            log.info("HandlerTagEpcOver:"+s);
+            close(hardware);
+            open(hardware);
+        };
     }
 }

+ 7 - 2
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/WuYuanRFIDServiceImpl.java

@@ -166,7 +166,12 @@ public class WuYuanRFIDServiceImpl implements IService {
     public void setDevice(RemoteLabHardware hardware) {
         Reader reader;
         String ipAddress = hardware.getIpAddress();
-        int uniformPower = Integer.parseInt(hardware.getUniformPower());
+        int power=33;
+        String uniformPower = hardware.getUniformPower();
+        String index = uniformPower.split(",")[0].split(":")[0];
+        if (StringUtils.hasLength(index)){
+            power= Integer.parseInt(index);
+        }
         if (readerMap.containsKey(ipAddress)) {
             reader = readerMap.get(ipAddress);
         } else {
@@ -175,7 +180,7 @@ public class WuYuanRFIDServiceImpl implements IService {
 
         stopMonitor(hardware);
         reader.setOutputPowerUniformly(
-                (byte) Integer.parseInt(Integer.toHexString(uniformPower)),
+                (byte) Integer.parseInt(Integer.toHexString(power)),
                 true,
                 success -> successMsg(success, "设置读写器的射频输出功率"),
                 failure -> errorMsg(failure, (byte) -1, "设置读写器的射频输出功率失败:", hardware));

+ 2 - 2
zd-modules/zd-speaker/src/main/java/com/zd/speaker/service/impl/SpeakerServiceImpl.java

@@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
 @RefreshScope
 public class SpeakerServiceImpl implements ISpeakerService {
 
-    @Value("${speaker.port:8080}")
+    @Value("${speaker.port:8888}")
     private String port;
 
     @Value("${speaker.isOnline:0}")
@@ -188,7 +188,7 @@ public class SpeakerServiceImpl implements ISpeakerService {
             }
             String deviceIp =playVoList.get(0).getDeviceIp();
             playBatchVo.setSns(snsList.toArray(new String[snsList.size()]));
-            boolean isTrue = invokePost(JSONObject.toJSON(playBatchVo).toString(), deviceIp,1, 0);
+            boolean isTrue = invokePost(JSONObject.toJSON(playBatchVo).toString(), deviceIp,1, playVoList.get(0).getPort());
             if (isTrue) {
                 textParseVoiceAppIps(texts,playVoList);
             }