diff --git a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcHkbgRecard.java b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcHkbgRecard.java index 1b6312e..f456ba9 100644 --- a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcHkbgRecard.java +++ b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcHkbgRecard.java @@ -12,7 +12,7 @@ import java.util.Date; * 户口变更记录对象 szxc_hkbg_recard * * @author hs - * @date 2024-03-26 + * @date 2024-03-27 */ public class SzxcHkbgRecard extends BaseEntity { @@ -53,8 +53,8 @@ public class SzxcHkbgRecard extends BaseEntity @Excel(name = "变更原因(字典)") private String bgReason; - /** 原居民id */ - @Excel(name = "原居民id") + /** 新居民id */ + @Excel(name = "新居民id") private Long xJmId; /** 新户主姓名 */ @@ -69,15 +69,23 @@ public class SzxcHkbgRecard extends BaseEntity @Excel(name = "与户主关系") private String relation; - /** 变更编号 */ - @Excel(name = "变更编号") - private String number; - /** 变更时间 */ @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "变更时间", width = 30, dateFormat = "yyyy-MM-dd") private Date bgTime; + /** 户籍地址 */ + @Excel(name = "户籍地址") + private String hjAddress; + + /** 户籍性质 */ + @Excel(name = "户籍性质") + private String jgNature; + + /** 是否常住(0是 1否) */ + @Excel(name = "是否常住", readConverterExp = "0=是,1=否") + private String longLive; + /** 部门id */ @Excel(name = "部门id") private Long deptId; @@ -86,6 +94,10 @@ public class SzxcHkbgRecard extends BaseEntity @Excel(name = "创建者ID") private Long userId; + /** 所属网格 */ + @Excel(name = "所属网格") + private String deptName; + public void setId(Long id) { this.id = id; @@ -203,23 +215,41 @@ public class SzxcHkbgRecard extends BaseEntity { return relation; } - public void setNumber(String number) + public void setBgTime(Date bgTime) { - this.number = number; + this.bgTime = bgTime; } - public String getNumber() + public Date getBgTime() { - return number; + return bgTime; } - public void setBgTime(Date bgTime) + public void setHjAddress(String hjAddress) { - this.bgTime = bgTime; + this.hjAddress = hjAddress; } - public Date getBgTime() + public String getHjAddress() { - return bgTime; + return hjAddress; + } + public void setJgNature(String jgNature) + { + this.jgNature = jgNature; + } + + public String getJgNature() + { + return jgNature; + } + public void setLongLive(String longLive) + { + this.longLive = longLive; + } + + public String getLongLive() + { + return longLive; } public void setDeptId(Long deptId) { @@ -239,6 +269,15 @@ public class SzxcHkbgRecard extends BaseEntity { return userId; } + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public String getDeptName() + { + return deptName; + } @Override public String toString() { @@ -256,8 +295,10 @@ public class SzxcHkbgRecard extends BaseEntity .append("xName", getxName()) .append("xIdCard", getxIdCard()) .append("relation", getRelation()) - .append("number", getNumber()) .append("bgTime", getBgTime()) + .append("hjAddress", getHjAddress()) + .append("jgNature", getJgNature()) + .append("longLive", getLongLive()) .append("remark", getRemark()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) @@ -265,6 +306,7 @@ public class SzxcHkbgRecard extends BaseEntity .append("updateTime", getUpdateTime()) .append("deptId", getDeptId()) .append("userId", getUserId()) + .append("deptName", getDeptName()) .toString(); } } diff --git a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcJmInfo.java b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcJmInfo.java index 6cb4791..125122b 100644 --- a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcJmInfo.java +++ b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/domain/SzxcJmInfo.java @@ -52,7 +52,7 @@ public class SzxcJmInfo extends BaseEntity /** 年龄 */ @Excel(name = "年龄") - private Long age; + private Integer age; /** 性别(0男 1女 2未知) */ @Excel(name = "性别", readConverterExp = "0=男,1=女,2=未知") @@ -206,12 +206,12 @@ public class SzxcJmInfo extends BaseEntity { return bornDate; } - public void setAge(Long age) + public void setAge(Integer age) { this.age = age; } - public Long getAge() + public Integer getAge() { return age; } diff --git a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcHkbgRecardServiceImpl.java b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcHkbgRecardServiceImpl.java index 38e6ae9..8947a67 100644 --- a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcHkbgRecardServiceImpl.java +++ b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcHkbgRecardServiceImpl.java @@ -1,12 +1,16 @@ package com.ruoyi.szxc.service.impl; -import java.util.List; import com.ruoyi.common.utils.DateUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.szxc.mapper.SzxcHkbgRecardMapper; import com.ruoyi.szxc.domain.SzxcHkbgRecard; +import com.ruoyi.szxc.domain.SzxcJmInfo; +import com.ruoyi.szxc.mapper.SzxcHkbgRecardMapper; +import com.ruoyi.szxc.mapper.SzxcJmInfoMapper; import com.ruoyi.szxc.service.ISzxcHkbgRecardService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; /** * 户口变更记录Service业务层处理 @@ -17,8 +21,10 @@ import com.ruoyi.szxc.service.ISzxcHkbgRecardService; @Service public class SzxcHkbgRecardServiceImpl implements ISzxcHkbgRecardService { - @Autowired + @Resource private SzxcHkbgRecardMapper szxcHkbgRecardMapper; + @Resource + private SzxcJmInfoMapper szxcJmInfoMapper; /** * 查询户口变更记录 @@ -51,8 +57,25 @@ public class SzxcHkbgRecardServiceImpl implements ISzxcHkbgRecardService * @return 结果 */ @Override + @Transactional public int insertSzxcHkbgRecard(SzxcHkbgRecard szxcHkbgRecard) { + //先修改居民所属户主信息 + SzxcJmInfo jmInfo = new SzxcJmInfo(); + jmInfo.setAcountNo(szxcHkbgRecard.getAcountNo()); + jmInfo.setDeptId(szxcHkbgRecard.getDeptId()); + jmInfo.setDeptName(szxcHkbgRecard.getDeptName()); + jmInfo.setHjAddress(szxcHkbgRecard.getHjAddress()); + jmInfo.setRelation(szxcHkbgRecard.getRelation()); + jmInfo.setLongLive(szxcHkbgRecard.getLongLive()); + jmInfo.setJgNature(szxcHkbgRecard.getJgNature()); + try { + szxcJmInfoMapper.updateSzxcJmInfo(jmInfo); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + //添加户口变更记录 szxcHkbgRecard.setCreateTime(DateUtils.getNowDate()); return szxcHkbgRecardMapper.insertSzxcHkbgRecard(szxcHkbgRecard); } diff --git a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcJmInfoServiceImpl.java b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcJmInfoServiceImpl.java index f3ea76f..8856a6d 100644 --- a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcJmInfoServiceImpl.java +++ b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/service/impl/SzxcJmInfoServiceImpl.java @@ -5,9 +5,11 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.szxc.domain.SzxcJmInfo; import com.ruoyi.szxc.mapper.SzxcJmInfoMapper; import com.ruoyi.szxc.service.ISzxcJmInfoService; -import org.springframework.beans.factory.annotation.Autowired; +import com.ruoyi.szxc.util.GetAgeByBirthdayUtil; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.Date; import java.util.List; /** @@ -19,7 +21,7 @@ import java.util.List; @Service public class SzxcJmInfoServiceImpl implements ISzxcJmInfoService { - @Autowired + @Resource private SzxcJmInfoMapper szxcJmInfoMapper; /** @@ -31,7 +33,11 @@ public class SzxcJmInfoServiceImpl implements ISzxcJmInfoService @Override public SzxcJmInfo selectSzxcJmInfoById(Long id) { - return szxcJmInfoMapper.selectSzxcJmInfoById(id); + SzxcJmInfo jmInfo = szxcJmInfoMapper.selectSzxcJmInfoById(id); + Date bornDate = jmInfo.getBornDate(); + int ageByBirth = GetAgeByBirthdayUtil.getAgeByBirth(bornDate); + jmInfo.setAge(ageByBirth); + return jmInfo; } /** @@ -44,7 +50,13 @@ public class SzxcJmInfoServiceImpl implements ISzxcJmInfoService @DataScope(deptAlias = "j") public List selectSzxcJmInfoList(SzxcJmInfo szxcJmInfo) { - return szxcJmInfoMapper.selectSzxcJmInfoList(szxcJmInfo); + List szxcJmInfos = szxcJmInfoMapper.selectSzxcJmInfoList(szxcJmInfo); + szxcJmInfos.forEach(info->{ + Date bornDate = info.getBornDate(); + int ageByBirth = GetAgeByBirthdayUtil.getAgeByBirth(bornDate); + info.setAge(ageByBirth); + }); + return szxcJmInfos; } /** diff --git a/ruoyi-szxc/src/main/java/com/ruoyi/szxc/util/GetAgeByBirthdayUtil.java b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/util/GetAgeByBirthdayUtil.java new file mode 100644 index 0000000..4df6d7e --- /dev/null +++ b/ruoyi-szxc/src/main/java/com/ruoyi/szxc/util/GetAgeByBirthdayUtil.java @@ -0,0 +1,45 @@ +package com.ruoyi.szxc.util; + +import java.util.Calendar; +import java.util.Date; + +public class GetAgeByBirthdayUtil { + /** + * + * 根据出生年月日计算年龄 + * @param birthday + * @return: int + */ + public static int getAgeByBirth(Date birthday){ + + //获取当前时间 + Calendar cal = Calendar.getInstance(); + + //获取出生日期的Calendar对象 + Calendar bir = Calendar.getInstance(); + bir.setTime(birthday); + //如果出生日期大于当前日期,则返回0 + if(cal.before(birthday)){ + return 0; + } + //取出当前年月日 + int nowYear = cal.get(Calendar.YEAR); + int nowMonth = cal.get(Calendar.MONTH); + int nowDay = cal.get(Calendar.DAY_OF_MONTH); + + //取出出生日期的年月日 + int birthYear = bir.get(Calendar.YEAR); + int birthMonth = bir.get(Calendar.MONTH); + int birthDay = bir.get(Calendar.DAY_OF_MONTH); + + //计算年份 + int age = nowYear - birthYear; + + //计算月份和日,看看是否大于当前月日,如果小于则减去一岁 + if(nowMonth < birthMonth || (nowMonth == birthMonth && nowDay < birthDay)){ + age--; + } + return age; + } + +} diff --git a/ruoyi-szxc/src/main/resources/mapper/szxc/SzxcHkbgRecardMapper.xml b/ruoyi-szxc/src/main/resources/mapper/szxc/SzxcHkbgRecardMapper.xml index d4639dc..0ade021 100644 --- a/ruoyi-szxc/src/main/resources/mapper/szxc/SzxcHkbgRecardMapper.xml +++ b/ruoyi-szxc/src/main/resources/mapper/szxc/SzxcHkbgRecardMapper.xml @@ -18,8 +18,10 @@ - + + + @@ -27,10 +29,11 @@ + - select id, acount_no, jm_id, name, id_card, y_jm_id, y_name, y_id_card, bg_reason, x_jm_id, x_name, x_id_card, relation, number, bg_time, remark, create_by, create_time, update_by, update_time, dept_id, user_id from szxc_hkbg_recard + select id, acount_no, jm_id, name, id_card, y_jm_id, y_name, y_id_card, bg_reason, x_jm_id, x_name, x_id_card, relation, bg_time, hj_address, jg_nature, long_live, remark, create_by, create_time, update_by, update_time, dept_id, user_id, dept_name from szxc_hkbg_recard @@ -75,8 +81,10 @@ x_name, x_id_card, relation, - number, bg_time, + hj_address, + jg_nature, + long_live, remark, create_by, create_time, @@ -84,6 +92,7 @@ update_time, dept_id, user_id, + dept_name, #{acountNo}, @@ -98,8 +107,10 @@ #{xName}, #{xIdCard}, #{relation}, - #{number}, #{bgTime}, + #{hjAddress}, + #{jgNature}, + #{longLive}, #{remark}, #{createBy}, #{createTime}, @@ -107,6 +118,7 @@ #{updateTime}, #{deptId}, #{userId}, + #{deptName}, @@ -125,8 +137,10 @@ x_name = #{xName}, x_id_card = #{xIdCard}, relation = #{relation}, - number = #{number}, bg_time = #{bgTime}, + hj_address = #{hjAddress}, + jg_nature = #{jgNature}, + long_live = #{longLive}, remark = #{remark}, create_by = #{createBy}, create_time = #{createTime}, @@ -134,6 +148,7 @@ update_time = #{updateTime}, dept_id = #{deptId}, user_id = #{userId}, + dept_name = #{deptName}, where id = #{id} diff --git a/ruoyi-ui/src/views/szxc/recard/index.vue b/ruoyi-ui/src/views/szxc/recard/index.vue index cd5e0e1..5513482 100644 --- a/ruoyi-ui/src/views/szxc/recard/index.vue +++ b/ruoyi-ui/src/views/szxc/recard/index.vue @@ -65,10 +65,10 @@ @keyup.enter.native="handleQuery" /> - + @@ -97,14 +97,6 @@ @keyup.enter.native="handleQuery" /> - - - + + + + + + + + + + + + 搜索 重置 @@ -192,19 +216,22 @@ - + - + + + +