Commit 3907edba authored by 秦嘉's avatar 秦嘉

抗原异常上报导入和下载空模板

parent 62d1a3e7
......@@ -20,10 +20,11 @@ import com.ruoyi.system.domain.Ycsb;
import com.ruoyi.system.service.IYcsbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
/**
* 抗原异常上报Controller
*
*
* @author ruoyi
* @date 2022-11-28
*/
......@@ -101,4 +102,35 @@ public class YcsbController extends BaseController
{
return toAjax(ycsbService.deleteYcsbByIds(ids));
}
/**
* 抗原异常上报导入空模板下载
*/
@PostMapping("/importTemplate")
@PreAuthorize("@ss.hasPermi('system:ycsb:import')")
@Log(title = "下载抗原异常上报模板", businessType = BusinessType.IMPORT)
public void importTemplate(HttpServletResponse response) throws Exception {
ExcelUtil<Ycsb> util = new ExcelUtil<>(Ycsb.class);
Class<? extends Ycsb> clazz = new Ycsb().getClass();
// 是否做核酸
String[] hasAcid = new String[]{"是", "否"};
ExcelUtil.setClassExcelAttribute( clazz,"hasAcid","combo",hasAcid);
util.importTemplateExcel(response,"抗原异常上报");
}
/**
* 导入接口
* @param file 导入的excel文件
* @param response
* @throws Exception
*/
@Log(title = "导入抗原异常上报", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:ycsb:import')")
@PostMapping("/importData")
public void importData(MultipartFile file, HttpServletResponse response) throws Exception {
ExcelUtil<Ycsb> util = new ExcelUtil<>(Ycsb.class);
List<Ycsb> list = util.importExcel(file.getInputStream());
ycsbService.importList(list, response);
}
}
......@@ -10,7 +10,7 @@ import com.ruoyi.common.utils.spring.SpringUtils;
/**
* 字典工具类
*
*
* @author ruoyi
*/
public class DictUtils
......@@ -22,7 +22,7 @@ public class DictUtils
/**
* 设置字典缓存
*
*
* @param key 参数键
* @param dictDatas 字典数据列表
*/
......@@ -33,7 +33,7 @@ public class DictUtils
/**
* 获取字典缓存
*
*
* @param key 参数键
* @return dictDatas 字典数据列表
*/
......@@ -49,7 +49,7 @@ public class DictUtils
/**
* 根据字典类型和字典值获取字典标签
*
*
* @param dictType 字典类型
* @param dictValue 字典值
* @return 字典标签
......@@ -61,7 +61,7 @@ public class DictUtils
/**
* 根据字典类型和字典标签获取字典值
*
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @return 字典值
......@@ -73,7 +73,7 @@ public class DictUtils
/**
* 根据字典类型和字典值获取字典标签
*
*
* @param dictType 字典类型
* @param dictValue 字典值
* @param separator 分隔符
......@@ -116,7 +116,7 @@ public class DictUtils
/**
* 根据字典类型和字典标签获取字典值
*
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @param separator 分隔符
......@@ -156,7 +156,7 @@ public class DictUtils
/**
* 删除指定字典缓存
*
*
* @param key 字典键
*/
public static void removeDictCache(String key)
......@@ -175,7 +175,7 @@ public class DictUtils
/**
* 设置cache key
*
*
* @param configKey 参数键
* @return 缓存键key
*/
......
......@@ -20,15 +20,19 @@ public class Ycsb extends BaseEntity
/** 主键 */
private Long id;
/** 日期 */
/** 上报日期 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date sbDate;
/** 姓名 */
/** 异常人员姓名 */
@Excel(name = "姓名")
private String userName;
/** 是否做核酸 */
@Excel(name = "是否做核酸")
private String hasAcid;
/** 身份证号码 */
@Excel(name = "身份证号")
private String cardNo;
......@@ -37,20 +41,16 @@ public class Ycsb extends BaseEntity
@Excel(name = "联系电话")
private String phone;
/** 联系方式 */
@Excel(name = "家庭现住址")
private String address;
/** 居住地所在区 */
// @Excel(name = "居住地所在区")
@Excel(name = "居住地所在区", dictType = "residential_area")
private String area;
/** 街道/镇 */
@Excel(name = "单位")
@Excel(name = "单位", dictType = "street_town")
private String street;
// 新增字段
@Excel(name = "居委会")
/** 居委会 */
@Excel(name = "居委会", dictType = "committee")
private String committee;
/** 小区/村名称 */
......@@ -69,20 +69,30 @@ public class Ycsb extends BaseEntity
@Excel(name = "门牌号")
private String house;
/** 是否做核酸 */
// @Excel(name = "是否做核酸")
private String hasAcid;
/** 联系方式 */
@Excel(name = "家庭现住址")
private String address;
/** 备注 */
@Excel(name = "备注")
private String remark;
/** 状态(0正常 1停用) */
// @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 删除标志(0代表存在 2代表删除) */
private String delFlag;
/** 备注 */
@Excel(name = "备注")
private String remark;
private String checkCard;
public String getCheckCard() {
return checkCard;
}
public void setCheckCard(String checkCard) {
this.checkCard = checkCard;
}
public void setId(Long id)
{
......
......@@ -5,15 +5,15 @@ import com.ruoyi.system.domain.Ycsb;
/**
* 抗原异常上报Mapper接口
*
*
* @author ruoyi
* @date 2022-11-28
*/
public interface YcsbMapper
public interface YcsbMapper
{
/**
* 查询抗原异常上报
*
*
* @param id 抗原异常上报主键
* @return 抗原异常上报
*/
......@@ -21,7 +21,7 @@ public interface YcsbMapper
/**
* 查询抗原异常上报列表
*
*
* @param ycsb 抗原异常上报
* @return 抗原异常上报集合
*/
......@@ -29,7 +29,7 @@ public interface YcsbMapper
/**
* 新增抗原异常上报
*
*
* @param ycsb 抗原异常上报
* @return 结果
*/
......@@ -37,7 +37,7 @@ public interface YcsbMapper
/**
* 修改抗原异常上报
*
*
* @param ycsb 抗原异常上报
* @return 结果
*/
......@@ -45,7 +45,7 @@ public interface YcsbMapper
/**
* 删除抗原异常上报
*
*
* @param id 抗原异常上报主键
* @return 结果
*/
......@@ -53,9 +53,16 @@ public interface YcsbMapper
/**
* 批量删除抗原异常上报
*
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteYcsbByIds(Long[] ids);
/**
* 根据身份证号查询
* @param cardNo 身份证号
* @return
*/
List<Ycsb> selectYcsbByCard(String cardNo);
}
......@@ -3,17 +3,19 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Ycsb;
import javax.servlet.http.HttpServletResponse;
/**
* 抗原异常上报Service接口
*
*
* @author ruoyi
* @date 2022-11-28
*/
public interface IYcsbService
public interface IYcsbService
{
/**
* 查询抗原异常上报
*
*
* @param id 抗原异常上报主键
* @return 抗原异常上报
*/
......@@ -21,7 +23,7 @@ public interface IYcsbService
/**
* 查询抗原异常上报列表
*
*
* @param ycsb 抗原异常上报
* @return 抗原异常上报集合
*/
......@@ -29,7 +31,7 @@ public interface IYcsbService
/**
* 新增抗原异常上报
*
*
* @param ycsb 抗原异常上报
* @return 结果
*/
......@@ -37,7 +39,7 @@ public interface IYcsbService
/**
* 修改抗原异常上报
*
*
* @param ycsb 抗原异常上报
* @return 结果
*/
......@@ -45,7 +47,7 @@ public interface IYcsbService
/**
* 批量删除抗原异常上报
*
*
* @param ids 需要删除的抗原异常上报主键集合
* @return 结果
*/
......@@ -53,9 +55,16 @@ public interface IYcsbService
/**
* 删除抗原异常上报信息
*
*
* @param id 抗原异常上报主键
* @return 结果
*/
public int deleteYcsbById(Long id);
/**
* 导入抗原异常上报信息
* @param list 导入的list数据
* @param response
*/
void importList(List<Ycsb> list, HttpServletResponse response);
}
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DataUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Yxry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.system.mapper.YcsbMapper;
import com.ruoyi.system.domain.Ycsb;
import com.ruoyi.system.service.IYcsbService;
import javax.servlet.http.HttpServletResponse;
/**
* 抗原异常上报Service业务层处理
*
......@@ -107,4 +112,76 @@ public class YcsbServiceImpl implements IYcsbService
{
return ycsbMapper.deleteYcsbById(id);
}
/**
* 导入
* @param list 导入的list数据
* @param response
*/
@Override
public void importList(List<Ycsb> list, HttpServletResponse response) {
if (StringUtils.isNull(list) || list.size() == 0) {
throw new ServiceException("导入数据不能为空!");
}
List<Ycsb> trueList = new ArrayList<>();
List<Ycsb> failureList = new ArrayList<>();
for (Ycsb ycsb : list) {
if (StringUtils.isNotEmpty(ycsb.getUserName())
&& StringUtils.isNotEmpty(ycsb.getCardNo())
&& StringUtils.isNotEmpty(ycsb.getArea())
&& StringUtils.isNotEmpty(ycsb.getStreet())
&& StringUtils.isNotEmpty(ycsb.getCommittee())
&& StringUtils.isNotEmpty(ycsb.getSbDate().toString())) {
// 校验身份证号是否重复(同excel表验证)
List<Ycsb> ycsbList = list.stream().filter(i -> ycsb.getCardNo().equals(i.getCardNo())).collect(Collectors.toList());
if (ycsbList.size() > 1) {
failureList.add(ycsb);
} else {
// 校验身份证格式
if (CheckUtils.checkCard(ycsb.getCardNo())) {
ycsb.setCheckCard("1");
// 校验手机号格式
if (!CheckUtils.checkPhone(ycsb.getPhone())) {
failureList.add(ycsb);
} else {
// 匹配小区参数
if (StringUtils.isNotEmpty(ycsb.getCommunity())) {
List<SysDictData> communities = DictUtils.getDictCache("community");
List<String> values = communities.stream().map(SysDictData::getDictValue)
.filter(dictValue -> ycsb.getCommunity().equals(dictValue)).collect(Collectors.toList());
if (!values.isEmpty()) {
ycsb.setCommunity(values.get(0));
String createBy = DataUtils.getValue(ycsb.getArea(), ycsb.getStreet(), ycsb.getCommittee());
ycsb.setCreateBy(createBy);
ycsb.setCreateTime(DateUtils.getNowDate());
trueList.add(ycsb);
} else {
failureList.add(ycsb);
}
}
}
} else {
ycsb.setCheckCard("0");
failureList.add(ycsb);
}
}
} else {
failureList.add(ycsb);
}
}
if (!trueList.isEmpty()) {
for (Ycsb ycsb : trueList) {
// 校验身份证号是否重复(数据库验证)
List<Ycsb> ycsbList = ycsbMapper.selectYcsbByCard(ycsb.getCardNo());
if (ycsbList.size() > 0) {
ycsbMapper.updateYcsb(ycsb);
}
ycsbMapper.insertYcsb(ycsb);
}
}
if (!failureList.isEmpty()) {
ExcelUtil<Ycsb> util = new ExcelUtil<>(Ycsb.class);
util.exportExcel(response, failureList, "抗原异常上报错误数据");
}
}
}
......@@ -74,6 +74,10 @@
<include refid="selectYcsbVo"/>
where id = #{id}
</select>
<select id="selectYcsbByCard" resultType="com.ruoyi.system.domain.Ycsb">
<include refid="selectYcsbVo"/>
where del_flag = '0' and card_no = #{cardNo}
</select>
<insert id="insertYcsb" parameterType="Ycsb" useGeneratedKeys="true" keyProperty="id">
insert into ycsb
......
......@@ -42,3 +42,23 @@ export function delYcsb(id) {
method: 'delete'
})
}
// 下载抗原异常上报导入模板
export function importTemplate(params) {
return request({
url: '/system/ycsb/importTemplate',
method: 'post',
responseType: 'blob',
params
})
}
// 导入抗原异常上报信息
export function importExcel(data) {
return request({
url: '/system/ycsb/importData',
method: 'post',
responseType: 'blob',
data
})
}
......@@ -421,7 +421,7 @@
<script>
import { listYcsb, getYcsb, delYcsb, addYcsb, updateYcsb } from "@/api/system/ycsb";
import { getToken } from '@/utils/auth'
import { importTemplate, importExcel } from "@/api/system/zlqk";
import { importTemplate, importExcel } from "@/api/system/ycsb";
export default {
name: "Ycsb",
......@@ -677,7 +677,7 @@ export default {
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/system/zlqk/importTemplate"
url: process.env.VUE_APP_BASE_API + "/system/ycbs/importTemplate"
},
// 遮罩层
loading: true,
......@@ -849,7 +849,7 @@ export default {
/** 导入按钮操作 */
handleImport() {
this.importLoading = false
this.upload.title = "治疗情况导入";
this.upload.title = "抗原异常上报导入";
this.upload.open = true;
},
/** 下载模板操作 */
......
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