|
@@ -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));
|
|
|
}
|
|
|
}
|