czh 2 lat temu
rodzic
commit
7531c3f4e9

+ 2 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEntCertificateDao.java

@@ -66,4 +66,6 @@ public interface KwsEntCertificateDao {
      * @date: 2023/6/30
      * @date: 2023/6/30
      */
      */
     List<KwsEntCertificate> findByEntType(@Param(value = "entId") Long entId, @Param(value = "type") Integer type);
     List<KwsEntCertificate> findByEntType(@Param(value = "entId") Long entId, @Param(value = "type") Integer type);
+
+    List<KwsEntCertificate> findPrevious(@Param(value = "entId") Long entId, @Param(value = "type") Integer type);
 }
 }

+ 2 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/vo/res/EntDetailResVo.java

@@ -146,4 +146,6 @@ public class EntDetailResVo implements Serializable {
      * 主营业务
      * 主营业务
      */
      */
     private String business;
     private String business;
+
+    private boolean valid;
 }
 }

+ 55 - 12
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -429,17 +429,20 @@ public class KwsEnterpriseService {
         List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
         List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
         for (KwsEntCertificate kwsEntCertificate : kwsEntCertificateList) {
         for (KwsEntCertificate kwsEntCertificate : kwsEntCertificateList) {
             //先把旧的作废
             //先把旧的作废
-            List<KwsEntCertificate> previous = kwsEntCertificateDao.findByEntType(kwsEntCertificate.getEntId(), kwsEntCertificate.getType());
-            previous = previous.stream().filter(item -> !item.getId().equals(kwsEntCertificate.getId())).toList();
-            if (!CollectionUtils.isEmpty(previous)) {
-                for (KwsEntCertificate kwsEntCertificate1 : previous) {
-                    kwsEntCertificate1.setDelFlag(Global.YES);
-                    kwsEntCertificateDao.update(kwsEntCertificate1);
+            if (status.equals(ApprovalEnum.OK.getCode())) {
+                List<KwsEntCertificate> previous = kwsEntCertificateDao.findPrevious(kwsEntCertificate.getEntId(), kwsEntCertificate.getType());
+                if (CollectionUtils.isNotEmpty(previous)) {
+                    for (KwsEntCertificate kwsEntCertificate1 : previous) {
+                        kwsEntCertificate1.setDelFlag(Global.YES);
+                        kwsEntCertificateDao.update(kwsEntCertificate1);
+                    }
                 }
                 }
             }
             }
 
 
-            kwsEntCertificate.setStatus(ApprovalEnum.OK.getCode() == status ? Global.NO : Global.YES);
-            kwsEntCertificateDao.update(kwsEntCertificate);
+            if (kwsEntCertificate.getStatus().equals(ApprovalEnum.PROCESS.getCode())) {
+                kwsEntCertificate.setStatus(status.equals(ApprovalEnum.OK.getCode()) ? Global.NO : Global.YES);
+                kwsEntCertificateDao.update(kwsEntCertificate);
+            }
 
 
             entId = kwsEntCertificate.getEntId();
             entId = kwsEntCertificate.getEntId();
             kwsEntCertificates.add(kwsEntCertificate);
             kwsEntCertificates.add(kwsEntCertificate);
@@ -458,6 +461,7 @@ public class KwsEnterpriseService {
         KwsEntCheckTrack kwsEntCheckTrack = new KwsEntCheckTrack();
         KwsEntCheckTrack kwsEntCheckTrack = new KwsEntCheckTrack();
         kwsEntCheckTrack.setEntId(entId);
         kwsEntCheckTrack.setEntId(entId);
         kwsEntCheckTrack.setRemark(reqVo.getRemark());
         kwsEntCheckTrack.setRemark(reqVo.getRemark());
+        kwsEntCheckTrack.setStatus(status.equals(ApprovalEnum.OK.getCode()) ? Global.NO : Global.YES);
         if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
         if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
         }
@@ -560,13 +564,45 @@ public class KwsEnterpriseService {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
         }
         }
 
 
-        kwsEntCertificates = kwsEntCertificates.stream().filter(item -> item.getStatus().equals(Global.NO)).toList();
-        if (CollectionUtils.isEmpty(kwsEntCertificates)) {
-            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENTCERTIFICATES_NOT_EXISTS);
+        KwsEnterprise kwsEnterprise = kwsEnterpriseDao.selectByKey(entId);
+        List<KwsEntCertificate> finalList = new ArrayList<>();
+        if (kwsEnterprise.getApproval().equals(ApprovalEnum.PROCESS.getCode()) || kwsEnterprise.getApproval().equals(ApprovalEnum.REFRESH.getCode())) {
+            finalList = kwsEntCertificates.stream().filter(item -> item.getStatus().equals(ApprovalEnum.PROCESS.getCode())).toList();
+        }
+
+
+        if (kwsEnterprise.getApproval().equals(ApprovalEnum.OK.getCode())) {
+            finalList = kwsEntCertificates.stream().filter(item -> item.getStatus().equals(Global.NO)).toList();
+        }
+
+        if (kwsEnterprise.getApproval().equals(ApprovalEnum.PASS.getCode())) {
+            List<KwsEntCheckTrack> list = kwsEntCheckTrackDao.findList(entId);
+            if (list.stream().anyMatch(item -> item.getStatus().equals(Global.NO))) {
+                //通过了一次
+                finalList = kwsEntCertificates.stream().filter(item -> item.getStatus().equals(Global.NO)).toList();
+            } else {
+                //未通过过,按时间倒序取最后一次驳回
+                finalList = kwsEntCertificates.stream().filter(item -> item.getStatus().equals(Global.YES)).collect(Collectors.toList());
+                if (CollectionUtils.isNotEmpty(finalList)) {
+                    Map<Integer, List<KwsEntCertificate>> collect = finalList.stream().collect(Collectors.groupingBy(KwsEntCertificate::getType));
+                    for (Integer type : collect.keySet()) {
+                        List<KwsEntCertificate> kwsEntCertificates1 = collect.get(type);
+                        if (CollectionUtils.isNotEmpty(kwsEntCertificates1)) {
+                            List<KwsEntCertificate> collect1 = kwsEntCertificates1.stream().sorted(Comparator.comparing(KwsEntCertificate::getUpdateTime).reversed()).collect(Collectors.toList());
+                            finalList.add(collect1.get(0));
+                        }
+                    }
+                }
+            }
         }
         }
+
+        if (CollectionUtils.isEmpty(finalList)) {
+            return Collections.emptyList();
+        }
+
         /*拼装返参*/
         /*拼装返参*/
         List<CertificateResVo> list = new ArrayList<>();
         List<CertificateResVo> list = new ArrayList<>();
-        kwsEntCertificates.forEach(item -> {
+        finalList.forEach(item -> {
             CertificateResVo certificateResVo = new CertificateResVo();
             CertificateResVo certificateResVo = new CertificateResVo();
             certificateResVo.setTypeName(Objects.requireNonNull(CertificateTypeEnum.getName(item.getType())).getName());
             certificateResVo.setTypeName(Objects.requireNonNull(CertificateTypeEnum.getName(item.getType())).getName());
             BeanUtils.copyProperties(item, certificateResVo);
             BeanUtils.copyProperties(item, certificateResVo);
@@ -810,6 +846,13 @@ public class KwsEnterpriseService {
         if (CollectionUtils.isNotEmpty(listByEntIds)) {
         if (CollectionUtils.isNotEmpty(listByEntIds)) {
             entDetailResVo.setEntTypes(String.join(Global.COMMA, listByEntIds.stream().map(KwsEntType::getType).map(String::valueOf).distinct().toList()));
             entDetailResVo.setEntTypes(String.join(Global.COMMA, listByEntIds.stream().map(KwsEntType::getType).map(String::valueOf).distinct().toList()));
         }
         }
+
+        List<KwsEntCheckTrack> list = kwsEntCheckTrackDao.findList(id);
+        if (CollectionUtils.isNotEmpty(list)) {
+            entDetailResVo.setValid(list.stream().anyMatch(item -> item.getStatus().equals(Global.NO)));
+        } else {
+            entDetailResVo.setValid(false);
+        }
         return entDetailResVo;
         return entDetailResVo;
     }
     }
 
 

+ 4 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEntCertificateDao.xml

@@ -38,6 +38,10 @@
     select a.* from kws_ent_certificate a where a.ent_id = #{entId} and a.type = #{type} and a.del_flag = 0 and a.status = 0
     select a.* from kws_ent_certificate a where a.ent_id = #{entId} and a.type = #{type} and a.del_flag = 0 and a.status = 0
   </select>
   </select>
 
 
+  <select id="findPrevious" resultType="com.sckw.system.model.KwsEntCertificate">
+    select a.* from kws_ent_certificate a where a.ent_id = #{entId} and a.type = #{type} and a.del_flag = 0 and a.status in (0, 1)
+  </select>
+
   <insert id="insert" parameterType="com.sckw.system.model.KwsEntCertificate">
   <insert id="insert" parameterType="com.sckw.system.model.KwsEntCertificate">
     insert into kws_ent_certificate
     insert into kws_ent_certificate
     <trim prefix="(" suffix=")" suffixOverrides=",">
     <trim prefix="(" suffix=")" suffixOverrides=",">