Commit 38a531bd authored by 韩桐桐's avatar 韩桐桐

fix(jg):三环车用气瓶监听查询接口排除已经入库的一部分数据

parent 75771fd9
...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto; import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCar; import com.yeejoin.amos.boot.module.jg.api.entity.ShCar;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/** /**
* 三环系统-车辆信息表 Mapper 接口 * 三环系统-车辆信息表 Mapper 接口
...@@ -15,4 +17,6 @@ public interface ShCarMapper extends BaseMapper<ShCar> { ...@@ -15,4 +17,6 @@ public interface ShCarMapper extends BaseMapper<ShCar> {
Page<ShCarDto> queryForshCarPage(Page<ShCarDto> page, ShCarDto dto); Page<ShCarDto> queryForshCarPage(Page<ShCarDto> page, ShCarDto dto);
Integer alreadyExist(@Param("value") String value);
} }
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.api.service; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.api.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto; import com.yeejoin.amos.boot.module.jg.api.dto.ShCarDto;
import com.yeejoin.amos.boot.module.jg.api.entity.ShCar;
import java.util.Map; import java.util.Map;
...@@ -16,4 +17,6 @@ public interface IShCarService { ...@@ -16,4 +17,6 @@ public interface IShCarService {
Page<ShCarDto> queryForShCarPage(Page<ShCarDto> page, ShCarDto dto); Page<ShCarDto> queryForShCarPage(Page<ShCarDto> page, ShCarDto dto);
Boolean claim(Map<String, Object> paramMap); Boolean claim(Map<String, Object> paramMap);
ShCar searchForSanHan(Map<?, ?> map);
} }
...@@ -25,4 +25,18 @@ ...@@ -25,4 +25,18 @@
ORDER BY ORDER BY
tsc.USE_REGISTRATION_CODE DESC tsc.USE_REGISTRATION_CODE DESC
</select> </select>
<select id="alreadyExist" resultType="java.lang.Integer">
SELECT SUM(num) AS total_count
FROM (SELECT COUNT(*) AS num
FROM "amos_tzs_biz"."idx_biz_jg_register_info" jri
LEFT JOIN "amos_tzs_biz"."idx_biz_jg_other_info" joi ON joi."RECORD" = jri."RECORD"
WHERE (jri."USE_ORG_CODE" = #{value} OR jri."CAR_NUMBER" = #{value})
AND joi.CLAIM_STATUS = '已认领'
UNION ALL
SELECT COUNT(*) AS num
FROM "amos_tzs_biz"."tzs_jg_vehicle_information"
WHERE "identification_code" = #{value}
and "status" != '已作废') AS combined_counts;
</select>
</mapper> </mapper>
...@@ -42,9 +42,6 @@ public class ShCarController extends BaseController { ...@@ -42,9 +42,6 @@ public class ShCarController extends BaseController {
@Autowired @Autowired
ShCarServiceImpl shCarServiceImpl; ShCarServiceImpl shCarServiceImpl;
@Resource
ShCarEquServiceImpl shCarEquServiceImpl;
@Autowired @Autowired
IShCarService iShCarService; IShCarService iShCarService;
...@@ -161,58 +158,7 @@ public class ShCarController extends BaseController { ...@@ -161,58 +158,7 @@ public class ShCarController extends BaseController {
if (map == null || map.isEmpty()) { if (map == null || map.isEmpty()) {
return ResponseHelper.buildResponse(new ShCar()); // 返回空对象 return ResponseHelper.buildResponse(new ShCar()); // 返回空对象
} }
return ResponseHelper.buildResponse(shCarServiceImpl.searchForSanHan(map));
ShCar shCar = null;
for (Object value : map.values()) {
String sanHuanInputValue = String.valueOf(value);
// 如果值为空,直接跳过
if (ValidationUtil.isEmpty(sanHuanInputValue)) {
continue;
}
// 查询 ShCar 表
shCar = shCarServiceImpl.getBaseMapper()
.selectList(new LambdaQueryWrapper<ShCar>()
.eq(ShCar::getClaimedFlag, Boolean.FALSE)
.and(w -> w
.eq(ShCar::getCarNumber, sanHuanInputValue)
.or()
.eq(ShCar::getUseRegistrationCode, sanHuanInputValue)
.or()
.eq(ShCar::getFrameNumber, sanHuanInputValue)
)
).stream().findFirst().orElse(null);
// 如果找到符合条件的 ShCar,直接返回
if (shCar != null && !ValidationUtil.isEmpty(shCar.getSequenceNbr())) {
return ResponseHelper.buildResponse(shCar);
}
// 查询 ShCarEqu 表
Optional<ShCarEqu> carEqu = shCarEquServiceImpl.getBaseMapper()
.selectList(new LambdaQueryWrapper<ShCarEqu>()
.eq(ShCarEqu::getEquCode, sanHuanInputValue))
.stream().findFirst();
// 如果 ShCarEqu 存在,继续查询 ShCar
if (carEqu.isPresent()) {
shCar = shCarServiceImpl.getBaseMapper()
.selectList(new LambdaQueryWrapper<ShCar>()
.eq(ShCar::getClaimedFlag, Boolean.FALSE)
.eq(ShCar::getSequenceNbr, carEqu.get().getCarId())
).stream().findFirst().orElse(null);
// 如果找到,直接返回
if (shCar != null && !ValidationUtil.isEmpty(shCar.getSequenceNbr())) {
return ResponseHelper.buildResponse(shCar);
}
}
}
// 如果未找到,返回空对象
return ResponseHelper.buildResponse(new ShCar());
} }
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
...@@ -64,6 +65,8 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -64,6 +65,8 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
@Resource @Resource
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Resource @Resource
ShCarEquServiceImpl shCarEquServiceImpl;
@Resource
private SnowflakeIdUtil sequence; private SnowflakeIdUtil sequence;
@Resource @Resource
private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService; private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
...@@ -128,6 +131,63 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp ...@@ -128,6 +131,63 @@ public class ShCarServiceImpl extends BaseService<ShCar, ShCar, ShCarMapper> imp
} }
@Override @Override
public ShCar searchForSanHan(Map<?, ?> map) {
ShCar shCar = null;
for (Object value : map.values()) {
String sanHuanInputValue = String.valueOf(value);
// 如果值为空,直接跳过
if (ValidationUtil.isEmpty(sanHuanInputValue)) {
continue;
}
// 查询 ShCar 表
shCar = this.getBaseMapper()
.selectList(new LambdaQueryWrapper<ShCar>()
.eq(ShCar::getClaimedFlag, Boolean.FALSE)
.and(w -> w
.eq(ShCar::getCarNumber, sanHuanInputValue)
.or()
.eq(ShCar::getUseRegistrationCode, sanHuanInputValue)
.or()
.eq(ShCar::getFrameNumber, sanHuanInputValue)
)
).stream().findFirst().orElse(null);
// 如果找到符合条件的 ShCar,再检查该使用登记证号、车牌号或者车架号是否已经在系统中通过历史设备登记入库
if (shCar != null && !ValidationUtil.isEmpty(shCar.getSequenceNbr()) && !alreadyExist(sanHuanInputValue)) {
return shCar;
}
// 查询 ShCarEqu 表
Optional<ShCarEqu> carEqu = shCarEquServiceImpl.getBaseMapper()
.selectList(new LambdaQueryWrapper<ShCarEqu>()
.eq(ShCarEqu::getEquCode, sanHuanInputValue))
.stream().findFirst();
// 如果 ShCarEqu 存在,继续查询 ShCar
if (carEqu.isPresent()) {
shCar = this.getBaseMapper()
.selectList(new LambdaQueryWrapper<ShCar>()
.eq(ShCar::getClaimedFlag, Boolean.FALSE)
.eq(ShCar::getSequenceNbr, carEqu.get().getCarId())
).stream().findFirst().orElse(null);
// 如果找到,再检查该使用登记证号、车牌号或者车架号是否已经在系统中通过历史设备登记入库
if (shCar != null && !ValidationUtil.isEmpty(shCar.getSequenceNbr()) && !alreadyExist(sanHuanInputValue)) {
return shCar;
}
}
}
// 如果未找到,返回空对象
return new ShCar();
}
/**
* 判断是否已存在在一码通库中
*
* @param value 登记证号、车牌号或者车架号
* @return result
*/
public Boolean alreadyExist(String value) {
return this.baseMapper.alreadyExist(value) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean claim(Map<String, Object> paramMap) { public Boolean claim(Map<String, Object> paramMap) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment