|
|
|
|
@ -35,6 +35,8 @@ import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
import org.springblade.desk.basic.service.ICraftAbilityService; |
|
|
|
|
import org.springblade.desk.basic.service.impl.WorkCenterServiceImpl; |
|
|
|
|
import org.springblade.desk.common.constant.BizTypeConstant; |
|
|
|
|
import org.springblade.desk.common.service.IMesNotifyMessageService; |
|
|
|
|
import org.springblade.desk.dashboard.constant.*; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.dto.DsTaskingDTO; |
|
|
|
|
import org.springblade.desk.dashboard.pojo.entity.*; |
|
|
|
|
@ -160,6 +162,9 @@ public class DsTaskingServiceImpl extends BaseServiceImpl<DsTaskingMapper, DsTas |
|
|
|
|
@Autowired |
|
|
|
|
IReviewSheetService reviewSheetService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
IMesNotifyMessageService mesNotifyMessageService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DsTaskingVO> selectAssignList(IPage<DsTaskingVO> page, DsTaskingVO dsTasking) { |
|
|
|
|
List<DsTaskingVO> dsTaskingVOS = baseMapper.selectDsTaskingPage(page, dsTasking); |
|
|
|
|
@ -614,21 +619,83 @@ public class DsTaskingServiceImpl extends BaseServiceImpl<DsTaskingMapper, DsTas |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean taskRedeploy(DsTaskingDTO tasking) { |
|
|
|
|
// 1. 参数校验
|
|
|
|
|
if (tasking == null || tasking.getId() == null) { |
|
|
|
|
throw new ServiceException("任务ID不能为空"); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isEmpty(tasking.getCraftMan())) { |
|
|
|
|
throw new ServiceException("转派目标工艺员不能为空"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2. 查询原任务信息
|
|
|
|
|
DsTaskingEntity dsTaskingEntity = taskingMapper.selectById(tasking.getId()); |
|
|
|
|
// if(!TaskingConstant.TASK_STATUS_ALREADY.equals(dsTaskingEntity.getTaskStatus())){
|
|
|
|
|
// throw new ServiceException("任务状态: 非待接收 禁止转派");
|
|
|
|
|
if (dsTaskingEntity == null) { |
|
|
|
|
throw new ServiceException("任务不存在"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3. 校验任务状态
|
|
|
|
|
// if (!TaskingConstant.TASK_STATUS_ALREADY.equals(dsTaskingEntity.getTaskStatus())) {
|
|
|
|
|
// throw new ServiceException("任务状态为非待接收状态,禁止转派");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//工艺分派人
|
|
|
|
|
// 4. 获取当前操作人(工艺分派人)
|
|
|
|
|
String assignMan = AuthUtil.getUser().getUserName(); |
|
|
|
|
//工艺员
|
|
|
|
|
String craftMan = userClient.userInfo(Func.toLong(tasking.getCraftMan())).getData().getUser().getName(); |
|
|
|
|
|
|
|
|
|
// 5. 校验目标工艺员是否存在
|
|
|
|
|
UserInfo craftUserInfo = userClient.userInfo(Func.toLong(tasking.getCraftMan())).getData(); |
|
|
|
|
if (craftUserInfo == null || craftUserInfo.getUser() == null) { |
|
|
|
|
throw new ServiceException("目标工艺员不存在"); |
|
|
|
|
} |
|
|
|
|
String craftMan = craftUserInfo.getUser().getName(); |
|
|
|
|
Long craftManId = craftUserInfo.getUser().getId(); |
|
|
|
|
|
|
|
|
|
// 6. 记录转派前的信息(便于日志记录)
|
|
|
|
|
String oldCraftMan = dsTaskingEntity.getCraftMan(); |
|
|
|
|
|
|
|
|
|
// 7. 更新任务信息
|
|
|
|
|
dsTaskingEntity.setAssignMan(assignMan); |
|
|
|
|
dsTaskingEntity.setCraftMan(craftMan); |
|
|
|
|
dsTaskingEntity.setAssignTime(new Date()); |
|
|
|
|
taskingMapper.updateById(dsTaskingEntity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int updateResult = taskingMapper.updateById(dsTaskingEntity); |
|
|
|
|
if (updateResult != 1) { |
|
|
|
|
throw new ServiceException("任务转派失败,请重试"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 8. 发送转派消息通知
|
|
|
|
|
// 建议同时通知原工艺员和现工艺员
|
|
|
|
|
try { |
|
|
|
|
// 通知新工艺员
|
|
|
|
|
mesNotifyMessageService.saveMsg( |
|
|
|
|
BizTypeConstant.CRAFT_TASK_REDEPLOY, |
|
|
|
|
"您有新的任务转派,请及时处理", |
|
|
|
|
String.valueOf(tasking.getId()), |
|
|
|
|
craftManId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 可选:通知原工艺员任务已被转派
|
|
|
|
|
if (!StringUtils.isEmpty(oldCraftMan)) { |
|
|
|
|
mesNotifyMessageService.saveMsg( |
|
|
|
|
BizTypeConstant.CRAFT_TASK_REDEPLOY, |
|
|
|
|
"您的任务已被转派", |
|
|
|
|
String.valueOf(tasking.getId()), |
|
|
|
|
Long.valueOf(oldCraftMan) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 可选:记录操作日志
|
|
|
|
|
log.info("任务转派成功,任务ID:{},原工艺员:{},新工艺员:{},操作人:{}", |
|
|
|
|
tasking.getId(), oldCraftMan, craftMan, assignMan); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("发送转派消息失败,任务ID:{}", tasking.getId(), e); |
|
|
|
|
// 消息发送失败不影响主流程,但需要记录日志
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|