Commit f41db72e by wqc

死亡系统

parent 241430e0
......@@ -165,17 +165,17 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.12.0</version>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
......
......@@ -11,4 +11,5 @@ import org.springframework.stereotype.Repository;
@DS(DBName.GXBZ)
public interface ReportDeathDao extends BaseMapper<ReportDeath> {
ReportDeath selectByIdCard(String idCard);
}
package com.zq.system.modules.system.domain.vo;
import com.zq.common.vo.PageReqVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
*
*
......@@ -16,7 +19,9 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ReportDeathVo {
public class ReportDeathVo extends PageReqVo {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
......@@ -30,16 +35,28 @@ public class ReportDeathVo {
@ApiModelProperty("死亡地点")
private String deathPlace;
@ApiModelProperty("死亡时间")
private String deathDate;
@ApiModelProperty("备注")
private String notes;
@ApiModelProperty("来源系统")
private String source;
@ApiModelProperty("上报人区域")
private String userArea;
@ApiModelProperty("上报人用户")
private String userName;
@ApiModelProperty("上报人用户")
private String deathType;
@ApiModelProperty("上报人时间")
private String createTime;
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
......@@ -44,16 +44,28 @@ public class ReportDeath {
@ApiModelProperty("死亡地点")
private String deathPlace;
@ApiModelProperty("死亡时间")
private String deathDate;
@ApiModelProperty("备注")
private String notes;
@ApiModelProperty("来源系统")
private String source;
@ApiModelProperty("上报人区域")
private String userArea;
@ApiModelProperty("上报人用户")
private String userName;
@ApiModelProperty("死亡状态")
private String deathType;
@ApiModelProperty("上报人时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
}
......@@ -2,36 +2,65 @@ package com.zq.system.modules.system.rest;
import com.zq.common.annotation.AnonymousAccess;
import com.zq.common.annotation.rest.AnonymousPostMapping;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.PageVo;
import com.zq.common.vo.ResultVo;
import com.zq.system.modules.system.domain.vo.ReportDeathVo;
import com.zq.system.modules.system.entity.ReportDeath;
import com.zq.system.modules.system.service.ReportDeathService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequiredArgsConstructor
@Api(tags = "死亡登记")
@RequestMapping("/death/regist")
@RequestMapping("/sys/death")
public class DeathRegisterController {
private final ReportDeathService reportDeathService;
@ApiOperation("死亡上报")
@AnonymousPostMapping(value = "/report")
@Transactional(rollbackFor = Exception.class)
public ResultVo register(@RequestBody ReportDeathVo vo) {
AssertUtils.hasText(vo.getDeathPlace(),"死亡地点未填写");
AssertUtils.notNull(vo.getIdCard(),"死者身份证未填写");
reportDeathService.save(vo);
return ResultVo.success("上报成功");
}
@ApiOperation("导入死亡登记表")
@AnonymousAccess
@PostMapping(value = "/importDeath")
public ResultVo importDeath(MultipartFile file) throws Exception {
AssertUtils.isTrue(file != null && file.getSize() > 0, "请选择文件");
return ResultVo.success(reportDeathService.importDeath(file));
}
@ApiOperation("获取死亡列表")
@PostMapping(value = "/getDeathList")
public ResultVo<PageVo<ReportDeath>> getDeathList(@RequestBody ReportDeathVo vo) {
return ResultVo.success(reportDeathService.getDeathList(vo));
}
@ApiOperation("获取死亡人详情")
@PostMapping(value = "/getDeathDetail")
public ResultVo getDeathDetail(@RequestBody ReportDeathVo vo) {
return ResultVo.success(reportDeathService.getDeathDetail(vo));
}
@ApiOperation("修改死亡数据")
@PostMapping(value = "/updateDeath")
public ResultVo updateDeath(@RequestBody ReportDeathVo vo) {
return ResultVo.success(reportDeathService.updateDeath(vo));
}
}
package com.zq.system.modules.system.service;
import com.zq.common.vo.PageVo;
import com.zq.common.vo.ResultVo;
import com.zq.system.modules.system.domain.vo.ReportDeathVo;
import com.zq.system.modules.system.entity.ReportDeath;
import org.springframework.web.multipart.MultipartFile;
public interface ReportDeathService {
void save(ReportDeathVo vo);
ResultVo save(ReportDeathVo vo);
Object importDeath(MultipartFile file);
PageVo<ReportDeath> getDeathList(ReportDeathVo vo);
Object getDeathDetail(ReportDeathVo vo);
ResultVo updateDeath(ReportDeathVo vo);
}
......@@ -303,7 +303,7 @@ public class SsoService {
}
public Object selectArea() {
return areaCodeDao.selectList(Wrappers.lambdaQuery(AreaCode.builder().admindivLevel("5").build()));
return areaCodeDao.selectList(Wrappers.lambdaQuery(AreaCode.builder().build()).last("WHERE ADMINDIV_LEVEL<=5 AND COUNTY_NAME IS NOT NULL AND TOWN_NAME IS NOT NULL"));
}
}
package com.zq.system.modules.system.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zq.common.constant.DBName;
import com.zq.common.context.ContextUtils;
import com.zq.common.exception.BusinessException;
import com.zq.common.utils.AssertUtils;
import com.zq.common.utils.PagingUtils;
import com.zq.common.vo.PageVo;
import com.zq.common.vo.ResultVo;
import com.zq.system.modules.system.dao.ReportDeathDao;
import com.zq.system.modules.system.domain.User;
import com.zq.system.modules.system.domain.vo.ReportDeathVo;
import com.zq.system.modules.system.entity.BindUserInfo;
import com.zq.system.modules.system.entity.ReportDeath;
import com.zq.system.modules.system.repository.UserRepository;
import com.zq.system.modules.system.service.ReportDeathService;
import com.zq.system.modules.system.service.SsoService;
import com.zq.system.modules.system.service.UserService;
import com.zq.system.modules.system.service.dto.UserDto;
import com.zq.system.utils.SecurityUtils;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
@Service
@RequiredArgsConstructor
public class ReportDeathImpl implements ReportDeathService {
private final ReportDeathDao reportDeathDao;
private final UserRepository userRepository;
private final SsoService ssoService;
@Override
@DS(DBName.GXBZ)
@Transactional
public void save(ReportDeathVo vo) {
public ResultVo save(ReportDeathVo vo) {
ReportDeath Death=reportDeathDao.selectByIdCard(vo.getIdCard());
if (Death!=null){
return ResultVo.fail("改死者已重复上报");
}else {
ReportDeath reportDeath = new ReportDeath();
reportDeath.setName(vo.getName());
reportDeath.setIdCard(vo.getIdCard());
......@@ -29,7 +59,95 @@ public class ReportDeathImpl implements ReportDeathService {
reportDeath.setUserArea(vo.getUserArea());
reportDeath.setNotes(vo.getNotes());
reportDeath.setUserName(vo.getUserName());
reportDeath.setSource(vo.getSource());
reportDeath.setDeathType("1");
reportDeath.setCreateTime(DateUtil.date());
reportDeathDao.insert(reportDeath);
}
return ResultVo.success(reportDeathDao.selectList(Wrappers.lambdaQuery(null)));
}
@Override
public Object importDeath(MultipartFile file) {
User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername());
ExcelReader reader;
try {
reader = ExcelUtil.getReader(file.getInputStream());
} catch (IOException e) {
e.printStackTrace();
throw new BusinessException("文件解析失败");
}
List<List<Object>> readList = reader.read(1);
for (List<Object> objectList : readList) {
ReportDeath reportDeath = new ReportDeath();
reportDeath.setName(Convert.toStr(CollUtil.get(objectList, 0)));
reportDeath.setIdCard(Convert.toStr(CollUtil.get(objectList, 1)));
reportDeath.setDeathDate(Convert.toStr(CollUtil.get(objectList, 2)));
reportDeath.setDeathReason(Convert.toStr(CollUtil.get(objectList, 3)));
reportDeath.setDeathPlace(Convert.toStr(CollUtil.get(objectList, 4)));
reportDeath.setNotes(Convert.toStr(CollUtil.get(objectList, 5)));
reportDeath.setUserName(Convert.toStr(CollUtil.get(objectList, 6)));
reportDeath.setCreateTime(DateUtil.date());
reportDeath.setUserArea(user.getUserArea());
reportDeath.setDeathType("1");
ReportDeath reportDeaths = reportDeathDao.selectOne(Wrappers.lambdaQuery(ReportDeath.builder().idCard(Convert.toStr(CollUtil.get(objectList, 2))).build()));
if (reportDeaths!=null){
return "已上报过该死者"+reportDeaths.getName()+"信息";
}else {
reportDeathDao.insert(reportDeath);
}
}
return null;
}
@Override
public PageVo<ReportDeath> getDeathList(ReportDeathVo vo) {
LambdaQueryWrapper<ReportDeath> lambdaQuery = Wrappers.lambdaQuery(ReportDeath.builder().build());
if (StringUtils.isNotBlank(vo.getIdCard())){
lambdaQuery.like(ReportDeath::getIdCard,vo.getIdCard());
}
if (StringUtils.isNotBlank(vo.getName())){
lambdaQuery.like(ReportDeath::getName,vo.getName());
}
if (StringUtils.isNotBlank(vo.getDeathType())) {
lambdaQuery.like(ReportDeath::getDeathType,vo.getDeathType());
}
PageVo<ReportDeath> paging = PagingUtils.paging(vo, reportDeathDao, lambdaQuery);
return paging;
}
@Override
public Object getDeathDetail(ReportDeathVo vo) {
return reportDeathDao.selectById(vo.getId());
}
@Override
public ResultVo updateDeath(ReportDeathVo vo) {
List<BindUserInfo> bindSysList = ssoService.getBindSysList();
for (BindUserInfo bindUser:bindSysList) {
if (bindUser.getSysId()==3||bindUser.getSysId()==9||bindUser.getSysId()==4) {
User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername());
ReportDeath reportDeath = reportDeathDao.selectById(vo.getId());
AssertUtils.notNull(reportDeath, "无此条记录");
ReportDeath death = new ReportDeath();
death.setId(vo.getId());
death.setName(vo.getName());
death.setIdCard(vo.getIdCard());
death.setDeathPlace(vo.getDeathPlace());
death.setDeathReason(vo.getDeathReason());
death.setDeathDate(vo.getDeathDate());
death.setDeathType(vo.getDeathType());
death.setNotes(vo.getNotes());
death.setSource(vo.getSource());
death.setUserArea(user.getUserArea());
death.setUserName(reportDeath.getUserName());
death.setUpdateTime(DateUtil.date());
reportDeathDao.updateById(death);
return ResultVo.success("标注成功");
}else{
return ResultVo.fail("无权限修改");
}
}
return ResultVo.success();
}
}
<?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.zq.system.modules.system.dao.ReportDeathDao">
<resultMap id="BaseResultMap" type="com.zq.system.modules.system.entity.ReportDeath">
<!--@Table DATA_TABLE-->
<result property="id" column="id" jdbcType="OTHER"/>
<result property="name" column="NAME" jdbcType="OTHER"/>
<result property="idCard" column="ID_CARD" jdbcType="OTHER"/>
<result property="deathReason" column="DEATH_REASON" jdbcType="OTHER"/>
<result property="deathPlace" column="DEATH_PLACE" jdbcType="OTHER"/>
<result property="deathDate" column="DEATH_DATE" jdbcType="OTHER"/>
<result property="notes" column="NOTES" jdbcType="OTHER"/>
<result property="source" column="SOURCE" jdbcType="OTHER"/>
<result property="userArea" column="USER_AREA" jdbcType="OTHER"/>
<result property="userName" column="USER_NAME" jdbcType="OTHER"/>
<result property="deathType" column="DEATH_TYPE" jdbcType="OTHER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="selectByIdCard" resultMap="BaseResultMap">
select * from report_death t where t.ID_CARD=#{idCard}
</select>
<!-- <update id="updateByappId">-->
<!-- UPDATE report_death-->
<!-- <set>-->
<!-- <if test="appId != null">-->
<!-- app_id = #{appId, jdbcType=OTHER},-->
<!-- </if>-->
<!-- <if test="systemName != null">-->
<!-- system_name = #{systemName, jdbcType=OTHER},-->
<!-- </if>-->
<!-- <if test="systemTag != null">-->
<!-- system_tag = #{systemTag, jdbcType=OTHER},-->
<!-- </if>-->
<!-- <if test="createTime != null">-->
<!-- create_time = #{createTime, jdbcType=TIMESTAMP},-->
<!-- </if>-->
<!-- <if test="updateTime != null">-->
<!-- update_time = #{updateTime, jdbcType=TIMESTAMP},-->
<!-- </if>-->
<!-- </set>-->
<!-- WHERE app_id = #{appId}-->
<!-- </update>-->
</mapper>
\ No newline at end of file
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