|
|
|
@ -96,8 +96,8 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public OperPhenomenonEntity startCheck(OperPhenomenonEntity entity) { |
|
|
|
|
if (ObjectUtil.isEmpty(AuthUtil.getDeptId())) { |
|
|
|
|
throw new ServiceException("获取当前用户机构失败!"); |
|
|
|
|
if (ObjectUtil.isEmpty(entity.getCreateDept())) { |
|
|
|
|
throw new ServiceException("获取缺陷所属机构失败!"); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(entity.getFinder())&&StringUtils.isBlank(entity.getFinderName())){ |
|
|
|
|
User user = UserCache.getUser(entity.getFinder()); |
|
|
|
@ -109,7 +109,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
|
|
|
|
|
entity.setCreateUserName(AuthUtil.getUserName()); |
|
|
|
|
} |
|
|
|
|
//加锁
|
|
|
|
|
Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + AuthUtil.getDeptId(), AuthUtil.getDeptId(), 30, TimeUnit.SECONDS); |
|
|
|
|
Boolean lock = redisTemplate.opsForValue().setIfAbsent("SysUserLock" + entity.getCreateDept(), entity.getCreateDept(), 30, TimeUnit.SECONDS); |
|
|
|
|
try { |
|
|
|
|
if (lock) { |
|
|
|
|
// 步骤1.保存现象
|
|
|
|
@ -122,7 +122,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
|
|
|
|
|
last("limit 1"); |
|
|
|
|
}}); |
|
|
|
|
this.startDefectCheckV2(operPhenomenon); |
|
|
|
|
redisTemplate.delete("SysUserLock" + AuthUtil.getDeptId()); //删除key,释放锁
|
|
|
|
|
redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁
|
|
|
|
|
} else { |
|
|
|
|
// 加锁失败,抛出异常
|
|
|
|
|
throw new ServiceException("开启现象流程失败!"); |
|
|
|
@ -134,7 +134,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
|
|
|
|
|
//抛出异常,以便回滚
|
|
|
|
|
throw new ServiceException("保存现象失败!"+e.getMessage()); |
|
|
|
|
}finally { |
|
|
|
|
redisTemplate.delete("SysUserLock" + AuthUtil.getDeptId()); //删除key,释放锁
|
|
|
|
|
redisTemplate.delete("SysUserLock" + entity.getCreateDept()); //删除key,释放锁
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -145,7 +145,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean savePhenomenon(OperPhenomenonEntity entity) { |
|
|
|
|
String deptId = AuthUtil.getDeptId(); |
|
|
|
|
String deptId = entity.getCreateDept().toString(); |
|
|
|
|
if (StringUtils.isBlank(deptId)) { |
|
|
|
|
throw new ServiceException("获取当前用户机构失败!"); |
|
|
|
|
} |
|
|
|
@ -180,7 +180,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl<OperPhenomenonMapper
|
|
|
|
|
// 现象更新时间
|
|
|
|
|
entity.setUpdateTime(new Date()); |
|
|
|
|
entity.setCreateUser(AuthUtil.getUserId()); |
|
|
|
|
entity.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); |
|
|
|
|
entity.setCreateDept(entity.getCreateDept()); |
|
|
|
|
// 现在最后甄别时间
|
|
|
|
|
// Date discriminateDeadline = DateUtil.plusHours(entity.getUpdateTime(), DefectConfiguration.discriminateDeadline);
|
|
|
|
|
// entity.setDiscriminateDeadline(discriminateDeadline);
|
|
|
|
|