This commit is contained in:
2025-07-01 17:54:58 +08:00
commit 57dcd609e2
5136 changed files with 346184 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhwl</groupId>
<artifactId>zhwl-business</artifactId>
<version>3.8.7</version>
</parent>
<artifactId>zhwl-resident</artifactId>
<description>居民模块</description>
<dependencies>
<dependency>
<groupId>com.zhwl</groupId>
<artifactId>zhwl-api-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,152 @@
package com.zhwl.resident.controller;
import com.zhwl.api.common.log.domain.ZdyApiLog;
import com.zhwl.api.common.log.service.IZdyApiLogService;
import com.zhwl.common.annotation.Log;
import com.zhwl.common.core.controller.BaseController;
import com.zhwl.common.core.domain.AjaxResult;
import com.zhwl.common.core.page.TableDataInfo;
import com.zhwl.common.enums.BusinessType;
import com.zhwl.common.utils.SecurityUtils;
import com.zhwl.common.utils.poi.ExcelUtil;
import com.zhwl.resident.domain.ZdyResidentInfo;
import com.zhwl.resident.service.IZdyResidentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 居民信息Controller
*
* @author sunxiaoyong
* @date 2024-06-25
*/
@RestController
@RequestMapping("/gate/residentInfo")
public class ZdyResidentInfoController extends BaseController {
@Autowired
private IZdyResidentInfoService zdyResidentInfoService;
@Autowired
private IZdyApiLogService zdyApiLogService;
/**
* 查询居民信息列表
*/
@PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:list')")
@GetMapping("/list")
public TableDataInfo list(ZdyResidentInfo zdyResidentInfo) {
startPage();
List<ZdyResidentInfo> list = zdyResidentInfoService.selectZdyResidentInfoList(zdyResidentInfo);
return getDataTable(list);
}
/**
* 导出居民信息列表
*/
// @PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:export')")
@Log(title = "居民信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ZdyResidentInfo zdyResidentInfo) {
List<ZdyResidentInfo> list = zdyResidentInfoService.selectZdyResidentInfoList(zdyResidentInfo);
ExcelUtil<ZdyResidentInfo> util = new ExcelUtil<ZdyResidentInfo>(ZdyResidentInfo.class);
util.exportExcel(response, list, "居民信息数据");
}
/**
* 导入居民信息
* @param file 文件
* @return
* @throws Exception
*/
@Log(title = "居民信息", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file) throws Exception
{
ExcelUtil<ZdyResidentInfo> util = new ExcelUtil<>(ZdyResidentInfo.class);
List<ZdyResidentInfo> residentInfoList = util.importExcel(file.getInputStream());
String message = zdyResidentInfoService.importResidentInfo(residentInfoList);
return success(message);
}
/**
* 导入模板
*/
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<ZdyResidentInfo> util = new ExcelUtil<ZdyResidentInfo>(ZdyResidentInfo.class);
util.importTemplateExcel(response, "居民信息数据");
}
/**
* 获取居民信息详细信息
*/
@PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(zdyResidentInfoService.selectZdyResidentInfoById(id));
}
/**
* 新增居民信息
*/
// @PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:add')")
@Log(title = "居民信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ZdyResidentInfo zdyResidentInfo) {
zdyResidentInfo.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
zdyResidentInfo.setDeptId(SecurityUtils.getDeptId());
return toAjax(zdyResidentInfoService.insertZdyResidentInfo(zdyResidentInfo));
}
/**
* 修改居民信息
*/
// @PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:edit')")
@Log(title = "居民信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ZdyResidentInfo zdyResidentInfo) {
zdyResidentInfo.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
return toAjax(zdyResidentInfoService.updateZdyResidentInfo(zdyResidentInfo));
}
/**
* 删除居民信息
*/
// @PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:remove')")
@Log(title = "居民信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(zdyResidentInfoService.deleteZdyResidentInfoByIds(ids, String.valueOf(SecurityUtils.getUserId())));
}
/**
* 查询同步日志列表
*/
@PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:sync')")
@GetMapping("/syncList")
public TableDataInfo syncList(ZdyApiLog zdyApiLog)
{
startPage();
List<ZdyApiLog> list = zdyApiLogService.selectZdyApiLogList(zdyApiLog);
return getDataTable(list);
}
/**
* 获取接口日志详细信息
*/
@PreAuthorize("@ss.hasPermi('residentInfo:residentInfo:syncQuery')")
@GetMapping(value = "/syncQuery/{id}")
public AjaxResult syncQuery(@PathVariable("id") Long id)
{
return success(zdyApiLogService.selectZdyApiLogById(id));
}
}

View File

@@ -0,0 +1,65 @@
package com.zhwl.resident.controller.open;
import com.zhwl.api.common.annotation.ZdyLog;
import com.zhwl.api.common.enums.ReqPattern;
import com.zhwl.api.common.enums.ReqSource;
import com.zhwl.common.annotation.Log;
import com.zhwl.common.constant.ZdyConstant;
import com.zhwl.common.core.controller.BaseController;
import com.zhwl.common.core.domain.ZdyAjaxResult;
import com.zhwl.common.exception.ZdyServiceException;
import com.zhwl.resident.service.IZdyResidentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.HashMap;
import java.util.Map;
/**
* 开放接口——居民信息Controller
*
* @author sunxiaoyong
* @date 2024-06-25
*/
@RestController
@RequestMapping("/open/gate/residentInfo")
public class OpenZdyResidentInfoController extends BaseController {
@Autowired
private IZdyResidentInfoService zdyResidentInfoService;
/**
* 全量居民信息推送
* @param json
* @return
*/
@ZdyLog(sign = "syncResidentInfo", name = "居民信息上报", reqPattern = ReqPattern.PASSIVE, reqSource = ReqSource.WEB)
@Log(title = "居民信息上报")
@PostMapping("/syncResidentInfo")
public ZdyAjaxResult syncResidentInfo(@RequestBody String json) {
logger.info("居民数据json:" + json);
ZdyAjaxResult ajaxResult = null;
String responseMsg = "";
int count = 0;
try {
count = zdyResidentInfoService.syncResidentInfo(json);
Map<String, Object> map = new HashMap<String, Object>();
map.put("count", count);
responseMsg = "上传数据成功";
ajaxResult = ZdyAjaxResult.success(ZdyConstant.API_SUCCESS, responseMsg, map);
} catch (ZdyServiceException e) {
e.printStackTrace();
logger.error("上传数据失败", e);
ajaxResult = ZdyAjaxResult.error(e.getCode(), e.getMessage());
} catch (Exception e) {
e.printStackTrace();
logger.error("上传数据异常", e);
ajaxResult = ZdyAjaxResult.error(ZdyConstant.API_FAIL, responseMsg);
}
return ajaxResult;
}
}

