接口优化
This commit is contained in:
parent
9b9d64a8d6
commit
42336505d2
|
|
@ -59,7 +59,7 @@ public interface TbPeopleMapper {
|
|||
* @param tbPeople
|
||||
* @return
|
||||
*/
|
||||
TbPeople queryByName(TbPeople tbPeople);
|
||||
List<TbPeople> queryByName(TbPeople tbPeople);
|
||||
|
||||
/**
|
||||
* 根据工程ID查询人员定位信息
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
if (StringUtils.isNotBlank(people.getRelPhone())) {
|
||||
people.setRelPhone(Sm4Utils.decode(people.getRelPhone()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(people.getIdCard())) {
|
||||
people.setIdCard(Sm4Utils.decode(people.getIdCard()));
|
||||
}
|
||||
});
|
||||
}
|
||||
return peopleList;
|
||||
|
|
@ -117,12 +120,24 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
}
|
||||
}
|
||||
//同名同身份证号判重
|
||||
TbPeople people = tbPeopleDao.queryByName(tbPeople);
|
||||
/*TbPeople people = tbPeopleDao.queryByName(tbPeople);
|
||||
if (people != null) {
|
||||
return AjaxResult.error(ExceptionEnum.ID_CARD_DUPLICATE.getCode(), ExceptionEnum.ID_CARD_DUPLICATE.getMsg());
|
||||
}*/
|
||||
List<TbPeople> peopleList = tbPeopleDao.queryByName(tbPeople);
|
||||
//对查询的身份证号进行解密处理,然后和新增的进行对比
|
||||
if (CollectionUtils.isNotEmpty(peopleList)) {
|
||||
for (TbPeople people : peopleList) {
|
||||
if (StringUtils.isNotBlank(people.getIdCard()) && StringUtils.isNotBlank(tbPeople.getIdCard())) {
|
||||
if (Objects.equals(Sm4Utils.decode(people.getIdCard()), tbPeople.getIdCard())) {
|
||||
return AjaxResult.error(ExceptionEnum.ID_CARD_DUPLICATE.getCode(), ExceptionEnum.ID_CARD_DUPLICATE.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tbPeople.setCreateUser(SecurityUtils.getUserId());
|
||||
tbPeople.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
tbPeople.setIdCard(Sm4Utils.encode(tbPeople.getIdCard()));
|
||||
int result = tbPeopleDao.insert(tbPeople);
|
||||
if (result > 0) {
|
||||
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);
|
||||
|
|
@ -183,14 +198,27 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
}
|
||||
}
|
||||
//同名同身份证号判重
|
||||
TbPeople people = tbPeopleDao.queryByName(tbPeople);
|
||||
/*TbPeople people = tbPeopleDao.queryByName(tbPeople);
|
||||
if (people != null) {
|
||||
if (!Objects.equals(people.getId(), tbPeople.getId())) {
|
||||
return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg());
|
||||
}
|
||||
}*/
|
||||
List<TbPeople> peopleList = tbPeopleDao.queryByName(tbPeople);
|
||||
if (CollectionUtils.isNotEmpty(peopleList)) {
|
||||
for (TbPeople people : peopleList) {
|
||||
if (StringUtils.isNotBlank(people.getIdCard()) && StringUtils.isNotBlank(tbPeople.getIdCard())) {
|
||||
if (Objects.equals(Sm4Utils.decode(people.getIdCard()), tbPeople.getIdCard())) {
|
||||
if (!Objects.equals(people.getId(), tbPeople.getId())) {
|
||||
return AjaxResult.error(ExceptionEnum.ID_CARD_DUPLICATE.getCode(), ExceptionEnum.ID_CARD_DUPLICATE.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tbPeople.setUpdateUser(SecurityUtils.getUserId());
|
||||
tbPeople.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
tbPeople.setIdCard(Sm4Utils.encode(tbPeople.getIdCard()));
|
||||
int result = tbPeopleDao.update(tbPeople);
|
||||
//根据人员id去班组表中修改人员信息,先根据人员id去班组表中查询
|
||||
List<TbTeam> tbTeamList = tbTeamDao.selectListById(tbPeople.getId());
|
||||
|
|
@ -354,29 +382,35 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
List<TbPeopleDto> tbPeopleList = util.importExcel(file.getInputStream());
|
||||
int result = 0;
|
||||
for (TbPeopleDto tbPeople : tbPeopleList) {
|
||||
TbPeople people = tbPeopleDao.queryByName(tbPeople);
|
||||
if (people != null) {
|
||||
//进行更新操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setId(people.getId());
|
||||
dto.setUpdateUser(SecurityUtils.getUserId());
|
||||
dto.setDelFlag(0);
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(tbPeople.getIdCard());
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.update(dto);
|
||||
} else {
|
||||
//新增操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setCreateUser(SecurityUtils.getUserId());
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(tbPeople.getIdCard());
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.insert(dto);
|
||||
List<TbPeople> peopleList = tbPeopleDao.queryByName(tbPeople);
|
||||
if (CollectionUtils.isNotEmpty(peopleList)) {
|
||||
for (TbPeople people : peopleList) {
|
||||
if (StringUtils.isNotBlank(people.getIdCard()) && StringUtils.isNotBlank(tbPeople.getIdCard())) {
|
||||
if (Objects.equals(Sm4Utils.decode(people.getIdCard()), tbPeople.getIdCard())) {
|
||||
//进行更新操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setId(people.getId());
|
||||
dto.setUpdateUser(SecurityUtils.getUserId());
|
||||
dto.setDelFlag(0);
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(Sm4Utils.encode(tbPeople.getIdCard()));
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.update(dto);
|
||||
} else {
|
||||
//新增操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setCreateUser(SecurityUtils.getUserId());
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(Sm4Utils.encode(tbPeople.getIdCard()));
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.insert(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result > 0) {
|
||||
|
|
@ -390,7 +424,15 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
|
||||
@Override
|
||||
public List<PeoplePositionVo> queryPeoplePositionByProId(Integer proId) {
|
||||
return tbPeopleDao.queryPeoplePositionByProId(proId);
|
||||
List<PeoplePositionVo> list = tbPeopleDao.queryPeoplePositionByProId(proId);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
list.forEach(peoplePositionVo -> {
|
||||
if (StringUtils.isNotBlank(peoplePositionVo.getIdCard())) {
|
||||
peoplePositionVo.setIdCard(Sm4Utils.decode(peoplePositionVo.getIdCard()));
|
||||
}
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -62,9 +62,6 @@
|
|||
tp.sex as sex
|
||||
from tb_people tp
|
||||
where tp.del_flag = '0'
|
||||
<if test="idCard != null and idCard != ''">
|
||||
and tp.id_card = #{idCard}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
|
|
@ -157,7 +154,7 @@
|
|||
</select>
|
||||
|
||||
<select id="getUserById" resultType="com.bonus.system.api.domain.SysUser">
|
||||
select user_id as userId, user_name as userName, password as password from sys_user where id = #{id}
|
||||
select user_id as userId, user_name as userName, password as password from sys_user where user_id = #{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
|
|
@ -78,19 +78,24 @@
|
|||
</select>
|
||||
|
||||
<select id="selectDeviceList" resultType="com.bonus.base.basic.vo.TbDeviceVo">
|
||||
select td.id as devId,
|
||||
td.dev_name as devName,
|
||||
td.dev_type as devType,
|
||||
td.dev_code as devCode
|
||||
from tb_device td
|
||||
where td.del_flag = '0' and td.dev_type = '123'
|
||||
AND NOT EXISTS(SELECT 1 FROM tb_people tp WHERE tp.dev_id = td.id AND tp.del_flag = '0')
|
||||
SELECT td.id AS devId,
|
||||
td.dev_name AS devName,
|
||||
td.dev_type AS devType,
|
||||
td.dev_code AS devCode
|
||||
FROM tb_device td
|
||||
LEFT JOIN tb_dev_attribute tda ON tda.dev_id = td.id AND tda.del_flag = 0
|
||||
WHERE td.del_flag = '0'
|
||||
AND td.dev_type = '123'
|
||||
AND NOT EXISTS (SELECT 1 FROM tb_people tp WHERE tp.dev_id = td.id AND tp.del_flag = '0')
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
td.dev_name LIKE CONCAT('%', #{keyWord}, '%')
|
||||
OR td.dev_code LIKE CONCAT('%', #{keyWord}, '%')
|
||||
)
|
||||
</if>
|
||||
GROUP BY td.id, td.dev_name, td.dev_type, td.dev_code
|
||||
HAVING COUNT(CASE WHEN tda.jc_name = '经度' AND tda.jc_value IS NOT NULL THEN 1 END) > 0
|
||||
AND COUNT(CASE WHEN tda.jc_name = '纬度' AND tda.jc_value IS NOT NULL THEN 1 END) > 0
|
||||
</select>
|
||||
|
||||
<select id="selectList" resultType="com.bonus.base.basic.domain.TbPeople">
|
||||
|
|
|
|||
Loading…
Reference in New Issue