Commit 4a504afb authored by gaoyingwei's avatar gaoyingwei

Merge remote-tracking branch 'origin/master' into master

parents e544abbf 0e0d3597
...@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.DictUtils; ...@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.system.domain.Gldry; import com.ruoyi.system.domain.Gldry;
import com.ruoyi.system.domain.HsjcExportTemplate; import com.ruoyi.system.domain.HsjcExportTemplate;
import com.ruoyi.system.domain.Yxry; import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import com.ruoyi.system.mapper.SysDictDataMapper; import com.ruoyi.system.mapper.SysDictDataMapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -27,7 +28,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -27,7 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
/** /**
* 核酸采集Controller * 核酸采集Controller
* *
* @author ruoyi * @author ruoyi
* @date 2022-11-28 * @date 2022-11-28
*/ */
...@@ -125,8 +126,8 @@ public class HscjController extends BaseController ...@@ -125,8 +126,8 @@ public class HscjController extends BaseController
@PreAuthorize("@ss.hasPermi('system:hscj:import')") @PreAuthorize("@ss.hasPermi('system:hscj:import')")
@PostMapping("/importData") @PostMapping("/importData")
public void importHscjData(MultipartFile file,HttpServletResponse response) throws Exception{ public void importHscjData(MultipartFile file,HttpServletResponse response) throws Exception{
ExcelUtil<Hscj> util = new ExcelUtil<Hscj>(Hscj.class); ExcelUtil<HscjErrorDto> util = new ExcelUtil<HscjErrorDto>(HscjErrorDto.class);
List<Hscj> dataList = util.importExcel(file.getInputStream()); List<HscjErrorDto> dataList = util.importExcel(file.getInputStream());
hscjService.importList(dataList,response); hscjService.importList(dataList,response);
} }
......
...@@ -6,19 +6,20 @@ spring: ...@@ -6,19 +6,20 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://124.71.16.228:18085/gxq?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true
username: root username: root
password: 111111 password: njk34nj3k423k
# url: jdbc:mysql://health_db:3306/gxq?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8 # url: jdbc:mysql://health_db:3306/gxq?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
# username: root # username: root
# password: njk34nj3k423k # password: njk34nj3k423k
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: false enabled: true
url: url: jdbc:mysql://127.0.0.1:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true
username: username: root
password: password: wc199921
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5
# 最小连接池数量 # 最小连接池数量
...@@ -38,7 +39,7 @@ spring: ...@@ -38,7 +39,7 @@ spring:
testWhileIdle: true testWhileIdle: true
testOnBorrow: false testOnBorrow: false
testOnReturn: false testOnReturn: false
webStatFilter: webStatFilter:
enabled: true enabled: true
statViewServlet: statViewServlet:
enabled: true enabled: true
...@@ -57,4 +58,4 @@ spring: ...@@ -57,4 +58,4 @@ spring:
merge-sql: true merge-sql: true
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
\ No newline at end of file
...@@ -4,9 +4,10 @@ import java.util.Date; ...@@ -4,9 +4,10 @@ import java.util.Date;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
...@@ -25,7 +26,7 @@ public class Hscj extends BaseEntity ...@@ -25,7 +26,7 @@ public class Hscj extends BaseEntity
/** 省 */ /** 省 */
// 新增字段 // 新增字段
@Excel(name = "省") @Excel(name = "省",type = Type.EXPORT)
private String province; private String province;
/** 市 */ /** 市 */
...@@ -33,14 +34,14 @@ public class Hscj extends BaseEntity ...@@ -33,14 +34,14 @@ public class Hscj extends BaseEntity
private String city; private String city;
/** 居住地所在区 */ /** 居住地所在区 */
@Excel(name = "居住地所在区", dictType = "residential_area") @Excel(name = "")
private String area; private String area;
/** 街道/镇 */ /** 街道/镇 */
@Excel(name = "街道/镇") @Excel(name = "街道")
private String street; private String street;
@Excel(name = "居委会") @Excel(name = "社区")
// 新增字段2 // 新增字段2
private String committee; private String committee;
...@@ -60,8 +61,7 @@ public class Hscj extends BaseEntity ...@@ -60,8 +61,7 @@ public class Hscj extends BaseEntity
@Excel(name = "采集管号", cellType = Excel.ColumnType.STRING) @Excel(name = "采集管号", cellType = Excel.ColumnType.STRING)
private String cjgh; private String cjgh;
/** 采集管号 */ @Excel(name = "是否混管", readConverterExp = "0=单管,1=混管")
@Excel(name = "是否混管", readConverterExp = "0=单管,1=混管",combo = {"单管","混管"})
private String isHun; private String isHun;
/** 姓名 */ /** 姓名 */
...@@ -69,15 +69,15 @@ public class Hscj extends BaseEntity ...@@ -69,15 +69,15 @@ public class Hscj extends BaseEntity
private String userName; private String userName;
/** 身份证号码 */ /** 身份证号码 */
@Excel(name = "身份证号", cellType = Excel.ColumnType.STRING) @Excel(name = "身份证号", cellType = Excel.ColumnType.STRING)
private String cardNo; private String cardNo;
/** 身份证号码格式校验 */ /** 身份证号码格式校验 */
@Excel(name = "身份证格式校验") @Excel(name = "身份证格式校验",type = Type.EXPORT)
private String checkCard; private String checkCard;
/** 联系方式 */ /** 联系方式 */
@Excel(name = "联系方式") @Excel(name = "电话")
private String phone; private String phone;
/** 性别 */ /** 性别 */
...@@ -93,7 +93,7 @@ public class Hscj extends BaseEntity ...@@ -93,7 +93,7 @@ public class Hscj extends BaseEntity
private Long age; private Long age;
/** 类别 */ /** 类别 */
@Excel(name = "人员类别") @Excel(name = "类别")
private String category; private String category;
/** 人员关系 */ /** 人员关系 */
...@@ -136,12 +136,7 @@ public class Hscj extends BaseEntity ...@@ -136,12 +136,7 @@ public class Hscj extends BaseEntity
@Excel(name = "备注") @Excel(name = "备注")
private String remark; private String remark;
// 新增字段
// @Excel(name = "居委会")
// private String committee;
/** 状态(0正常 1停用) */ /** 状态(0正常 1停用) */
// @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
/** 删除标志(0代表存在 2代表删除) */ /** 删除标志(0代表存在 2代表删除) */
...@@ -149,8 +144,8 @@ public class Hscj extends BaseEntity ...@@ -149,8 +144,8 @@ public class Hscj extends BaseEntity
/**创建时间*/ /**创建时间*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date createTime;
/**导出选中IDLIST */ /**导出选中IDLIST */
@Transient() @Transient()
private List<String> idList; private List<String> idList;
......
package com.ruoyi.system.domain.vo;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.system.domain.Hscj;
import org.apache.poi.ss.usermodel.IndexedColors;
public class HscjErrorDto extends Hscj {
@Excel(name = "错误提示", type = Type.EXPORT,color = IndexedColors.RED)
private String error;
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
...@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper; ...@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.Hscj; import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.domain.Yxry; import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
/** /**
...@@ -74,7 +75,7 @@ public interface HscjMapper ...@@ -74,7 +75,7 @@ public interface HscjMapper
List<Hscj> checkCardBatch(List<Hscj> hscjList); List<Hscj> checkCardBatch(List<Hscj> hscjList);
int insertBatch(@Param("list")List<Hscj> list); int insertBatch(@Param("list")List<HscjErrorDto> list);
int updateBatch(List<Hscj> updateList); int updateBatch(List<Hscj> updateList);
} }
...@@ -3,20 +3,21 @@ package com.ruoyi.system.service; ...@@ -3,20 +3,21 @@ package com.ruoyi.system.service;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.Hscj; import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.domain.Zlqk; import com.ruoyi.system.domain.Zlqk;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
/** /**
* 核酸采集Service接口 * 核酸采集Service接口
* *
* @author ruoyi * @author ruoyi
* @date 2022-11-28 * @date 2022-11-28
*/ */
public interface IHscjService public interface IHscjService
{ {
/** /**
* 查询核酸采集 * 查询核酸采集
* *
* @param id 核酸采集主键 * @param id 核酸采集主键
* @return 核酸采集 * @return 核酸采集
*/ */
...@@ -24,7 +25,7 @@ public interface IHscjService ...@@ -24,7 +25,7 @@ public interface IHscjService
/** /**
* 查询核酸采集列表 * 查询核酸采集列表
* *
* @param hscj 核酸采集 * @param hscj 核酸采集
* @return 核酸采集集合 * @return 核酸采集集合
*/ */
...@@ -39,7 +40,7 @@ public interface IHscjService ...@@ -39,7 +40,7 @@ public interface IHscjService
/** /**
* 新增核酸采集 * 新增核酸采集
* *
* @param hscj 核酸采集 * @param hscj 核酸采集
* @return 结果 * @return 结果
*/ */
...@@ -47,7 +48,7 @@ public interface IHscjService ...@@ -47,7 +48,7 @@ public interface IHscjService
/** /**
* 修改核酸采集 * 修改核酸采集
* *
* @param hscj 核酸采集 * @param hscj 核酸采集
* @return 结果 * @return 结果
*/ */
...@@ -55,7 +56,7 @@ public interface IHscjService ...@@ -55,7 +56,7 @@ public interface IHscjService
/** /**
* 批量删除核酸采集 * 批量删除核酸采集
* *
* @param ids 需要删除的核酸采集主键集合 * @param ids 需要删除的核酸采集主键集合
* @return 结果 * @return 结果
*/ */
...@@ -63,13 +64,13 @@ public interface IHscjService ...@@ -63,13 +64,13 @@ public interface IHscjService
/** /**
* 删除核酸采集信息 * 删除核酸采集信息
* *
* @param id 核酸采集主键 * @param id 核酸采集主键
* @return 结果 * @return 结果
*/ */
public int deleteHscjById(Long id); public int deleteHscjById(Long id);
void importList(List<Hscj> list, HttpServletResponse response); void importList(List<HscjErrorDto> list, HttpServletResponse response);
List<Hscj> checkCard(Hscj hscj); List<Hscj> checkCard(Hscj hscj);
} }
...@@ -8,15 +8,16 @@ import com.ruoyi.common.core.domain.entity.SysDictData; ...@@ -8,15 +8,16 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*; import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Yxry; import com.ruoyi.system.domain.vo.HscjErrorDto;
import com.ruoyi.system.domain.Zlqk;
import com.ruoyi.system.mapper.SysDictDataMapper; import com.ruoyi.system.mapper.SysDictDataMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.system.mapper.HscjMapper; import com.ruoyi.system.mapper.HscjMapper;
import com.ruoyi.system.domain.Hscj; import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.service.IHscjService; import com.ruoyi.system.service.IHscjService;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -55,6 +56,7 @@ public class HscjServiceImpl implements IHscjService { ...@@ -55,6 +56,7 @@ public class HscjServiceImpl implements IHscjService {
public List<Hscj> selectHscjList(Hscj hscj) { public List<Hscj> selectHscjList(Hscj hscj) {
return hscjMapper.selectHscjList(hscj); return hscjMapper.selectHscjList(hscj);
} }
/** /**
* 查询导出核酸采集列表 * 查询导出核酸采集列表
* *
...@@ -101,9 +103,6 @@ public class HscjServiceImpl implements IHscjService { ...@@ -101,9 +103,6 @@ public class HscjServiceImpl implements IHscjService {
String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee()); String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee());
if (createBy.equals("null")) if (createBy.equals("null"))
throw new ServiceException("所选居住地、街道、社区不存在"); throw new ServiceException("所选居住地、街道、社区不存在");
// List<Hscj> list = hscjMapper.checkCard(hscj);
// if (!list.isEmpty())
// throw new ServiceException("该身份证号当天不能重复提交");
hscj.setCreateBy(createBy); hscj.setCreateBy(createBy);
hscj.setUpdateTime(DateUtils.getNowDate()); hscj.setUpdateTime(DateUtils.getNowDate());
return hscjMapper.updateHscj(hscj); return hscjMapper.updateHscj(hscj);
...@@ -132,124 +131,64 @@ public class HscjServiceImpl implements IHscjService { ...@@ -132,124 +131,64 @@ public class HscjServiceImpl implements IHscjService {
} }
@Override @Override
public void importList(List<Hscj> list, HttpServletResponse response) { public void importList(List<HscjErrorDto> list, HttpServletResponse response) {
if (StringUtils.isNull(list) || list.size() == 0) { if (StringUtils.isNull(list) || list.size() == 0) {
throw new ServiceException("导入数据不能为空!"); throw new ServiceException("导入数据不能为空!");
} }
List<Hscj> trueList = new ArrayList<>(); List<HscjErrorDto> trueList = new ArrayList<>();
List<Hscj> failureList = new ArrayList<>(); List<HscjErrorDto> failureList = new ArrayList<>();
for (Hscj hscj : list) { List<String> error;
if (StringUtils.isEmpty(hscj.getProvince())) { for (HscjErrorDto hscj : list) {
hscj.setProvince("河北省"); error = new ArrayList<>();
} hscj.setProvince("河北省");
if (StringUtils.isEmpty(hscj.getCity())) { hscj.setCity("石家庄市");
hscj.setCity("石家庄市"); if (StringUtils.isEmpty(hscj.getCardNo()))
} error.add("身份证号不能为空");
if (StringUtils.isEmpty(hscj.getRygx())) { if (StringUtils.isEmpty(hscj.getArea()))
hscj.setRygx("本人"); error.add("区不能为空");
} if (StringUtils.isEmpty(hscj.getBoxhao()))
if (StringUtils.isNotEmpty(hscj.getCardNo()) error.add("箱号不能为空");
&& StringUtils.isNotEmpty(hscj.getArea()) if (StringUtils.isEmpty(hscj.getCjgh()))
&& StringUtils.isNotEmpty(hscj.getBoxhao()) error.add("采集管号不能为空");
&& StringUtils.isNotEmpty(hscj.getCjgh()) if (StringUtils.isEmpty(hscj.getUserName()))
&& StringUtils.isNotEmpty(hscj.getUserName()) error.add("姓名不能为空");
&& StringUtils.isNotEmpty(hscj.getSex()) if (StringUtils.isEmpty(hscj.getSex()))
&& StringUtils.isNotEmpty(hscj.getAge().toString()) error.add("性别不能为空");
&& StringUtils.isNotEmpty(hscj.getCjTime().toString()) if (ObjectUtils.isEmpty(hscj.getAge()))
&& StringUtils.isNotEmpty(hscj.getCjName()) error.add("年龄不能为空");
&& StringUtils.isNotEmpty(hscj.getCjPhone()) if (ObjectUtils.isEmpty((hscj.getCjTime())))
&& StringUtils.isNotEmpty(hscj.getBblx()) error.add("采集时间不能为空");
) { if (StringUtils.isEmpty(hscj.getCjName()))
// 校验单张Excel是否有多个重复的身份证号 error.add("采集人姓名不能为空");
// if (StringUtils.isNotEmpty(hscj.getCardNo())){ if (StringUtils.isEmpty(hscj.getCjPhone()))
// int isExist = 0; error.add("采集人电话不能为空");
// for (Hscj hscjTest : list){ if (StringUtils.isEmpty(hscj.getBblx()))
// if (hscj.getCardNo().equals(hscjTest.getCardNo())){ error.add("标本类型不能为空");
// isExist++; if (CollectionUtils.isEmpty(error)) {
// } if(hscj.getArea().equals("开发区"))
// } hscj.setArea("高新区");
// if (isExist > 1){ List<SysDictData> area = DictUtils.getDictCache("residential_area");
// failureList.add(hscj); List<String> areas = area.stream().filter(l -> hscj.getArea().equals(l.getDictLabel()))
// continue; .map(SysDictData::getDictValue).collect(Collectors.toList());
// } if (!areas.isEmpty())
List<Hscj> hsctList = list.stream().filter(l -> hscj.setArea(areas.get(0));
else {
hscj.setError("区不存在");
failureList.add(hscj);
continue;
}
if (StringUtils.isEmpty(hscj.getRygx())) {
hscj.setRygx("本人");
}
List<HscjErrorDto> hsctList = list.stream().filter(l ->
hscj.getCardNo().equals(l.getCardNo()) && l.getCjTime() != null && hscj.getCardNo().equals(l.getCardNo()) && l.getCjTime() != null &&
DateUtils.dateTime(hscj.getCjTime()).equals(DateUtils.dateTime(l.getCjTime()))) DateUtils.dateTime(hscj.getCjTime()).equals(DateUtils.dateTime(l.getCjTime())))
.collect(Collectors.toList()); .collect(Collectors.toList());
if (hsctList.size() > 1) { if (hsctList.size() > 1) {
hscj.setError("存在重复数据");
failureList.add(hscj); failureList.add(hscj);
continue; continue;
} }
// }
// // 校验四级联动是否对应字典的值
// // 校验 所在区
// if (StringUtils.isNotEmpty(hscj.getArea())){
// List<SysDictData> residential_area = DictUtils.getDictCache("residential_area");
// List<String> values = residential_area.stream().filter(l->hscj.getArea().equals(l.getDictLabel()))
// .map(SysDictData::getDictValue).collect(Collectors.toList());
// if (!values.isEmpty())
// hscj.setArea(values.get(0));
// else {
// failureList.add(hscj);
// continue;
// }
// }
// // 校验 街道/镇
// if (StringUtils.isNotEmpty(hscj.getStreet())){
// List<SysDictData> street_town = DictUtils.getDictCache("street_town");
// List<String> values = street_town.stream().filter(l->hscj.getStreet().equals(l.getDictLabel()))
// .map(SysDictData::getDictValue).collect(Collectors.toList());
// if (!values.isEmpty())
// hscj.setStreet(values.get(0));
// else {
// failureList.add(hscj);
// continue;
// }
// }
// // 校验 居委会
// if (StringUtils.isNotEmpty(hscj.getCommittee())){
// List<SysDictData> committee = DictUtils.getDictCache("committee");
// List<String> values = committee.stream().filter(l->hscj.getCommittee().equals(l.getDictLabel()))
// .map(SysDictData::getDictValue).collect(Collectors.toList());
// if (!values.isEmpty())
// hscj.setCommittee(values.get(0));
// else {
// failureList.add(hscj);
// continue;
// }
// }
// // 校验 小区/村名称
// if (StringUtils.isNotEmpty(hscj.getCommunity())){
// List<SysDictData> community = DictUtils.getDictCache("community");
// List<String> values = community.stream().filter(l->hscj.getCommunity().equals(l.getDictLabel()))
// .map(SysDictData::getDictValue).collect(Collectors.toList());
// if (!values.isEmpty())
// hscj.setCommunity(values.get(0));
// else {
// failureList.add(hscj);
// continue;
// }
// }
// if (StringUtils.isNotEmpty(hscj.getSex())){
// if (hscj.getSex().equals("女")){
// hscj.setSex("1");
// }else if (hscj.getSex().equals("男")){
// hscj.setSex("0");
// }else {
// failureList.add(hscj);
// continue;
// }
// }
// if (StringUtils.isNotEmpty(hscj.getCjResult())){
// if (hscj.getCjResult().equals("阳性")){
// hscj.setCjResult("1");
// }else if (hscj.getCjResult().equals("阴性")){
// hscj.setCjResult("0");
// }else {
// failureList.add(hscj);
// continue;
// }
// }
//如果小区不为空,去数据字典匹配value //如果小区不为空,去数据字典匹配value
if (StringUtils.isNotEmpty(hscj.getCommunity())) { if (StringUtils.isNotEmpty(hscj.getCommunity())) {
List<SysDictData> communitys = DictUtils.getDictCache("community"); List<SysDictData> communitys = DictUtils.getDictCache("community");
...@@ -258,8 +197,7 @@ public class HscjServiceImpl implements IHscjService { ...@@ -258,8 +197,7 @@ public class HscjServiceImpl implements IHscjService {
if (!values.isEmpty()) if (!values.isEmpty())
hscj.setCommunity(values.get(0)); hscj.setCommunity(values.get(0));
else { else {
failureList.add(hscj); hscj.setCommunity(null);
continue;
} }
} }
//如果委员会不为空,去数据字典匹配value //如果委员会不为空,去数据字典匹配value
...@@ -270,8 +208,7 @@ public class HscjServiceImpl implements IHscjService { ...@@ -270,8 +208,7 @@ public class HscjServiceImpl implements IHscjService {
if (!values.isEmpty()) if (!values.isEmpty())
hscj.setCommittee(values.get(0)); hscj.setCommittee(values.get(0));
else { else {
failureList.add(hscj); hscj.setCommittee(null);
continue;
} }
} }
//如果街道不为空,去数据字典匹配value //如果街道不为空,去数据字典匹配value
...@@ -282,15 +219,16 @@ public class HscjServiceImpl implements IHscjService { ...@@ -282,15 +219,16 @@ public class HscjServiceImpl implements IHscjService {
if (!values.isEmpty()) if (!values.isEmpty())
hscj.setStreet(values.get(0)); hscj.setStreet(values.get(0));
else { else {
failureList.add(hscj); hscj.setStreet(null);
continue;
} }
} }
if (StringUtils.isNotEmpty(hscj.getCommunity()) && StringUtils.isEmpty(hscj.getCommittee())) { if (StringUtils.isNotEmpty(hscj.getCommunity()) && StringUtils.isEmpty(hscj.getCommittee())) {
hscj.setError("小区存在时社区不能为空");
failureList.add(hscj); failureList.add(hscj);
continue; continue;
} }
if (StringUtils.isNotEmpty(hscj.getCommittee()) && StringUtils.isEmpty(hscj.getStreet())) { if (StringUtils.isNotEmpty(hscj.getCommittee()) && StringUtils.isEmpty(hscj.getStreet())) {
hscj.setError("社区存在时街道不能为空");
failureList.add(hscj); failureList.add(hscj);
continue; continue;
} }
...@@ -298,11 +236,12 @@ public class HscjServiceImpl implements IHscjService { ...@@ -298,11 +236,12 @@ public class HscjServiceImpl implements IHscjService {
hscj.setCheckCard("正确"); hscj.setCheckCard("正确");
trueList.add(hscj); trueList.add(hscj);
} else { } else {
hscj.setCheckCard("不正确"); hscj.setError("身份证号校验不正确");
failureList.add(hscj); failureList.add(hscj);
continue; continue;
} }
} else { } else {
hscj.setError(error.stream().collect(Collectors.joining(",")));
failureList.add(hscj); failureList.add(hscj);
} }
} }
...@@ -313,63 +252,17 @@ public class HscjServiceImpl implements IHscjService { ...@@ -313,63 +252,17 @@ public class HscjServiceImpl implements IHscjService {
if (i + 500 > trueList.size()) { if (i + 500 > trueList.size()) {
toIndex = trueList.size() - i; toIndex = trueList.size() - i;
} }
List<Hscj> list1 = trueList.subList(i, i + toIndex); List<HscjErrorDto> list1 = trueList.subList(i, i + toIndex);
for (Hscj hscj : list1) { for (HscjErrorDto hscj : list1) {
String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee()); String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee());
hscj.setCreateBy(createBy); hscj.setCreateBy(createBy);
hscj.setCreateTime(DateUtils.getNowDate()); hscj.setCreateTime(DateUtils.getNowDate());
} }
hscjMapper.insertBatch(list1); hscjMapper.insertBatch(list1);
} }
// // 因为数据量过大,所以将list拆分为每个数组100条的形式
// List<Hscj> hscjList = new ArrayList<>();
// int listSize = trueList.size();
// int count = listSize / 100;
//
// for (int i = 0; i < count; i++) {
// hscjList = trueList.subList(i*100,(i+1)*100-1);
//1、从集合中获取到所有查询所需的条件,进行批量数据查询
// List<Hscj> hscjs = hscjMapper.checkCardBatch(hscjList);
// //2、循环数据进行判断是否是新增还是更新
// List<Hscj> updateList = new ArrayList<>();
// List<Hscj> insertList = new ArrayList<>();
// if (!hscjs.isEmpty()) {
// for (Hscj hscj : hscjs) {
// updateList.addAll(hscjList.stream().filter(l -> hscj.getCardNo().equals(l.getCardNo())).collect(Collectors.toList()));
// insertList.addAll(hscjList.stream().filter(l -> !(hscj.getCardNo().equals(l.getCardNo()))).collect(Collectors.toList()));
// }
// } else {
// insertList.addAll(hscjList);
// }
//3、将数据分别写入到更新数据集合和插入数据集合中
//4、判断新增集合和插入集合是否有数据,如果有数据则执行SQL语句
// if (!hscjList.isEmpty()) {
// hscjMapper.insertBatch(hscjList);
// }
// if (!updateList.isEmpty()) {
// hscjMapper.updateBatch(updateList);
// }
// }
//判断是否还有剩余?如果有甚于数据,则,则将剩余数据取出,按照上面循环体中的代码逻辑执行即可
// if (listSize % 100 != 0) {
// hscjList = trueList.subList(count*100,listSize-1);
// if (!hscjList.isEmpty()) {
// hscjMapper.insertBatch(hscjList);
// }
// }
// List<Hscj> hscjs = hscjMapper.checkCard(hscj);
// if (!hscjs.isEmpty()) {
// hscjMapper.updateHscj(hscj);
// continue;
// }
// String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee());
// hscj.setCreateBy(createBy);
// hscj.setCreateTime(DateUtils.getNowDate());
// hscjMapper.insertHscj(hscj);
} }
if (!failureList.isEmpty()) { if (!failureList.isEmpty()) {
ExcelUtil<Hscj> util = new ExcelUtil<Hscj>(Hscj.class); ExcelUtil<HscjErrorDto> util = new ExcelUtil<HscjErrorDto>(HscjErrorDto.class);
util.exportExcel(response, failureList, "核算采集错误数据"); util.exportExcel(response, failureList, "核算采集错误数据");
} }
} }
......
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</trim> </trim>
</insert> </insert>
<insert id="insertBatch" parameterType="com.ruoyi.system.domain.Hscj"> <insert id="insertBatch" parameterType="com.ruoyi.system.domain.vo.HscjErrorDto">
insert into hscj insert into hscj
(committee,province,city,area,street,community,cj_place,cjgh,user_name,card_no,check_card,phone,sex,address, (committee,province,city,area,street,community,cj_place,cjgh,user_name,card_no,check_card,phone,sex,address,
age,category,cj_time,cj_name,cj_phone,b_type,laboratory,jc_time,cj_result,rygx,boxhao,create_by,create_time,remark, age,category,cj_time,cj_name,cj_phone,b_type,laboratory,jc_time,cj_result,rygx,boxhao,create_by,create_time,remark,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment