人口基本信息- 修改入住人员的页面布局以及后台的处理逻辑

This commit is contained in:
java_cuibaocheng@163.com 2023-11-20 16:15:17 +08:00
parent 723d12e185
commit f83df1cd20
9 changed files with 274 additions and 52 deletions

View File

@ -36,6 +36,21 @@ public class PopulationController extends AbstractController {
@Autowired
private IPopulationService populationService;
@ApiOperation(value = "搬离房屋", notes = "搬离房屋")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update-outhouse/{populationIds}")
public SuccessResult updateOuthouse(@PathVariable("populationIds") String populationIds) {
List<String> list = Arrays.asList(populationIds.split("\\_"));
populationService.updateOuthouseTrue(null, list);
return new SuccessResult();
}
@ApiOperation(value = "新增人房绑定", notes = "新增人房绑定接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("save-all/{houseId}")
public SuccessResult saveList(@PathVariable("houseId") String houseId, @RequestBody List<PopulationVO> populationVOList) {
populationService.saveAll(null, houseId, populationVOList, false);
return new SuccessResult();
}
@ApiOperation(value = "新增人房绑定", notes = "新增人房绑定接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@ -100,7 +115,7 @@ public class PopulationController extends AbstractController {
public SuccessResultList<List<PopulationDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return populationService.listPage(page);
return populationService.listPageAll(page);
}
@ApiOperation(value = "人房绑定统计", notes = "人房绑定统计接口")

View File

@ -125,4 +125,13 @@ public interface IPopulationDao {
*/
void deleteByHouseId(String houseId) throws RemoveException;
/**
* 搬离房屋
* @param params
*/
void updateOuthouseTrue(Map<String, Object> params);
List<PopulationDTO> listAll(Map<String, Object> params);
void updateBindTime(Map<String, Object> params);
}

View File

@ -94,13 +94,9 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
}
houseDao.save(params);
if (!CollectionUtils.isEmpty(houseVO.getPopulationVOList())) {
List<PopulationVO> populationVOList = houseVO.getPopulationVOList();
for (PopulationVO populationVO : populationVOList) {
populationVO.setHouseId(houseId);
populationService.saveReturnId(token, populationVO);
}
}
// 2023年11月20日15:38:06 崔宝铖 创建saveAll函数
populationService.saveAll(token, houseId, houseVO.getPopulationVOList(), true);
return houseId;
}
@ -149,24 +145,9 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
}
houseDao.update(params);
// 1. 判断创建房屋时是否有人员信息一起
// 2. 有的话删除旧的人员信息并录入新的人员信息
if (!CollectionUtils.isEmpty(houseVO.getPopulationVOList())) {
List<PopulationVO> populationVOList = houseVO.getPopulationVOList();
for (PopulationVO populationVO : populationVOList) {
if ("1".equals(populationVO.getOutHouse())) {
populationService.update(populationVO.getPopulationId(), populationVO);
}
}
// 2023年11月20日15:38:06 崔宝铖 创建saveAll函数
populationService.saveAll(token, houseId, houseVO.getPopulationVOList(), true);
populationdao.deleteByHouseId(houseId);
for (PopulationVO populationVO : populationVOList) {
if (!"1".equals(populationVO.getOutHouse())) {
populationVO.setHouseId(houseId);
populationService.save(token, populationVO);
}
}
}
}
@Override

View File

@ -21,6 +21,17 @@ import java.util.Map;
**/
public interface IPopulationService {
/**
* 新增人房绑定
* 崔宝铖
* 批量保存更新
* @param token
* @param houseId
* @param populationVOList
* @param isAllData true:在新增的时候会把旧的全部删除 , false:在新增的时候不会删除旧的数据
*/
void saveAll(String token, String houseId, List<PopulationVO> populationVOList, Boolean isAllData);
/**
* 新增人房绑定
*
@ -203,5 +214,10 @@ public interface IPopulationService {
*/
SuccessResultList<List<PopulationDTO>> findPopulation(ListPage pag);
/**
* 搬离房屋
*/
void updateOuthouseTrue(String token, List<String> populationIds) ;
SuccessResultList<List<PopulationDTO>> listPageAll(ListPage page);
}

View File