View File

@@ -0,0 +1,308 @@
package com.zhwl.resident.domain;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhwl.common.annotation.Excel;
import com.zhwl.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* 居民信息对象 zdy_resident_info
*
* @author sunxiaoyong
* @date 2024-06-25
*/
public class ZdyResidentInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private Long id;
/**
* 姓名
*/
@Excel(name = "姓名")
private String userName;
/**
* 性别
*/
@Excel(name = "性别",dictType = "sys_user_sex")
private String sex;
/**
* 人员编号
*/
private String userCode;
/**
* 联系电话
*/
@Excel(name = "联系电话")
private String phone;
/**
* 身份证号
*/
@Excel(name = "身份证号")
private String idNo;
/**
* 地址
*/
@Excel(name = "地址")
private String userAddress;
/**
* 本人身份证照片
*/
private String idCardImage;
/**
* 本人户口页照片
*/
private String hukouImage;
/**
* 人脸照片
*/
private String faceImage;
/**
* 类型 1本地居民
*/
private String userType;
/**
* 分组 1景区内居民
*/
private String groupType;
/**
* 状态 1启用 2停用 3删除
*/
private String userStatus;
/**
* 查询-开始时间
*/
private String startTime;
/**
* 查询-结束时间
*/
private String endTime;
private String groupTypeName;
private String userTypeName;
private String userStatusName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date syncTime;
/**
* 所属景区
*/
private Long scenicId;
/**
* 所属景区名称
*/
private String scenicName;
public Long getScenicId() {
return scenicId;
}
public String getScenicName() {
return scenicName;
}
public void setScenicName(String scenicName) {
this.scenicName = scenicName;
}
public void setScenicId(Long scenicId) {
this.scenicId = scenicId;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
public void setUserCode(String userCode) {
this.userCode = userCode;
}
public String getUserCode() {
return userCode;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPhone() {
return phone;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public String getIdNo() {
return idNo;
}
public void setUserAddress(String userAddress) {
this.userAddress = userAddress;
}
public String getUserAddress() {
return userAddress;
}
public void setIdCardImage(String idCardImage) {
this.idCardImage = idCardImage;
}
public String getIdCardImage() {
return idCardImage;
}
public void setHukouImage(String hukouImage) {
this.hukouImage = hukouImage;
}
public String getHukouImage() {
return hukouImage;
}
public void setFaceImage(String faceImage) {
this.faceImage = faceImage;
}
public String getFaceImage() {
return faceImage;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getUserType() {
return userType;
}
public void setGroupType(String groupType) {
this.groupType = groupType;
}
public String getGroupType() {
return groupType;
}
public void setUserStatus(String userStatus) {
this.userStatus = userStatus;
}
public String getUserStatus() {
return userStatus;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getGroupTypeName() {
return groupTypeName;
}
public void setGroupTypeName(String groupTypeName) {
this.groupTypeName = groupTypeName;
}
public String getUserTypeName() {
return userTypeName;
}
public void setUserTypeName(String userTypeName) {
this.userTypeName = userTypeName;
}
public String getUserStatusName() {
return userStatusName;
}
public void setUserStatusName(String userStatusName) {
this.userStatusName = userStatusName;
}
public Date getSyncTime() {
return syncTime;
}
public void setSyncTime(Date syncTime) {
this.syncTime = syncTime;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userName", getUserName())
.append("userCode", getUserCode())
.append("phone", getPhone())
.append("idNo", getIdNo())
.append("userAddress", getUserAddress())
.append("idCardImage", getIdCardImage())
.append("hukouImage", getHukouImage())
.append("faceImage", getFaceImage())
.append("remark", getRemark())
.append("userType", getUserType())
.append("groupType", getGroupType())
.append("userStatus", getUserStatus())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("syncTime", getSyncTime())
.toString();
}
}

View File

@@ -0,0 +1,102 @@
package com.zhwl.resident.mapper;
import com.zhwl.resident.domain.ZdyResidentInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 居民信息Mapper接口
*
* @author sunxiaoyong
* @date 2024-06-25
*/
@Mapper
public interface ZdyResidentInfoMapper {
/**
* 查询居民信息
*
* @param id 居民信息主键
* @return 居民信息
*/
public ZdyResidentInfo selectZdyResidentInfoById(Long id);
/**
* 查询居民信息
*
* @param idNo 居民信息主键
* @return 居民信息
*/
public ZdyResidentInfo selectZdyResidentInfoByIdNo(@Param("idNo")String idNo,@Param("deptId") Long deptId);
/**
* 查询居民信息列表
*
* @param zdyResidentInfo 居民信息
* @return 居民信息集合
*/
public List<ZdyResidentInfo> selectZdyResidentInfoList(ZdyResidentInfo zdyResidentInfo);
/**
* 新增居民信息
*
* @param zdyResidentInfo 居民信息
* @return 结果
*/
public int insertZdyResidentInfo(ZdyResidentInfo zdyResidentInfo);
/**
* 修改居民信息
*
* @param zdyResidentInfo 居民信息
* @return 结果
*/
public int updateZdyResidentInfo(ZdyResidentInfo zdyResidentInfo);
/**
* 删除居民信息
*
* @param id 居民信息主键
* @return 结果
*/
public int deleteZdyResidentInfoById(@Param("id")Long id,@Param("currentUserId")String currentUserId);
/**
* 批量删除居民信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteZdyResidentInfoByIds(@Param("ids")Long[] ids, @Param("currentUserId")String currentUserId);
/**
* 查询最大id
* @return
*/
Long selectMaxId();
/**
* 根据身份证号查询
* @param updateId
* @param idNo
* @return
*/
Long selectIdNo(@Param("updateId") Long updateId,@Param("idNo") String idNo,@Param("deptId")Long deptId);
/**
* 根据身份证号查询
* @param updateId
* @param idNo
* @return
*/
ZdyResidentInfo selectInfoByIdNo(@Param("updateId") Long updateId,@Param("idNo") String idNo);
/**
* 批量新增居民信息
* @return 结果
*/
public int insertZdyResidentInfoList(@Param("dataList") List<ZdyResidentInfo> dataList);
public List<Long> getExistingIds();
}

View File

@@ -0,0 +1,88 @@
package com.zhwl.resident.service;
import com.zhwl.resident.domain.ZdyResidentInfo;
import java.util.List;
/**
* 居民信息Service接口
*
* @author sunxiaoyong
* @date 2024-06-25
*/
public interface IZdyResidentInfoService {
/**
* 查询居民信息
*
* @param id 居民信息主键
* @return 居民信息
*/
public ZdyResidentInfo selectZdyResidentInfoById(Long id);
/**
* 查询居民信息列表
*
* @param zdyResidentInfo 居民信息
* @return 居民信息集合
*/
public List<ZdyResidentInfo> selectZdyResidentInfoList(ZdyResidentInfo zdyResidentInfo);
/**
* 新增居民信息
*
* @param zdyResidentInfo 居民信息
* @return 结果
*/
public int insertZdyResidentInfo(ZdyResidentInfo zdyResidentInfo);
/**
* 修改居民信息
*
* @param zdyResidentInfo 居民信息
* @return 结果
*/
public int updateZdyResidentInfo(ZdyResidentInfo zdyResidentInfo);
/**
* 批量删除居民信息
*
* @param ids 需要删除的居民信息主键集合
* @return 结果
*/
public int deleteZdyResidentInfoByIds(Long[] ids, String currentUserId);
/**
* 删除居民信息信息
*
* @param id 居民信息主键
* @return 结果
*/
public int deleteZdyResidentInfoById(Long id, String currentUserId);
/**
* 批量新增居民信息
* @return 结果
*/
public int insertZdyResidentInfoList(List<ZdyResidentInfo> entities);
/**
* 批量修改居民信息
* @return 结果
*/
public int updateZdyResidentInfoList(List<ZdyResidentInfo> entities);
/**
* 全量居民信息推送
* @return 结果
*/
public int syncResidentInfo(List<ZdyResidentInfo> ZdyResidentInfoList);
/**
* 全量居民信息推送
* @return 结果
*/
public int syncResidentInfo(String json) throws Exception;
String importResidentInfo(List<ZdyResidentInfo> residentInfoList);
}

View File

@@ -0,0 +1,284 @@
package com.zhwl.resident.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.zhwl.common.annotation.DataScope;
import com.zhwl.common.constant.ZdyConstant;
import com.zhwl.common.exception.ServiceException;
import com.zhwl.common.exception.ZdyServiceException;
import com.zhwl.common.utils.DateUtils;
import com.zhwl.common.utils.SecurityUtils;
import com.zhwl.common.utils.StringUtils;
import com.zhwl.common.utils.bean.BeanValidators;
import com.zhwl.resident.domain.ZdyResidentInfo;
import com.zhwl.resident.mapper.ZdyResidentInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.zhwl.resident.service.IZdyResidentInfoService;
import javax.validation.Validator;
import java.util.*;
/**
* 居民信息Service业务层处理
*
* @author sunxiaoyong
* @date 2024-06-25
*/
@Service
@Slf4j
public class ZdyResidentInfoServiceImpl implements IZdyResidentInfoService {
@Autowired
private ZdyResidentInfoMapper zdyResidentInfoMapper;
@Autowired
protected Validator validator;
/**
* 查询居民信息
*
* @param id 居民信息主键
* @return 居民信息
*/
@Override
public ZdyResidentInfo selectZdyResidentInfoById(Long id) {
return zdyResidentInfoMapper.selectZdyResidentInfoById(id);
}
/**
* 查询居民信息列表
*
* @param zdyResidentInfo 居民信息
* @return 居民信息
*/
@Override
@DataScope(deptAlias = "d")
public List<ZdyResidentInfo> selectZdyResidentInfoList(ZdyResidentInfo zdyResidentInfo) {
return zdyResidentInfoMapper.selectZdyResidentInfoList(zdyResidentInfo);
}
/**
* 新增居民信息
*
* @param zdyResidentInfo 居民信息
* @return 结果
*/
@Override
public int insertZdyResidentInfo(ZdyResidentInfo zdyResidentInfo) {
zdyResidentInfo.setCreateTime(DateUtils.getNowDate());
// 判断身份证号是否重复
checkIdNo(zdyResidentInfo);
// zdyResidentInfo.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
return zdyResidentInfoMapper.insertZdyResidentInfo(zdyResidentInfo);
}
private void checkIdNo(ZdyResidentInfo residentInfo) {
// 根据ID和身份证号查询用户ID且不包括状态3已删除的
Long idNo = zdyResidentInfoMapper.selectIdNo(residentInfo.getId(), residentInfo.getIdNo(),SecurityUtils.getDeptId());
if (idNo != null && idNo > 0) {
throw new ServiceException("当前身份证号已存在");
}
}
/**
* 修改居民信息
*
* @param zdyResidentInfo 居民信息
* @return 结果
*/
@Override
public int updateZdyResidentInfo(ZdyResidentInfo zdyResidentInfo) {
checkIdNo(zdyResidentInfo);
zdyResidentInfo.setUpdateTime(DateUtils.getNowDate());
// zdyResidentInfo.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
return zdyResidentInfoMapper.updateZdyResidentInfo(zdyResidentInfo);
}
/**
* 批量删除居民信息
*
* @param ids 需要删除的居民信息主键
* @return 结果
*/
@Override
public int deleteZdyResidentInfoByIds(Long[] ids, String currentUserId) {
return zdyResidentInfoMapper.deleteZdyResidentInfoByIds(ids, currentUserId);
}
/**
* 删除居民信息信息
*
* @param id 居民信息主键
* @return 结果
*/
@Override
public int deleteZdyResidentInfoById(Long id, String currentUserId) {
return zdyResidentInfoMapper.deleteZdyResidentInfoById(id, currentUserId);
}
@Override
public int insertZdyResidentInfoList(List<ZdyResidentInfo> entities) {
return zdyResidentInfoMapper.insertZdyResidentInfoList(entities);
}
@Override
public int updateZdyResidentInfoList(List<ZdyResidentInfo> entities) {
for (ZdyResidentInfo entity : entities) {
zdyResidentInfoMapper.updateZdyResidentInfo(entity);
}
return entities.size();
}
@Transactional
@Override
public int syncResidentInfo(List<ZdyResidentInfo> ZdyResidentInfoList) {
// 是否有数据
if (CollUtil.isEmpty(ZdyResidentInfoList)){
return 0;
}
log.info("开始同步居民信息,获取:" + ZdyResidentInfoList.size() + "条数据");
Date syncTime = DateUtils.getNowDate();
// 获取已存在的id
List<Long> existingIds = zdyResidentInfoMapper.getExistingIds();
List<ZdyResidentInfo> newItems = new ArrayList<>();
List<ZdyResidentInfo> updateItems = new ArrayList<>();
// 遍历列表根据id判断是否已存在
for (ZdyResidentInfo entity : ZdyResidentInfoList) {
entity.setSyncTime(syncTime); // 设置同步时间
if (!existingIds.contains(entity.getId())) {
newItems.add(entity); // 如果id不存在则添加到新列表中
} else {
updateItems.add(entity); // 如果id存在则添加到更新列表中
}
}
// 批量新增
if (newItems.size() > 0) {
zdyResidentInfoMapper.insertZdyResidentInfoList(newItems);
}
// 批量修改
if (updateItems.size() > 0) {
for (ZdyResidentInfo entity : updateItems) {
zdyResidentInfoMapper.updateZdyResidentInfo(entity);
}
}
log.info("批量新增:" + newItems.size() + "");
log.info("批量更新:" + updateItems.size() + "");
return newItems.size() + updateItems.size();
}
@Transactional
@Override
public int syncResidentInfo(String json) {
// json格式校验
if (!JSONUtil.isJson(json)) {
throw new ZdyServiceException("报文解析异常", ZdyConstant.API_FAIL);
}
JSONObject jsonObj = JSONObject.parseObject(json);
String params = jsonObj.getString("paramsData");
if (StringUtils.isEmpty(params)) {
throw new ZdyServiceException("参数paramsData缺失", ZdyConstant.API_PARAM_LOSS);
}
List<Map<String, String>> listObject = (List<Map<String, String>>) JSON.parse(params);
if (null != listObject && listObject.size() < 1) {
throw new ZdyServiceException("报文内容异常", ZdyConstant.API_DATA_FAIL);
}
List<ZdyResidentInfo> zdyResidentInfoList = JSON.parseArray(params, ZdyResidentInfo.class);
log.info("同步信息开始:接收到"+ zdyResidentInfoList.size() + "条数据");
Date syncTime = DateUtils.getNowDate();
// 获取已存在的id
List<Long> existingIds = zdyResidentInfoMapper.getExistingIds();
List<ZdyResidentInfo> newItems = new ArrayList<>();
List<ZdyResidentInfo> updateItems = new ArrayList<>();
// 遍历列表根据id判断是否已存在
for (ZdyResidentInfo entity : zdyResidentInfoList) {
// 报文默认按照ID校验内容有效性
if (null == entity.getId() || 0 == entity.getId()) {
throw new ZdyServiceException("报文内容异常", ZdyConstant.API_DATA_FAIL);
}
entity.setSyncTime(syncTime); // 设置同步时间
if (!existingIds.contains(entity.getId())) {
newItems.add(entity); // 如果id不存在则添加到新列表中
} else {
updateItems.add(entity); // 如果id存在则添加到更新列表中
}
}
// 批量新增
if (newItems.size() > 0) {
zdyResidentInfoMapper.insertZdyResidentInfoList(newItems);
}
// 批量修改
if (updateItems.size() > 0) {
for (ZdyResidentInfo entity : updateItems) {
zdyResidentInfoMapper.updateZdyResidentInfo(entity);
}
}
log.info("同步信息结束:新增:" + newItems.size() + "条;更新:"+ updateItems.size() + "");
return newItems.size() + updateItems.size();
}
@Override
public String importResidentInfo(List<ZdyResidentInfo> residentInfoList) {
if (StringUtils.isNull(residentInfoList) || residentInfoList.size() == 0)
{
throw new ServiceException("导入居民信息不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (ZdyResidentInfo resident : residentInfoList)
{
try
{
BeanValidators.validateWithException(validator, resident);
String idNo = resident.getIdNo();
// 如果身份证号不填写,则跳过该数据
if(StringUtils.isEmpty(idNo)){
continue;
}
ZdyResidentInfo zdyResidentInfo = zdyResidentInfoMapper.selectZdyResidentInfoByIdNo(idNo,SecurityUtils.getDeptId());
if(ObjectUtil.isNotNull(zdyResidentInfo)){
resident.setId(zdyResidentInfo.getId());
zdyResidentInfoMapper.updateZdyResidentInfo(resident);
}else{
resident.setDeptId(SecurityUtils.getDeptId());
// 默认设置类型为本地居民
resident.setUserType("1");
// 默认设置分组为景区内居民
resident.setGroupType("1");
resident.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
resident.setCreateTime(DateUtils.getNowDate());
zdyResidentInfoMapper.insertZdyResidentInfo(resident);
}
successNum++;
successMsg.append("<br/>" + successNum + "、姓名 " + resident.getUserName() + " 导入成功");
}
catch (Exception e)
{
failureNum++;
String msg = "<br/>" + failureNum + "、姓名 " + resident.getUserName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new ServiceException(failureMsg.toString());
}
else
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}

View File

@@ -0,0 +1,353 @@
<?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.zhwl.resident.mapper.ZdyResidentInfoMapper">
<resultMap type="ZdyResidentInfo" id="ZdyResidentInfoResult">
<result property="id" column="id"/>
<result property="userName" column="user_name"/>
<result property="userCode" column="user_code"/>
<result property="sex" column="sex"/>
<result property="phone" column="phone"/>
<result property="idNo" column="id_no"/>
<result property="userAddress" column="user_address"/>
<result property="idCardImage" column="id_card_image"/>
<result property="hukouImage" column="hukou_image"/>
<result property="faceImage" column="face_image"/>
<result property="remark" column="remark"/>
<result property="userType" column="user_type"/>
<result property="groupType" column="group_type"/>
<result property="userStatus" column="user_status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="groupTypeName" column="groupTypeName" />
<result property="userTypeName" column="userTypeName" />
<result property="userStatusName" column="userStatusName" />
<result property="syncTime" column="syncTime" />
<result property="deptId" column="dept_id"/>
<result property="scenicId" column="scenic_id"/>
<result property="scenicName" column="scenic_name"/>
</resultMap>
<!-- <sql id="selectZdyResidentInfoVo">-->
<!-- select id, user_name, user_code, phone, id_no, user_address, id_card_image, hukou_image, face_image, remark, user_type, group_type, user_status, create_by, create_time, update_by, update_time-->
<!-- from zdy_resident_info-->
<!-- </sql>-->
<sql id="selectZdyResidentInfoVo">
select tri.id, tri.user_name, tri.user_code,tri.sex, tri.phone, tri.id_no, tri.user_address, tri.id_card_image, tri.hukou_image, tri.face_image, tri.remark, tri.user_type, tri.group_type, tri.user_status, tri.create_by, tri.create_time, tri.update_by, tri.update_time, tri.sync_time,tri.dept_id
</sql>
<sql id="selectResidentInfoTuoMinVo">
select tri.id, tri.user_name, tri.user_code,tri.sex, tri.phone
, CONCAT( LEFT(tri.id_no, CHAR_LENGTH(tri.id_no) - 4), REPEAT('*', 4) ) as id_no , tri.user_address, tri.id_card_image, tri.hukou_image, tri.face_image, tri.remark, tri.user_type, tri.group_type, tri.user_status, tri.create_by, tri.create_time, tri.update_by, tri.update_time, tri.sync_time,tri.dept_id
</sql>
<select id="selectZdyResidentInfoList" parameterType="ZdyResidentInfo" resultMap="ZdyResidentInfoResult">
<include refid="selectResidentInfoTuoMinVo"/>
,sdd1.dict_label as groupTypeName
,sdd2.dict_label as userTypeName
,sdd3.dict_label as userStatusName,
tri.scenic_id,
zs.scenic_name
from zdy_resident_info tri
left join sys_dict_data sdd1 on sdd1.dict_value = tri.group_type and sdd1.dict_type = 'group_type'
left join sys_dict_data sdd2 on sdd2.dict_value = tri.user_type and sdd2.dict_type = 'user_type'
left join sys_dict_data sdd3 on sdd3.dict_value = tri.user_status and sdd3.dict_type = 'identity_status'
left join sys_dept d on tri.dept_id = d.dept_id
left join zdy_scenic zs on zs.id = tri.scenic_id
<where>
and tri.user_status not in (3)
<if test="sex != null and sex != ''"> and tri.sex = #{sex}</if>
<if test="userName != null and userName != ''"> and tri.user_name like concat('%', #{userName}, '%')</if>
<if test="userCode != null and userCode != ''"> and tri.user_code = #{userCode}</if>
<if test="phone != null and phone != ''"> and tri.phone like concat('%', #{phone}, '%')</if>
<if test="idNo != null and idNo != ''"> and tri.id_no like concat('%', #{idNo}, '%')</if>
<if test="userAddress != null and userAddress != ''"> and tri.user_address = #{userAddress}</if>
<if test="idCardImage != null and idCardImage != ''"> and tri.id_card_image = #{idCardImage}</if>
<if test="hukouImage != null and hukouImage != ''"> and tri.hukou_image = #{hukouImage}</if>
<if test="faceImage != null and faceImage != ''"> and tri.face_image = #{faceImage}</if>
<if test="userType != null and userType != ''"> and tri.user_type = #{userType}</if>
<if test="groupType != null and groupType != ''"> and tri.group_type = #{groupType}</if>
<if test="userStatus != null and userStatus != ''"> and tri.user_status = #{userStatus}</if>
<if test="startTime != null "> and date(tri.create_time) <![CDATA[ >= ]]> #{startTime}</if>
<if test="endTime != null "> and date(tri.create_time) <![CDATA[ <= ]]> #{endTime}</if>
<if test="scenicId != null "> and tri.scenic_id = #{scenicId}</if>
${params.dataScope}
</where>
order by tri.id desc
</select>
<select id="selectZdyResidentInfoById" parameterType="Long"
resultMap="ZdyResidentInfoResult">
<include refid="selectZdyResidentInfoVo"/>
,sdd1.dict_label as groupTypeName
,sdd2.dict_label as userTypeName
,sdd3.dict_label as userStatusName,
tri.scenic_id,
zs.scenic_name
from zdy_resident_info tri
left join sys_dict_data sdd1 on sdd1.dict_value = tri.group_type and sdd1.dict_type = 'group_type'
left join sys_dict_data sdd2 on sdd2.dict_value = tri.user_type and sdd2.dict_type = 'user_type'
left join sys_dict_data sdd3 on sdd3.dict_value = tri.user_status and sdd3.dict_type = 'identity_status'
left join zdy_scenic zs on zs.id = tri.scenic_id
where tri.id = #{id}
</select>
<select id="selectZdyResidentInfoByIdNo"
resultMap="ZdyResidentInfoResult">
<include refid="selectZdyResidentInfoVo"/>
from zdy_resident_info tri
where tri.user_status not in (3) and tri.id_no = #{idNo} and tri.dept_id = #{deptId}
</select>
<insert id="insertZdyResidentInfo" parameterType="ZdyResidentInfo" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_resident_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userName != null">user_name,
</if>
<if test="userCode != null">user_code,
</if>
<if test="sex != null">sex,</if>
<if test="phone != null">phone,
</if>
<if test="idNo != null and idNo != ''">id_no,
</if>
<if test="userAddress != null">user_address,
</if>
<if test="idCardImage != null">id_card_image,
</if>
<if test="hukouImage != null">hukou_image,
</if>
<if test="faceImage != null">face_image,
</if>
<if test="remark != null">remark,
</if>
<if test="userType != null">user_type,
</if>
<if test="groupType != null">group_type,
</if>
<if test="userStatus != null">user_status,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="syncTime != null">sync_time,
</if>
<if test="deptId != null">dept_id,
</if>
<if test="scenicId != null">scenic_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userName != null and userName != ''">#{userName},
</if>
<if test="userCode != null">#{userCode},
</if>
<if test="sex != null">#{sex},</if>
<if test="phone != null">#{phone},
</if>
<if test="idNo != null and idNo != ''">#{idNo},
</if>
<if test="userAddress != null">#{userAddress},
</if>
<if test="idCardImage != null">#{idCardImage},
</if>
<if test="hukouImage != null">#{hukouImage},
</if>
<if test="faceImage != null">#{faceImage},
</if>
<if test="remark != null">#{remark},
</if>
<if test="userType != null">#{userType},
</if>
<if test="groupType != null">#{groupType},
</if>
<if test="userStatus != null">#{userStatus},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="syncTime != null">#{syncTime},
</if>
<if test="deptId != null">#{deptId},
</if>
<if test="scenicId != null">#{scenicId},
</if>
</trim>
</insert>
<update id="updateZdyResidentInfo" parameterType="ZdyResidentInfo">
update zdy_resident_info
<trim prefix="SET" suffixOverrides=",">
<if test="userName != null and userName != ''">user_name =
#{userName},
</if>
<if test="userCode != null">user_code =
#{userCode},
</if>
<if test="sex != null">sex = #{sex},</if>
<if test="phone != null">phone =
#{phone},
</if>
<if test="idNo != null and idNo != ''">id_no =
#{idNo},
</if>
<if test="userAddress != null">user_address =
#{userAddress},
</if>
<if test="idCardImage != null">id_card_image =
#{idCardImage},
</if>
<if test="hukouImage != null">hukou_image =
#{hukouImage},
</if>
<if test="faceImage != null">face_image =
#{faceImage},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="userType != null">user_type =
#{userType},
</if>
<if test="groupType != null">group_type =
#{groupType},
</if>
<if test="userStatus != null">user_status =
#{userStatus},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="syncTime != null">sync_time =
#{syncTime},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
<if test="scenicId != null">scenic_id =
#{scenicId},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteZdyResidentInfoById" parameterType="Long">
update zdy_resident_info set user_status = 3,update_time = now(),update_by =#{currentUserId} where id = #{id}
</update>
<update id="deleteZdyResidentInfoByIds" parameterType="String">
update zdy_resident_info set user_status = 3,
update_time = now()
,update_by =#{currentUserId}
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectMaxId" resultType="java.lang.Long">
select MAX(id) from zdy_resident_info where user_status not in (3)
</select>
<select id="selectIdNo" resultType="java.lang.Long">
select id from zdy_resident_info where user_status not in (3)
and id_no = #{idNo} and dept_id = #{deptId}
<if test="updateId != null">
and id <![CDATA[ <> ]]> #{updateId}
</if>
limit 1
</select>
<select id="selectInfoByIdNo" resultMap="ZdyResidentInfoResult">
<include refid="selectZdyResidentInfoVo"/>
from zdy_resident_info tri
where tri.user_status not in (3)
and tri.id_no = #{idNo}
<if test="updateId != null">
and tri.id <![CDATA[ <> ]]> #{updateId}
</if>
limit 1
</select>
<insert id="insertZdyResidentInfoList" parameterType="java.util.List">
insert into zdy_resident_info
(
id,
user_name,
user_code,
phone,
id_no,
user_address,
id_card_image,
hukou_image,
face_image,
remark,
user_type,
group_type,
user_status,
create_by,
create_time,
update_by,
update_time,
sync_time
)
values
<foreach item="item" index="index" collection="dataList" separator="," close=";">
(
#{item.id},
#{item.userName},
#{item.userCode},
#{item.phone},
#{item.idNo},
#{item.userAddress},
#{item.idCardImage},
#{item.hukouImage},
#{item.faceImage},
#{item.remark},
#{item.userType},
#{item.groupType},
#{item.userStatus},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
#{item.syncTime}
)
</foreach>
</insert>
<select id="getExistingIds" resultType="Long">
-- select * from (select id from zdy_resident_info where user_status not in (3));
select id from zdy_resident_info
</select>
</mapper>

View File

@@ -0,0 +1,353 @@
<?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.zhwl.resident.mapper.ZdyResidentInfoMapper">
<resultMap type="ZdyResidentInfo" id="ZdyResidentInfoResult">
<result property="id" column="id"/>
<result property="userName" column="user_name"/>
<result property="userCode" column="user_code"/>
<result property="sex" column="sex"/>
<result property="phone" column="phone"/>
<result property="idNo" column="id_no"/>
<result property="userAddress" column="user_address"/>
<result property="idCardImage" column="id_card_image"/>
<result property="hukouImage" column="hukou_image"/>
<result property="faceImage" column="face_image"/>
<result property="remark" column="remark"/>
<result property="userType" column="user_type"/>
<result property="groupType" column="group_type"/>
<result property="userStatus" column="user_status"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="groupTypeName" column="groupTypeName" />
<result property="userTypeName" column="userTypeName" />
<result property="userStatusName" column="userStatusName" />
<result property="syncTime" column="syncTime" />
<result property="deptId" column="dept_id"/>
<result property="scenicId" column="scenic_id"/>
<result property="scenicName" column="scenic_name"/>
</resultMap>
<!-- <sql id="selectZdyResidentInfoVo">-->
<!-- select id, user_name, user_code, phone, id_no, user_address, id_card_image, hukou_image, face_image, remark, user_type, group_type, user_status, create_by, create_time, update_by, update_time-->
<!-- from zdy_resident_info-->
<!-- </sql>-->
<sql id="selectZdyResidentInfoVo">
select tri.id, tri.user_name, tri.user_code,tri.sex, tri.phone, tri.id_no, tri.user_address, tri.id_card_image, tri.hukou_image, tri.face_image, tri.remark, tri.user_type, tri.group_type, tri.user_status, tri.create_by, tri.create_time, tri.update_by, tri.update_time, tri.sync_time,tri.dept_id
</sql>
<sql id="selectResidentInfoTuoMinVo">
select tri.id, tri.user_name, tri.user_code,tri.sex, tri.phone
, CONCAT( LEFT(tri.id_no, CHAR_LENGTH(tri.id_no) - 4), REPEAT('*', 4) ) as id_no , tri.user_address, tri.id_card_image, tri.hukou_image, tri.face_image, tri.remark, tri.user_type, tri.group_type, tri.user_status, tri.create_by, tri.create_time, tri.update_by, tri.update_time, tri.sync_time,tri.dept_id
</sql>
<select id="selectZdyResidentInfoList" parameterType="ZdyResidentInfo" resultMap="ZdyResidentInfoResult">
<include refid="selectResidentInfoTuoMinVo"/>
,sdd1.dict_label as groupTypeName
,sdd2.dict_label as userTypeName
,sdd3.dict_label as userStatusName,
tri.scenic_id,
zs.scenic_name
from zdy_resident_info tri
left join sys_dict_data sdd1 on sdd1.dict_value = tri.group_type and sdd1.dict_type = 'group_type'
left join sys_dict_data sdd2 on sdd2.dict_value = tri.user_type and sdd2.dict_type = 'user_type'
left join sys_dict_data sdd3 on sdd3.dict_value = tri.user_status and sdd3.dict_type = 'identity_status'
left join sys_dept d on tri.dept_id = d.dept_id
left join zdy_scenic zs on zs.id = tri.scenic_id
<where>
and tri.user_status not in (3)
<if test="sex != null and sex != ''"> and tri.sex = #{sex}</if>
<if test="userName != null and userName != ''"> and tri.user_name like concat('%', #{userName}, '%')</if>
<if test="userCode != null and userCode != ''"> and tri.user_code = #{userCode}</if>
<if test="phone != null and phone != ''"> and tri.phone like concat('%', #{phone}, '%')</if>
<if test="idNo != null and idNo != ''"> and tri.id_no like concat('%', #{idNo}, '%')</if>
<if test="userAddress != null and userAddress != ''"> and tri.user_address = #{userAddress}</if>
<if test="idCardImage != null and idCardImage != ''"> and tri.id_card_image = #{idCardImage}</if>
<if test="hukouImage != null and hukouImage != ''"> and tri.hukou_image = #{hukouImage}</if>
<if test="faceImage != null and faceImage != ''"> and tri.face_image = #{faceImage}</if>
<if test="userType != null and userType != ''"> and tri.user_type = #{userType}</if>
<if test="groupType != null and groupType != ''"> and tri.group_type = #{groupType}</if>
<if test="userStatus != null and userStatus != ''"> and tri.user_status = #{userStatus}</if>
<if test="startTime != null "> and date(tri.create_time) <![CDATA[ >= ]]> #{startTime}</if>
<if test="endTime != null "> and date(tri.create_time) <![CDATA[ <= ]]> #{endTime}</if>
<if test="scenicId != null "> and tri.scenic_id = #{scenicId}</if>
${params.dataScope}
</where>
order by tri.id desc
</select>
<select id="selectZdyResidentInfoById" parameterType="Long"
resultMap="ZdyResidentInfoResult">
<include refid="selectZdyResidentInfoVo"/>
,sdd1.dict_label as groupTypeName
,sdd2.dict_label as userTypeName
,sdd3.dict_label as userStatusName,
tri.scenic_id,
zs.scenic_name
from zdy_resident_info tri
left join sys_dict_data sdd1 on sdd1.dict_value = tri.group_type and sdd1.dict_type = 'group_type'
left join sys_dict_data sdd2 on sdd2.dict_value = tri.user_type and sdd2.dict_type = 'user_type'
left join sys_dict_data sdd3 on sdd3.dict_value = tri.user_status and sdd3.dict_type = 'identity_status'
left join zdy_scenic zs on zs.id = tri.scenic_id
where tri.id = #{id}
</select>
<select id="selectZdyResidentInfoByIdNo"
resultMap="ZdyResidentInfoResult">
<include refid="selectZdyResidentInfoVo"/>
from zdy_resident_info tri
where tri.user_status not in (3) and tri.id_no = #{idNo} and tri.dept_id = #{deptId}
</select>
<insert id="insertZdyResidentInfo" parameterType="ZdyResidentInfo" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_resident_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userName != null">user_name,
</if>
<if test="userCode != null">user_code,
</if>
<if test="sex != null">sex,</if>
<if test="phone != null">phone,
</if>
<if test="idNo != null and idNo != ''">id_no,
</if>
<if test="userAddress != null">user_address,
</if>
<if test="idCardImage != null">id_card_image,
</if>
<if test="hukouImage != null">hukou_image,
</if>
<if test="faceImage != null">face_image,
</if>
<if test="remark != null">remark,
</if>
<if test="userType != null">user_type,
</if>
<if test="groupType != null">group_type,
</if>
<if test="userStatus != null">user_status,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="syncTime != null">sync_time,
</if>
<if test="deptId != null">dept_id,
</if>
<if test="scenicId != null">scenic_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userName != null and userName != ''">#{userName},
</if>
<if test="userCode != null">#{userCode},
</if>
<if test="sex != null">#{sex},</if>
<if test="phone != null">#{phone},
</if>
<if test="idNo != null and idNo != ''">#{idNo},
</if>
<if test="userAddress != null">#{userAddress},
</if>
<if test="idCardImage != null">#{idCardImage},
</if>
<if test="hukouImage != null">#{hukouImage},
</if>
<if test="faceImage != null">#{faceImage},
</if>
<if test="remark != null">#{remark},
</if>
<if test="userType != null">#{userType},
</if>
<if test="groupType != null">#{groupType},
</if>
<if test="userStatus != null">#{userStatus},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="syncTime != null">#{syncTime},
</if>
<if test="deptId != null">#{deptId},
</if>
<if test="scenicId != null">#{scenicId},
</if>
</trim>
</insert>
<update id="updateZdyResidentInfo" parameterType="ZdyResidentInfo">
update zdy_resident_info
<trim prefix="SET" suffixOverrides=",">
<if test="userName != null and userName != ''">user_name =
#{userName},
</if>
<if test="userCode != null">user_code =
#{userCode},
</if>
<if test="sex != null">sex = #{sex},</if>
<if test="phone != null">phone =
#{phone},
</if>
<if test="idNo != null and idNo != ''">id_no =
#{idNo},
</if>
<if test="userAddress != null">user_address =
#{userAddress},
</if>
<if test="idCardImage != null">id_card_image =
#{idCardImage},
</if>
<if test="hukouImage != null">hukou_image =
#{hukouImage},
</if>
<if test="faceImage != null">face_image =
#{faceImage},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="userType != null">user_type =
#{userType},
</if>
<if test="groupType != null">group_type =
#{groupType},
</if>
<if test="userStatus != null">user_status =
#{userStatus},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="syncTime != null">sync_time =
#{syncTime},
</if>
<if test="deptId != null">dept_id =
#{deptId},
</if>
<if test="scenicId != null">scenic_id =
#{scenicId},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteZdyResidentInfoById" parameterType="Long">
update zdy_resident_info set user_status = 3,update_time = now(),update_by =#{currentUserId} where id = #{id}
</update>
<update id="deleteZdyResidentInfoByIds" parameterType="String">
update zdy_resident_info set user_status = 3,
update_time = now()
,update_by =#{currentUserId}
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="selectMaxId" resultType="java.lang.Long">
select MAX(id) from zdy_resident_info where user_status not in (3)
</select>
<select id="selectIdNo" resultType="java.lang.Long">
select id from zdy_resident_info where user_status not in (3)
and id_no = #{idNo} and dept_id = #{deptId}
<if test="updateId != null">
and id <![CDATA[ <> ]]> #{updateId}
</if>
limit 1
</select>
<select id="selectInfoByIdNo" resultMap="ZdyResidentInfoResult">
<include refid="selectZdyResidentInfoVo"/>
from zdy_resident_info tri
where tri.user_status not in (3)
and tri.id_no = #{idNo}
<if test="updateId != null">
and tri.id <![CDATA[ <> ]]> #{updateId}
</if>
limit 1
</select>
<insert id="insertZdyResidentInfoList" parameterType="java.util.List">
insert into zdy_resident_info
(
id,
user_name,
user_code,
phone,
id_no,
user_address,
id_card_image,
hukou_image,
face_image,
remark,
user_type,
group_type,
user_status,
create_by,
create_time,
update_by,
update_time,
sync_time
)
values
<foreach item="item" index="index" collection="dataList" separator="," close=";">
(
#{item.id},
#{item.userName},
#{item.userCode},
#{item.phone},
#{item.idNo},
#{item.userAddress},
#{item.idCardImage},
#{item.hukouImage},
#{item.faceImage},
#{item.remark},
#{item.userType},
#{item.groupType},
#{item.userStatus},
#{item.createBy},
#{item.createTime},
#{item.updateBy},
#{item.updateTime},
#{item.syncTime}
)
</foreach>
</insert>
<select id="getExistingIds" resultType="Long">
-- select * from (select id from zdy_resident_info where user_status not in (3));
select id from zdy_resident_info
</select>
</mapper>