|
|
@@ -73,7 +73,9 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
@Service("repairApplicationFormService")
|
|
|
@Slf4j
|
|
|
-public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairApplicationFormMapper, RepairApplicationForm, RepairApplicationFormDTO> implements RepairApplicationFormService {
|
|
|
+public class RepairApplicationFormServiceImpl
|
|
|
+ extends BaseServiceImpl<RepairApplicationFormMapper, RepairApplicationForm, RepairApplicationFormDTO>
|
|
|
+ implements RepairApplicationFormService {
|
|
|
|
|
|
private RepairReasonMapper repairReasonMapper;
|
|
|
private final SysUserService sysUserService;
|
|
|
@@ -86,7 +88,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
@Override
|
|
|
public void refuseOrder(RepairApplicationFormDTO repairApplicationFormDTO) {
|
|
|
repairApplicationFormDTO.setStatus(RepairApplicationFormStatusEnum.REFUSED.getValue());
|
|
|
- mapper.updateByPrimaryKeySelective(BeanConverterUtil.copyObjectProperties(repairApplicationFormDTO, RepairApplicationForm.class));
|
|
|
+ mapper.updateByPrimaryKeySelective(
|
|
|
+ BeanConverterUtil.copyObjectProperties(repairApplicationFormDTO, RepairApplicationForm.class));
|
|
|
|
|
|
// 通知机台
|
|
|
List<String> openIds = new ArrayList<>();
|
|
|
@@ -116,7 +119,6 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
if (StringUtils.isBlank(domain)) {
|
|
|
throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
|
|
|
@@ -127,7 +129,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
String repairUrl = domain + "repair/form?no=" + repairApplicationFormDTO.getNo();
|
|
|
|
|
|
// 发送邮件给机台人员
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
repairApplicationFormDTO.getId(),
|
|
|
MessageTemplateUtil.getFreemarkerHtmlContentRefuse(repairUrl, repairApplicationFormDTO, sbInfo),
|
|
|
repairApplicationFormDTO.getId(), userIds, mails));
|
|
|
@@ -141,7 +144,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (!mobileDomain.endsWith("/")) {
|
|
|
mobileDomain = mobileDomain + "/";
|
|
|
}
|
|
|
- String mobileRepairUrl = mobileDomain + "pages/repair-detail/repair-detail?detailId=" + repairApplicationFormDTO.getId();
|
|
|
+ String mobileRepairUrl = mobileDomain + "pages/repair-detail/repair-detail?detailId="
|
|
|
+ + repairApplicationFormDTO.getId();
|
|
|
for (String openId : openIds) {
|
|
|
WeChatMessageUtil.repairRefuseMessage(openId, mobileRepairUrl, repairApplicationFormDTO, sbInfo);
|
|
|
}
|
|
|
@@ -152,7 +156,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
@Override
|
|
|
public void sendMessage() {
|
|
|
Weekend<RepairApplicationForm> weekend = new Weekend(RepairApplicationForm.class);
|
|
|
- weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
|
|
|
+ weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus,
|
|
|
+ RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue());
|
|
|
LocalDateTime time = LocalDateTime.now().minusHours(1);
|
|
|
weekend.weekendCriteria().andLessThan(RepairApplicationForm::getCreatedTime, time);
|
|
|
List<RepairApplicationForm> list = mapper.selectAll();
|
|
|
@@ -210,14 +215,20 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
@Override
|
|
|
public int batchDelete(List<String> ids) {
|
|
|
// 判断是否允许删除
|
|
|
- /* Weekend<RepairApplicationForm> weekendSelect = new Weekend<>(RepairApplicationForm.class);
|
|
|
- WeekendCriteria<RepairApplicationForm, Object> weekendCriteriaSelect = weekendSelect.weekendCriteria();
|
|
|
- weekendCriteriaSelect.andIn(RepairApplicationForm::getId, ids);
|
|
|
- weekendCriteriaSelect.andNotEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED);
|
|
|
- List<RepairApplicationForm> repairApplicationForms = mapper.selectByExample(weekendSelect);
|
|
|
- if (CollectionUtil.isNotEmpty(repairApplicationForms)) {
|
|
|
- throw new BusinessException("部分状态不允许删除");
|
|
|
- }*/
|
|
|
+ /*
|
|
|
+ * Weekend<RepairApplicationForm> weekendSelect = new
|
|
|
+ * Weekend<>(RepairApplicationForm.class);
|
|
|
+ * WeekendCriteria<RepairApplicationForm, Object> weekendCriteriaSelect =
|
|
|
+ * weekendSelect.weekendCriteria();
|
|
|
+ * weekendCriteriaSelect.andIn(RepairApplicationForm::getId, ids);
|
|
|
+ * weekendCriteriaSelect.andNotEqualTo(RepairApplicationForm::getStatus,
|
|
|
+ * RepairApplicationFormStatusEnum.NOT_ALLOCATED);
|
|
|
+ * List<RepairApplicationForm> repairApplicationForms =
|
|
|
+ * mapper.selectByExample(weekendSelect);
|
|
|
+ * if (CollectionUtil.isNotEmpty(repairApplicationForms)) {
|
|
|
+ * throw new BusinessException("部分状态不允许删除");
|
|
|
+ * }
|
|
|
+ */
|
|
|
Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
|
|
|
WeekendCriteria<RepairApplicationForm, Object> weekendCriteria = weekend.weekendCriteria();
|
|
|
weekendCriteria.andIn(RepairApplicationForm::getId, ids);
|
|
|
@@ -234,7 +245,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public MyVOPage<RepairApplicationFormVO> selectPageInfoVO(RepairApplicationFormDTO record, int pageNum, int pageSize) {
|
|
|
+ public MyVOPage<RepairApplicationFormVO> selectPageInfoVO(RepairApplicationFormDTO record, int pageNum,
|
|
|
+ int pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
|
|
if (record.getSearchType() != null) {
|
|
|
@@ -256,9 +268,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (record.getSearchType() == 3) {
|
|
|
if (record.getFilter() != null && DataFilterTypeEnum.SELF.getValue() == record.getFilter().intValue()) {
|
|
|
record.setStatus(RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue());
|
|
|
- String verifyUser = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.VERIFY_REPAIR_USER_LIST.name());
|
|
|
+ String verifyUser = ConfigCache
|
|
|
+ .getLabelByValueAllowNull(SysConfigEnum.VERIFY_REPAIR_USER_LIST.name());
|
|
|
UserInfo userInfo = SecurityUtils.getUserInfo();
|
|
|
- if(StringUtils.isNotBlank(verifyUser) && !verifyUser.contains(userInfo.getUsername())){
|
|
|
+ if (StringUtils.isNotBlank(verifyUser) && !verifyUser.contains(userInfo.getUsername())) {
|
|
|
record.setCheckUserId(userInfo.getUserId());
|
|
|
}
|
|
|
}
|
|
|
@@ -304,9 +317,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public RepairApplicationForm saveModelByDTO(RepairApplicationFormDTO model) {
|
|
|
-/* if (model.getCategory() == null) {
|
|
|
- throw new BusinessException("未获取到工单类别!");
|
|
|
- }*/
|
|
|
+ /*
|
|
|
+ * if (model.getCategory() == null) {
|
|
|
+ * throw new BusinessException("未获取到工单类别!");
|
|
|
+ * }
|
|
|
+ */
|
|
|
if (StringUtils.isBlank(model.getSbId())) {
|
|
|
throw new BusinessException("请填写报修设备");
|
|
|
}
|
|
|
@@ -316,7 +331,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
model.setType(type);
|
|
|
}
|
|
|
Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
|
|
|
- weekend.weekendCriteria().andIsNotNull(RepairApplicationForm::getId).andEqualTo(RepairApplicationForm::getType, model.getType());
|
|
|
+ weekend.weekendCriteria().andIsNotNull(RepairApplicationForm::getId).andEqualTo(RepairApplicationForm::getType,
|
|
|
+ model.getType());
|
|
|
int count = mapper.selectCountByExample(weekend);
|
|
|
// 查询对应的维修人,保存维修单
|
|
|
String sbId = model.getSbId();
|
|
|
@@ -366,7 +382,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
updateSb = true;
|
|
|
}
|
|
|
// 如果选择了设备停机,则要修改设备状态,记录设备状态变更变
|
|
|
- if (model.getNeedStop() != null && model.getNeedStop().intValue() == RepairApplicationFormStopEnum.STOP.getValue()) {
|
|
|
+ if (model.getNeedStop() != null
|
|
|
+ && model.getNeedStop().intValue() == RepairApplicationFormStopEnum.STOP.getValue()) {
|
|
|
info.setStatus(SbInfoStatusEnum.IN_STOP.getValue());
|
|
|
updateSb = true;
|
|
|
}
|
|
|
@@ -450,7 +467,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
String repairUrl = domain + "repair/form?no=" + model.getNo();
|
|
|
|
|
|
// 通过给当天值班维修人员
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
model.getId(),
|
|
|
MessageTemplateUtil.getFreemarkerHtmlContent(repairUrl, model, sb),
|
|
|
model.getId(), userIds, mails));
|
|
|
@@ -494,12 +512,13 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, "1", 24, TimeUnit.HOURS);
|
|
|
} else if (Integer.valueOf(numStr) < 5) {
|
|
|
isSend = true;
|
|
|
- RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
|
|
|
+ RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver,
|
|
|
+ String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
|
|
|
}
|
|
|
if (isSend) {
|
|
|
System.out.println("templateParas_repair: " + templateParas_repair);
|
|
|
String template = "[\"369751\"]";
|
|
|
- //SendSms.sendCodeSms(receiver, template);
|
|
|
+ // SendSms.sendCodeSms(receiver, template);
|
|
|
SendSms.sendRepairSms(receiver, templateParas_repair);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -514,9 +533,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (StringUtils.isNotBlank(minuteStr)) {
|
|
|
minute = Integer.valueOf(minuteStr);
|
|
|
}
|
|
|
- RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_STEP_FIRST + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), minute, TimeUnit.MINUTES);
|
|
|
+ RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_STEP_FIRST
|
|
|
+ + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), minute, TimeUnit.MINUTES);
|
|
|
|
|
|
- // 启动维修超时监控,维修时间升级流程:超过3个小时没修好,升级给牛工,超过8个小时没修好,升级给相工,超过24 没修好,升级给田总,现在把三阶段的人员位置留好,可以先暂时升级给我,后期再改为具体的人。
|
|
|
+ // 启动维修超时监控,维修时间升级流程:超过3个小时没修好,升级给牛工,超过8个小时没修好,升级给相工,超过24
|
|
|
+ // 没修好,升级给田总,现在把三阶段的人员位置留好,可以先暂时升级给我,后期再改为具体的人。
|
|
|
String hourFirstStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_OVERTIME_MINUTE_FIRST.name());
|
|
|
int hourFirst = 3;// 默认3小时
|
|
|
if (StringUtils.isNotBlank(hourFirstStr)) {
|
|
|
@@ -532,9 +553,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (StringUtils.isNotBlank(hourThirdStr)) {
|
|
|
hourThird = Integer.valueOf(hourThirdStr);
|
|
|
}
|
|
|
- RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_FIRST + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourFirst, TimeUnit.HOURS);
|
|
|
- RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_SECOND + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourSecond, TimeUnit.HOURS);
|
|
|
- RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_THIRD + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourThird, TimeUnit.HOURS);
|
|
|
+ RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_FIRST
|
|
|
+ + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourFirst, TimeUnit.HOURS);
|
|
|
+ RedisUtils.setString(
|
|
|
+ RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_SECOND
|
|
|
+ + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(),
|
|
|
+ model.getId(), hourSecond, TimeUnit.HOURS);
|
|
|
+ RedisUtils.setString(RedisKeyConstants.EXPIRE_BUSINESS_KEY_REPAIR_OVERTIME_STEP_THIRD
|
|
|
+ + RedisKeyConstants.EXPIRE_BUSINESS_SEP + model.getId(), model.getId(), hourThird, TimeUnit.HOURS);
|
|
|
|
|
|
return form;
|
|
|
}
|
|
|
@@ -579,9 +605,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
private void saveFile(RepairApplicationFormDTO model) {
|
|
|
if (CollectionUtil.isNotEmpty(model.getApplicationFileList())) {
|
|
|
Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
- weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
+ weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue())
|
|
|
+ .andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
sysFileMapper.deleteByExample(weekend);
|
|
|
- List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(), SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue());
|
|
|
+ List<SysFile> list = SysFileUtils.changeFileList(model.getApplicationFileList(), model.getId(),
|
|
|
+ SysFileTypeEnum.REPAIR_APPLICATION_IMGS.getValue());
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
sysFileMapper.insertListforComplex(list);
|
|
|
}
|
|
|
@@ -596,9 +624,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
private void saveRepairFile(RepairApplicationFormDTO model) {
|
|
|
if (CollectionUtil.isNotEmpty(model.getRepairFileList())) {
|
|
|
Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
- weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
+ weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue())
|
|
|
+ .andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
sysFileMapper.deleteByExample(weekend);
|
|
|
- List<SysFile> list = SysFileUtils.changeFileList(model.getRepairFileList(), model.getId(), SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue());
|
|
|
+ List<SysFile> list = SysFileUtils.changeFileList(model.getRepairFileList(), model.getId(),
|
|
|
+ SysFileTypeEnum.REPAIR_REPAIR_IMGS.getValue());
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
sysFileMapper.insertListforComplex(list);
|
|
|
}
|
|
|
@@ -613,9 +643,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
private void saveCheckFile(RepairApplicationFormDTO model) {
|
|
|
if (CollectionUtil.isNotEmpty(model.getCheckFileList())) {
|
|
|
Weekend<SysFile> weekend = new Weekend<>(SysFile.class);
|
|
|
- weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue()).andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
+ weekend.weekendCriteria().andEqualTo(SysFile::getType, SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue())
|
|
|
+ .andEqualTo(SysFile::getTargetId, model.getId());
|
|
|
sysFileMapper.deleteByExample(weekend);
|
|
|
- List<SysFile> list = SysFileUtils.changeFileList(model.getCheckFileList(), model.getId(), SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue());
|
|
|
+ List<SysFile> list = SysFileUtils.changeFileList(model.getCheckFileList(), model.getId(),
|
|
|
+ SysFileTypeEnum.REPAIR_CHECK_IMGS.getValue());
|
|
|
if (CollectionUtil.isNotEmpty(list)) {
|
|
|
sysFileMapper.insertListforComplex(list);
|
|
|
}
|
|
|
@@ -630,7 +662,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
@Override
|
|
|
public void receive(String id) {
|
|
|
RepairApplicationForm applicationForm = mapper.selectById(id);
|
|
|
- if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
|
|
|
+ if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus())
|
|
|
+ && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
|
|
|
throw new BusinessException("该状态不允许接收任务");
|
|
|
}
|
|
|
UserInfo userInfo = SecurityUtils.getUser().getUserInfo();
|
|
|
@@ -644,19 +677,24 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (sbInfo.getRepairUserSecond() == null) {
|
|
|
throw new BusinessException("设备的第二维修人未设置,无法接受任务");
|
|
|
}
|
|
|
- if (!SecurityUtils.isRole(SysRoleCodeEnum.MM.name()) && !SecurityUtils.isRole(SysRoleCodeEnum.Maintenance.name())) {
|
|
|
+ if (!SecurityUtils.isRole(SysRoleCodeEnum.MM.name())
|
|
|
+ && !SecurityUtils.isRole(SysRoleCodeEnum.Maintenance.name())) {
|
|
|
throw new BusinessException("您不是维修人或维修主管,无法接受任务");
|
|
|
}
|
|
|
|
|
|
- /* if (!sbInfo.getRepairUser().equals(userInfo.getUserId()) && !sbInfo.getRepairUserSecond().equals(userInfo.getUserId())) {
|
|
|
- throw new BusinessException("您不是该设备的第一维修人或第二维修人,无法接受任务");
|
|
|
- }*/
|
|
|
+ /*
|
|
|
+ * if (!sbInfo.getRepairUser().equals(userInfo.getUserId()) &&
|
|
|
+ * !sbInfo.getRepairUserSecond().equals(userInfo.getUserId())) {
|
|
|
+ * throw new BusinessException("您不是该设备的第一维修人或第二维修人,无法接受任务");
|
|
|
+ * }
|
|
|
+ */
|
|
|
applicationForm.setRepairUserId(userInfo.getUserId());
|
|
|
applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
|
|
|
if (applicationForm.getRepairStartTime() == null) {
|
|
|
applicationForm.setRepairStartTime(LocalDateTime.now());
|
|
|
}
|
|
|
- applicationForm.setReceiveMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairStartTime()));
|
|
|
+ applicationForm.setReceiveMinutes(
|
|
|
+ DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairStartTime()));
|
|
|
|
|
|
// 根据配置判断维修是否超时
|
|
|
String minuteStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_WARN_MINUTE.name());
|
|
|
@@ -670,7 +708,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
applicationForm.setUpdateTime(LocalDateTime.now());
|
|
|
super.modModelByPrimaryKey(applicationForm);
|
|
|
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.RECEIVE.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_RECEIVE.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.RECEIVE.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_RECEIVE.getValue(),
|
|
|
applicationForm.getId(), MessageTemplateUtil.getReceive(applicationForm.getNo()),
|
|
|
applicationForm.getId(), ListUtils.newArrayList(applicationForm.getUserId())));
|
|
|
|
|
|
@@ -684,26 +723,40 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
@Override
|
|
|
public void dispatchModelByDTO(RepairApplicationFormDTO model) {
|
|
|
RepairApplicationForm applicationForm = mapper.selectById(model.getId());
|
|
|
- if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus()) && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
|
|
|
- throw new BusinessException("该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
|
|
|
+ if (!RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue().equals(applicationForm.getStatus())
|
|
|
+ && !RepairApplicationFormStatusEnum.REBACK.getValue().equals(applicationForm.getStatus())) {
|
|
|
+ throw new BusinessException(
|
|
|
+ "该状态不允许派工任务, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询原维修人姓名(selectById 返回的是实体,repairUserName 为 @Transient 不会被填充)
|
|
|
+ String oldRepairUserName = null;
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
|
|
|
+ SysUser oldRepairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
|
|
|
+ if (oldRepairUser != null) {
|
|
|
+ oldRepairUserName = oldRepairUser.getRealName();
|
|
|
+ }
|
|
|
}
|
|
|
+ // 查询操作人(当前登录用户)姓名,用于记录是谁派的工
|
|
|
+ UserInfo currentUser = SecurityUtils.getUserInfo();
|
|
|
+ String operatorName = currentUser != null ? currentUser.getRealName() : null;
|
|
|
+ String operatorId = currentUser != null ? currentUser.getUserId() : null;
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("userId", applicationForm.getRepairUserId());
|
|
|
+ jsonObject.put("username", oldRepairUserName);
|
|
|
+ jsonObject.put("remark", model.getRepairDispatchRemark());
|
|
|
+ jsonObject.put("time", LocalDateTime.now());
|
|
|
+ jsonObject.put("type", "dispatch");
|
|
|
+ jsonObject.put("operatorId", operatorId);
|
|
|
+ jsonObject.put("operatorName", operatorName);
|
|
|
|
|
|
if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("userId", applicationForm.getRepairUserId());
|
|
|
- jsonObject.put("username", applicationForm.getRepairUserName());
|
|
|
- jsonObject.put("remark", model.getRepairDispatchRemark());
|
|
|
- jsonObject.put("time", LocalDateTime.now());
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
jsonArray.add(jsonObject);
|
|
|
applicationForm.setRepairDispatchList(jsonArray.toJSONString());
|
|
|
} else {
|
|
|
JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("userId", applicationForm.getRepairUserId());
|
|
|
- jsonObject.put("username", applicationForm.getRepairUserName());
|
|
|
- jsonObject.put("remark", applicationForm.getRepairDispatchRemark());
|
|
|
- jsonObject.put("time", LocalDateTime.now());
|
|
|
jsonArray.add(jsonObject);
|
|
|
applicationForm.setRepairDispatchList(jsonArray.toJSONString());
|
|
|
}
|
|
|
@@ -716,9 +769,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
super.modModelByPrimaryKey(applicationForm);
|
|
|
|
|
|
SysUser repairUser = userMapper.selectByPrimaryKey(model.getRepairUserId());
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
|
|
|
applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
|
|
|
- applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()), ListUtils.newArrayList(repairUser.getEmail())));
|
|
|
+ applicationForm.getId(), ListUtils.newArrayList(model.getRepairUserId()),
|
|
|
+ ListUtils.newArrayList(repairUser.getEmail())));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -747,8 +802,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
applicationForm.setRepairEndTime(dto.getRepairEndTime());
|
|
|
}
|
|
|
|
|
|
- applicationForm.setRepairMinutes(DateUtils.getDurationHours(applicationForm.getRepairStartTime(), applicationForm.getRepairEndTime()));
|
|
|
- applicationForm.setDealMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairEndTime()));
|
|
|
+ applicationForm.setRepairMinutes(
|
|
|
+ DateUtils.getDurationHours(applicationForm.getRepairStartTime(), applicationForm.getRepairEndTime()));
|
|
|
+ applicationForm.setDealMinutes(
|
|
|
+ DateUtils.getDurationHours(applicationForm.getApplyTime(), applicationForm.getRepairEndTime()));
|
|
|
|
|
|
// 根据配置判断维修是否超时
|
|
|
String hourFirstStr = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.REPAIR_OVERTIME_MINUTE_FIRST.name());
|
|
|
@@ -763,11 +820,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
}
|
|
|
applicationForm.setRepairContent(dto.getRepairContent());
|
|
|
applicationForm.setNeedStop(dto.getNeedStop());
|
|
|
- //applicationForm.setLevel(dto.getLevel());
|
|
|
+ // applicationForm.setLevel(dto.getLevel());
|
|
|
applicationForm.setRepairContent(dto.getRepairContent());
|
|
|
- //applicationForm.setRepairErrorTypeId(dto.getRepairErrorTypeId());
|
|
|
+ // applicationForm.setRepairErrorTypeId(dto.getRepairErrorTypeId());
|
|
|
applicationForm.setUpdateTime(LocalDateTime.now());
|
|
|
- //applicationForm.setContent(dto.getContent());
|
|
|
+ // applicationForm.setContent(dto.getContent());
|
|
|
applicationForm.setOutType(dto.getOutType());
|
|
|
applicationForm.setCategory(dto.getCategory());
|
|
|
|
|
|
@@ -805,10 +862,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
String checkUserId = null;
|
|
|
|
|
|
// // 有可能维修人不是本设备绑定的维修人,则统一给牛工
|
|
|
- /* if(applicationForm.getRepairUserId().equals(sbInfoVO.getRepairUser())){
|
|
|
- applicationForm.setCheckUserId(sbInfoVO.getRepairUserSecond());
|
|
|
- userVO = BeanConverterUtil.copyObjectProperties(userMapper.selectByPrimaryKey(sbInfoVO.getRepairUserSecond()), SysUserVO.class);
|
|
|
- }else{*/
|
|
|
+ /*
|
|
|
+ * if(applicationForm.getRepairUserId().equals(sbInfoVO.getRepairUser())){
|
|
|
+ * applicationForm.setCheckUserId(sbInfoVO.getRepairUserSecond());
|
|
|
+ * userVO =
|
|
|
+ * BeanConverterUtil.copyObjectProperties(userMapper.selectByPrimaryKey(sbInfoVO
|
|
|
+ * .getRepairUserSecond()), SysUserVO.class);
|
|
|
+ * }else{
|
|
|
+ */
|
|
|
SysUserDTO query = new SysUserDTO();
|
|
|
query.setRoleCode(SysRoleCodeEnum.REPAIR_EXAMINE.name());
|
|
|
List<SysUserVO> users = userMapper.selectDeptRoleUser(query);
|
|
|
@@ -818,7 +879,7 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
throw new BusinessException("审核角色:REPAIR_EXAMINE未绑定用户,REPAIR_EXAMINE为维修单最终验收人,请设置用户");
|
|
|
}
|
|
|
applicationForm.setCheckUserId(userVO.getUserId());
|
|
|
- /*}*/
|
|
|
+ /* } */
|
|
|
|
|
|
super.modModelByPrimaryKey(applicationForm);
|
|
|
|
|
|
@@ -831,9 +892,17 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
domain = domain + "/";
|
|
|
}
|
|
|
String repairUrl = domain + "repair/application/form/check?no=" + applicationForm.getNo();
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_EXAMINE.getValue(),
|
|
|
- applicationForm.getId(), MessageTemplateUtil.getFreemarkerHtmlContentCheck(repairUrl, BeanConverterUtil.copyObjectProperties(applicationForm, RepairApplicationFormDTO.class), sbInfoVO),
|
|
|
- applicationForm.getId(), ListUtils.newArrayList(userVO.getUserId()), ListUtils.newArrayList(userVO.getEmail())));
|
|
|
+ SpringContextHolder
|
|
|
+ .publishEvent(
|
|
|
+ new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_EXAMINE.getValue(),
|
|
|
+ applicationForm.getId(),
|
|
|
+ MessageTemplateUtil.getFreemarkerHtmlContentCheck(repairUrl,
|
|
|
+ BeanConverterUtil.copyObjectProperties(applicationForm,
|
|
|
+ RepairApplicationFormDTO.class),
|
|
|
+ sbInfoVO),
|
|
|
+ applicationForm.getId(), ListUtils.newArrayList(userVO.getUserId()),
|
|
|
+ ListUtils.newArrayList(userVO.getEmail())));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -847,7 +916,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
|
|
|
+ public List<RepairReport24VO> getMonthReportBig24(RepairApplicationFormDTO repairApplicationFormDTO,
|
|
|
+ Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
|
|
|
List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
|
|
|
LocalDateTime searchStartTime = null;
|
|
|
LocalDateTime searchEndTime = null;
|
|
|
@@ -892,7 +962,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
+ if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth"))
|
|
|
+ && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
i++;
|
|
|
detailList.add(repairApplicationForm);
|
|
|
}
|
|
|
@@ -919,7 +990,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<RepairReport24VO> getMonthReportTime(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
|
|
|
+ public List<RepairReport24VO> getMonthReportTime(RepairApplicationFormDTO repairApplicationFormDTO,
|
|
|
+ Integer searchYear, LocalDate startMonth, LocalDate endMonth, Integer type) {
|
|
|
|
|
|
// 只能一个月一个月的查询
|
|
|
int monthNum = DateUtils.monthDiff(startMonth, endMonth);
|
|
|
@@ -955,7 +1027,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
List<RepairApplicationFormVO> list = mapper.selectPageList(repairApplicationFormDTO);
|
|
|
|
|
|
// 按照人员分组
|
|
|
- Map<String, List<RepairApplicationFormVO>> mapList = list.stream().collect(Collectors.groupingBy(RepairApplicationFormVO::getRepairUser));
|
|
|
+ Map<String, List<RepairApplicationFormVO>> mapList = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(RepairApplicationFormVO::getRepairUser));
|
|
|
|
|
|
List<RepairReport24VO> result = new ArrayList<RepairReport24VO>();
|
|
|
int i = 0;
|
|
|
@@ -976,7 +1049,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
}
|
|
|
double minutes = repairApplicationForm.getDealMinutes();
|
|
|
time = time + minutes;
|
|
|
- if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
+ if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth"))
|
|
|
+ && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
i++;
|
|
|
detailList.add(repairApplicationForm);
|
|
|
}
|
|
|
@@ -995,22 +1069,171 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void transfer(RepairApplicationFormDTO record) {
|
|
|
- if(StringUtils.isBlank(record.getSecondRepairUser()) && StringUtils.isBlank(record.getThreeRepairUser()) && StringUtils.isBlank(record.getFourRepairUser())) {
|
|
|
+ RepairApplicationForm applicationForm = mapper.selectById(record.getId());
|
|
|
+ if (applicationForm == null) {
|
|
|
+ throw new BusinessException("维修单不存在,id:" + record.getId());
|
|
|
+ }
|
|
|
+ // 只有维修中状态可以发起转派
|
|
|
+ if (!RepairApplicationFormStatusEnum.PROCESSING.getValue().equals(applicationForm.getStatus())) {
|
|
|
+ throw new BusinessException(
|
|
|
+ "该状态不允许转派, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
|
|
|
+ }
|
|
|
+ // 转派目标维修人不能为空
|
|
|
+ if (StringUtils.isBlank(record.getRepairUserId())) {
|
|
|
throw new BusinessException("转派的维修人不可为空");
|
|
|
}
|
|
|
- RepairApplicationForm form = new RepairApplicationForm();
|
|
|
- form.setId(record.getId());
|
|
|
- if(StringUtils.isNotBlank(record.getSecondRepairUser())){
|
|
|
- form.setSecondRepairUser(record.getSecondRepairUser());
|
|
|
+
|
|
|
+ // 查询原维修人姓名
|
|
|
+ String oldRepairUserName = null;
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
|
|
|
+ SysUser oldRepairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
|
|
|
+ if (oldRepairUser != null) {
|
|
|
+ oldRepairUserName = oldRepairUser.getRealName();
|
|
|
+ }
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(record.getThreeRepairUser())){
|
|
|
- form.setThreeRepairUser(record.getThreeRepairUser());
|
|
|
+ // 查询新维修人姓名
|
|
|
+ SysUser newRepairUser = userMapper.selectByPrimaryKey(record.getRepairUserId());
|
|
|
+ String newRepairUserName = newRepairUser != null ? newRepairUser.getRealName() : null;
|
|
|
+ // 查询操作人(当前登录用户)
|
|
|
+ UserInfo currentUser = SecurityUtils.getUserInfo();
|
|
|
+ String operatorName = currentUser != null ? currentUser.getRealName() : null;
|
|
|
+ String operatorId = currentUser != null ? currentUser.getUserId() : null;
|
|
|
+
|
|
|
+ // 追加转派记录到 repairDispatchList
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("userId", record.getRepairUserId());
|
|
|
+ jsonObject.put("username", newRepairUserName);
|
|
|
+ jsonObject.put("remark", record.getRepairDispatchRemark());
|
|
|
+ jsonObject.put("time", LocalDateTime.now());
|
|
|
+ jsonObject.put("type", "transfer");
|
|
|
+ jsonObject.put("operatorId", operatorId);
|
|
|
+ jsonObject.put("operatorName", operatorName);
|
|
|
+ jsonObject.put("fromUserId", applicationForm.getRepairUserId());
|
|
|
+ jsonObject.put("fromUsername", oldRepairUserName);
|
|
|
+ jsonObject.put("status", "pending"); // pending / approved / rejected
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(applicationForm.getRepairDispatchList())) {
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
+ applicationForm.setRepairDispatchList(jsonArray.toJSONString());
|
|
|
+ } else {
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
+ applicationForm.setRepairDispatchList(jsonArray.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存转派备注,暂不更新 repairUserId(审批通过后才更新)
|
|
|
+ applicationForm.setRepairDispatchRemark(record.getRepairDispatchRemark());
|
|
|
+ // 将待转派维修人暂存到 secondRepairUser 字段(审批通过后赋值给 repairUserId)
|
|
|
+ applicationForm.setSecondRepairUser(record.getRepairUserId());
|
|
|
+ // 状态变更为转派审批中
|
|
|
+ applicationForm.setStatus(RepairApplicationFormStatusEnum.TRANSFER_APPROVAL.getValue());
|
|
|
+ applicationForm.setUpdateTime(LocalDateTime.now());
|
|
|
+ super.modModelByPrimaryKey(applicationForm);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void transferApprove(RepairApplicationFormDTO record) {
|
|
|
+ RepairApplicationForm applicationForm = mapper.selectById(record.getId());
|
|
|
+ if (applicationForm == null) {
|
|
|
+ throw new BusinessException("维修单不存在,id:" + record.getId());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(record.getFourRepairUser())){
|
|
|
- form.setFourRepairUser(record.getFourRepairUser());
|
|
|
+ if (!RepairApplicationFormStatusEnum.TRANSFER_APPROVAL.getValue().equals(applicationForm.getStatus())) {
|
|
|
+ throw new BusinessException(
|
|
|
+ "该状态不允许审批转派, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
|
|
|
}
|
|
|
- mapper.updateByPrimaryKeySelective(form);
|
|
|
+
|
|
|
+ // 查询审批人(当前登录用户)
|
|
|
+ UserInfo currentUser = SecurityUtils.getUserInfo();
|
|
|
+ String approverName = currentUser != null ? currentUser.getRealName() : null;
|
|
|
+ String approverId = currentUser != null ? currentUser.getUserId() : null;
|
|
|
+
|
|
|
+ // 更新 repairDispatchList 中最后一条转派记录的状态为 approved
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairDispatchList())) {
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
|
|
|
+ // 从后往前找最后一条 type=transfer 且 status=pending 的记录
|
|
|
+ for (int i = jsonArray.size() - 1; i >= 0; i--) {
|
|
|
+ JSONObject obj = jsonArray.getJSONObject(i);
|
|
|
+ if ("transfer".equals(obj.getString("type")) && "pending".equals(obj.getString("status"))) {
|
|
|
+ obj.put("status", "approved");
|
|
|
+ obj.put("approverId", approverId);
|
|
|
+ obj.put("approverName", approverName);
|
|
|
+ obj.put("approveTime", LocalDateTime.now());
|
|
|
+ obj.put("approveRemark", record.getRepairDispatchRemark());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ applicationForm.setRepairDispatchList(jsonArray.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 审批通过:将暂存在 secondRepairUser 中的待转派维修人赋值给 repairUserId
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getSecondRepairUser())) {
|
|
|
+ applicationForm.setRepairUserId(applicationForm.getSecondRepairUser());
|
|
|
+ applicationForm.setSecondRepairUser(null);
|
|
|
+ }
|
|
|
+ // 状态恢复为维修中
|
|
|
+ applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
|
|
|
+ applicationForm.setRepairDispatchRemark(record.getRepairDispatchRemark());
|
|
|
+ applicationForm.setUpdateTime(LocalDateTime.now());
|
|
|
+ super.modModelByPrimaryKey(applicationForm);
|
|
|
+
|
|
|
+ // 通知新维修人
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairUserId())) {
|
|
|
+ SysUser repairUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
|
|
|
+ if (repairUser != null) {
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_DISPATCH.getValue(),
|
|
|
+ applicationForm.getId(), MessageTemplateUtil.getRepairDispatch(applicationForm.getNo()),
|
|
|
+ applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()),
|
|
|
+ ListUtils.newArrayList(repairUser.getEmail())));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void transferReject(RepairApplicationFormDTO record) {
|
|
|
+ RepairApplicationForm applicationForm = mapper.selectById(record.getId());
|
|
|
+ if (applicationForm == null) {
|
|
|
+ throw new BusinessException("维修单不存在,id:" + record.getId());
|
|
|
+ }
|
|
|
+ if (!RepairApplicationFormStatusEnum.TRANSFER_APPROVAL.getValue().equals(applicationForm.getStatus())) {
|
|
|
+ throw new BusinessException(
|
|
|
+ "该状态不允许审批转派, id, status:" + applicationForm.getId() + "," + applicationForm.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询审批人(当前登录用户)
|
|
|
+ UserInfo currentUser = SecurityUtils.getUserInfo();
|
|
|
+ String approverName = currentUser != null ? currentUser.getRealName() : null;
|
|
|
+ String approverId = currentUser != null ? currentUser.getUserId() : null;
|
|
|
+
|
|
|
+ // 更新 repairDispatchList 中最后一条转派记录的状态为 rejected
|
|
|
+ if (StringUtils.isNotBlank(applicationForm.getRepairDispatchList())) {
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(applicationForm.getRepairDispatchList());
|
|
|
+ for (int i = jsonArray.size() - 1; i >= 0; i--) {
|
|
|
+ JSONObject obj = jsonArray.getJSONObject(i);
|
|
|
+ if ("transfer".equals(obj.getString("type")) && "pending".equals(obj.getString("status"))) {
|
|
|
+ obj.put("status", "rejected");
|
|
|
+ obj.put("approverId", approverId);
|
|
|
+ obj.put("approverName", approverName);
|
|
|
+ obj.put("approveTime", LocalDateTime.now());
|
|
|
+ obj.put("approveRemark", record.getRepairDispatchRemark());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ applicationForm.setRepairDispatchList(jsonArray.toJSONString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 审批驳回:清除暂存的待转派维修人,保持原 repairUserId 不变
|
|
|
+ applicationForm.setSecondRepairUser(null);
|
|
|
+ // 状态恢复为维修中
|
|
|
+ applicationForm.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
|
|
|
+ applicationForm.setRepairDispatchRemark(record.getRepairDispatchRemark());
|
|
|
+ applicationForm.setUpdateTime(LocalDateTime.now());
|
|
|
+ super.modModelByPrimaryKey(applicationForm);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1061,8 +1284,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
vo.setYear(map.get("searchStartTime").getYear());
|
|
|
double workYear = sbWorkYear - (map.get("searchStartTime").getYear() - sbStartYear);
|
|
|
for (RepairApplicationFormVO repairApplicationForm : list) {
|
|
|
- if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTime")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTime"))) {
|
|
|
- if (repairApplicationForm.getCategory() != null && dictVO.getValue().equals(repairApplicationForm.getCategory())) {
|
|
|
+ if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTime"))
|
|
|
+ && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTime"))) {
|
|
|
+ if (repairApplicationForm.getCategory() != null
|
|
|
+ && dictVO.getValue().equals(repairApplicationForm.getCategory())) {
|
|
|
num++;
|
|
|
detailList.add(repairApplicationForm);
|
|
|
}
|
|
|
@@ -1089,7 +1314,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO, Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
|
|
|
+ public List<RepairReportMttr> getMonthReportMtrr(RepairApplicationFormDTO repairApplicationFormDTO,
|
|
|
+ Integer searchYear, LocalDate startMonth, LocalDate endMonth) {
|
|
|
|
|
|
List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
|
|
|
LocalDateTime searchStartTime = null;
|
|
|
@@ -1132,7 +1358,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (repairApplicationForm.getDealMinutes() == null || (repairApplicationForm.getDealMinutes() > 24.0)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth")) && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
+ if (repairApplicationForm.getApplyTime().isAfter(map.get("searchStartTimeMonth"))
|
|
|
+ && repairApplicationForm.getApplyTime().isBefore(map.get("searchEndTimeMonth"))) {
|
|
|
i++;
|
|
|
detailList.add(repairApplicationForm);
|
|
|
totalMinuties = totalMinuties + repairApplicationForm.getDealMinutes();
|
|
|
@@ -1174,11 +1401,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
applicationForm.setCategory(dto.getCategory());
|
|
|
if (dto.getRepairStartTime() != null) {
|
|
|
applicationForm.setRepairStartTime(dto.getRepairStartTime());
|
|
|
- applicationForm.setReceiveMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairStartTime()));
|
|
|
+ applicationForm.setReceiveMinutes(
|
|
|
+ DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairStartTime()));
|
|
|
if (dto.getRepairEndTime() != null) {
|
|
|
applicationForm.setRepairEndTime(dto.getRepairEndTime());
|
|
|
- applicationForm.setRepairMinutes(DateUtils.getDurationHours(dto.getRepairStartTime(), dto.getRepairEndTime()));
|
|
|
- applicationForm.setDealMinutes(DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairEndTime()));
|
|
|
+ applicationForm
|
|
|
+ .setRepairMinutes(DateUtils.getDurationHours(dto.getRepairStartTime(), dto.getRepairEndTime()));
|
|
|
+ applicationForm.setDealMinutes(
|
|
|
+ DateUtils.getDurationHours(applicationForm.getApplyTime(), dto.getRepairEndTime()));
|
|
|
}
|
|
|
}
|
|
|
applicationForm.setCategory(dto.getCategory());
|
|
|
@@ -1230,15 +1460,15 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
}
|
|
|
}
|
|
|
// 发送微信
|
|
|
- sendCompleteWechat(openIds,applicationForm,info);
|
|
|
+ sendCompleteWechat(openIds, applicationForm, info);
|
|
|
// 发送邮件
|
|
|
- sendCompleteEmail(userIds,applicationForm,info,mails);
|
|
|
+ sendCompleteEmail(userIds, applicationForm, info, mails);
|
|
|
// 发送短信
|
|
|
- sendCompleteSms(receiverList,info,applicationForm);
|
|
|
+ sendCompleteSms(receiverList, info, applicationForm);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void sendCompleteWechat(List<String> openIds,RepairApplicationForm form,SbInfo info) {
|
|
|
+ private void sendCompleteWechat(List<String> openIds, RepairApplicationForm form, SbInfo info) {
|
|
|
// 发送微信通知给设备使用人员
|
|
|
if (CollectionUtil.isNotEmpty(openIds) && BeanUtils.isProd()) {
|
|
|
String mobileDomain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN_MOBILE.name());
|
|
|
@@ -1252,24 +1482,24 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
|
|
|
for (String openId : openIds) {
|
|
|
// 封装请求参数
|
|
|
- WechatTemplateRequest request = WechatTemplateRequestBuilder.
|
|
|
- getRepairSynergism(mobileRepairUrl,
|
|
|
- WeChatMessageUtil.template_id_send_repair,
|
|
|
- openId,
|
|
|
- new String[]{
|
|
|
- "维修工单已验收请知悉",
|
|
|
- info.getNo(),
|
|
|
- "已完成",
|
|
|
- DateUtils.dateToString(LocalDateTime.now()),
|
|
|
- info.getName()
|
|
|
- }, new String[]{"#000000",
|
|
|
- "#000000", "#000000", "#000000", "#000000" });
|
|
|
- WeChatMessageUtil.sendRepairMessage(openId,request);
|
|
|
+ WechatTemplateRequest request = WechatTemplateRequestBuilder.getRepairSynergism(mobileRepairUrl,
|
|
|
+ WeChatMessageUtil.template_id_send_repair,
|
|
|
+ openId,
|
|
|
+ new String[] {
|
|
|
+ "维修工单已验收请知悉",
|
|
|
+ info.getNo(),
|
|
|
+ "已完成",
|
|
|
+ DateUtils.dateToString(LocalDateTime.now()),
|
|
|
+ info.getName()
|
|
|
+ },
|
|
|
+ new String[] { "#000000",
|
|
|
+ "#000000", "#000000", "#000000", "#000000" });
|
|
|
+ WeChatMessageUtil.sendRepairMessage(openId, request);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void sendCompleteEmail(List<String> userIds,RepairApplicationForm form,SbInfo info,List<String> mails){
|
|
|
+ private void sendCompleteEmail(List<String> userIds, RepairApplicationForm form, SbInfo info, List<String> mails) {
|
|
|
String domain = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.SYSTEM_DOMAIN.name());
|
|
|
if (StringUtils.isBlank(domain)) {
|
|
|
throw new BusinessException("请先设置系统域名地址,系统管理-》系统参数配置-》SYSTEM_DOMAIN");
|
|
|
@@ -1284,13 +1514,14 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
model.setSbCph(form.getSbCph());
|
|
|
model.setContent(form.getContent());
|
|
|
model.setActualUser(form.getActualUser());
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_FINISH.getValue(),
|
|
|
form.getId(),
|
|
|
MessageTemplateUtil.getFreemarkerHtmlContent(repairUrl, model, info),
|
|
|
form.getId(), userIds, mails));
|
|
|
}
|
|
|
|
|
|
- private void sendCompleteSms(List<String> receiverList,SbInfo sb,RepairApplicationForm model){
|
|
|
+ private void sendCompleteSms(List<String> receiverList, SbInfo sb, RepairApplicationForm model) {
|
|
|
if (CollectionUtil.isNotEmpty(receiverList) && BeanUtils.isProd()) {
|
|
|
String no = sb.getNo();
|
|
|
if (StringUtils.isNotBlank(no)) {
|
|
|
@@ -1314,7 +1545,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, "1", 24, TimeUnit.HOURS);
|
|
|
} else if (Integer.valueOf(numStr) < 5) {
|
|
|
isSend = true;
|
|
|
- RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver, String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
|
|
|
+ RedisUtils.setString(RedisKeyConstants.HW_SMS + receiver,
|
|
|
+ String.valueOf(Integer.valueOf(numStr) + 1), 24, TimeUnit.HOURS);
|
|
|
}
|
|
|
if (isSend) {
|
|
|
System.out.println("templateParas_repair: " + templateParas_repair);
|
|
|
@@ -1343,9 +1575,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
super.modModelByPrimaryKey(applicationForm);
|
|
|
|
|
|
SysUser noticeUser = userMapper.selectByPrimaryKey(applicationForm.getRepairUserId());
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_BACK.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_BACK.getValue(),
|
|
|
dto.getId(), MessageTemplateUtil.getRepairBack(applicationForm.getNo()),
|
|
|
- applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()), ListUtils.newArrayList(noticeUser.getEmail())));
|
|
|
+ applicationForm.getId(), ListUtils.newArrayList(applicationForm.getRepairUserId()),
|
|
|
+ ListUtils.newArrayList(noticeUser.getEmail())));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1378,7 +1612,8 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
public void autoAssignTaskForTimer() {
|
|
|
LocalDateTime minutesAgo = DateUtils.minus(LocalDateTime.now(), 10, ChronoUnit.MINUTES);
|
|
|
Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
|
|
|
- weekend.weekendCriteria().andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue())
|
|
|
+ weekend.weekendCriteria()
|
|
|
+ .andEqualTo(RepairApplicationForm::getStatus, RepairApplicationFormStatusEnum.NOT_ALLOCATED.getValue())
|
|
|
.andLessThan(RepairApplicationForm::getCreatedTime, minutesAgo);
|
|
|
List<RepairApplicationForm> tasks = mapper.selectByExample(weekend);
|
|
|
List<SysUser> users = userMapper.select(new SysUser().setIdentityType(SysUserIdentityType.WXZG.getValue()));
|
|
|
@@ -1395,9 +1630,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
update.setStatus(RepairApplicationFormStatusEnum.PROCESSING.getValue());
|
|
|
mapper.updateByPrimaryKeySelective(update);
|
|
|
|
|
|
- SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
item.getId(), MessageTemplateUtil.getRepairApplicationForReceive(item.getNo()),
|
|
|
- item.getId(), Arrays.asList(repairManager.getUserId()), Arrays.asList(repairManager.getEmail())));
|
|
|
+ item.getId(), Arrays.asList(repairManager.getUserId()),
|
|
|
+ Arrays.asList(repairManager.getEmail())));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -1406,15 +1643,16 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
public void unFinishNoticeForTimer() {
|
|
|
// 3小时通知
|
|
|
List<RepairApplicationForm> tasks = getOverTimeTask(3);
|
|
|
- List<SysUser> users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.WXJL.getValue(), SysUserIdentityType.SCJL.getValue()}));
|
|
|
+ List<SysUser> users = getUsersByIdentity(Arrays
|
|
|
+ .asList(new Integer[] { SysUserIdentityType.WXJL.getValue(), SysUserIdentityType.SCJL.getValue() }));
|
|
|
sendOverTimeNotice(users, tasks);
|
|
|
// 8小时通知
|
|
|
tasks = getOverTimeTask(8);
|
|
|
- users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.YYJL.getValue()}));
|
|
|
+ users = getUsersByIdentity(Arrays.asList(new Integer[] { SysUserIdentityType.YYJL.getValue() }));
|
|
|
sendOverTimeNotice(users, tasks);
|
|
|
// 24小时通知
|
|
|
tasks = getOverTimeTask(24);
|
|
|
- users = getUsersByIdentity(Arrays.asList(new Integer[]{SysUserIdentityType.ZJL.getValue()}));
|
|
|
+ users = getUsersByIdentity(Arrays.asList(new Integer[] { SysUserIdentityType.ZJL.getValue() }));
|
|
|
sendOverTimeNotice(users, tasks);
|
|
|
}
|
|
|
|
|
|
@@ -1427,7 +1665,10 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
private List<RepairApplicationForm> getOverTimeTask(int hour) {
|
|
|
LocalDateTime threeHourAgo = DateUtils.minus(LocalDateTime.now(), hour, ChronoUnit.HOURS);
|
|
|
Weekend<RepairApplicationForm> weekend = new Weekend<>(RepairApplicationForm.class);
|
|
|
- weekend.weekendCriteria().andNotIn(RepairApplicationForm::getStatus, Arrays.asList(new Integer[]{RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue(), RepairApplicationFormStatusEnum.FINISHED.getValue()}))
|
|
|
+ weekend.weekendCriteria()
|
|
|
+ .andNotIn(RepairApplicationForm::getStatus,
|
|
|
+ Arrays.asList(new Integer[] { RepairApplicationFormStatusEnum.NOT_ACCEPTANCE.getValue(),
|
|
|
+ RepairApplicationFormStatusEnum.FINISHED.getValue() }))
|
|
|
.andLessThan(RepairApplicationForm::getCreatedTime, threeHourAgo);
|
|
|
return mapper.selectByExample(weekend);
|
|
|
}
|
|
|
@@ -1442,9 +1683,11 @@ public class RepairApplicationFormServiceImpl extends BaseServiceImpl<RepairAppl
|
|
|
if (CollectionUtil.isNotEmpty(users) && CollectionUtil.isNotEmpty(tasks)) {
|
|
|
List<String> userIds = users.stream().map(item -> item.getUserId()).collect(Collectors.toList());
|
|
|
List<String> mails = users.stream().map(item -> item.getEmail()).collect(Collectors.toList());
|
|
|
- tasks.forEach(item -> SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR_NOT_FINISH.getValue(), WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
- item.getId(), MessageTemplateUtil.getRepairApplicationForNotFinishNotic(item.getNo(), 3),
|
|
|
- item.getId(), userIds, mails)));
|
|
|
+ tasks.forEach(item -> SpringContextHolder
|
|
|
+ .publishEvent(new WorkplaceBacklogEvent(WorkplaceBacklogTypeEnum.REPAIR_NOT_FINISH.getValue(),
|
|
|
+ WorkplaceBacklogDetailTypeEnum.REPAIR_APPLICATION.getValue(),
|
|
|
+ item.getId(), MessageTemplateUtil.getRepairApplicationForNotFinishNotic(item.getNo(), 3),
|
|
|
+ item.getId(), userIds, mails)));
|
|
|
}
|
|
|
}
|
|
|
|