自测问题

This commit is contained in:
jjLv 2024-08-22 10:34:31 +08:00
parent 982f01231b
commit fd89054e91
4 changed files with 64 additions and 35 deletions

View File

@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ELSE ''
END AS idCard
FROM tb_bracelet blt
left join tb_sh_box sbx on blt.box_id=sbx.id and sbx.del_flag = 0
left join tb_sh_box sbx on blt.box_ix=sbx.id and sbx.del_flag = 0
left join t_work_team twt on sbx.team_id = twt.team_id and twt.del_flag= 0
left join tb_project_power tpp on tpp.id=sbx.gt_id and tpp.del_flag = 0
left join tb_people tpe on blt.bid_id=tpe.id and peopel_type=0 and tpe.name is not null and tpe.name!=''

View File

@ -100,6 +100,13 @@ public interface BraceletMapper {
*/
BraceletVo isCodeExist(ShboxVo vo);
/**
* 修改时手环编号是否重复
* @param vo
* @return
*/
BraceletVo isCodeEditExist(ShboxVo vo);
/**
* 新增时级联编码是否重复
* @param vo

View File

@ -51,27 +51,21 @@ public class BraceletServiceImpl implements IBraceletService {
@Override
public List<BraceletVo> getBraceletLists(BraceletVo data) {
List<BraceletVo> list = new ArrayList<>();
List<BraceletVo> listFilter = new ArrayList<>();
List<BraceletVo> listFilter = new ArrayList<>();
try {
list = braceletMapper.getBraceletLists(data);
for (int i = 0; i < list.size(); i++) {
if(list.get(i).getShPersonType()==0){
String name = braceletMapper.getBraceletPersonName(list.get(i).getShPersonId());
list.get(i).setShPersonName(name);
}else if(list.get(i).getShPersonType()==1){
String name = braceletMapper.getDeviceLyPersonNameTemp(list.get(i).getShPersonId());
list.get(i).setShPersonName(name);
}
if(list.get(i).getShboxName()==null || list.get(i).getShboxName().equals("")){
list.get(i).setShboxName("未绑定");
if(list.get(i).getShPersonName()==null || list.get(i).getShPersonName().equals("")){
list.get(i).setShStatus(1);
}else{
list.get(i).setShStatus(0);
}
}
if(data.getShPersonName()!=null){
listFilter = list.stream().filter(bracelet -> data.getShPersonName().equals(bracelet.getShPersonName())).collect(Collectors.toList());
}else{
listFilter = list;
}
if(data.getShStatus()!=null){
listFilter = list.stream().filter(bracelet -> data.getShStatus()==(bracelet.getShStatus())).collect(Collectors.toList());
}else{
listFilter = list;
}
} catch (Exception e) {
log.error(e.toString(), e);
}
@ -175,9 +169,16 @@ public class BraceletServiceImpl implements IBraceletService {
@Transactional(rollbackFor = Exception.class)
public AjaxResult addSh(ShboxVo vo) {
try {
if(vo.getShboxBindNum()!=null && vo.getShboxCapacity()!=null)
{
if(vo.getShboxBindNum()>=vo.getShboxCapacity()){
return AjaxResult.error("手环箱绑定数量已满,请重新选择");
}
}
BraceletVo result = braceletMapper.isCodeExist(vo);
if (result != null) {
return AjaxResult.error("手环编号已存在");
return AjaxResult.error("手环编号已存在,请重新输入");
}
if(vo.getShboxId()==null){
vo.setShStatus(1);
@ -334,11 +335,11 @@ public class BraceletServiceImpl implements IBraceletService {
try {
ShboxVo result = braceletMapper.isBoxCodeExistTemp(vo);
if (result != null) {
return AjaxResult.error("手环箱编号已存在");
return AjaxResult.error("手环箱编号已存在,请重新输入");
}
ShboxVo result2 = braceletMapper.isBoxNameExistTemp(vo);
if (result2 != null) {
return AjaxResult.error("手环箱名称已存在");
return AjaxResult.error("手环箱名称已存在,请重新输入");
}
int num = braceletMapper.addBox(vo);
if(num==1){
@ -361,7 +362,7 @@ public class BraceletServiceImpl implements IBraceletService {
public AjaxResult addShBind(ShboxVo vo) {
try {
if(vo.getShboxBindNum()>=vo.getShboxCapacity()){
return AjaxResult.error("手环箱绑定数量已满,无法绑定");
return AjaxResult.error("手环箱绑定数量已满,请重新选择");
}
int num = braceletMapper.addShBind(vo);
if(num==1){
@ -399,11 +400,13 @@ public class BraceletServiceImpl implements IBraceletService {
@Transactional(rollbackFor = Exception.class)
public AjaxResult editSh(ShboxVo vo) {
try {
if(vo.getShboxId()==null){
vo.setShStatus(1);
}else{
vo.setShStatus(0);
}
if(vo.getShboxBindNum()>=vo.getShboxCapacity()){
return AjaxResult.error("手环箱绑定数量已满,请重新选择");
}
BraceletVo result = braceletMapper.isCodeEditExist(vo);
if (result != null) {
return AjaxResult.error("手环编号已存在,请重新输入");
}
int num = braceletMapper.updateSh(vo);
if(num==1){
return AjaxResult.success();
@ -421,11 +424,11 @@ public class BraceletServiceImpl implements IBraceletService {
try {
ShboxVo result = braceletMapper.isBoxCodeExist(vo);
if (result != null) {
return AjaxResult.error("手环箱编号已存在");
return AjaxResult.error("手环箱编号已存在,请重新输入");
}
ShboxVo result2 = braceletMapper.isBoxNameExist(vo);
if (result2 != null) {
return AjaxResult.error("手环箱名称已存在");
return AjaxResult.error("手环箱名称已存在,请重新输入");
}
int num = braceletMapper.updateShbox(vo);
if(num==1){

View File

@ -5,22 +5,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bonus.bracelet.mapper.BraceletMapper">
<!--手环列表-->
<select id="getBraceletLists" resultType="com.bonus.common.entity.bracelet.vo.BraceletVo">
select tb.id as shId,tb.sh_code as shCode,sh_status as shStatus,tsb.box_name as shboxName,
select tb.id as shId,tb.sh_code as shCode,
case
WHEN tb.peopel_type=0 then tpe.name
WHEN tb.peopel_type=1 then tlu.name
ELSE ''
END AS shPersonName,
case
WHEN (tsb.box_name is null or tsb.box_name='') then '未绑定'
WHEN (tsb.box_name is not null and tsb.box_name!='') then tsb.box_name
ELSE '未绑定'
END AS shboxName,
tsb.box_code as shboxCode,tb.peopel_type as shPersonType,tb.bid_id as shPersonId,tsb.id as shboxId
from tb_bracelet tb
left join tb_sh_box tsb on tb.box_id = tsb.id and tsb.del_flag = 0
left join tb_people tpe on tb.bid_id=tpe.id and tb.peopel_type=0
left join tb_ls_user tlu on tb.bid_id=tlu.id and tb.peopel_type=1
where tb.del_flag = 0
<if test="shCode != null and shCode!=''">
AND INSTR(tb.sh_code,#{shCode}) > 0
</if>
<if test="shboxName != null and shboxName!=''">
AND INSTR(tsb.box_name,#{shboxName}) > 0
<if test="shboxName != null and shboxName!='' and shboxName != '未绑定'">
AND INSTR(tsb.box_name,#{shboxName}) > 0
</if>
<if test="shboxCode != null and shboxCode!=''">
AND INSTR(tsb.box_code,#{shboxCode}) > 0
<if test="shboxName == '未绑定'">
AND (tsb.box_name is null or tsb.box_name='')
</if>
<if test="shStatus != null">
AND tb.sh_status = #{shStatus}
<if test="shPersonName != null and shPersonName!=''">
AND (tpe.name=#{shPersonName} or tlu.name=#{shPersonName})
</if>
order by tb.id ASC
</select>
@ -130,6 +142,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where tb.sh_code = #{shCode} and del_flag = 0
</select>
<!--判断修改时手环编号是否存在-->
<select id="isCodeEditExist" resultType="com.bonus.common.entity.bracelet.vo.BraceletVo">
select id as shId
from tb_bracelet tb
where tb.sh_code = #{shCode} and tb.id != #{shId} and del_flag = 0
</select>
<!--判断新增时级联编码是否存在-->
<select id="isDataCodeExist" resultType="com.bonus.common.entity.bracelet.vo.AttributeVo">
select dev_id as devId,data_name as dataName,data_val as dataVal,data_unit as dataUnit,data_code as dataCode