|
@@ -8,6 +8,7 @@ import com.rongwei.bscommon.sys.service.ReportCheckService;
|
|
|
import com.rongwei.bsentity.domain.*;
|
|
|
import com.rongwei.bsentity.vo.CancelProcessOperationVo;
|
|
|
import com.rongwei.bsentity.vo.CommonUpdateProductionStatusReq;
|
|
|
+import com.rongwei.commonservice.service.RedisService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
@@ -18,6 +19,7 @@ import com.rongwei.wfentity.sys.vo.RunTaskVo;
|
|
|
import com.rongwei.wfserver.wfcommon.core.service.impl.WorkFlowServiceImpl;
|
|
|
import com.rongwei.wfserver.wfcommon.sys.service.RunTaskService;
|
|
|
import jodd.util.StringUtil;
|
|
|
+import lombok.Synchronized;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -58,6 +60,7 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
public static final String MATERIAL_PREPARATION_ORDER = "备料订单";
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
|
|
|
+
|
|
|
private final ConcurrentHashMap<String, String> locks = new ConcurrentHashMap<>();
|
|
|
@Autowired
|
|
|
private ApsReportRecordsService apsReportRecordsService;
|
|
@@ -79,6 +82,8 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
private WorkFlowServiceImpl workFlowService;
|
|
|
@Autowired
|
|
|
private RunTaskService runTaskService;
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
/**
|
|
|
* 保存检验结果后更新相关信息
|
|
@@ -91,7 +96,8 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
public R updateRelevantInformation(String id) {
|
|
|
log.info("保存检验结果后更新相关信息");
|
|
|
SysUserVo currentUser = CXCommonUtils.getCurrentUser();
|
|
|
- if(locks.containsKey(id) && !locks.get(id).equals(currentUser.getId())){
|
|
|
+
|
|
|
+ if(redisService.hasKey(id) && !redisService.getRedisCatchObj(id).equals(currentUser.getId())){
|
|
|
log.error("该作业已被其他人:{}检验",locks.get(id));
|
|
|
return R.error("该作业已被其他人检验");
|
|
|
}
|
|
@@ -225,7 +231,7 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
}
|
|
|
} finally {
|
|
|
log.debug("从map中清空当前报工记录:{}",id);
|
|
|
- locks.remove(id);
|
|
|
+ redisService.getRedisTemplate().delete(id);
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
@@ -281,22 +287,25 @@ public class ReportCheckServiceImpl implements ReportCheckService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Synchronized
|
|
|
public R preSaveCheck(String id) {
|
|
|
log.info("报工检验前校验");
|
|
|
SysUserVo currentUser = CXCommonUtils.getCurrentUser();
|
|
|
- if (locks.containsKey(id)) {
|
|
|
- log.error("报工检验前校验失败,当前报工记录已被他人:{}检验", locks.get(id));
|
|
|
+ if (redisService.hasKey(id)) {
|
|
|
+ log.error("报工检验前校验失败,当前报工记录已被他人:{}检验", redisService.getRedisCatchObj(currentUser.getId()));
|
|
|
return R.error("该作业已被其他人检验");
|
|
|
}
|
|
|
- locks.put(id, currentUser.getId());
|
|
|
+ redisService.redisCatchInit(id,currentUser.getId(),10);
|
|
|
// 获取报工记录
|
|
|
ApsReportRecordsDo reportRecordsDo = apsReportRecordsService.getById(id);
|
|
|
if (reportRecordsDo == null) {
|
|
|
log.error("无法根据ID:{}获取到报工记录", id);
|
|
|
+ redisService.getRedisTemplate().delete(id);
|
|
|
return R.error("无法获取到报工记录");
|
|
|
}
|
|
|
if (VERIFIED.equals(reportRecordsDo.getCheckstatus())) {
|
|
|
log.error("当前报工记录已检验无法再次检验");
|
|
|
+ redisService.getRedisTemplate().delete(id);
|
|
|
return R.error("该作业已被其他人检验");
|
|
|
}
|
|
|
log.debug("报工检验前校验成功");
|