소스 검색

2023-11-30 化学品添加电子信息牌apk升级功能。

chaiyunlong 2 년 전
부모
커밋
5b7525be3d

+ 11 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/XxpCardInfo.java

@@ -160,6 +160,9 @@ public class XxpCardInfo extends BaseEntity {
      */
     private String endTime;
 
+    @ApiModelProperty("实验室ids")
+    private String[] subjectIds;
+
     @Override
     public Long getUserId() {
         return userId;
@@ -241,4 +244,12 @@ public class XxpCardInfo extends BaseEntity {
     public Integer getAuthType() {        return authType;    }
 
     public void setAuthType(Integer authType) {        this.authType = authType;    }
+
+    public String[] getSubjectIds() {
+        return subjectIds;
+    }
+
+    public void setSubjectIds(String[] subjectIds) {
+        this.subjectIds = subjectIds;
+    }
 }

+ 50 - 22
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/ApkFileUpLoadServiceImpl.java

@@ -5,10 +5,12 @@ import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.domain.LabHardware;
+import com.zd.laboratory.domain.XxpCardInfo;
 import com.zd.laboratory.domain.vo.LabHardwareVO;
 import com.zd.laboratory.mapper.ApkFileUpLoadMapper;
 import com.zd.laboratory.mapper.ApkLogMapper;
 import com.zd.laboratory.mapper.LabHardwareMapper;
+import com.zd.laboratory.mapper.XxpCardInfoMapper;
 import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
 import com.zd.laboratory.onemachine.domain.ApkLog;
 import com.zd.laboratory.onemachine.domain.ApkLogVo;
@@ -52,6 +54,9 @@ public class ApkFileUpLoadServiceImpl implements ApkFileUpLoadService {
     private SubMessageSendManager messageSendService;
 
     @Autowired
+    private XxpCardInfoMapper xxpCardInfoMapper;
+
+    @Autowired
     private static final Logger log = LoggerFactory.getLogger(ApkFileUpLoadServiceImpl.class);
 
     @Override
@@ -100,30 +105,53 @@ public class ApkFileUpLoadServiceImpl implements ApkFileUpLoadService {
 
     @Override
     public int addApkLog(ApkLogVo apkLogVo) {
-        LabHardwareVO labHardware = new LabHardwareVO();
-        labHardware.setDeptId(apkLogVo.getDeptId());
-        labHardware.setSubjectIds(apkLogVo.getSubId());
-        if(labHardware.getDeptId()!=null || labHardware.getSubjectIds()!=null){
-            if(apkLogVo.getOnepcType()==1){
-                labHardware.setPcType(0);
-            }else if(apkLogVo.getOnepcType()==2){
-                labHardware.setPcType(1);
-            }else{
-                throw new ServiceException("无效的设备类型");
+        if(apkLogVo.getOnepcType()==1 || apkLogVo.getOnepcType()==2){
+            //这里是新增管控一体机和考试一体机
+            LabHardwareVO labHardware = new LabHardwareVO();
+            labHardware.setDeptId(apkLogVo.getDeptId());
+            labHardware.setSubjectIds(apkLogVo.getSubId());
+            if(labHardware.getDeptId()!=null || labHardware.getSubjectIds()!=null){
+                if(apkLogVo.getOnepcType()==1){
+                    labHardware.setPcType(0);
+                }else if(apkLogVo.getOnepcType()==2){
+                    labHardware.setPcType(1);
+                }
+                List <LabHardware> hardwareList =  labHardwareMapper.getHardwareListBySubId(labHardware);
+                Optional.ofNullable(hardwareList).orElseGet(Collections::emptyList).stream().forEach(a->{
+                    ApkLog apkLog = new ApkLog();
+                    apkLog.setOnepcHardwareNum(a.getHardwareNum());
+                    apkLog.setApkUploadId(apkLogVo.getApkId()+"");
+                    apkLog.setLogStatus(3);
+                    apkLog.setCreateBy(tokenService.getLoginUser().getSysUser().getNickName());
+                    apkLog.setCreateTime(new Date());
+                    apkLogMapper.insertApkLog(apkLog);
+                    //调用一体机推送方法
+                    sendOnePcInfo(apkLog.getId());
+                });
             }
-            List <LabHardware> hardwareList =  labHardwareMapper.getHardwareListBySubId(labHardware);
-            Optional.ofNullable(hardwareList).orElseGet(Collections::emptyList).stream().forEach(a->{
-                ApkLog apkLog = new ApkLog();
-                apkLog.setOnepcHardwareNum(a.getHardwareNum());
-                apkLog.setApkUploadId(apkLogVo.getApkId()+"");
-                apkLog.setLogStatus(3);
-                apkLog.setCreateBy(tokenService.getLoginUser().getSysUser().getNickName());
-                apkLog.setCreateTime(new Date());
-                apkLogMapper.insertApkLog(apkLog);
-                //调用一体机推送方法
-                sendOnePcInfo(apkLog.getId());
-            });
+        }else if(apkLogVo.getOnepcType()==3){
+            //这里是电子信息牌代码
+            XxpCardInfo cardInfo = new XxpCardInfo();
+            cardInfo.setCollegeId(apkLogVo.getDeptId());
+            cardInfo.setSubjectIds(apkLogVo.getSubId());
+            if(cardInfo.getCollegeId()!=null || cardInfo.getSubjectIds()!=null){
+                List<XxpCardInfo> cardInfoList = xxpCardInfoMapper.selectXxpCardInfoList(cardInfo);
+                Optional.ofNullable(cardInfoList).orElseGet(Collections::emptyList).stream().forEach(a->{
+                    ApkLog apkLog = new ApkLog();
+                    apkLog.setOnepcHardwareNum(a.getCardNum());
+                    apkLog.setApkUploadId(apkLogVo.getApkId()+"");
+                    apkLog.setLogStatus(3);
+                    apkLog.setCreateBy(tokenService.getLoginUser().getSysUser().getNickName());
+                    apkLog.setCreateTime(new Date());
+                    apkLogMapper.insertApkLog(apkLog);
+                    //调用一体机推送方法
+                    sendOnePcInfo(apkLog.getId());
+                });
+            }
+        }else{
+            throw new ServiceException("无效的设备类型");
         }
+
         return 1;
     }
 

+ 39 - 12
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/ApkLogMapper.xml

@@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <select id="selectApkLogList" parameterType="com.zd.laboratory.onemachine.domain.ApkLogVo" resultType="com.zd.laboratory.onemachine.domain.ApkLogVo">
+        SELECT xxp.* FROM (
         SELECT lg.id,lg.`onepc_hardware_num` onepcHardwareNum,lg.`apk_upload_id` apkUploadId,lg.`log_status` logStatus,lg.`create_by` createBy,lg.`create_time` createTime,
         ul.`apk_file_upload` apkFileUpload,ul.`apk_name` apkName,ul.`version`,ul.`version_name` versionName,ul.onepc_type onepcType,hw.`name` hardName,sb.`name` subName,ul.id apkId
         FROM apk_log lg INNER JOIN (SELECT l.`onepc_hardware_num`,MAX(l.`create_time`) create_time FROM apk_log l GROUP BY l.`onepc_hardware_num`)l
@@ -24,19 +25,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         INNER JOIN apk_upload ul ON lg.`apk_upload_id` = ul.`id`
         INNER JOIN lab_hardware hw ON lg.`onepc_hardware_num` = hw.`hardware_num`
         INNER JOIN lab_subject sb ON hw.`subject_id` = sb.`id`
+        WHERE ul.onepc_type IN(1,2)
+
+        UNION ALL
+
+        SELECT lg.id,lg.`onepc_hardware_num` onepcHardwareNum,lg.`apk_upload_id` apkUploadId,lg.`log_status` logStatus,lg.`create_by` createBy,lg.`create_time` createTime,
+        ul.`apk_file_upload` apkFileUpload,ul.`apk_name` apkName,ul.`version`,ul.`version_name` versionName,ul.onepc_type onepcType,hw.`card_name` hardName,sb.`name` subName,ul.id apkId
+        FROM apk_log lg INNER JOIN (SELECT l.`onepc_hardware_num`,MAX(l.`create_time`) create_time FROM apk_log l GROUP BY l.`onepc_hardware_num`)l
+        ON lg.`onepc_hardware_num` = l.onepc_hardware_num AND lg.`create_time` = l.create_time
+        INNER JOIN apk_upload ul ON lg.`apk_upload_id` = ul.`id`
+        INNER JOIN xxp_card_info hw ON lg.`onepc_hardware_num` = hw.`card_num`
+        INNER JOIN lab_subject sb ON hw.`subject_id` = sb.`id`
+        WHERE ul.onepc_type IN(3)
+        )xxp
         <where>
-            <if test="id != null "> and lg.`id` = #{id} </if>
-            <if test="onepcHardwareNum != null "> and lg.`onepc_hardware_num` = #{onepcHardwareNum} </if>
-            <if test="subName != null "> and sb.`name` like concat('%', #{subName}, '%') </if>
-            <if test="hardName != null "> and hw.`name` like concat('%',#{hardName}, '%')</if>
-            <if test="versionName != null "> and ul.`version_name` like concat('%',#{versionName}, '%')</if>
-            <if test="onepcType != null "> and ul.onepc_type = #{onepcType} </if>
-            <if test="logStatus != null "> and lg.`log_status` = #{logStatus} </if>
+            <if test="id != null "> and xxp.`id` = #{id} </if>
+            <if test="onepcHardwareNum != null "> and xxp.`onepcHardwareNum` = #{onepcHardwareNum} </if>
+            <if test="subName != null "> and xxp.`subName` like concat('%', #{subName}, '%') </if>
+            <if test="hardName != null "> and xxp.hardName like concat('%',#{hardName}, '%')</if>
+            <if test="versionName != null "> and xxp.`versionName` like concat('%',#{versionName}, '%')</if>
+            <if test="onepcType != null "> and xxp.onepcType = #{onepcType} </if>
+            <if test="logStatus != null "> and xxp.`logStatus` = #{logStatus} </if>
             <if test="searchValue != null and searchValue != ''">
                 and (
-                sb.`name` like concat('%', #{searchValue}, '%') or
-                hw.`name` like concat('%',#{searchValue}, '%') or
-                ul.`version_name` like concat('%',#{searchValue}, '%')
+                xxp.`subName` like concat('%', #{searchValue}, '%') or
+                xxp.hardName like concat('%',#{searchValue}, '%') or
+                xxp.`versionName` like concat('%',#{searchValue}, '%')
                 )
             </if>
 
@@ -44,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectApkLogDetail" parameterType="com.zd.laboratory.onemachine.domain.ApkLogVo" resultType="com.zd.laboratory.onemachine.domain.ApkLogVo">
+        select xxp.* from (
         SELECT lg.id,lg.`onepc_hardware_num` onepcHardwareNum,lg.`apk_upload_id` apkUploadId,lg.`log_status` logStatus,lg.`create_by` createBy,lg.`create_time` createTime,
         ul.`apk_file_upload` apkFileUpload,ul.`apk_name` apkName,ul.`version`,ul.`version_name` versionName,ul.onepc_type onepcType,hw.`name` hardName,sb.`name` subName,ul.id apkId
         FROM apk_log lg INNER JOIN (SELECT l.`onepc_hardware_num`,MAX(l.`create_time`) create_time FROM apk_log l GROUP BY l.`onepc_hardware_num`)l
@@ -51,11 +66,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         INNER JOIN apk_upload ul ON lg.`apk_upload_id` = ul.`id`
         INNER JOIN lab_hardware hw ON lg.`onepc_hardware_num` = hw.`hardware_num`
         INNER JOIN lab_subject sb ON hw.`subject_id` = sb.`id`
+        where ul.onepc_type in(1,2)
+
+        union all
+
+        SELECT lg.id,lg.`onepc_hardware_num` onepcHardwareNum,lg.`apk_upload_id` apkUploadId,lg.`log_status` logStatus,lg.`create_by` createBy,lg.`create_time` createTime,
+        ul.`apk_file_upload` apkFileUpload,ul.`apk_name` apkName,ul.`version`,ul.`version_name` versionName,ul.onepc_type onepcType,hw.`card_name` hardName,sb.`name` subName,ul.id apkId
+        FROM apk_log lg INNER JOIN (SELECT l.`onepc_hardware_num`,MAX(l.`create_time`) create_time FROM apk_log l GROUP BY l.`onepc_hardware_num`)l
+        ON lg.`onepc_hardware_num` = l.onepc_hardware_num AND lg.`create_time` = l.create_time
+        INNER JOIN apk_upload ul ON lg.`apk_upload_id` = ul.`id`
+        INNER JOIN xxp_card_info hw ON lg.`onepc_hardware_num` = hw.`card_num`
+        INNER JOIN lab_subject sb ON hw.`subject_id` = sb.`id`
+        WHERE ul.onepc_type IN(3)
+        )xxp
         <where>
-            1=1
             <if test="onepcHardwareNum != null ">
-              and lg.`onepc_hardware_num` = #{onepcHardwareNum}
+              and xxp.onepcHardwareNum = #{onepcHardwareNum}
             </if>
         </where>
     </select>

+ 6 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/XxpCardInfoMapper.xml

@@ -81,6 +81,12 @@
                 or t.subject_name like concat('%', #{searchValue}, '%')
                 )
             </if>
+            <if test="subjectIds != null ">
+                and t.subject_id IN
+                <foreach item="subId" collection="subjectIds" open="(" separator="," close=")">
+                    #{subId}
+                </foreach>
+            </if>
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>