Commit 0ec9b81d authored by lilongyang's avatar lilongyang

解决bug20292 【web端-投融管理】 两个人同时操作一条数据(待推送、整改待推送)状态,去推送融资,select * from hygf_financing_auditing 会插入重复记录

parent c07fb06d
...@@ -30,11 +30,13 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.FinancingRectificationOrder; ...@@ -30,11 +30,13 @@ import com.yeejoin.amos.boot.module.hygf.api.entity.FinancingRectificationOrder;
import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower; import com.yeejoin.amos.boot.module.hygf.api.entity.StdUserEmpower;
import com.yeejoin.amos.boot.module.hygf.api.mapper.FinancingInfoMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.FinancingInfoMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.IFinancingInfoService; import com.yeejoin.amos.boot.module.hygf.api.service.IFinancingInfoService;
import com.yeejoin.amos.boot.module.hygf.api.util.RedisLockUtil;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO; import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO; import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO; import com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO; import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import io.seata.spring.annotation.GlobalTransactional; import io.seata.spring.annotation.GlobalTransactional;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -42,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -42,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.annotation.Resource;
import java.util.*; import java.util.*;
/** /**
...@@ -71,6 +74,9 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina ...@@ -71,6 +74,9 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina
@Autowired @Autowired
private CommonServiceImpl commonService; private CommonServiceImpl commonService;
@Resource(type = RedisLockUtil.class)
private RedisLockUtil redisLockUtil;
@UserLimits @UserLimits
public Page<Map<String, Object>> queryForFinancingInfoPage(Page<Map<String, Object>> page, String type, String status, String regionalCompaniesCode, String ownersName) { public Page<Map<String, Object>> queryForFinancingInfoPage(Page<Map<String, Object>> page, String type, String status, String regionalCompaniesCode, String ownersName) {
StdUserEmpower orgCode = (StdUserEmpower) redisUtils.get("Emp_" + RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())); StdUserEmpower orgCode = (StdUserEmpower) redisUtils.get("Emp_" + RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()));
...@@ -115,6 +121,13 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina ...@@ -115,6 +121,13 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina
} }
public FinancingInfoDto saveModel(FinancingInfoDto model) { public FinancingInfoDto saveModel(FinancingInfoDto model) {
String lockName = String.format("LockName:powerStationExamine");
try{
Boolean isLocked = redisLockUtil.tryLock(lockName, lockName, 10, 1);
if (BooleanUtils.isNotTrue(isLocked)) {
throw new com.yeejoin.amos.component.robot.BadRequest("其他用户正在操作,请刷新后再试!");
}
List<String> ids; List<String> ids;
if (model.getPeasantHouseholdIds().contains(",")) { if (model.getPeasantHouseholdIds().contains(",")) {
ids = Arrays.asList(model.getPeasantHouseholdIds().split(",")); ids = Arrays.asList(model.getPeasantHouseholdIds().split(","));
...@@ -179,12 +192,12 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina ...@@ -179,12 +192,12 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina
map.put("instanceId",financingInfos1.getInstanceId()); map.put("instanceId",financingInfos1.getInstanceId());
this.execueFlow(map); this.execueFlow(map);
} }
//发起待办 //发起待办
// commonService.buildTaskModel(buildDZTRZTaskModel(model, workflowResultDto, date)); // commonService.buildTaskModel(buildDZTRZTaskModel(model, workflowResultDto, date));
}); });
}finally {
redisLockUtil.releaseLock(lockName);
}
return model; return model;
} }
......
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