tianwu.sun 9 hónapja
szülő
commit
93bac5b8f7

+ 2 - 0
src/main/java/com/bootdo/datas/dao/GyUnitDao.java

@@ -7,6 +7,8 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface GyUnitDao {
 
+    GyUnitDO getGyUnitByCreditCode(String creditCode);
+
     int getGyUnit(GyUnitDO gyUnitDO);
 
     int save(GyUnitDO gyUnitDO);

+ 13 - 0
src/main/java/com/bootdo/datas/domain/GyUnitDO.java

@@ -84,6 +84,11 @@ public class GyUnitDO implements Serializable {
      */
     private String status;
 
+    /**
+     * 审核状态,0待审核,1已通过,2已驳回
+     */
+    private String auditStatus;
+
     /**
      * 创建时间
      */
@@ -99,6 +104,14 @@ public class GyUnitDO implements Serializable {
      */
     private String note;
 
+    public String getAuditStatus() {
+        return auditStatus;
+    }
+
+    public void setAuditStatus(String auditStatus) {
+        this.auditStatus = auditStatus;
+    }
+
     public Long getId() {
         return id;
     }

+ 28 - 7
src/main/java/com/bootdo/datas/service/impl/GyDataServiceImpl.java

@@ -18,6 +18,7 @@ import com.bootdo.system.domain.RoleDO;
 import com.bootdo.system.domain.UserDO;
 import com.bootdo.system.service.RoleService;
 import com.google.common.collect.Lists;
+import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -229,6 +230,7 @@ public class GyDataServiceImpl implements GyDataService {
         int otherProvince = 0;
         int otherCity = 0;
         int auditPass = 0;
+        int unitNoAudit = 0;
         XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is);
         XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
         // 企业信息
@@ -251,12 +253,21 @@ public class GyDataServiceImpl implements GyDataService {
                 userCity = sysCity;
             }
         }
+        //判断是哪种格式的
+        Row firstRow = xssfSheet.getRow(0);
+        Cell firstRowCell = firstRow.getCell(0);
+        int beginDataRowIndex = 0;
+        if("序号".equals(firstRowCell.getStringCellValue())){
+            beginDataRowIndex = 1;
+        } else {
+            beginDataRowIndex = 4;
+        }
 
-        if(xssfSheet.getLastRowNum() < 1){ //getLastRowNum返回最后一行的索引,即 比行总数小1
+        if(xssfSheet.getLastRowNum() < beginDataRowIndex){ //getLastRowNum返回最后一行的索引,即 比行总数小1
             throw new BDException("excel文件无数据");
         }
         // 遍历
-        for (int i = 1; i <= xssfSheet.getLastRowNum(); i++) {
+        for (int i = beginDataRowIndex; i <= xssfSheet.getLastRowNum(); i++) {
             log.info("userProvince: {}, i: {}", userProvince, i);
 
             Row row = xssfSheet.getRow(i);
@@ -283,6 +294,13 @@ public class GyDataServiceImpl implements GyDataService {
                 continue;
             }
 
+            GyUnitDO tmpGyUnitDO = gyUnitDao.getGyUnitByCreditCode(row.getCell(17).getStringCellValue());
+
+            if (ObjectUtils.isEmpty(tmpGyUnitDO) || !"1".equals(tmpGyUnitDO.getAuditStatus())) {
+                unitNoAudit++;
+                continue;
+            }
+
             // 企业单位
             GyUnitDO gyUnitDO = new GyUnitDO();
             // 数据信息
@@ -353,9 +371,9 @@ public class GyDataServiceImpl implements GyDataService {
             gyDataDO.setIsForeignData(row.getCell(37).getStringCellValue());//是否为涉外数据
             gyDataDO.setIsCrossmainFlow(row.getCell(38).getStringCellValue());//是否涉及跨主体流动
             gyDataDO.setInfoSystemName(row.getCell(39).getStringCellValue());//信息系统名称
-            gyDataDO.setInfoSystemType(row.getCell(40).getStringCellValue());//信息系统类型
-            gyDataDO.setInfoSystemIpAddress(row.getCell(41).getStringCellValue());//信息系统ip地址
-            gyDataDO.setInfoSystemDomainName(row.getCell(42).getStringCellValue());//信息系统域名
+            gyDataDO.setInfoSystemIpAddress(row.getCell(40).getStringCellValue());//信息系统ip地址
+            gyDataDO.setInfoSystemDomainName(row.getCell(41).getStringCellValue());//信息系统域名
+            gyDataDO.setInfoSystemType(row.getCell(42).getStringCellValue());//信息系统类型
             gyDataDO.setSecurityCognizance(row.getCell(43).getStringCellValue());//网络安全等级保护认定情况
             gyDataDO.setComSecurityCognizance(row.getCell(44).getStringCellValue());//通信网络安全防护定级备案情况
             gyDataDO.setIsKetSystem(row.getCell(45).getStringCellValue());//是否为关键信息基础设施
@@ -452,6 +470,7 @@ public class GyDataServiceImpl implements GyDataService {
                     try {
                         gyUnitDO.setCreateTime(new Date());
                         gyUnitDO.setStatus("0");
+                        gyUnitDO.setAuditStatus("0");
                         gyUnitDao.save(gyUnitDO);
                     } catch (Exception e) {
                         log.error("error enterprise-only : {}", e.getMessage());
@@ -465,7 +484,7 @@ public class GyDataServiceImpl implements GyDataService {
             gyDataDao.batchSave(dataList);
         }
         String result = null;
-        if ((otherProvince + otherCity + auditPass) > 0) {
+        if ((otherProvince + otherCity + auditPass + unitNoAudit) > 0) {
             StringBuilder sb = new StringBuilder();
             if (otherProvince > 0) {
                 sb.append(otherProvince).append("条非本省数据(已忽略导入)! <br/>");
@@ -476,7 +495,9 @@ public class GyDataServiceImpl implements GyDataService {
             if (auditPass > 0) {
                 sb.append(auditPass).append("条已经审核通过数据(已忽略导入)! <br/>");
             }
-
+            if (unitNoAudit > 0) {
+                sb.append(unitNoAudit).append("条所属企业未注册或还没通过审核(已忽略导入)! <br/>");
+            }
             result = sb.toString();
         }
         return result;

+ 21 - 1
src/main/resources/mybatis/datas/GyUnitMapper.xml

@@ -2,7 +2,27 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="com.bootdo.datas.dao.GyUnitDao">
-
+    <select id="getGyUnitByCreditCode" resultType="com.bootdo.datas.domain.GyUnitDO">
+        a.ID as id,
+            a.REPORTER_UNIT as reporterUnit,
+            a.CREDIT_CODE as creditCode,
+            a.UNIT_CHARACTER as unitCharacter,
+            a.INDUSTRY_TYPE_ONE as industryTypeOne,
+            a.INDUSTRY_TYPE_TWO as industryTypeTwo,
+            a.UNIT_PROVINCE as unitProvince,
+            a.UNIT_CITY as unitCity,
+            a.SUPERVISORY_ORG as supervisoryOrg,
+            a.UNIT_MAN as unitMan,
+            a.UNIT_OFFICE as unitOffice,
+            a.DATA_SECURITY_MAN as dataSecurityMan,
+            a.DATA_SECURITY_OFFICE as dataSecurityOffice,
+            a.DATA_SECURITY_WAY as dataSecurityWay,
+            a.CREATE_TIME as createTime,
+            a.UPDATE_TIME as updateTime,
+            a.audit_status as auditStatus
+        from gy_unit a
+            a.STATUS = '0' and a.CREDIT_CODE = #{creditCode}
+    </select>
     <select id="getGyUnit" resultType="java.lang.Integer">
         SELECT
             count(*)

+ 2 - 1
src/main/resources/mybatis/datas/UnitMapper.xml

@@ -41,7 +41,8 @@
             a.DATA_SECURITY_OFFICE as dataSecurityOffice,
             a.DATA_SECURITY_WAY as dataSecurityWay,
             a.CREATE_TIME as createTime,
-            a.UPDATE_TIME as updateTime
+            a.UPDATE_TIME as updateTime,
+            a.audit_status as auditStatus
         from gy_unit a
         where a.ID = #{value}
     </select>