Commit 0e0d3597 authored by 王琮's avatar 王琮

修改核酸采集导入

parent 82e29673
......@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.system.domain.Gldry;
import com.ruoyi.system.domain.HsjcExportTemplate;
import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import com.ruoyi.system.mapper.SysDictDataMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -125,8 +126,8 @@ public class HscjController extends BaseController
@PreAuthorize("@ss.hasPermi('system:hscj:import')")
@PostMapping("/importData")
public void importHscjData(MultipartFile file,HttpServletResponse response) throws Exception{
ExcelUtil<Hscj> util = new ExcelUtil<Hscj>(Hscj.class);
List<Hscj> dataList = util.importExcel(file.getInputStream());
ExcelUtil<HscjErrorDto> util = new ExcelUtil<HscjErrorDto>(HscjErrorDto.class);
List<HscjErrorDto> dataList = util.importExcel(file.getInputStream());
hscjService.importList(dataList,response);
}
......
......@@ -6,19 +6,20 @@ spring:
druid:
# 主库数据源
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
password: 111111
password: njk34nj3k423k
# url: jdbc:mysql://health_db:3306/gxq?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
# username: root
# password: njk34nj3k423k
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
enabled: true
url: jdbc:mysql://127.0.0.1:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true
username: root
password: wc199921
# 初始连接数
initialSize: 5
# 最小连接池数量
......
......@@ -4,9 +4,10 @@ import java.util.Date;
import java.util.List;
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.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.data.annotation.Transient;
......@@ -25,7 +26,7 @@ public class Hscj extends BaseEntity
/** 省 */
// 新增字段
@Excel(name = "省")
@Excel(name = "省",type = Type.EXPORT)
private String province;
/** 市 */
......@@ -33,14 +34,14 @@ public class Hscj extends BaseEntity
private String city;
/** 居住地所在区 */
@Excel(name = "居住地所在区", dictType = "residential_area")
@Excel(name = "")
private String area;
/** 街道/镇 */
@Excel(name = "街道/镇")
@Excel(name = "街道")
private String street;
@Excel(name = "居委会")
@Excel(name = "社区")
// 新增字段2
private String committee;
......@@ -60,8 +61,7 @@ public class Hscj extends BaseEntity
@Excel(name = "采集管号", cellType = Excel.ColumnType.STRING)
private String cjgh;
/** 采集管号 */
@Excel(name = "是否混管", readConverterExp = "0=单管,1=混管",combo = {"单管","混管"})
@Excel(name = "是否混管", readConverterExp = "0=单管,1=混管")
private String isHun;
/** 姓名 */
......@@ -69,15 +69,15 @@ public class Hscj extends BaseEntity
private String userName;
/** 身份证号码 */
@Excel(name = "身份证号", cellType = Excel.ColumnType.STRING)
@Excel(name = "身份证号", cellType = Excel.ColumnType.STRING)
private String cardNo;
/** 身份证号码格式校验 */
@Excel(name = "身份证格式校验")
@Excel(name = "身份证格式校验",type = Type.EXPORT)
private String checkCard;
/** 联系方式 */
@Excel(name = "联系方式")
@Excel(name = "电话")
private String phone;
/** 性别 */
......@@ -93,7 +93,7 @@ public class Hscj extends BaseEntity
private Long age;
/** 类别 */
@Excel(name = "人员类别")
@Excel(name = "类别")
private String category;
/** 人员关系 */
......@@ -136,12 +136,7 @@ public class Hscj extends BaseEntity
@Excel(name = "备注")
private String remark;
// 新增字段
// @Excel(name = "居委会")
// private String committee;
/** 状态(0正常 1停用) */
// @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志(0代表存在 2代表删除) */
......@@ -149,8 +144,8 @@ public class Hscj extends BaseEntity
/**创建时间*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @Excel(name = "创建时间",dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**导出选中IDLIST */
@Transient()
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;
import java.util.List;
import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import org.apache.ibatis.annotations.Param;
/**
......@@ -74,7 +75,7 @@ public interface HscjMapper
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);
}
......@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.domain.Zlqk;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import javax.servlet.http.HttpServletResponse;
......@@ -69,7 +70,7 @@ public interface IHscjService
*/
public int deleteHscjById(Long id);
void importList(List<Hscj> list, HttpServletResponse response);
void importList(List<HscjErrorDto> list, HttpServletResponse response);
List<Hscj> checkCard(Hscj hscj);
}
......@@ -8,15 +8,16 @@ import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Yxry;
import com.ruoyi.system.domain.Zlqk;
import com.ruoyi.system.domain.vo.HscjErrorDto;
import com.ruoyi.system.mapper.SysDictDataMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.system.mapper.HscjMapper;
import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.service.IHscjService;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
......@@ -55,6 +56,7 @@ public class HscjServiceImpl implements IHscjService {
public List<Hscj> selectHscjList(Hscj hscj) {
return hscjMapper.selectHscjList(hscj);
}
/**
* 查询导出核酸采集列表
*
......@@ -101,9 +103,6 @@ public class HscjServiceImpl implements IHscjService {
String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee());
if (createBy.equals("null"))
throw new ServiceException("所选居住地、街道、社区不存在");
// List<Hscj> list = hscjMapper.checkCard(hscj);
// if (!list.isEmpty())
// throw new ServiceException("该身份证号当天不能重复提交");
hscj.setCreateBy(createBy);
hscj.setUpdateTime(DateUtils.getNowDate());
return hscjMapper.updateHscj(hscj);
......@@ -132,124 +131,64 @@ public class HscjServiceImpl implements IHscjService {
}
@Override
public void importList(List<Hscj> list, HttpServletResponse response) {
public void importList(List<HscjErrorDto> list, HttpServletResponse response) {
if (StringUtils.isNull(list) || list.size() == 0) {
throw new ServiceException("导入数据不能为空!");
}
List<Hscj> trueList = new ArrayList<>();
List<Hscj> failureList = new ArrayList<>();
for (Hscj hscj : list) {
if (StringUtils.isEmpty(hscj.getProvince())) {
List<HscjErrorDto> trueList = new ArrayList<>();
List<HscjErrorDto> failureList = new ArrayList<>();
List<String> error;
for (HscjErrorDto hscj : list) {
error = new ArrayList<>();
hscj.setProvince("河北省");
}
if (StringUtils.isEmpty(hscj.getCity())) {
hscj.setCity("石家庄市");
if (StringUtils.isEmpty(hscj.getCardNo()))
error.add("身份证号不能为空");
if (StringUtils.isEmpty(hscj.getArea()))
error.add("区不能为空");
if (StringUtils.isEmpty(hscj.getBoxhao()))
error.add("箱号不能为空");
if (StringUtils.isEmpty(hscj.getCjgh()))
error.add("采集管号不能为空");
if (StringUtils.isEmpty(hscj.getUserName()))
error.add("姓名不能为空");
if (StringUtils.isEmpty(hscj.getSex()))
error.add("性别不能为空");
if (ObjectUtils.isEmpty(hscj.getAge()))
error.add("年龄不能为空");
if (ObjectUtils.isEmpty((hscj.getCjTime())))
error.add("采集时间不能为空");
if (StringUtils.isEmpty(hscj.getCjName()))
error.add("采集人姓名不能为空");
if (StringUtils.isEmpty(hscj.getCjPhone()))
error.add("采集人电话不能为空");
if (StringUtils.isEmpty(hscj.getBblx()))
error.add("标本类型不能为空");
if (CollectionUtils.isEmpty(error)) {
if(hscj.getArea().equals("开发区"))
hscj.setArea("高新区");
List<SysDictData> area = DictUtils.getDictCache("residential_area");
List<String> areas = area.stream().filter(l -> hscj.getArea().equals(l.getDictLabel()))
.map(SysDictData::getDictValue).collect(Collectors.toList());
if (!areas.isEmpty())
hscj.setArea(areas.get(0));
else {
hscj.setError("区不存在");
failureList.add(hscj);
continue;
}
if (StringUtils.isEmpty(hscj.getRygx())) {
hscj.setRygx("本人");
}
if (StringUtils.isNotEmpty(hscj.getCardNo())
&& StringUtils.isNotEmpty(hscj.getArea())
&& StringUtils.isNotEmpty(hscj.getBoxhao())
&& StringUtils.isNotEmpty(hscj.getCjgh())
&& StringUtils.isNotEmpty(hscj.getUserName())
&& StringUtils.isNotEmpty(hscj.getSex())
&& StringUtils.isNotEmpty(hscj.getAge().toString())
&& StringUtils.isNotEmpty(hscj.getCjTime().toString())
&& StringUtils.isNotEmpty(hscj.getCjName())
&& StringUtils.isNotEmpty(hscj.getCjPhone())
&& StringUtils.isNotEmpty(hscj.getBblx())
) {
// 校验单张Excel是否有多个重复的身份证号
// if (StringUtils.isNotEmpty(hscj.getCardNo())){
// int isExist = 0;
// for (Hscj hscjTest : list){
// if (hscj.getCardNo().equals(hscjTest.getCardNo())){
// isExist++;
// }
// }
// if (isExist > 1){
// failureList.add(hscj);
// continue;
// }
List<Hscj> hsctList = list.stream().filter(l ->
List<HscjErrorDto> hsctList = list.stream().filter(l ->
hscj.getCardNo().equals(l.getCardNo()) && l.getCjTime() != null &&
DateUtils.dateTime(hscj.getCjTime()).equals(DateUtils.dateTime(l.getCjTime())))
.collect(Collectors.toList());
if (hsctList.size() > 1) {
hscj.setError("存在重复数据");
failureList.add(hscj);
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
if (StringUtils.isNotEmpty(hscj.getCommunity())) {
List<SysDictData> communitys = DictUtils.getDictCache("community");
......@@ -258,8 +197,7 @@ public class HscjServiceImpl implements IHscjService {
if (!values.isEmpty())
hscj.setCommunity(values.get(0));
else {
failureList.add(hscj);
continue;
hscj.setCommunity(null);
}
}
//如果委员会不为空,去数据字典匹配value
......@@ -270,8 +208,7 @@ public class HscjServiceImpl implements IHscjService {
if (!values.isEmpty())
hscj.setCommittee(values.get(0));
else {
failureList.add(hscj);
continue;
hscj.setCommittee(null);
}
}
//如果街道不为空,去数据字典匹配value
......@@ -282,15 +219,16 @@ public class HscjServiceImpl implements IHscjService {
if (!values.isEmpty())
hscj.setStreet(values.get(0));
else {
failureList.add(hscj);
continue;
hscj.setStreet(null);
}
}
if (StringUtils.isNotEmpty(hscj.getCommunity()) && StringUtils.isEmpty(hscj.getCommittee())) {
hscj.setError("小区存在时社区不能为空");
failureList.add(hscj);
continue;
}
if (StringUtils.isNotEmpty(hscj.getCommittee()) && StringUtils.isEmpty(hscj.getStreet())) {
hscj.setError("社区存在时街道不能为空");
failureList.add(hscj);
continue;
}
......@@ -298,11 +236,12 @@ public class HscjServiceImpl implements IHscjService {
hscj.setCheckCard("正确");
trueList.add(hscj);
} else {
hscj.setCheckCard("不正确");
hscj.setError("身份证号校验不正确");
failureList.add(hscj);
continue;
}
} else {
hscj.setError(error.stream().collect(Collectors.joining(",")));
failureList.add(hscj);
}
}
......@@ -313,63 +252,17 @@ public class HscjServiceImpl implements IHscjService {
if (i + 500 > trueList.size()) {
toIndex = trueList.size() - i;
}
List<Hscj> list1 = trueList.subList(i, i + toIndex);
for (Hscj hscj : list1) {
List<HscjErrorDto> list1 = trueList.subList(i, i + toIndex);
for (HscjErrorDto hscj : list1) {
String createBy = DataUtils.getValue(hscj.getArea(), hscj.getStreet(), hscj.getCommittee());
hscj.setCreateBy(createBy);
hscj.setCreateTime(DateUtils.getNowDate());
}
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()) {
ExcelUtil<Hscj> util = new ExcelUtil<Hscj>(Hscj.class);
ExcelUtil<HscjErrorDto> util = new ExcelUtil<HscjErrorDto>(HscjErrorDto.class);
util.exportExcel(response, failureList, "核算采集错误数据");
}
}
......
......@@ -260,7 +260,7 @@
</trim>
</insert>
<insert id="insertBatch" parameterType="com.ruoyi.system.domain.Hscj">
<insert id="insertBatch" parameterType="com.ruoyi.system.domain.vo.HscjErrorDto">
insert into hscj
(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,
......
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