Kaynağa Gözat

导入 错误日志

shiqian 3 yıl önce
ebeveyn
işleme
4920467053

+ 122 - 0
boman-api/boman-domain/src/main/java/com.boman.domain/YmjzImportErrorLog.java

@@ -0,0 +1,122 @@
+package com.boman.domain;
+
+
+import lombok.Builder;
+
+import java.util.Date;
+
+/**
+ * 疫苗接种导入错误日志
+ */
+@Builder
+public class YmjzImportErrorLog {
+
+    private Long id;
+    private String username;
+    private String place;
+    private String vaccineName;
+    private String jici;
+    private Date vaccinationTime;
+    private String vaccinationPlace;
+    private String isDel;
+    private String createBy;
+    private Date createTime;
+    private String updateBy;
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPlace() {
+        return place;
+    }
+
+    public void setPlace(String place) {
+        this.place = place;
+    }
+
+    public String getVaccineName() {
+        return vaccineName;
+    }
+
+    public void setVaccineName(String vaccineName) {
+        this.vaccineName = vaccineName;
+    }
+
+    public String getJici() {
+        return jici;
+    }
+
+    public void setJici(String jici) {
+        this.jici = jici;
+    }
+
+    public Date getVaccinationTime() {
+        return vaccinationTime;
+    }
+
+    public void setVaccinationTime(Date vaccinationTime) {
+        this.vaccinationTime = vaccinationTime;
+    }
+
+    public String getVaccinationPlace() {
+        return vaccinationPlace;
+    }
+
+    public void setVaccinationPlace(String vaccinationPlace) {
+        this.vaccinationPlace = vaccinationPlace;
+    }
+
+    public String getIsDel() {
+        return isDel;
+    }
+
+    public void setIsDel(String isDel) {
+        this.isDel = isDel;
+    }
+
+    public String getCreateBy() {
+        return createBy;
+    }
+
+    public void setCreateBy(String createBy) {
+        this.createBy = createBy;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 9 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/VaccineInfoUserMapper.java

@@ -64,4 +64,13 @@ public interface VaccineInfoUserMapper {
     int listBy1jici();
 
     List<JSONObject> todayCnt(@Param("todayStart") String todayStart, @Param("todayEnd") String todayEnd);
+
+    /**
+     * 功能描述: 根据身份证和接种计次查询
+     *
+     * @param sfz  sfz
+     * @param jzjc jzjc
+     * @return int
+     */
+    int countByIdCardAndJici(@Param("sfz") String sfz, @Param("jzjc") String jzjc);
 }

+ 15 - 0
boman-web-core/src/main/java/com/boman/web/core/mapper/YmjzImportErrorLogMapper.java

@@ -0,0 +1,15 @@
+package com.boman.web.core.mapper;
+
+import com.boman.domain.YmjzImportErrorLog;
+
+public interface YmjzImportErrorLogMapper {
+
+    /**
+     * 功能描述: insert错误日志
+     *
+     * @param errorLog errorLog
+     * @return int
+     */
+    int insertErrorLog(YmjzImportErrorLog errorLog);
+
+}

+ 76 - 11
boman-web-core/src/main/java/com/boman/web/core/service/excel/ImportExportExcelServiceImpl.java

@@ -7,13 +7,16 @@ import com.boman.common.core.utils.SecurityUtils;
 import com.boman.common.core.utils.poi.ExcelUtil;
 import com.boman.domain.VaccineInfoOperation;
 import com.boman.domain.VaccineInfoUser;
+import com.boman.domain.YmjzImportErrorLog;
 import com.boman.domain.dto.AjaxResult;
 import com.boman.domain.dto.FormDataDto;
+import com.boman.domain.utils.ThreadPoolService;
 import com.boman.web.core.mapper.StandardlyMapper;
 import com.boman.web.core.mapper.VaccineInfoMapper;
 import com.boman.web.core.mapper.VaccineInfoUserMapper;
 import com.boman.web.core.service.TableServiceCmdService;
 import com.boman.web.core.service.vaccineInfo.impl.VaccineInfoServiceImpl;
+import com.boman.web.core.service.ymjz.YmjzImportErrorLogService;
 import com.boman.web.core.utils.IdUtils;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -46,6 +49,8 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
     private VaccineInfoMapper vaccineInfoMapper;
     @Resource
     private VaccineInfoUserMapper vaccineInfoUserMapper;
+    @Resource
+    private YmjzImportErrorLogService errorLogService;
 
 
     /**
@@ -89,15 +94,29 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
         ExcelUtil<VaccineInfoOperation> util = new ExcelUtil<>(VaccineInfoOperation.class);
         Sheet sheet = util.importExcel4Ymjz("", file.getInputStream());
         int rows = sheet.getPhysicalNumberOfRows();
-        // 往data中赋值
-        for (int i = 1; i < rows; i++) {
-            saveRel(sheet.getRow(i), i);
+        String username = SecurityUtils.getUsername();
+        ThreadPoolService.execute(() -> {
+            // 往data中赋值
+            for (int i = 1; i < rows; i++) {
+                saveRel(sheet.getRow(i), i, username);
+            }
+        });
+
+        String msg = "数据导入中,系统将自动处理数据,%s后请查看结果。";
+        if (rows <= 1000) {
+            msg = String.format(msg, "20分钟");
+        } else if (rows >= 5000 && rows <= 10000) {
+            msg = String.format(msg, "1小时");
+        } else if (rows > 10000 && rows <= 50000) {
+            msg = String.format(msg, "2小时");
+        } else {
+            msg = String.format(msg, "4小时");
         }
 
-        return "成功";
+        return msg;
     }
 
-    private void saveRel(Row row, int i) {
+    private void saveRel(Row row, int i, String username) {
         // excel 14列
         // 身份证
         String sfz = row.getCell(4).getStringCellValue();
@@ -116,6 +135,8 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
         String csrq = row.getCell(3).getStringCellValue();
         // 电话号码
         String dhhm = row.getCell(5).getStringCellValue();
+        // 住址
+        String place = row.getCell(6).getStringCellValue();
         // 工作单位
         String gzdw = row.getCell(7).getStringCellValue();
         // 人群分类
@@ -126,6 +147,7 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
         String jzsj = row.getCell(13).getStringCellValue();
         VaccineInfoOperation in = mapper.getByCode(szzbm, "%" + split[1] + "%", "%" + szzxm + "%");
         String progress = VaccineInfoServiceImpl.getIsSuccess(sccj, jzjc);
+        Date now = new Date();
         if (in == null) {
             in = new VaccineInfoOperation();
             Long maxId = IdUtils.getMaxId("vaccine_info", "id");
@@ -150,7 +172,21 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
             in.setAge(0);
             in.setDeptId(1L);
             in.setStatus("2");
-            vaccineInfoMapper.insertVaccineInfo(in);
+            in.setCreateBy(username);
+            in.setUpdateBy(username);
+            in.setCreateTime(now);
+            in.setUpdateTime(now);
+            try {
+                vaccineInfoMapper.insertVaccineInfo(in);
+            } catch (Exception e) {
+                YmjzImportErrorLog log = YmjzImportErrorLog.builder()
+                        .id(IdUtils.getMaxId("ymjz_import_error_log", "id"))
+                        .username(szzxm).place(place).vaccineName(sccj).jici(jzjc).vaccinationTime(DateUtils.formatDate(jzsj))
+                        .vaccinationPlace(jzdw).createBy(username).updateBy(username).createTime(now).updateTime(now).build();
+                errorLogService.insertErrorLog(log);
+                e.printStackTrace();
+            }
+
             LOGGER.info("count: {}, info insert: [{}]", i, JSON.toJSONString(in));
         } else {
             sfz = in.getIdCard();
@@ -174,10 +210,29 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
             in.setIdCard(split[1]);
             in.setUserName(szzxm);
             in.setAge(age);
-            vaccineInfoMapper.update(in);
+            in.setUpdateTime(now);
+            in.setUpdateBy(username);
+            try {
+                vaccineInfoMapper.update(in);
+            } catch (Exception e) {
+                YmjzImportErrorLog log = YmjzImportErrorLog.builder()
+                        .id(IdUtils.getMaxId("ymjz_import_error_log", "id"))
+                        .username(szzxm).place(place).vaccineName(sccj).jici(jzjc).vaccinationTime(DateUtils.formatDate(jzsj))
+                        .vaccinationPlace(jzdw).createBy(username).updateBy(username).createTime(now).updateTime(now).build();
+                errorLogService.insertErrorLog(log);
+                e.printStackTrace();
+            }
             LOGGER.info("count: {}, info update: [{}]", i, JSON.toJSONString(in));
         }
 
+        // 防止重复导入
+        if (!sfz.contains("\\**")) {
+            int count = vaccineInfoUserMapper.countByIdCardAndJici(sfz, jzjc);
+            if (count > 0) {
+                return;
+            }
+        }
+
         Long maxId = IdUtils.getMaxId("vaccine_info_user", "id");
         VaccineInfoUser user = new VaccineInfoUser();
         user.setId(maxId);
@@ -186,10 +241,20 @@ public class ImportExportExcelServiceImpl implements IImportExportExcelService {
         user.setJici(jzjc);
         user.setVaccinationTime(DateUtils.formatDate(jzsj));
         user.setVaccinationPlace(jzdw);
-        user.setCreateBy(SecurityUtils.getUsername());
-        user.setUpdateBy(SecurityUtils.getUsername());
-        user.setUpdateTime(new Date());
-        vaccineInfoUserMapper.insertVaccineInfoUser(user);
+        user.setCreateBy(username);
+        user.setUpdateBy(username);
+        user.setUpdateTime(now);
+        user.setCreateTime(now);
+        try {
+            vaccineInfoUserMapper.insertVaccineInfoUser(user);
+        } catch (Exception e) {
+            YmjzImportErrorLog log = YmjzImportErrorLog.builder()
+                    .id(IdUtils.getMaxId("ymjz_import_error_log", "id"))
+                    .username(szzxm).place(place).vaccineName(sccj).jici(jzjc).vaccinationTime(DateUtils.formatDate(jzsj))
+                    .vaccinationPlace(jzdw).createBy(username).updateBy(username).createTime(now).updateTime(now).build();
+            errorLogService.insertErrorLog(log);
+            e.printStackTrace();
+        }
         LOGGER.info("count: {}, vaccine user: [{}]", i, JSON.toJSONString(user));
     }
 }

+ 8 - 0
boman-web-core/src/main/java/com/boman/web/core/service/vaccineInfo/impl/VaccineInfoServiceImpl.java

@@ -164,7 +164,9 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 }
             }
             vaccineInfoOperation.setDeptIdList(deptIdList);
+            LOGGER.info("查询开始");
             vaccineInfoOperations = vaccineInfoMapper.selectVaccineInfoList(vaccineInfoOperation);
+            LOGGER.info("查询结束");
         }
         if (vaccineInfoOperations != null && vaccineInfoOperations.size() > 0) {
             for (VaccineInfoOperation infoOperation : vaccineInfoOperations) {
@@ -461,7 +463,12 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
             } else {
                 return "否";
             }
+        } else if ("康希诺生物".equals(vaccineName)) {
+            if ("1".equals(jici)) {
+                return "是";
+            }
         }
+
         return "否";
     }
 
@@ -795,6 +802,7 @@ public class VaccineInfoServiceImpl implements IVaccineInfoService {
                 }
             }
         }
+
         return age;
     }
 

+ 18 - 0
boman-web-core/src/main/java/com/boman/web/core/service/ymjz/YmjzImportErrorLogService.java

@@ -0,0 +1,18 @@
+package com.boman.web.core.service.ymjz;
+
+import com.boman.domain.YmjzImportErrorLog;
+
+/**
+ * @author shiqian
+ * @date 2021年09月29日 15:52
+ **/
+public interface YmjzImportErrorLogService {
+
+    /**
+     * 功能描述: insert错误日志
+     *
+     * @param errorLog errorLog
+     * @return int
+     */
+    int insertErrorLog(YmjzImportErrorLog errorLog);
+}

+ 23 - 0
boman-web-core/src/main/java/com/boman/web/core/service/ymjz/YmjzImportErrorLogServiceImpl.java

@@ -0,0 +1,23 @@
+package com.boman.web.core.service.ymjz;
+
+import com.boman.domain.YmjzImportErrorLog;
+import com.boman.web.core.mapper.YmjzImportErrorLogMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * @author shiqian
+ * @date 2021年09月29日 15:53
+ **/
+@Service
+public class YmjzImportErrorLogServiceImpl implements YmjzImportErrorLogService{
+
+    @Resource
+    private YmjzImportErrorLogMapper mapper;
+
+    @Override
+    public int insertErrorLog(YmjzImportErrorLog errorLog) {
+        return mapper.insertErrorLog(errorLog);
+    }
+}

+ 5 - 0
boman-web-core/src/main/resources/mapper/VaccineInfoUserMapper.xml

@@ -104,6 +104,11 @@
         SELECT count(1) FROM vaccine_info_user where is_del = 'N' and jici = '1';
     </select>
 
+    <select id="countByIdCardAndJici" resultType="int">
+        SELECT count(1) FROM vaccine_info_user where id_card = #{sfz} and jici = #{jzjc};
+    </select>
+
+
     <select id="todayCnt" resultType="com.alibaba.fastjson.JSONObject">
         SELECT count(1) one FROM vaccine_info_user WHERE is_del = 'N' AND jici = '1'
             AND vaccination_time &gt;= #{todayStart}

+ 46 - 0
boman-web-core/src/main/resources/mapper/YmjzImportErrorLogMapper.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.boman.web.core.mapper.YmjzImportErrorLogMapper">
+
+    <resultMap type="com.boman.domain.YmjzImportErrorLog" id="YmjzImportErrorLogResult">
+        <result property="id"    column="id"    />
+        <result property="username"    column="username"    />
+        <result property="town"    column="town"    />
+        <result property="vaccineName"    column="vaccine_name"    />
+        <result property="jici"    column="jici"    />
+        <result property="vaccinationTime"    column="vaccination_time"    />
+        <result property="vaccinationPlace"    column="vaccination_place"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="isDel"    column="is_del"    />
+    </resultMap>
+
+    <insert id="insertErrorLog" parameterType="com.boman.domain.YmjzImportErrorLog">
+        insert into ymjz_import_error_log (
+            <if test="username != null and username != ''">username,</if>
+            <if test="town != null and town != ''">town,</if>
+            <if test="vaccineName != null and vaccineName != ''">vaccine_name,</if>
+            <if test="jici != null and remark != ''">jici,</if>
+            <if test="vaccinationTime != null and vaccinationTime != ''">vaccination_time,</if>
+            <if test="vaccinationPlace != null and vaccinationPlace != ''">vaccination_place,</if>
+            <if test="createBy != null and createBy != ''">create_by,</if>
+            <if test="updateBy != null and updateBy != ''">update_by,</if>
+            create_time, updateTime
+        )values(
+            <if test="username != null and username != ''">#{username},</if>
+            <if test="town != null and town != ''">#{town},</if>
+            <if test="vaccineName != null and vaccineName != ''">#{vaccine_name},</if>
+            <if test="jici != null and remark != ''">#{jici},</if>
+            <if test="vaccinationTime != null and vaccinationTime != ''">#{vaccination_time},</if>
+            <if test="vaccinationPlace != null and vaccinationPlace != ''">#{vaccination_place},</if>
+            <if test="createBy != null and createBy != ''">#{create_by},</if>
+            <if test="updateBy != null and updateBy != ''">#{update_by},</if>
+            sysdate(), sysdate()
+        )
+    </insert>
+
+</mapper>