23 changed files with 1993 additions and 1 deletions
@ -0,0 +1,119 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
public class IcVaccineDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 唯一标识 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户Id customer.id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
private String isResiUser; |
|||
|
|||
/** |
|||
* 数据来源【导入的:import;】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
/** |
|||
* 接种时间 |
|||
*/ |
|||
private Date inoculateTime; |
|||
|
|||
/** |
|||
* 接种地点 |
|||
*/ |
|||
private String inoculateAddress; |
|||
|
|||
/** |
|||
* 疫苗厂家 |
|||
*/ |
|||
private String manufacturer; |
|||
|
|||
/** |
|||
* 预留字段1 |
|||
*/ |
|||
private String field1; |
|||
|
|||
/** |
|||
* 预留字段2 |
|||
*/ |
|||
private String field2; |
|||
|
|||
/** |
|||
* 预留字段3 |
|||
*/ |
|||
private String field3; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remaek; |
|||
|
|||
/** |
|||
* 删除标识 0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
public class IcVaccineRelationDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 组织pids,包含当前agencyId值 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 疫苗记录表Id(ic_vaccine.id) |
|||
*/ |
|||
private String icVaccineId; |
|||
|
|||
/** |
|||
* 关系数据的绑定途径【 |
|||
数字社区录入:icresi; |
|||
导入的:import; |
|||
同步的:synchro】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
/** |
|||
* 删除标识 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* @Description 疫苗接种信息查询 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class VaccineListFormDTO extends PageFormDTO { |
|||
|
|||
private static final long serialVersionUID = -6809065476616323072L; |
|||
|
|||
public interface Detail extends CustomerClientShowGroup { |
|||
} |
|||
public interface Del extends CustomerClientShowGroup { |
|||
} |
|||
public interface Synchro extends CustomerClientShowGroup { |
|||
} |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
/** |
|||
* 当前组织:current 根组织:all |
|||
*/ |
|||
private String searchType; |
|||
private String agencyId; |
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
private String isResiUser; |
|||
/** |
|||
* 检测开始时间yyyy-MM-dd HH:mm |
|||
*/ |
|||
private String startTime; |
|||
/** |
|||
* 检测结束时间yyyy-MM-dd HH:mm间yy-mm-dd |
|||
*/ |
|||
private String endTime; |
|||
|
|||
/** |
|||
* 核酸记录Id |
|||
*/ |
|||
@NotBlank(message = "疫苗接种记录Id不能为空", groups = { Detail.class, Del.class, Synchro.class}) |
|||
private String icVaccineId; |
|||
|
|||
/** |
|||
* token里设置 |
|||
*/ |
|||
private String customerId; |
|||
private String userId; |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import com.alibaba.excel.annotation.write.style.HeadStyle; |
|||
import com.alibaba.excel.enums.poi.FillPatternTypeEnum; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 疫苗接种-全局导出 |
|||
* @Author sun |
|||
*/ |
|||
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) |
|||
@Data |
|||
public class IcVaccineListCommonExcelResultDTO extends IcVaccineListResultDTO{ |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "本辖区居民",order = 6) |
|||
private String isResiUser; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,90 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelIgnore; |
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import com.alibaba.excel.annotation.write.style.HeadStyle; |
|||
import com.alibaba.excel.enums.poi.FillPatternTypeEnum; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Description 核酸检测-我的上报记录 |
|||
* @Author sun |
|||
*/ |
|||
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) |
|||
@Data |
|||
public class IcVaccineListResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 核酸记录Id |
|||
*/ |
|||
@ExcelIgnore |
|||
private String icNatId; |
|||
/** |
|||
* 组织Id |
|||
*/ |
|||
@ExcelIgnore |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 居民端小程序的人:resi;数字社区的居民:icresi;未关联上的:other |
|||
*/ |
|||
@ExcelIgnore |
|||
private String userType; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "姓名",order = 1) |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "手机号",order = 2) |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
@ColumnWidth(25) |
|||
@ExcelProperty(value = "身份证号",order = 3) |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 检测时间,yyyy-MM-dd HH:mm |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
|||
@ColumnWidth(25) |
|||
@ExcelProperty(value = "接种时间",order = 4) |
|||
private Date inoculateTime; |
|||
|
|||
/** |
|||
* 检测结果 |
|||
*/ |
|||
@ColumnWidth(20) |
|||
@ExcelProperty(value = "接种地点",order = 5) |
|||
private String inoculateAddress; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
@ExcelIgnore |
|||
private String isResiUser; |
|||
|
|||
/** |
|||
* 检测地点 |
|||
*/ |
|||
@ColumnWidth(30) |
|||
@ExcelProperty(value = "疫苗厂家",order = 7) |
|||
private String manufacturer; |
|||
|
|||
|
|||
} |
@ -0,0 +1,229 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.alibaba.excel.EasyExcel; |
|||
import com.alibaba.excel.ExcelWriter; |
|||
import com.alibaba.excel.write.metadata.WriteSheet; |
|||
import com.epmet.commons.tools.annotation.LoginUser; |
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.constant.ServiceConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.*; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.constants.ImportTaskConstants; |
|||
import com.epmet.dto.form.ImportTaskCommonFormDTO; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.IcVaccineListCommonExcelResultDTO; |
|||
import com.epmet.dto.result.IcVaccineListResultDTO; |
|||
import com.epmet.dto.result.ImportTaskCommonResultDTO; |
|||
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|||
import com.epmet.service.IcVaccineService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.apache.commons.io.IOUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import javax.servlet.ServletOutputStream; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.FileOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.URLEncoder; |
|||
import java.nio.file.Path; |
|||
import java.util.List; |
|||
import java.util.UUID; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("icVaccine") |
|||
public class IcVaccineController implements ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private IcVaccineService icVaccineService; |
|||
|
|||
@Autowired |
|||
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【疫苗】疫苗接种信息列表 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("vaccine-list") |
|||
public Result<PageData<IcVaccineListResultDTO>> vaccineList(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
return new Result<PageData<IcVaccineListResultDTO>>().ok(icVaccineService.icVaccineList(formDTO)); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息同步 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("synchro") |
|||
public Result synchro(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, VaccineListFormDTO.Synchro.class); |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
icVaccineService.synchro(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息取消同步 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("cancelsynchro") |
|||
public Result cancelSynchro(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, VaccineListFormDTO.Synchro.class); |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
icVaccineService.cancelSynchro(formDTO); |
|||
return new Result<>(); |
|||
} |
|||
|
|||
/** |
|||
* 导入excel |
|||
* @return |
|||
*/ |
|||
@PostMapping("import") |
|||
public Result importExcel(MultipartFile file) { |
|||
String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); |
|||
|
|||
// 1.暂存文件
|
|||
String originalFilename = file.getOriginalFilename(); |
|||
String extName = originalFilename.substring(originalFilename.lastIndexOf(".")); |
|||
|
|||
Path fileSavePath; |
|||
try { |
|||
Path importPath = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_vaccine", "import"); |
|||
fileSavePath = importPath.resolve(UUID.randomUUID().toString().concat(extName)); |
|||
} catch (IOException e) { |
|||
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|||
log.error("【疫苗接种导入】创建临时存储文件失败:{}", errorMsg); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "文件上传失败", "文件上传失败"); |
|||
} |
|||
|
|||
InputStream is = null; |
|||
FileOutputStream os = null; |
|||
|
|||
try { |
|||
is = file.getInputStream(); |
|||
os = new FileOutputStream(fileSavePath.toString()); |
|||
IOUtils.copy(is, os); |
|||
} catch (Exception e) { |
|||
log.error("importExcel exception", e); |
|||
} finally { |
|||
org.apache.poi.util.IOUtils.closeQuietly(is); |
|||
org.apache.poi.util.IOUtils.closeQuietly(os); |
|||
} |
|||
|
|||
// 2.生成导入任务记录
|
|||
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); |
|||
importTaskForm.setOperatorId(userId); |
|||
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_IC_VACCINE); |
|||
importTaskForm.setOriginFileName(originalFilename); |
|||
|
|||
ImportTaskCommonResultDTO rstData = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm), |
|||
ServiceConstant.EPMET_COMMON_SERVICE, |
|||
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), |
|||
"excel导入疫苗接种信息错误", |
|||
"导入居民疫苗接种信息失败"); |
|||
|
|||
// 3.执行导入
|
|||
icVaccineService.execAsyncExcelImport(fileSavePath, rstData.getTaskId()); |
|||
|
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息下载模板 |
|||
**/ |
|||
@RequestMapping(value = "import-template-download", method = {RequestMethod.GET, RequestMethod.POST}) |
|||
public void downloadTemplate(HttpServletResponse response) throws IOException { |
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition"); |
|||
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("疫苗接种导入模板", "UTF-8") + ".xlsx"); |
|||
|
|||
InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_vaccine.xlsx"); |
|||
try { |
|||
ServletOutputStream os = response.getOutputStream(); |
|||
IOUtils.copy(is, os); |
|||
} finally { |
|||
if (is != null) { |
|||
is.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【疫苗】疫苗接种信息列表 |
|||
**/ |
|||
@NoRepeatSubmit |
|||
@PostMapping("export") |
|||
public void export(@LoginUser TokenDto tokenDto, @RequestBody VaccineListFormDTO formDTO, HttpServletResponse response) { |
|||
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|||
formDTO.setUserId(tokenDto.getUserId()); |
|||
formDTO.setIsPage(false); |
|||
ExcelWriter excelWriter = null; |
|||
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|||
int pageNo = formDTO.getPageNo(); |
|||
try { |
|||
// 这里 需要指定写用哪个class去写
|
|||
String fileName = "疫苗接种信息.xlsx"; |
|||
if ("all".equals(formDTO.getSearchType())) { |
|||
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcVaccineListResultDTO.class).build(); |
|||
}else { |
|||
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcVaccineListCommonExcelResultDTO.class).build(); |
|||
} |
|||
|
|||
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").build(); |
|||
PageData<IcVaccineListResultDTO> data = null; |
|||
do { |
|||
data = icVaccineService.icVaccineList(formDTO); |
|||
data.getList().forEach(o-> { |
|||
o.setIsResiUser(NumConstant.ONE_STR.equals(o.getIsResiUser()) ? "是" : "否"); |
|||
}); |
|||
formDTO.setPageNo(++pageNo); |
|||
if ("current".equals(formDTO.getSearchType())) { |
|||
List<IcVaccineListResultDTO> list = ConvertUtils.sourceToTarget(data.getList(), IcVaccineListResultDTO.class); |
|||
excelWriter.write(list, writeSheet); |
|||
}else{ |
|||
excelWriter.write(data.getList(), writeSheet); |
|||
} |
|||
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); |
|||
|
|||
}catch (Exception e){ |
|||
log.error("export exception", e); |
|||
}finally { |
|||
// 千万别忘记finish 会帮忙关闭流
|
|||
if (excelWriter != null) { |
|||
excelWriter.finish(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,72 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.AssertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|||
import com.epmet.dto.IcVaccineRelationDTO; |
|||
import com.epmet.service.IcVaccineRelationService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("icVaccineRelation") |
|||
public class IcVaccineRelationController { |
|||
|
|||
@Autowired |
|||
private IcVaccineRelationService icVaccineRelationService; |
|||
|
|||
@RequestMapping("page") |
|||
public Result<PageData<IcVaccineRelationDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<IcVaccineRelationDTO> page = icVaccineRelationService.page(params); |
|||
return new Result<PageData<IcVaccineRelationDTO>>().ok(page); |
|||
} |
|||
|
|||
@RequestMapping(value = "{id}",method = {RequestMethod.POST,RequestMethod.GET}) |
|||
public Result<IcVaccineRelationDTO> get(@PathVariable("id") String id){ |
|||
IcVaccineRelationDTO data = icVaccineRelationService.get(id); |
|||
return new Result<IcVaccineRelationDTO>().ok(data); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("save") |
|||
public Result save(@RequestBody IcVaccineRelationDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
icVaccineRelationService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("update") |
|||
public Result update(@RequestBody IcVaccineRelationDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
icVaccineRelationService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("delete") |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
icVaccineRelationService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,70 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.IcNatDTO; |
|||
import com.epmet.dto.form.MyNatListFormDTO; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.MyNatListResultDTO; |
|||
import com.epmet.dto.result.NatListResultDTO; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Mapper |
|||
public interface IcVaccineDao extends BaseDao<IcVaccineEntity> { |
|||
/** |
|||
* @Author sun |
|||
* @Description 核酸检测-按条件查询核酸记录 |
|||
**/ |
|||
List<MyNatListResultDTO> getMyNatList(MyNatListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【核酸】本辖区核酸检测信息列表 |
|||
* |
|||
* @param formDTO*/ |
|||
List<NatListResultDTO> getIcVaccineList(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【核酸】客户下核酸检测信息列表 |
|||
* |
|||
* @param formDTO*/ |
|||
List<NatListResultDTO> getCustomerIcVaccineList(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 删除操作--物理删除业务数据 |
|||
**/ |
|||
int delById(@Param("icNatId") String icNatId); |
|||
|
|||
/** |
|||
* 插入或者更新 |
|||
* |
|||
* @param e |
|||
*/ |
|||
void insertOrUpdate(IcVaccineEntity e); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 按条件查询业务数据 |
|||
**/ |
|||
IcNatDTO getNatDTO(@Param("customerId") String customerId, @Param("icNatId") String icNatId, @Param("idCard") String idCard, @Param("natTime") String natTime, @Param("natResult") String natResult); |
|||
|
|||
/** |
|||
* desc:根据客户id 更新是否居民状态 |
|||
* |
|||
* @param customerId |
|||
* @param icResiUserId 如果为空则更新全部 |
|||
* @return |
|||
*/ |
|||
int updateIsResiFlag(@Param("customerId") String customerId, @Param("icResiUserId") String icResiUserId); |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.entity.IcVaccineRelationEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Mapper |
|||
public interface IcVaccineRelationDao extends BaseDao<IcVaccineRelationEntity> { |
|||
int delRelation(@Param("icNatId") String icNatId, @Param("agencyId") String agencyId); |
|||
} |
@ -0,0 +1,92 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.FieldFill; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_vaccine") |
|||
public class IcVaccineEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id customer.id |
|||
*/ |
|||
@TableField(fill = FieldFill.INSERT_UPDATE) |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
|
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
|
|||
/** |
|||
* 是否客户下居民(0:否 1:是) |
|||
*/ |
|||
private String isResiUser; |
|||
|
|||
/** |
|||
* 数据来源【导入的:import;】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
/** |
|||
* 接种时间 |
|||
*/ |
|||
private Date inoculateTime; |
|||
|
|||
/** |
|||
* 接种地点 |
|||
*/ |
|||
private String inoculateAddress; |
|||
|
|||
/** |
|||
* 疫苗厂家 |
|||
*/ |
|||
private String manufacturer; |
|||
|
|||
/** |
|||
* 预留字段1 |
|||
*/ |
|||
private String field1; |
|||
|
|||
/** |
|||
* 预留字段2 |
|||
*/ |
|||
private String field2; |
|||
|
|||
/** |
|||
* 预留字段3 |
|||
*/ |
|||
private String field3; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("ic_vaccine_relation") |
|||
public class IcVaccineRelationEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户Id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id |
|||
*/ |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 组织pids,包含当前agencyId值 |
|||
*/ |
|||
private String pids; |
|||
|
|||
/** |
|||
* 疫苗记录表Id(ic_vaccine.id) |
|||
*/ |
|||
private String icVaccineId; |
|||
|
|||
/** |
|||
* 关系数据的绑定途径【 |
|||
数字社区录入:icresi; |
|||
导入的:import; |
|||
同步的:synchro】 |
|||
*/ |
|||
private String userType; |
|||
|
|||
} |
@ -0,0 +1,64 @@ |
|||
package com.epmet.excel.data; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 疫苗接种信息导入excel数据 |
|||
*/ |
|||
@Data |
|||
public class IcVaccineImportExcelData implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -700535059296633797L; |
|||
@NotBlank(message = "姓名为必填项") |
|||
@ExcelProperty("姓名") |
|||
private String name; |
|||
|
|||
@NotBlank(message = "手机号为必填项") |
|||
@ExcelProperty("手机号") |
|||
private String mobile; |
|||
|
|||
@NotBlank(message = "身份证号为必填项") |
|||
@ExcelProperty("身份证号") |
|||
@Length(max = 18, message = "身份证号长度不正确,应小于18位") |
|||
private String idCard; |
|||
|
|||
@NotNull(message = "接种时间为必填项") |
|||
@ExcelProperty("接种时间") |
|||
private Date inoculateTime; |
|||
|
|||
@NotBlank(message = "接种地点为必填项") |
|||
@ExcelProperty("接种地点") |
|||
private String inoculateAddress; |
|||
|
|||
@NotBlank(message = "疫苗厂家为必填项") |
|||
@ExcelProperty("疫苗厂家") |
|||
private String manufacturer; |
|||
|
|||
@Data |
|||
public static class RowRemarkMessage { |
|||
|
|||
@ExcelProperty("姓名") |
|||
@ColumnWidth(20) |
|||
private String name; |
|||
|
|||
@ExcelProperty("手机号") |
|||
@ColumnWidth(20) |
|||
private String mobile; |
|||
|
|||
@ColumnWidth(20) |
|||
@ExcelProperty("身份证号") |
|||
private String idCard; |
|||
|
|||
@ColumnWidth(60) |
|||
@ExcelProperty("错误信息") |
|||
private String errorInfo; |
|||
} |
|||
} |
@ -0,0 +1,136 @@ |
|||
package com.epmet.excel.handler; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.read.listener.ReadListener; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.exception.ValidateException; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
import com.epmet.excel.data.IcNatImportExcelData; |
|||
import com.epmet.excel.data.IcVaccineImportExcelData; |
|||
import com.epmet.service.impl.IcNatServiceImpl; |
|||
import com.epmet.service.impl.IcVaccineServiceImpl; |
|||
import lombok.Data; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 核酸检测excel导入监听器 |
|||
*/ |
|||
@Data |
|||
@Slf4j |
|||
public class IcVaccineExcelImportListener implements ReadListener<IcVaccineImportExcelData> { |
|||
|
|||
/** |
|||
* 最大条数阈值 |
|||
*/ |
|||
public static final int MAX_THRESHOLD = 200; |
|||
|
|||
private String currentUserId; |
|||
/** |
|||
* 当前组织ID |
|||
*/ |
|||
private String currentAgencyId; |
|||
|
|||
private String currentAgencyPids; |
|||
|
|||
/** |
|||
* 数据 |
|||
*/ |
|||
private List<IcVaccineEntity> datas = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 错误项列表 |
|||
*/ |
|||
private List<IcVaccineImportExcelData.RowRemarkMessage> errorRows = new ArrayList<>(); |
|||
/** |
|||
* 其他被标记出来的列表列表 |
|||
*/ |
|||
private List<IcVaccineImportExcelData.RowRemarkMessage> otherRows = new ArrayList<>(); |
|||
|
|||
private IcVaccineServiceImpl icVaccineService; |
|||
|
|||
public IcVaccineExcelImportListener(String currentUserId, String currentAgencyId, String currentAgencyPids, IcVaccineServiceImpl icVaccineService) { |
|||
this.currentUserId = currentUserId; |
|||
this.currentAgencyId = currentAgencyId; |
|||
this.currentAgencyPids = currentAgencyPids; |
|||
this.icVaccineService = icVaccineService; |
|||
} |
|||
|
|||
@Override |
|||
public void invoke(IcVaccineImportExcelData data, AnalysisContext context) { |
|||
|
|||
try { |
|||
// 先校验数据
|
|||
ValidatorUtils.validateEntity(data); |
|||
|
|||
// 取出前后空格
|
|||
if (StringUtils.isNotBlank(data.getName())) { |
|||
data.setName(data.getName().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(data.getMobile())) { |
|||
data.setMobile(data.getMobile().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(data.getInoculateAddress())) { |
|||
data.setInoculateAddress(data.getInoculateAddress().trim()); |
|||
} |
|||
if (StringUtils.isNotBlank(data.getIdCard())) { |
|||
data.setIdCard(data.getIdCard().trim()); |
|||
} |
|||
|
|||
IcVaccineEntity icVaccineEntity = ConvertUtils.sourceToTarget(data, IcVaccineEntity.class); |
|||
icVaccineEntity.setUserType("import"); |
|||
datas.add(icVaccineEntity); |
|||
|
|||
if (datas.size() == MAX_THRESHOLD) { |
|||
execPersist(); |
|||
} |
|||
} catch (Exception e) { |
|||
String errorMsg = null; |
|||
if (e instanceof ValidateException) { |
|||
errorMsg = ((ValidateException) e).getMsg(); |
|||
} else { |
|||
errorMsg = "未知错误"; |
|||
log.error("【疫苗接种信息导入】出错:{}", ExceptionUtils.getErrorStackTrace(e)); |
|||
} |
|||
|
|||
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|||
errorRow.setName(data.getName()); |
|||
errorRow.setMobile(data.getMobile()); |
|||
errorRow.setIdCard(data.getIdCard()); |
|||
errorRow.setErrorInfo(errorMsg); |
|||
errorRows.add(errorRow); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
// 最后几条达不到阈值,这里必须再调用一次
|
|||
execPersist(); |
|||
} |
|||
|
|||
/** |
|||
* 执行持久化 |
|||
*/ |
|||
private void execPersist() { |
|||
try { |
|||
if (datas != null && datas.size() > 0) { |
|||
icVaccineService.batchPersist(datas, this); |
|||
} |
|||
} finally { |
|||
datas.clear(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 获取错误行 |
|||
* @return |
|||
*/ |
|||
public List<IcVaccineImportExcelData.RowRemarkMessage> getErrorRows() { |
|||
return errorRows; |
|||
} |
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.IcVaccineRelationDTO; |
|||
import com.epmet.entity.IcVaccineRelationEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
public interface IcVaccineRelationService extends BaseService<IcVaccineRelationEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<IcVaccineRelationDTO> |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
PageData<IcVaccineRelationDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<IcVaccineRelationDTO> |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
List<IcVaccineRelationDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return IcVaccineRelationDTO |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
IcVaccineRelationDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
void save(IcVaccineRelationDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
void update(IcVaccineRelationDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-04-06 |
|||
*/ |
|||
void delete(String[] ids); |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.IcVaccineListResultDTO; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
|
|||
import java.nio.file.Path; |
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
public interface IcVaccineService extends BaseService<IcVaccineEntity> { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【核酸】核酸检测信息列表 |
|||
* |
|||
* @param formDTO |
|||
* @return*/ |
|||
PageData<IcVaccineListResultDTO> icVaccineList(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【核酸】核酸检测信息同步 |
|||
**/ |
|||
void synchro(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【核酸】核酸检测信息取消同步 |
|||
**/ |
|||
void cancelSynchro(VaccineListFormDTO formDTO); |
|||
|
|||
/** |
|||
* 执行Excel导入 |
|||
* @param filePath |
|||
*/ |
|||
void execAsyncExcelImport(Path filePath, String importTaskId); |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.dao.IcVaccineRelationDao; |
|||
import com.epmet.dto.IcVaccineRelationDTO; |
|||
import com.epmet.entity.IcVaccineRelationEntity; |
|||
import com.epmet.service.IcVaccineRelationService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 疫苗接种记录关系表 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Service |
|||
public class IcVaccineRelationServiceImpl extends BaseServiceImpl<IcVaccineRelationDao, IcVaccineRelationEntity> implements IcVaccineRelationService { |
|||
|
|||
@Override |
|||
public PageData<IcVaccineRelationDTO> page(Map<String, Object> params) { |
|||
IPage<IcVaccineRelationEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, IcVaccineRelationDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<IcVaccineRelationDTO> list(Map<String, Object> params) { |
|||
List<IcVaccineRelationEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, IcVaccineRelationDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<IcVaccineRelationEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<IcVaccineRelationEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public IcVaccineRelationDTO get(String id) { |
|||
IcVaccineRelationEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, IcVaccineRelationDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(IcVaccineRelationDTO dto) { |
|||
IcVaccineRelationEntity entity = ConvertUtils.sourceToTarget(dto, IcVaccineRelationEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(IcVaccineRelationDTO dto) { |
|||
IcVaccineRelationEntity entity = ConvertUtils.sourceToTarget(dto, IcVaccineRelationEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,433 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.alibaba.excel.EasyExcel; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.AppClientConstant; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.exception.ExceptionUtils; |
|||
import com.epmet.commons.tools.feign.ResultDataResolver; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|||
import com.epmet.commons.tools.utils.FileUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.constants.ImportTaskConstants; |
|||
import com.epmet.dao.IcResiUserDao; |
|||
import com.epmet.dao.IcVaccineDao; |
|||
import com.epmet.dao.IcVaccineRelationDao; |
|||
import com.epmet.dto.form.ImportTaskCommonFormDTO; |
|||
import com.epmet.dto.form.VaccineListFormDTO; |
|||
import com.epmet.dto.result.IcVaccineListResultDTO; |
|||
import com.epmet.dto.result.LoginUserDetailsResultDTO; |
|||
import com.epmet.dto.result.UploadImgResultDTO; |
|||
import com.epmet.entity.IcResiUserEntity; |
|||
import com.epmet.entity.IcVaccineEntity; |
|||
import com.epmet.entity.IcVaccineRelationEntity; |
|||
import com.epmet.excel.data.IcNatImportExcelData; |
|||
import com.epmet.excel.data.IcVaccineImportExcelData; |
|||
import com.epmet.excel.handler.IcVaccineExcelImportListener; |
|||
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|||
import com.epmet.feign.OssFeignClient; |
|||
import com.epmet.service.IcVaccineService; |
|||
import com.epmet.service.UserService; |
|||
import com.github.pagehelper.PageHelper; |
|||
import com.github.pagehelper.PageInfo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.fileupload.FileItem; |
|||
import org.apache.commons.fileupload.FileItemFactory; |
|||
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|||
import org.apache.http.entity.ContentType; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.scheduling.annotation.Async; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.OutputStream; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* 疫苗接种记录 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-04-06 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccineEntity> implements IcVaccineService, ResultDataResolver { |
|||
|
|||
@Autowired |
|||
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|||
@Autowired |
|||
private OssFeignClient ossFeignClient; |
|||
@Autowired |
|||
private IcVaccineRelationDao icVaccineRelationDao; |
|||
@Autowired |
|||
private IcResiUserDao icResiUserDao; |
|||
@Autowired |
|||
private UserService userService; |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 【疫苗】本组织及下级疫苗接种信息列表 |
|||
* |
|||
* @param formDTO |
|||
* @return*/ |
|||
@Override |
|||
public PageData<IcVaccineListResultDTO> icVaccineList(VaccineListFormDTO formDTO) { |
|||
//1.根据是查询客户数据还是本辖区数据走不同逻辑
|
|||
if ("current".equals(formDTO.getSearchType())) { |
|||
//本辖区数据
|
|||
//2.获取工作人员缓存信息
|
|||
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
if (null == staffInfo) { |
|||
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |
|||
} |
|||
formDTO.setAgencyId(staffInfo.getAgencyId()); |
|||
//3.按条件查询业务数据
|
|||
PageInfo<IcVaccineListResultDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) |
|||
.doSelectPageInfo(() -> baseDao.getIcVaccineList(formDTO)); |
|||
return new PageData(data.getList(), data.getTotal()); |
|||
} else if ("all".equals(formDTO.getSearchType())) { |
|||
//客户下数据
|
|||
PageInfo<IcVaccineListResultDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) |
|||
.doSelectPageInfo(() -> baseDao.getCustomerIcVaccineList(formDTO)); |
|||
return new PageData(data.getList(), data.getTotal()); |
|||
} |
|||
|
|||
return new PageData(new ArrayList(), 0); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息同步 |
|||
**/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void synchro(VaccineListFormDTO formDTO) { |
|||
//1.检验疫苗基础信息是否存在
|
|||
IcVaccineEntity entity = baseDao.selectById(formDTO.getIcVaccineId()); |
|||
if (null == entity) { |
|||
log.error(String.format("疫苗记录数据不存在同步失败,疫苗记录Id->%s", formDTO.getIcVaccineId())); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据同步失败,疫苗记录数据不存在"); |
|||
} |
|||
//获取工作人员缓存数据
|
|||
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
if (null == staffInfo) { |
|||
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |
|||
} |
|||
//2.不管是否已存在关系数据都是先删后增
|
|||
icVaccineRelationDao.delRelation(formDTO.getIcVaccineId(), staffInfo.getAgencyId()); |
|||
//3.新增关系数据
|
|||
IcVaccineRelationEntity icVaccineRelationEntity = new IcVaccineRelationEntity(); |
|||
icVaccineRelationEntity.setCustomerId(formDTO.getCustomerId()); |
|||
icVaccineRelationEntity.setIcVaccineId(formDTO.getIcVaccineId()); |
|||
icVaccineRelationEntity.setAgencyId(staffInfo.getAgencyId()); |
|||
icVaccineRelationEntity.setPids(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(staffInfo.getAgencyPIds())?staffInfo.getAgencyPIds()+":"+staffInfo.getAgencyId():staffInfo.getAgencyId()); |
|||
icVaccineRelationEntity.setUserType("synchro"); |
|||
icVaccineRelationDao.insert(icVaccineRelationEntity); |
|||
} |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @Description 【疫苗】疫苗接种信息取消同步 |
|||
* |
|||
* @param formDTO*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void cancelSynchro(VaccineListFormDTO formDTO) { |
|||
//1.获取工作人员缓存数据
|
|||
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
if (null == staffInfo) { |
|||
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |
|||
} |
|||
//1.物理删除关系数据
|
|||
if (icVaccineRelationDao.delRelation(formDTO.getIcVaccineId(), staffInfo.getAgencyId()) < NumConstant.ONE) { |
|||
log.error(String.format("数据取消同步失败,疫苗记录Id->%s", formDTO.getAgencyId())); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "取消同步操作失败"); |
|||
} |
|||
} |
|||
|
|||
@Async |
|||
@Override |
|||
public void execAsyncExcelImport(Path filePath, String importTaskId) { |
|||
String userId = null; |
|||
try { |
|||
userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); |
|||
String app = EpmetRequestHolder.getHeader(AppClientConstant.APP); |
|||
String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); |
|||
|
|||
LoginUserDetailsResultDTO loginUserDetails = userService.getLoginUserDetails(app, client, userId); |
|||
|
|||
String agencyId = loginUserDetails.getAgencyId(); |
|||
|
|||
IcVaccineExcelImportListener listener = new IcVaccineExcelImportListener(userId, agencyId, loginUserDetails.getOrgIdPath().replace(":".concat(agencyId), ""), this); |
|||
|
|||
EasyExcel.read(filePath.toFile(), IcVaccineImportExcelData.class, listener).headRowNumber(2).sheet(0).doRead(); |
|||
|
|||
Path errorDescFile = null; |
|||
String errorDesFileUrl = null; |
|||
|
|||
List<IcVaccineImportExcelData.RowRemarkMessage> errorRows = listener.getErrorRows(); |
|||
List<IcVaccineImportExcelData.RowRemarkMessage> otherRows = listener.getOtherRows(); |
|||
|
|||
boolean failed = errorRows.size() > 0; |
|||
|
|||
// 合并到一起写入
|
|||
errorRows.addAll(otherRows); |
|||
|
|||
// 生成并上传描述文件
|
|||
if (errorRows.size() > 0) { |
|||
try { |
|||
// 文件生成
|
|||
Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_vaccine", "import", "error_des"); |
|||
String fileName = UUID.randomUUID().toString().concat(".xlsx"); |
|||
errorDescFile = errorDescDir.resolve(fileName); |
|||
|
|||
FileItemFactory factory = new DiskFileItemFactory(16, errorDescDir.toFile()); |
|||
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, fileName); |
|||
OutputStream os = fileItem.getOutputStream(); |
|||
|
|||
EasyExcel.write(os, IcNatImportExcelData.RowRemarkMessage.class).sheet("信息列表").doWrite(errorRows); |
|||
// 文件上传oss
|
|||
Result<UploadImgResultDTO> errorDesFileUploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); |
|||
if (errorDesFileUploadResult.success()) { |
|||
errorDesFileUrl = errorDesFileUploadResult.getData().getUrl(); |
|||
} |
|||
|
|||
} finally { |
|||
if (Files.exists(errorDescFile)) { |
|||
Files.delete(errorDescFile); |
|||
} |
|||
} |
|||
} |
|||
|
|||
ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); |
|||
importFinishTaskForm.setTaskId(importTaskId); |
|||
importFinishTaskForm.setProcessStatus(failed ? ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL : ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); |
|||
importFinishTaskForm.setOperatorId(userId); |
|||
importFinishTaskForm.setResultDesc(""); |
|||
importFinishTaskForm.setResultDescFilePath(errorDesFileUrl); |
|||
|
|||
Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); |
|||
if (!result.success()) { |
|||
log.error("【疫苗接种导入】finishImportTask失败"); |
|||
} |
|||
} catch (Exception e) { |
|||
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|||
log.error("【疫苗接种导入】出错:{}", errorMsg); |
|||
|
|||
ImportTaskCommonFormDTO importFinishTaskForm = new ImportTaskCommonFormDTO(); |
|||
importFinishTaskForm.setTaskId(importTaskId); |
|||
importFinishTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); |
|||
importFinishTaskForm.setOperatorId(userId); |
|||
importFinishTaskForm.setResultDesc("导入失败"); |
|||
|
|||
Result result = commonServiceOpenFeignClient.finishImportTask(importFinishTaskForm); |
|||
if (!result.success()) { |
|||
log.error("【疫苗接种导入】导入记录状态修改为'完成'失败"); |
|||
} |
|||
} finally { |
|||
// 删除临时文件
|
|||
if (Files.exists(filePath)) { |
|||
try { |
|||
Files.delete(filePath); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 批量持久化 |
|||
* @param entities |
|||
*/ |
|||
public void batchPersist(List<IcVaccineEntity> entities, IcVaccineExcelImportListener listener) { |
|||
String customerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID); |
|||
String currentUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID); |
|||
|
|||
entities.forEach(e -> { |
|||
try { |
|||
persisVaccine(e, customerId, currentUserId, listener); |
|||
} catch (Exception exception) { |
|||
String errorMsg = ExceptionUtils.getErrorStackTrace(exception); |
|||
log.error(errorMsg); |
|||
|
|||
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|||
errorRow.setName(e.getName()); |
|||
errorRow.setMobile(e.getMobile()); |
|||
errorRow.setIdCard(e.getIdCard()); |
|||
errorRow.setErrorInfo("未知系统错误"); |
|||
listener.getErrorRows().add(errorRow); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 单条持久化 |
|||
* @param e |
|||
* @param customerId |
|||
* @param currentUserId |
|||
* @param listener |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void persisVaccine(IcVaccineEntity e, String customerId, String currentUserId, IcVaccineExcelImportListener listener) { |
|||
List<IcVaccineImportExcelData.RowRemarkMessage> otherRows = listener.getOtherRows(); |
|||
String agencyPids = listener.getCurrentAgencyPids(); |
|||
String agencyId = listener.getCurrentAgencyId(); |
|||
|
|||
String idCard = e.getIdCard(); |
|||
String name = e.getName(); |
|||
String mobile = e.getMobile(); |
|||
String manufacturer = e.getManufacturer(); |
|||
Date inoculateTime = e.getInoculateTime(); |
|||
String inoculateAddress = e.getInoculateAddress(); |
|||
|
|||
//1.先看客户下有没有这个人
|
|||
IcVaccineEntity resiVaccine = getResiVaccine(customerId, idCard, inoculateTime); |
|||
if (resiVaccine != null && !"import".equals(resiVaccine.getUserType())) { |
|||
// 有这个人,并且不是导入的
|
|||
String message = "已存在该次疫苗接种录入记录,请到系统中修改"; |
|||
|
|||
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|||
errorRow.setName(name); |
|||
errorRow.setMobile(mobile); |
|||
errorRow.setIdCard(idCard); |
|||
errorRow.setErrorInfo(message); |
|||
otherRows.add(errorRow); |
|||
return; |
|||
} |
|||
|
|||
if (resiVaccine != null) { |
|||
boolean needUpdate = false; |
|||
|
|||
// 有这个人,也是导入的,那就要更新le
|
|||
Boolean isNameChanged = false; |
|||
if (!name.equals(resiVaccine.getName())) { |
|||
isNameChanged = true; |
|||
resiVaccine.setName(name); |
|||
needUpdate = true; |
|||
} |
|||
|
|||
if (!inoculateAddress.equals(resiVaccine.getInoculateAddress())) { |
|||
resiVaccine.setInoculateAddress(inoculateAddress); |
|||
needUpdate = true; |
|||
} |
|||
|
|||
if (!manufacturer.equals(resiVaccine.getManufacturer())) { |
|||
resiVaccine.setManufacturer(manufacturer); |
|||
needUpdate = true; |
|||
} |
|||
|
|||
if (!mobile.equals(resiVaccine.getMobile())) { |
|||
resiVaccine.setMobile(mobile); |
|||
needUpdate = true; |
|||
} |
|||
|
|||
if (isNameChanged) { |
|||
String message = "平台存在相同记录身份证号与姓名不一致,已更新最新姓名"; |
|||
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|||
errorRow.setName(name); |
|||
errorRow.setMobile(mobile); |
|||
errorRow.setIdCard(idCard); |
|||
errorRow.setErrorInfo(message); |
|||
otherRows.add(errorRow); |
|||
} |
|||
|
|||
if (needUpdate) { |
|||
resiVaccine.setUpdatedBy(currentUserId); |
|||
resiVaccine.setUpdatedTime(new Date()); |
|||
|
|||
IcResiUserEntity resi = getResi(customerId, idCard, null); |
|||
resiVaccine.setIsResiUser(resi != null ? "1" : "0"); |
|||
|
|||
baseDao.updateById(resiVaccine); |
|||
} |
|||
|
|||
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|||
if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { |
|||
createVaccineRelation(resiVaccine.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); |
|||
} |
|||
|
|||
return; |
|||
} |
|||
|
|||
// 执行新增操作
|
|||
IcResiUserEntity resi = getResi(customerId, idCard, null); |
|||
e.setIsResiUser(resi != null ? "1" : "0"); |
|||
e.setUserType("import"); |
|||
|
|||
baseDao.insert(e); |
|||
|
|||
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|||
if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { |
|||
createVaccineRelation(e.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 是否是指定条件下的居民; |
|||
* 0:否 |
|||
* 1:是 |
|||
* @param customerId |
|||
* @param idCard |
|||
* @return |
|||
*/ |
|||
public IcResiUserEntity getResi(String customerId, String idCard, String pids) { |
|||
LambdaQueryWrapper<IcResiUserEntity> query = new LambdaQueryWrapper(); |
|||
query.eq(IcResiUserEntity::getCustomerId, customerId); |
|||
query.eq(IcResiUserEntity::getIdCard, idCard); |
|||
if (StringUtils.isNotBlank(pids)) { |
|||
query.likeRight(IcResiUserEntity::getPids, pids); |
|||
} |
|||
return icResiUserDao.selectOne(query); |
|||
} |
|||
|
|||
/** |
|||
* |
|||
* @param customerId |
|||
* @param idCard |
|||
* @return |
|||
*/ |
|||
public IcVaccineEntity getResiVaccine(String customerId, String idCard, Date natTime) { |
|||
LambdaQueryWrapper<IcVaccineEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(IcVaccineEntity::getCustomerId, customerId); |
|||
query.eq(IcVaccineEntity::getIdCard, idCard); |
|||
query.eq(IcVaccineEntity::getInoculateTime, natTime); |
|||
return baseDao.selectOne(query); |
|||
} |
|||
|
|||
/** |
|||
* 创建关系 |
|||
* @param vaccineId |
|||
* @param currentUserAgencyId |
|||
*/ |
|||
private void createVaccineRelation(String vaccineId, String currentUserAgencyId, String agencyPids) { |
|||
|
|||
// 没有关系创建关系,有关系就跳过
|
|||
LambdaQueryWrapper<IcVaccineRelationEntity> query = new LambdaQueryWrapper<>(); |
|||
query.eq(IcVaccineRelationEntity::getIcVaccineId, vaccineId); |
|||
query.eq(IcVaccineRelationEntity::getAgencyId, currentUserAgencyId); |
|||
if (icVaccineRelationDao.selectCount(query) > 0) { |
|||
return; |
|||
} |
|||
|
|||
IcVaccineRelationEntity relation = new IcVaccineRelationEntity(); |
|||
relation.setAgencyId(currentUserAgencyId); |
|||
relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId))); |
|||
relation.setIcVaccineId(vaccineId); |
|||
relation.setUserType("import"); |
|||
icVaccineRelationDao.insert(relation); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,41 @@ |
|||
#添加 疫苗接种相关表 |
|||
CREATE TABLE `ic_vaccine` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '唯一标识', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id customer.id', |
|||
`NAME` varchar(64) NOT NULL COMMENT '姓名', |
|||
`MOBILE` varchar(11) NOT NULL COMMENT '手机号', |
|||
`ID_CARD` varchar(18) NOT NULL COMMENT '身份证号', |
|||
`IS_RESI_USER` varchar(1) NOT NULL DEFAULT '0' COMMENT '是否客户下居民(0:否 1:是)', |
|||
`USER_TYPE` varchar(32) NOT NULL COMMENT '数据来源【导入的:import;】', |
|||
`INOCULATE_TIME` datetime NOT NULL COMMENT '接种时间', |
|||
`INOCULATE_ADDRESS` varchar(32) NOT NULL DEFAULT '' COMMENT '接种地点', |
|||
`MANUFACTURER` varchar(32) NOT NULL DEFAULT '' COMMENT '疫苗厂家', |
|||
`FIELD1` varchar(32) DEFAULT NULL COMMENT '预留字段1', |
|||
`FIELD2` varchar(255) DEFAULT NULL COMMENT '预留字段2', |
|||
`FIELD3` varchar(255) DEFAULT NULL COMMENT '预留字段3', |
|||
`REMARK` varchar(255) DEFAULT NULL COMMENT '备注', |
|||
`DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', |
|||
`REVISION` int(2) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE, |
|||
KEY `idx_ic_card` (`ID_CARD`) USING BTREE |
|||
) COMMENT='疫苗接种记录'; |
|||
|
|||
CREATE TABLE `ic_vaccine_relation` ( |
|||
`ID` varchar(64) NOT NULL COMMENT 'ID', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id', |
|||
`AGENCY_ID` varchar(64) NOT NULL COMMENT '居民端上报时存储用户所在网格的组织id.居民信息的人存储居民所在组织id.单个新增或者导入的存储登录用户所属的组织id', |
|||
`PIDS` varchar(255) NOT NULL COMMENT '组织pids,包含当前agencyId值', |
|||
`IC_VACCINE_ID` varchar(64) NOT NULL COMMENT '疫苗记录表Id(ic_vaccine.id)', |
|||
`USER_TYPE` varchar(32) NOT NULL COMMENT '关系数据的绑定途径【\r\n数字社区录入:icresi;\r\n导入的:import;\r\n同步的:synchro】', |
|||
`DEL_FLAG` int(1) NOT NULL COMMENT '删除标识', |
|||
`REVISION` int(2) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) COMMENT='疫苗接种记录关系表'; |
Binary file not shown.
@ -0,0 +1,176 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.IcVaccineDao"> |
|||
<select id="getMyNatList" resultType="com.epmet.dto.result.MyNatListResultDTO"> |
|||
SELECT |
|||
id icNatId, |
|||
user_id userId, |
|||
user_type userType, |
|||
`name` `name`, |
|||
mobile mobile, |
|||
id_card idCard, |
|||
nat_time natTime, |
|||
nat_result natResult, |
|||
nat_address natAddress, |
|||
file_name fileName, |
|||
attachment_url attachmentUrl, |
|||
created_time reportTime |
|||
FROM |
|||
ic_nat |
|||
WHERE |
|||
del_flag = '0' |
|||
AND customer_id = #{customerId} |
|||
AND ( |
|||
CREATED_BY = #{userId} |
|||
<if test='null != idCard and "" != idCard'> |
|||
OR id_card = #{idCard} |
|||
</if> |
|||
) |
|||
ORDER BY nat_time DESC |
|||
</select> |
|||
|
|||
<select id="getIcVaccineList" resultType="com.epmet.dto.result.NatListResultDTO"> |
|||
SELECT |
|||
a.ic_nat_id icNatId, |
|||
a.agency_id agencyId, |
|||
a.user_type userType, |
|||
b.user_id userId, |
|||
b.is_resi_user isResiUser, |
|||
b.`name` `name`, |
|||
b.mobile mobile, |
|||
b.id_card idCard, |
|||
b.nat_time natTime, |
|||
b.nat_result natResult, |
|||
b.nat_address natAddress |
|||
FROM |
|||
ic_nat_relation a |
|||
INNER JOIN ic_nat b ON a.IC_NAT_ID = b.ID |
|||
WHERE |
|||
a.DEL_FLAG = '0' |
|||
AND b.DEL_FLAG = '0' |
|||
AND a.customer_id = #{customerId} |
|||
AND a.pids like concat('%', #{agencyId}, '%') |
|||
<if test='null != name and "" != name'> |
|||
AND b.name like concat('%', #{name}, '%') |
|||
</if> |
|||
<if test='null != mobile and "" != mobile'> |
|||
AND b.mobile = #{mobile} |
|||
</if> |
|||
<if test='null != idCard and "" != idCard'> |
|||
AND b.id_card = #{idCard} |
|||
</if> |
|||
<if test='null != startTime and "" != startTime'> |
|||
AND b.nat_time <![CDATA[ >= ]]> #{startTime} |
|||
</if> |
|||
<if test='null != endTime and "" != endTime'> |
|||
AND b.nat_time <![CDATA[ <= ]]> #{endTime} |
|||
</if> |
|||
<if test='null != isResiUser and "" != isResiUser'> |
|||
AND b.is_resi_user = #{isResiUser} |
|||
</if> |
|||
ORDER BY b.nat_time DESC, b.id ASC |
|||
</select> |
|||
|
|||
<select id="getCustomerIcVaccineList" resultType="com.epmet.dto.result.NatListResultDTO"> |
|||
SELECT |
|||
id icNatId, |
|||
user_id userId, |
|||
is_resi_user isResiUser, |
|||
user_type userType, |
|||
`name` `name`, |
|||
mobile mobile, |
|||
id_card idCard, |
|||
nat_time natTime, |
|||
nat_result natResult, |
|||
nat_address natAddress |
|||
FROM |
|||
ic_nat |
|||
WHERE |
|||
del_flag = '0' |
|||
AND customer_id = #{customerId} |
|||
<if test='null != name and "" != name'> |
|||
AND name like concat('%', #{name}, '%') |
|||
</if> |
|||
<if test='null != mobile and "" != mobile'> |
|||
AND mobile = #{mobile} |
|||
</if> |
|||
<if test='null != idCard and "" != idCard'> |
|||
AND id_card = #{idCard} |
|||
</if> |
|||
<if test='null != startTime and "" != startTime'> |
|||
AND nat_time <![CDATA[ >= ]]> #{startTime} |
|||
</if> |
|||
<if test='null != endTime and "" != endTime'> |
|||
AND nat_time <![CDATA[ <= ]]> #{endTime} |
|||
</if> |
|||
ORDER BY nat_time DESC, id ASC |
|||
</select> |
|||
|
|||
<select id="getNatDTO" resultType="com.epmet.dto.IcNatDTO"> |
|||
SELECT |
|||
id, |
|||
user_id, |
|||
user_type, |
|||
`name`, |
|||
mobile, |
|||
id_card, |
|||
nat_time, |
|||
nat_result, |
|||
nat_address |
|||
FROM |
|||
ic_nat |
|||
WHERE |
|||
del_flag = '0' |
|||
AND customer_id = #{customerId} |
|||
AND id_card = #{idCard} |
|||
AND DATE_FORMAT(nat_time, '%Y-%m-%d %h:%i') = DATE_FORMAT(#{natTime}, '%Y-%m-%d %h:%i') |
|||
<if test='null != natResult and "" != natResult'> |
|||
AND nat_result = #{natResult} |
|||
</if> |
|||
<if test='null != icNatId and "" != icNatId'> |
|||
AND id != #{icNatId} |
|||
</if> |
|||
LIMIT 1 |
|||
</select> |
|||
|
|||
<delete id="delById"> |
|||
DELETE FROM ic_nat WHERE id = #{icNatId} |
|||
</delete> |
|||
|
|||
<insert id="insertOrUpdate"> |
|||
INSERT INTO epmet_user.ic_nat |
|||
(ID, CUSTOMER_ID, AGENCY_ID, PIDS, USER_ID, |
|||
USER_TYPE, NAME, MOBILE, ID_CARD, NAT_TIME, NAT_RESULT, NAT_ADDRESS, FILE_NAME, ATTACHMENT_TYPE, ATTACHMENT_URL, |
|||
DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) |
|||
VALUES (#{id}, #{customerId}, #{agencyId}, #{pids}, #{userId}, |
|||
#{userType}, #{name}, #{mobile}, #{idCard}, #{natTime}, |
|||
#{natResult}, #{natAddress}, #{fileName}, #{attachmentType}, #{attachmentUrl}, |
|||
#{delFlag}, #{revision}, #{createdBy}, #{createdTime}, #{updatedBy}, |
|||
#{updatedTime}) |
|||
ON DUPLICATE KEY update |
|||
NAME=#{name}, |
|||
MOBILE=#{mobile}, |
|||
NAT_ADDRESS=#{natAddress}, |
|||
NAT_RESULT=#{natResult}, |
|||
UPDATED_BY=#{updatedBy}, |
|||
UPDATED_TIME=NOW() |
|||
</insert> |
|||
<update id="updateIsResiFlag"> |
|||
UPDATE ic_nat m, |
|||
( |
|||
SELECT if(DEL_FLAG,0,1) resiFlag, ID_CARD FROM ic_resi_user |
|||
WHERE |
|||
1=1 |
|||
<if test="icResiUserId != null and icResiUserId != ''"> |
|||
AND ID = #{icResiUserId} |
|||
</if> |
|||
AND CUSTOMER_ID = #{customerId} |
|||
AND DEL_FLAG = '0' |
|||
) t |
|||
SET m.IS_RESI_USER = t.resiFlag |
|||
WHERE |
|||
m.ID_CARD = t.ID_CARD |
|||
AND m.DEL_FLAG = '0' |
|||
</update> |
|||
</mapper> |
@ -0,0 +1,16 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.IcVaccineRelationDao"> |
|||
|
|||
<delete id="delRelation"> |
|||
DELETE |
|||
FROM ic_nat_relation |
|||
WHERE |
|||
ic_nat_id = #{icNatId} |
|||
<if test='null != agencyId and "" != agencyId'> |
|||
AND AGENCY_ID = #{agencyId} |
|||
</if> |
|||
</delete> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue