Commit e544abbf authored by gaoyingwei's avatar gaoyingwei

修改 方舱导入

parent 82e29673
......@@ -13,6 +13,7 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.FcryDTO;
import com.ruoyi.system.domain.Fkqk;
import com.ruoyi.system.domain.vo.FcryVo;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.impl.FkqkServiceImpl;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -239,8 +240,8 @@ public class FcryController extends BaseController
@PostMapping("/import")
public void importResidential(MultipartFile file,HttpServletResponse response) throws Exception
{
ExcelUtil<Fcry> util = new ExcelUtil<Fcry>(Fcry.class);
List<Fcry> residentialList = util.importExcel(file.getInputStream());
ExcelUtil<FcryVo> util = new ExcelUtil<FcryVo>(FcryVo.class);
List<FcryVo> residentialList = util.importExcel(file.getInputStream());
String operName = getUsername();
fcryService.importUser(residentialList, operName,response);
}
......
package com.ruoyi.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.system.domain.Fcry;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.springframework.data.annotation.Transient;
import java.util.Date;
import java.util.List;
/**
* 方舱人员对象 fcry
*
* @author ruoyi
* @date 2022-11-28
*/
public class FcryVo extends Fcry
{
private static final long serialVersionUID = 1L;
//错误提示
@Transient
@Excel(name = "错误提示",type = Excel.Type.EXPORT,color = IndexedColors.RED)
private String failure;
public String getFailure() {
return failure;
}
public void setFailure(String failure) {
this.failure = failure;
}
}
......@@ -3,6 +3,7 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Fcry;
import com.ruoyi.system.domain.FcryDTO;
import com.ruoyi.system.domain.vo.FcryVo;
import javax.servlet.http.HttpServletResponse;
......@@ -69,5 +70,5 @@ public interface IFcryService
*/
public int deleteFcryById(Long id);
void importUser(List<Fcry> residentialList, String operName, HttpServletResponse response);
void importUser(List<FcryVo> residentialList, String operName, HttpServletResponse response);
}
......@@ -9,6 +9,7 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.vo.FcryVo;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -144,15 +145,15 @@ public class FcryServiceImpl implements IFcryService
}
@Override
public void importUser(List<Fcry> residentialList, String operName, HttpServletResponse response) {
public void importUser(List<FcryVo> residentialList, String operName, HttpServletResponse response) {
if (StringUtils.isNull(residentialList) || residentialList.size() == 0)
{
throw new ServiceException("导入方舱人员管理数据不能为空!");
}
List<Fcry> trueList = new ArrayList<>();
List<Fcry> failureList = new ArrayList<>();
List<FcryVo> failureList = new ArrayList<>();
List<Fcry> updateList = new ArrayList<>();
for (Fcry fcry : residentialList){
for (FcryVo fcry : residentialList){
if (StringUtils.isNotEmpty(fcry.getFcPlace())
&& StringUtils.isNotEmpty(fcry.getJzName()) && StringUtils.isNotEmpty(fcry.getCardNo())
&& StringUtils.isNotEmpty(fcry.getPhone()) && StringUtils.isNotEmpty(fcry.getArea())
......@@ -169,6 +170,7 @@ public class FcryServiceImpl implements IFcryService
if (!values.isEmpty())
communityValue = values.get(0);
else {
fcry.setFailure("小区不存在");
failureList.add(fcry);
continue;
}
......@@ -180,6 +182,7 @@ public class FcryServiceImpl implements IFcryService
if (!values.isEmpty())
committeeValue=values.get(0);
else {
fcry.setFailure("居委会不存在");
failureList.add(fcry);
continue;
}
......@@ -191,6 +194,7 @@ public class FcryServiceImpl implements IFcryService
if (!values.isEmpty())
streetValue=values.get(0);
else {
fcry.setFailure("街道不存在");
failureList.add(fcry);
continue;
}
......@@ -202,6 +206,7 @@ public class FcryServiceImpl implements IFcryService
if (!values.isEmpty())
areaValue =values.get(0);
else {
fcry.setFailure("居住地所在区不存在");
failureList.add(fcry);
continue;
}
......@@ -213,12 +218,14 @@ public class FcryServiceImpl implements IFcryService
if (!values.isEmpty())
fcValue = values.get(0);
else {
fcry.setFailure("方舱不存在");
failureList.add(fcry);
continue;
}
}
if ((StringUtils.isNotEmpty(fcry.getCommunity())&&StringUtils.isEmpty(fcry.getCommittee()))||
(StringUtils.isNotEmpty(fcry.getCommittee())&&StringUtils.isEmpty(fcry.getStreet()))){
fcry.setFailure("街道或居委会不存在");
failureList.add(fcry);
continue;
}
......@@ -233,10 +240,12 @@ public class FcryServiceImpl implements IFcryService
}
else {
fcrys = residentialList.stream().filter(l -> fcry.getCardNo().equals(l.getCardNo())).collect(Collectors.toList());
if (fcrys.size()>1)
if (fcrys.size()>1) {
fcry.setFailure("存在重复数据");
failureList.add(fcry);
else {
} else {
if (!CheckUtils.checkPhone(fcry.getPhone())) {
fcry.setFailure("联系方式格式不正确");
failureList.add(fcry);
}else {
if (CheckUtils.checkCard(fcry.getCardNo())){
......@@ -250,12 +259,25 @@ public class FcryServiceImpl implements IFcryService
}
else{
fcry.setCheckCard("不正确");
fcry.setFailure("身份证格式不正确");
failureList.add(fcry);
}
}
}
}
}else {
if(StringUtils.isEmpty(fcry.getFcPlace()))
fcry.setFailure("方舱名称不能为空");
else if ( StringUtils.isEmpty(fcry.getJzName()))
fcry.setFailure("居住人姓名不能为空");
else if ( StringUtils.isEmpty(fcry.getCardNo()))
fcry.setFailure("身份证号码不能为空");
else if (StringUtils.isEmpty(fcry.getPhone()))
fcry.setFailure("联系方式不能为空");
else if (StringUtils.isEmpty(fcry.getArea()))
fcry.setFailure("居住地所在区不能为空");
else if ( fcry.getZrTime() == null)
fcry.setFailure("转入时间不能为空");
failureList.add(fcry);
}
}
......@@ -276,7 +298,7 @@ public class FcryServiceImpl implements IFcryService
fcryMapper.insertBatchFcry(trueList);
}
if (!failureList.isEmpty()) {
ExcelUtil<Fcry> util = new ExcelUtil<Fcry>(Fcry.class);
ExcelUtil<FcryVo> util = new ExcelUtil<FcryVo>(FcryVo.class);
util.exportExcel(response, failureList, "方舱人员管理数据");
}
}
......
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