Commit 8043834c authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register_test' into develop_tzs_register

parents ab29a405 d6986cfa
......@@ -654,8 +654,8 @@ public class ElevatorController extends BaseController {
* @return 成功处理条数
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/v1/es/insert", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "电梯信息放入es", notes = "电梯信息放入es")
@RequestMapping(value = "/v1/es/insert", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "电梯信息放入es", notes = "电梯信息放入es")
public ResponseModel<String> esInsert() {
Long total = iElevatorService.esInsert();
return ResponseHelper.buildResponse("success insert: " + total);
......
......@@ -4,6 +4,7 @@ package com.yeejoin.amos.boot.module.jg.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.jg.api.bo.JgBizCountDataBO;
......@@ -251,10 +252,10 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
/**
* 查询指定设备,使用登记后,后续业务的数据
*
* @param record 设备标识
* @param equipTransferId 使用登记主表id
* @return 后续业务数量
*/
Integer countBizNumAfterUseReg(@Param("record") String record);
Long countBizNumAfterUseReg(@Param("equipTransferId") String equipTransferId);
/**
* 车用气瓶-使用登记证编号全库唯一校验
......
......@@ -2477,7 +2477,7 @@
where record = #{record}
</if>
</update>
<select id="countBizNumAfterUseReg" resultType="java.lang.Integer">
<select id="countBizNumAfterUseReg" resultType="java.lang.Long">
select
sum(inUseNumber)
from (
......@@ -2488,7 +2488,7 @@
tzs_jg_change_registration_reform_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and b.equ_id in (SELECT equ_id FROM "amos_tzs_biz"."tzs_jg_use_registration_eq" WHERE "equip_transfer_id" = #{equipTransferId})
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
......@@ -2498,7 +2498,7 @@
tzs_jg_change_registration_transfer_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and b.equ_id in (SELECT equ_id FROM "amos_tzs_biz"."tzs_jg_use_registration_eq" WHERE "equip_transfer_id" = #{equipTransferId})
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
......@@ -2508,7 +2508,7 @@
tzs_jg_change_registration_unit_eq b
where
a.sequence_nbr = b.unit_change_registration_id
and b.equ_id = #{record}
and b.equ_id in (SELECT equ_id FROM "amos_tzs_biz"."tzs_jg_use_registration_eq" WHERE "equip_transfer_id" = #{equipTransferId})
and (a.status <![CDATA[ <> ]]> '使用单位待提交' and a.status <![CDATA[ <> ]]> '已作废')
UNION all
select
......@@ -2518,7 +2518,7 @@
tzs_jg_scrap_cancel_eq b
where
a.sequence_nbr = b.equip_transfer_id
and b.equ_id = #{record}
and b.equ_id in (SELECT equ_id FROM "amos_tzs_biz"."tzs_jg_use_registration_eq" WHERE "equip_transfer_id" = #{equipTransferId})
and (a.audit_status <![CDATA[ <> ]]> '使用单位待提交' and a.audit_status <![CDATA[ <> ]]> '已作废')
UNION all
select
......@@ -2533,7 +2533,7 @@
n.sequence_nbr = e.name_change_registration_id
and n.audit_status <![CDATA[ <> ]]> '使用单位待提交' and n.audit_status <![CDATA[ <> ]]> '已作废') ne
where
ne.record = #{record}
ne.record in (SELECT equ_id FROM "amos_tzs_biz"."tzs_jg_use_registration_eq" WHERE "equip_transfer_id" = #{equipTransferId})
)
</select>
......
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.yeejoin.amos.boot.module.jg.api.dto.FlowingEquipRedisKeyDTO;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IEquipUsedCheck;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBucket;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.Collections;
import java.util.List;
......@@ -23,8 +21,6 @@ import java.util.stream.Collectors;
@Slf4j
public abstract class BaseEquipUsedCheckService implements IEquipUsedCheck {
@Autowired
CommonMapper commonMapper;
/**
* 并发校验(页面同时提交或者页面同时打开多个时,某些设备都是为使用状态)校验设备流程在用状态及更新不在用为再使用状态
......@@ -44,26 +40,29 @@ public abstract class BaseEquipUsedCheckService implements IEquipUsedCheck {
RBucket<Set<String>> RBucket = getRedisClient().getBucket(this.getFlowingEquipRedisKey(companyCode, getApplyBizType()));
Set<String> equipListOfUsed = RBucket.get();
// 查询当前设备在流程中的申请单号列表
List<String> equipInUseList = commonMapper.findEquipInUseService(record);
if (equipListOfUsed != null && equipListOfUsed.contains(record)) {
String joinedEquipInUse = String.join(",", equipInUseList);
log.error("设备已被其他流程使用,不允许重复提交,设备ID:{},在流程中申请单:{}", record, joinedEquipInUse);
log.error("设备已被其他流程使用,不允许重复提交,设备ID:{}", record);
throw new BadRequest("设备已被其他流程使用,不允许重复提交,请联系管理员!");
}
if (equipListOfUsed == null || equipListOfUsed.isEmpty()) {
equipListOfUsed = new TreeSet<>();
}
equipListOfUsed.add(record);
getRedisClient().getBucket(this.getFlowingEquipRedisKey(companyCode, getApplyBizType())).set(equipListOfUsed);
FlowingEquipRedisContext.setRedisKeyInfo(new FlowingEquipRedisKeyDTO(this.getFlowingEquipRedisKey(companyCode, getApplyBizType()), Collections.singletonList(record)));
setUsingData2Redis(record, companyCode, equipListOfUsed);
} catch (InterruptedException e) {
e.printStackTrace();
log.error( e.getMessage(), e);
} finally {
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
private void setUsingData2Redis(String record, String companyCode, Set<String> equipListOfUsed) {
if (equipListOfUsed == null || equipListOfUsed.isEmpty()) {
equipListOfUsed = new TreeSet<>();
}
equipListOfUsed.add(record);
getRedisClient().getBucket(this.getFlowingEquipRedisKey(companyCode, getApplyBizType())).set(equipListOfUsed);
FlowingEquipRedisContext.setRedisKeyInfo(new FlowingEquipRedisKeyDTO(this.getFlowingEquipRedisKey(companyCode, getApplyBizType()), Collections.singletonList(record)));
}
@Override
public void registrationRepeatUsedCheck(String record, String companyCode) {
RLock lock = getRedisClient().getLock(this.getRepeatUsedCheckLockKey(companyCode, getApplyBizType(), record));
......@@ -76,20 +75,13 @@ public abstract class BaseEquipUsedCheckService implements IEquipUsedCheck {
RBucket<Set<String>> RBucket = getRedisClient().getBucket(this.getFlowingEquipRedisKey(companyCode, getApplyBizType()));
Set<String> equipListOfUsed = RBucket.get();
// 查询当前设备在用的申请单号列表
List<String> equipInUseList = commonMapper.findEquipInUseService(record);
if (equipListOfUsed != null && equipListOfUsed.contains(record)) {
String joinedEquipInUse = String.join(",", equipInUseList);
log.error("使用登记证已被其他流程使用,不允许重复提交,设备ID:{},在流程中申请单:{}", record, joinedEquipInUse);
log.error("使用登记证已被其他流程使用,不允许重复提交,使用登记证ID:{}", record);
throw new BadRequest("使用登记证已被其他流程使用,不允许重复提交,请联系管理员!");
}
if (equipListOfUsed == null || equipListOfUsed.isEmpty()) {
equipListOfUsed = new TreeSet<>();
}
equipListOfUsed.add(record);
getRedisClient().getBucket(this.getFlowingEquipRedisKey(companyCode, getApplyBizType())).set(equipListOfUsed);
FlowingEquipRedisContext.setRedisKeyInfo(new FlowingEquipRedisKeyDTO(this.getFlowingEquipRedisKey(companyCode, getApplyBizType()), Collections.singletonList(record)));
setUsingData2Redis(record, companyCode, equipListOfUsed);
} catch (InterruptedException e) {
e.printStackTrace();
log.error( e.getMessage(), e);
} finally {
if (lock.isHeldByCurrentThread()) {
lock.unlock();
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
......@@ -41,23 +42,13 @@ public class FillingUseRegisterResult extends BaseUseRegisterResultData {
*/
private void fillingEditPermission(JSONObject jsonObject) {
jsonObject.put(HAPPEN_AFTER_BIZ, false);
List<JgUseRegistrationEq> useRegistrationEqs = getJgUseRegistrationEqService().list(new LambdaQueryWrapper<JgUseRegistrationEq>()
.eq(JgUseRegistrationEq::getEquipTransferId, userRegisterId)
.select(JgUseRegistrationEq::getEquId, BaseEntity::getSequenceNbr));
for (JgUseRegistrationEq useRegistrationEq : useRegistrationEqs) {
Integer useTimes = getCommonMapper().countBizNumAfterUseReg(useRegistrationEq.getEquId());
if (useTimes > 0) {
log.warn("设备:{}做过后续业务, 此使用登记:{}不可再变更设备信息", useRegistrationEq.getEquId(), userRegisterId);
jsonObject.put(HAPPEN_AFTER_BIZ, true);
break;
}
Long useTimes = getCommonMapper().countBizNumAfterUseReg(userRegisterId + "");
if (useTimes > 0) {
log.warn("此使用登记:{},存在设备做过后续业务,不可再变更设备信息", userRegisterId);
jsonObject.put(HAPPEN_AFTER_BIZ, true);
}
}
private JgUseRegistrationEqServiceImpl getJgUseRegistrationEqService() {
return applicationContext.getBean(JgUseRegistrationEqServiceImpl.class);
}
private CommonMapper getCommonMapper() {
return applicationContext.getBean(CommonMapper.class);
}
......
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