|
@@ -3,9 +3,12 @@ package com.platform.service.sb.impl;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.platform.activiti.bean.ActObj;
|
|
|
|
+import com.platform.activiti.enums.ActApplyEnum;
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
import com.platform.common.constant.CommonConstants;
|
|
import com.platform.common.constant.CommonConstants;
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
|
|
+import com.platform.common.enums.ResultCode;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.exception.BusinessException;
|
|
import com.platform.common.model.UserInfo;
|
|
import com.platform.common.model.UserInfo;
|
|
import com.platform.common.util.*;
|
|
import com.platform.common.util.*;
|
|
@@ -19,6 +22,8 @@ import com.platform.dao.dto.sb.SbModelSpareBomDTO;
|
|
import com.platform.dao.dto.store.SpareRestoreDetailDTO;
|
|
import com.platform.dao.dto.store.SpareRestoreDetailDTO;
|
|
import com.platform.dao.dto.upms.SysDeptDTO;
|
|
import com.platform.dao.dto.upms.SysDeptDTO;
|
|
import com.platform.dao.dto.upms.SysUserDeptDTO;
|
|
import com.platform.dao.dto.upms.SysUserDeptDTO;
|
|
|
|
+import com.platform.dao.dto.workplace.WorkplaceBacklogDTO;
|
|
|
|
+import com.platform.dao.dto.workplace.WorkplaceBacklogUserDTO;
|
|
import com.platform.dao.entity.firm.FirmProducer;
|
|
import com.platform.dao.entity.firm.FirmProducer;
|
|
import com.platform.dao.entity.repair.RepairApplicationForm;
|
|
import com.platform.dao.entity.repair.RepairApplicationForm;
|
|
import com.platform.dao.entity.sb.*;
|
|
import com.platform.dao.entity.sb.*;
|
|
@@ -34,16 +39,21 @@ import com.platform.dao.mapper.upms.SysDeptMapper;
|
|
import com.platform.dao.mapper.upms.SysFileMapper;
|
|
import com.platform.dao.mapper.upms.SysFileMapper;
|
|
import com.platform.dao.mapper.upms.SysUserDeptMapper;
|
|
import com.platform.dao.mapper.upms.SysUserDeptMapper;
|
|
import com.platform.dao.mapper.upms.SysUserMapper;
|
|
import com.platform.dao.mapper.upms.SysUserMapper;
|
|
|
|
+import com.platform.dao.mapper.workplace.WorkplaceBacklogUserMapper;
|
|
import com.platform.dao.util.CustomExcelImportUtil;
|
|
import com.platform.dao.util.CustomExcelImportUtil;
|
|
|
|
+import com.platform.dao.util.MessageTemplateUtil;
|
|
import com.platform.dao.util.UserUtil;
|
|
import com.platform.dao.util.UserUtil;
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
|
|
+import com.platform.dao.vo.SysUserVO;
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
import com.platform.dao.vo.export.store.ExportInStoreFormVO;
|
|
import com.platform.dao.vo.export.store.ExportInStoreFormVO;
|
|
import com.platform.dao.vo.query.upms.SysDeptVO;
|
|
import com.platform.dao.vo.query.upms.SysDeptVO;
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
import com.platform.dao.vo.sb.SbInfoVO;
|
|
import com.platform.dao.vo.sb.SbModelVO;
|
|
import com.platform.dao.vo.sb.SbModelVO;
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
|
+import com.platform.service.business.ActivitiBusinessService;
|
|
import com.platform.service.check.CheckStandardService;
|
|
import com.platform.service.check.CheckStandardService;
|
|
|
|
+import com.platform.service.event.WorkplaceBacklogEvent;
|
|
import com.platform.service.part.PartInfoService;
|
|
import com.platform.service.part.PartInfoService;
|
|
import com.platform.service.sb.SbInfoService;
|
|
import com.platform.service.sb.SbInfoService;
|
|
import com.platform.service.sb.SbModelSpareBomService;
|
|
import com.platform.service.sb.SbModelSpareBomService;
|
|
@@ -57,6 +67,7 @@ import lombok.AllArgsConstructor;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.springframework.core.env.Environment;
|
|
import org.springframework.core.env.Environment;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -111,6 +122,8 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
private final PartInfoService partInfoService;
|
|
private final PartInfoService partInfoService;
|
|
private final SbModelSpareBomService sbModelSpareBomService;
|
|
private final SbModelSpareBomService sbModelSpareBomService;
|
|
private final CheckStandardService checkStandardService;
|
|
private final CheckStandardService checkStandardService;
|
|
|
|
+ private final WorkplaceBacklogUserMapper backlogUserMapper;
|
|
|
|
+ private final ActivitiBusinessService activitiBusinessService;
|
|
|
|
|
|
private final String useArea = "5e64ac691c527828b2114da0";
|
|
private final String useArea = "5e64ac691c527828b2114da0";
|
|
private final String useCompany = "6063f905eb190003685af6d4";
|
|
private final String useCompany = "6063f905eb190003685af6d4";
|
|
@@ -816,6 +829,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ vo.setCurrentAuditUserName(activitiBusinessService.getCurrentAuditUserName(vo.getProcessInstanceId()));
|
|
return vo;
|
|
return vo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1187,4 +1201,144 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
info.setParentId(null);
|
|
info.setParentId(null);
|
|
mapper.updateByPrimaryKey(info);
|
|
mapper.updateByPrimaryKey(info);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 提交报废审批,修改状态为-报废中
|
|
|
|
+ *
|
|
|
|
+ * @param sbInfoDTO
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void modModelByDTOForScrap(SbInfoDTO sbInfoDTO) {
|
|
|
|
+ sbInfoDTO.setStatus(SbInfoStatusEnum.IN_SCRAP.getValue());
|
|
|
|
+ this.modModelByDTO(sbInfoDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void submitScrapAudit(SbInfoDTO sbInfoDTO) {
|
|
|
|
+ startFlow(sbInfoDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void startFlow(SbInfoDTO sbInfoDTO) {
|
|
|
|
+ String companyId = SecurityUtils.getUserInfo().getCompanyId();
|
|
|
|
+ validAuditPerson(companyId);
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+ String projectId = null;
|
|
|
|
+ String roleCode = SysRoleCodeEnum.FGS_SBZG.name();
|
|
|
|
+ Integer result = null;
|
|
|
|
+ Integer auditNode = SbInfoScrapAuditNodeEnum.FGS_SBZG.getValue();
|
|
|
|
+ if (StringUtils.isNotEmpty(companyId)) {
|
|
|
|
+ projectId = companyId;
|
|
|
|
+ roleCode = SysRoleCodeEnum.FGS_SBZG.name();
|
|
|
|
+ result = 2;
|
|
|
|
+ auditNode = SbInfoScrapAuditNodeEnum.FGS_SBZG.getValue();
|
|
|
|
+ }
|
|
|
|
+ ActObj obj = activitiBusinessService.startWorkflow(sbInfoDTO.getId(), sbInfoDTO.getName() + "-" + sbInfoDTO.getNo(), projectId, sbInfoDTO.getProcessInstanceId(),
|
|
|
|
+ ActApplyEnum.SB_INFO_SCRAP.getName(), SbInfoScrapAuditNodeEnum.START.getValue(), roleCode,
|
|
|
|
+ now, result, sbInfoDTO.getRemark());
|
|
|
|
+ // 通知消息
|
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(new WorkplaceBacklogDTO(WorkplaceBacklogTypeEnum.SB_SCRAP.getValue(),
|
|
|
|
+ WorkplaceBacklogDetailTypeEnum.SB_SCRAP.getValue(),
|
|
|
|
+ obj.getTaskId(), MessageTemplateUtil.getSbInfoScrapTask(sbInfoDTO.getName() + "-" + sbInfoDTO.getNo()),
|
|
|
|
+ sbInfoDTO.getId(), ListUtils.newArrayList(obj.getAssignee()))));
|
|
|
|
+ sbInfoDTO.setProcessInstanceId(obj.getProcessId());
|
|
|
|
+ sbInfoDTO.setAuditNode(auditNode);
|
|
|
|
+ sbInfoDTO.setStatus(SbInfoStatusEnum.IN_SCRAP.getValue());
|
|
|
|
+ sbInfoDTO.setScrapUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
|
+ sbInfoDTO.setScrapUserName(SecurityUtils.getUserInfo().getRealName());
|
|
|
|
+ this.modModelByDTO(sbInfoDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验分公司设备主管,分公司分管领导审批人是否设置
|
|
|
|
+ */
|
|
|
|
+ private void validAuditPerson(String companyId) {
|
|
|
|
+ SysUserVO user = activitiBusinessService.getLeadDeptAuditUserIdInCompany(companyId, null, SysRoleCodeEnum.FGS_SBZG.name());
|
|
|
|
+ if (user == null) {
|
|
|
|
+ throw new BusinessException("该项目审批流程中分公司设备主管未设置");
|
|
|
|
+ }
|
|
|
|
+ user = activitiBusinessService.getLeadDeptAuditUserIdInCompany(companyId, null, SysRoleCodeEnum.FGS_CWZG.name());
|
|
|
|
+ if (user == null) {
|
|
|
|
+ throw new BusinessException("该项目审批流程中分公司财务未设置");
|
|
|
|
+ }
|
|
|
|
+ user = activitiBusinessService.getLeadDeptAuditUserIdInCompany(companyId, null, SysRoleCodeEnum.FGS_SBFGLD.name());
|
|
|
|
+ if (user == null) {
|
|
|
|
+ throw new BusinessException("该项目审批流程中分公司分管领导未设置");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.SERIALIZABLE)
|
|
|
|
+ public void audit(SbInfoDTO record) {
|
|
|
|
+ String id = record.getId();
|
|
|
|
+ SbInfo sbInfo = mapper.selectByPrimaryKeyForUpdate(id);
|
|
|
|
+ if (sbInfo == null) {
|
|
|
|
+ throw new BusinessException(ResultCode.DATA_NOT_EXIST);
|
|
|
|
+ }
|
|
|
|
+ Integer result;
|
|
|
|
+ Integer node = sbInfo.getAuditNode();
|
|
|
|
+ Integer nextNode = node;
|
|
|
|
+ String roleCode = null;
|
|
|
|
+ if (!record.getAuditFlag()) {
|
|
|
|
+ result = 0;
|
|
|
|
+ } else {
|
|
|
|
+ result = 2;
|
|
|
|
+ if (SbInfoScrapAuditNodeEnum.FGS_SBZG.getValue().equals(node)) {
|
|
|
|
+ roleCode = SysRoleCodeEnum.FGS_CWZG.name();
|
|
|
|
+ nextNode = SbInfoScrapAuditNodeEnum.FGS_CWZG.getValue();
|
|
|
|
+ } else if (SbInfoScrapAuditNodeEnum.FGS_CWZG.getValue().equals(node)) {
|
|
|
|
+ roleCode = SysRoleCodeEnum.FGS_SBFGLD.name();
|
|
|
|
+ nextNode = SbInfoScrapAuditNodeEnum.FGS_SBFGLD.getValue();
|
|
|
|
+ } else {
|
|
|
|
+ result = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 更新
|
|
|
|
+ UserInfo user = SecurityUtils.getUserInfo();
|
|
|
|
+ SbInfo update = new SbInfo();
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
+ update.setId(id);
|
|
|
|
+ if (result == 0) {
|
|
|
|
+ update.setStatus(SbInfoStatusEnum.REFUSE_SCRAPED.getValue());
|
|
|
|
+ update.setAuditNode(SbInfoScrapAuditNodeEnum.START.getValue());
|
|
|
|
+ } else if (result == 1) {
|
|
|
|
+ update.setStatus(SbInfoStatusEnum.SCRAPED.getValue());
|
|
|
|
+ update.setAuditNode(SbInfoScrapAuditNodeEnum.END.getValue());
|
|
|
|
+ update.setAuditTime(now);
|
|
|
|
+ } else {
|
|
|
|
+ update.setAuditNode(nextNode);
|
|
|
|
+ }
|
|
|
|
+ update.setRefuseReason(record.getRefuseReason());
|
|
|
|
+ update.setUpdateTime(now);
|
|
|
|
+ update.setUpdateUserId(user.getUserId());
|
|
|
|
+ update.setUpdateUserName(user.getRealName());
|
|
|
|
+ mapper.updateByPrimaryKeySelective(update);
|
|
|
|
+
|
|
|
|
+ // 执行审批流程
|
|
|
|
+ ActObj obj = activitiBusinessService.executeFlow(record.getTaskId(), sbInfo.getProcessInstanceId(), null, result,
|
|
|
|
+ record.getRefuseReason(), record.getAuditFlag(), node, roleCode, null, LocalDateTime.now());
|
|
|
|
+ String assignee = obj.getAssignee();
|
|
|
|
+ WorkplaceBacklogDTO dto = null;
|
|
|
|
+ if (result > 1 && StringUtils.isNotEmpty(assignee)) {
|
|
|
|
+ dto = new WorkplaceBacklogDTO(WorkplaceBacklogTypeEnum.SB_SCRAP.getValue(),
|
|
|
|
+ WorkplaceBacklogDetailTypeEnum.SB_SCRAP.getValue(),
|
|
|
|
+ obj.getTaskId(), MessageTemplateUtil.getSbInfoScrapTask(sbInfo.getName() + "-" + sbInfo.getNo()),
|
|
|
|
+ sbInfo.getId(), ListUtils.newArrayList(obj.getAssignee()));
|
|
|
|
+ }
|
|
|
|
+ if (result == 1 || result == 0) {
|
|
|
|
+ dto = new WorkplaceBacklogDTO(WorkplaceBacklogTypeEnum.SB_SCRAP.getValue(),
|
|
|
|
+ WorkplaceBacklogDetailTypeEnum.SB_SCRAP_RESULT.getValue(),
|
|
|
|
+ obj.getTaskId(), MessageTemplateUtil.getSbInfoScrapTaskResult(sbInfo.getName() + "-" + sbInfo.getNo(), result == 1),
|
|
|
|
+ sbInfo.getId(), ListUtils.newArrayList(sbInfo.getScrapUserId()));
|
|
|
|
+ }
|
|
|
|
+ if (dto != null) {
|
|
|
|
+ // 通知消息
|
|
|
|
+ SpringContextHolder.publishEvent(new WorkplaceBacklogEvent(dto));
|
|
|
|
+ }
|
|
|
|
+ WorkplaceBacklogUserDTO backlogUserDTO = new WorkplaceBacklogUserDTO();
|
|
|
|
+ backlogUserDTO.setUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
|
+ backlogUserDTO.setOtherId(sbInfo.getId());
|
|
|
|
+ backlogUserDTO.setDetailType(WorkplaceBacklogDetailTypeEnum.SB_SCRAP_RESULT.getValue());
|
|
|
|
+ backlogUserMapper.updateByUser(backlogUserDTO);
|
|
|
|
+ }
|
|
}
|
|
}
|