@ -3,6 +3,7 @@ package com.cm.population.service.population.impl;
import com.cm.common.base.AbstractService;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.DateUtil;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.population.dao.house.IHouseDao;
@ -26,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import sun.security.krb5.internal.PAData;
import javax.mail.search.SearchException;
import java.util.*;
@ -49,6 +52,62 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
@Autowired
private IPopulationInfoService populationInfoService;
@Override
public void saveAll(String token, String houseId, List<PopulationVO> populationVOList, Boolean isAllData) {
// 1. 查出所有当前居住的人员
Map<String, Object> params = new HashMap<>();
params.put("houseId", houseId);
params.put("outHouse", "0");
List<PopulationDTO> list = populationDao.listAll(params);
Map<String, PopulationDTO> map = new HashMap<>();
for(PopulationDTO dto : list) {
map.put(dto.getPopulationInfoId(), dto);
}
// 1. 判断创建房屋时是否有人员信息一起
// 2. 有的话删除旧的人员信息并录入新的人员信息
if(!CollectionUtils.isEmpty(populationVOList)) {
for (PopulationVO populationVO : populationVOList) {
// 2.将搬离的改掉
if("1".equals(populationVO.getOutHouse())) {
update(populationVO.getPopulationId(), populationVO);
map.remove(populationVO.getPopulationInfoId());
}
}
// 记录绑定时间
for (PopulationVO populationVO : populationVOList) {
PopulationDTO dto = map.get(populationVO.getPopulationInfoId());
if (dto != null) {
populationVO.setBindTime(dto.getBindTime());
}
}
// 删除旧的所有的入住信息
if(isAllData) {
populationDao.deleteByHouseId(houseId);
}else{
// 剔除已存在的人员的再次新增
Iterator<PopulationVO> iterator = populationVOList.iterator();
while(iterator.hasNext()) {
PopulationVO vo = iterator.next();
if (map.get(vo.getPopulationInfoId()) != null) {
// 更新绑定事件
Map<String, Object> update = new HashMap<>();
update.put("populationId", map.get(vo.getPopulationInfoId()).getPopulationId());
update.put("bindTime", DateUtil.getTime());
populationDao.updateBindTime(update);
iterator.remove();
}
}
}
// 保存新的入住信息
for (PopulationVO populationVO : populationVOList) {
if(!"1".equals(populationVO.getOutHouse())) {
populationVO.setHouseId(houseId);
save(token, populationVO);
}
}
}
}
@Override
public void save(PopulationVO populationVO) {
saveReturnId(populationVO);
@ -79,7 +138,7 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
} else {
setSaveInfo(token, params);
}
params.put("bindTime", params.get("gmtCreate"));
params.put("bindTime", StringUtils.isEmpty(populationVO.getBindTime()) ? params.get("gmtCreate") : populationVO.getBindTime());
params.put("outHouse", 0);
// 解除脱敏
@ -185,7 +244,7 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
@Override
public List<PopulationDTO> list(Map<String, Object> params) {
List<PopulationDTO> list = populationDao.list(params);
for (PopulationDTO populationDTO : list) {
/* for (PopulationDTO populationDTO : list) {
PopulationInfoDTO populationInfoDTO = new PopulationInfoDTO();
if(StringUtils.isNotEmpty(populationDTO.getPopulationInfoId())) {
populationInfoDTO = populationInfoService.get(populationDTO.getPopulationInfoId());
@ -201,7 +260,7 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
populationDTO.setCardNum(populationInfoDTO.getIdcard());
populationDTO.setName(populationInfoDTO.getName());
populationDTO.setPhone(populationInfoDTO.getPhone());
}
}*/
return list;
}
@ -319,4 +378,24 @@ public class PopulationServiceImpl extends AbstractService implements IPopulatio
return new SuccessResultList<>(overList, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
public void updateOuthouseTrue(String token, List<String> populationIds) {
Map<String, Object> params = super.getHashMap(2);
params.put("populationIds", populationIds);
if (StringUtils.isBlank(token)) {
setUpdateInfo(params);
} else {
setUpdateInfo(token, params);
}
populationDao.updateOuthouseTrue(params);
}
@Override
public SuccessResultList<List<PopulationDTO>> listPageAll(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows());
List<PopulationDTO> populationDTOs = populationDao.listAll(page.getParams());
PageInfo<PopulationDTO> pageInfo = new PageInfo<>(populationDTOs);
return new SuccessResultList<>(populationDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
}

View File

@ -114,8 +114,34 @@
DELETE FROM
house_population
WHERE
house_id = #{houseId}
AND out_house != 1
house_id = #{houseId} AND out_house != 1
</update>
<update id="updateOuthouseTrue" parameterType="map">
UPDATE
house_population
SET
out_house = '1',
gmt_modified = #{gmtModified},
modifier = #{modifier}
WHERE
is_delete = 0
<if test="populationIds != null and populationIds.size > 0">
AND
population_id IN
<foreach collection="populationIds" index="index" open="(" separator="," close=")">
#{populationIds[${index}]}
</foreach>
</if>
</update>
<update id="updateBindTime" parameterType="map">
UPDATE
house_population
SET
bind_time = #{bindTime}
WHERE
population_id = #{populationId}
</update>
<!-- 修改人房绑定 -->
@ -224,6 +250,38 @@
</if>
</select>
<!-- 人房绑定列表 -->
<select id="listAll" parameterType="map" resultMap="populationDTO">
SELECT
t1.population_id,
t1.house_id,
t1.population_info_id,
t1.name,
t1.card_num,
t1.phone,
t1.bind_time,
t1.out_house,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete
FROM
house_population t1
WHERE
t1.is_delete = 0 AND t1.house_id = #{houseId}
<if test="outHouse != null and outHouse != ''">
AND t1.out_house = #{outHouse}
</if>
<if test="keywords != null and keywords != ''">
AND (t1.card_num LIKE CONCAT('%', #{keywords}, '%')
OR t1.phone LIKE CONCAT('%', #{keywords}, '%')
OR t1.name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
ORDER BY t1.gmt_modified DESC, t1.gmt_create DESC
</select>
<!-- 人房绑定列表 -->
<select id="list" parameterType="map" resultMap="populationDTO">
SELECT

View File

@ -1896,9 +1896,9 @@
function rentalHis(data) {
top.dialog.open({
url: top.restAjax.path('route/population/list?houseId={houseId}', [data.houseId]),
title: "房屋人",
width: '60%',
height: '70%',
title: "房屋人员列表",
width: '80%',
height: '90%',
onClose: function() {
reloadTable();
}

View File

@ -561,7 +561,7 @@
}
}
if (!exists) {
cohabitArray.push({populationId: "xxxx", populationInfoId: list[i].populationInfoId, cardNum: list[i].idcard, phone: list[i].phone, name: list[i].name, outHouse: "0"});
cohabitArray.push({populationId: "", populationInfoId: list[i].populationInfoId, cardNum: list[i].idcard, phone: list[i].phone, name: list[i].name, outHouse: "0"});
}
}
reloadCohabit();

View File

@ -18,7 +18,7 @@
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
<input type="text" id="keywords" class="layui-input search-item search-item-width-200" placeholder="输入证件号或姓名查询">
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
@ -29,13 +29,13 @@
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑
<i class="fa fa-lg fa-plus"></i> 搜索添加同住人
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
<i class="fa fa-lg fa-trash"></i> 录错删除
</button>
<button type="button" class="layui-btn layui-btn-sm" lay-event="outHouseEvent">
<i class="fa fa-lg fa-outdent"></i> 搬离房屋
</button>
</div>
</script>
@ -70,6 +70,7 @@
url: top.restAjax.path(tableUrl, [houseId]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 60,
defaultToolbar: [],
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
@ -108,13 +109,19 @@
return rowData;
}
},
{field: 'bindTime', width: 180, title: '绑定时间', align:'center',
{field: 'outHouse', width: 280, title: '居住情况', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
if (rowData == 0) {
var bindTime = row['bindTime'];
return '<span style="color:green">正居住/' + bindTime + '</span>';
}else{
var gmtModified = row['gmtModified'];
return '<span style="color:red">已搬离/' + gmtModified + '</span>';
}
}
}
]
@ -196,16 +203,50 @@
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['75%', '60%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/population/save?houseId={houseId}', [houseId]),
end: function() {
reloadTable();
// layer.open({
// type: 2,
// title: false,
// closeBtn: 0,
// area: ['75%', '60%'],
// shadeClose: true,
// anim: 2,
// content: top.restAjax.path('route/population/save?houseId={houseId}', [houseId]),
// end: function() {
// reloadTable();
// }
// });
top.dialog.open({
url: top.restAjax.path('route/populationinfo/query-multiple', []),
title: '人员选择',
width: '80%',
height: '80%',
onClose: function(data) {
var cohabitArray = new Array();
var list = top.dialog.dialogData.populationinfoQueryMultiple;
// 判断是否已选择
for(var i = 0 ; i < list.length ; i++){
var exists = false;
for(var j = 0 ; j < cohabitArray.length ; j++) {
if(list[i].populationInfoId == cohabitArray[j].populationInfoId) {
exists = true;
break;
}
}
cohabitArray.push({populationId: "", populationInfoId: list[i].populationInfoId, cardNum: list[i].idcard, phone: list[i].phone, name: list[i].name, outHouse: "0"});
}
// 保存
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/population/save-all/{houseId}', [houseId]), cohabitArray, null, function(code, data) {
// 刷新列表
window.location.reload();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
});
} else if(layEvent === 'updateEvent') {
@ -240,6 +281,29 @@
}
removeData(ids);
}
} else if(layEvent === 'outHouseEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);
} else {
var ids = '';
for(var i = 0, item; item = checkDatas[i++];) {
if(i > 1) {
ids += '_';
}
ids += item['populationId'];
}
var layIndex;
top.restAjax.put(top.restAjax.path('api/population/update-outhouse/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg("信息修改成功", {time: 1000});
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
layIndex = top.dialog.msg("正在修改中...", {icon: 16, time: 0, shade: 0.3});
}, function () {
top.dialog.close(layIndex);
});
}
}
});
});