| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.HfTemplateCategoryEnum; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationOrderChangeStatusEnum; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationOrderStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamBaseHFCode; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrder; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusEvaluationOrderChange; |
| | | import org.jeecg.modules.eam.mapper.EamTechnicalStatusEvaluationOrderChangeMapper; |
| | | import org.jeecg.modules.eam.request.EamTechnicalStatusEvaluationOrderChangeQuery; |
| | | import org.jeecg.modules.eam.service.IEamBaseHFCodeService; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationOrderChangeService; |
| | | import org.jeecg.modules.eam.service.IEamTechnicalStatusEvaluationOrderService; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.BaseFactoryUser; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | | import org.jeecg.modules.system.service.IBaseFactoryUserService; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 技术状态鉴定工单变更 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-07-09 |
| | | * @Date: 2025-07-09 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class EamTechnicalStatusEvaluationOrderChangeServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationOrderChangeMapper, EamTechnicalStatusEvaluationOrderChange> implements IEamTechnicalStatusEvaluationOrderChangeService { |
| | | @Service("IEamTechnicalStatusEvaluationOrderChangeService") |
| | | public class EamTechnicalStatusEvaluationOrderChangeServiceImpl extends ServiceImpl<EamTechnicalStatusEvaluationOrderChangeMapper, EamTechnicalStatusEvaluationOrderChange> implements IEamTechnicalStatusEvaluationOrderChangeService, FlowCallBackServiceI { |
| | | @Autowired |
| | | private IBaseFactoryUserService baseFactoryUserService; |
| | | @Autowired |
| | | private IBaseFactoryService baseFactoryService; |
| | | @Autowired |
| | | private IEamTechnicalStatusEvaluationOrderService evaluationOrderService; |
| | | @Autowired |
| | | private IEamEquipmentService equipmentService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | @Autowired |
| | | private IEamBaseHFCodeService hfCodeService; |
| | | |
| | | @Override |
| | | public IPage<EamTechnicalStatusEvaluationOrderChange> queryPageList(Page<EamTechnicalStatusEvaluationOrderChange> page, EamTechnicalStatusEvaluationOrderChangeQuery query) { |
| | | QueryWrapper<EamTechnicalStatusEvaluationOrderChange> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("ems.del_flag", CommonConstant.DEL_FLAG_0); |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据中心过滤设备 |
| | | List<BaseFactoryUser> baseFactoryUserList = baseFactoryUserService. |
| | | list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId, sysUser.getId())); |
| | | if (!CollectionUtils.isEmpty(baseFactoryUserList)) { |
| | | Set<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toSet()); |
| | | Set<String> factoryCodeList = baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getOrgCode).collect(Collectors.toSet()); |
| | | queryWrapper.in("e.factory_org_code", factoryCodeList); |
| | | } else { |
| | | return page; |
| | | } |
| | | } |
| | | if (query != null) { |
| | | //编码 模糊查询 |
| | | if (StringUtils.isNotBlank(query.getChangeOrderNum())) { |
| | | queryWrapper.like("ems.change_order_num", query.getChangeOrderNum()); |
| | | } |
| | | //设备 |
| | | if (StringUtils.isNotBlank(query.getEquipmentId())) { |
| | | queryWrapper.eq("ems.equipment_id", query.getEquipmentId()); |
| | | } |
| | | |
| | | //保养分类 |
| | | if (StringUtils.isNotBlank(query.getChangeStatus())) { |
| | | queryWrapper.eq("ems.change_status", query.getChangeStatus()); |
| | | } |
| | | if (query.getDateBegin() != null && query.getDateEnd() != null) { |
| | | queryWrapper.between("ems.apply_date", query.getDateBegin(), query.getDateEnd()); |
| | | } |
| | | //排序 |
| | | if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { |
| | | String column = query.getColumn(); |
| | | if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); |
| | | } |
| | | if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(query.getOrder())) { |
| | | queryWrapper.orderByAsc("ems." + oConvertUtils.camelToUnderline(column)); |
| | | } else { |
| | | queryWrapper.orderByDesc("ems." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("ems.create_time"); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("ems.create_time"); |
| | | } |
| | | return this.getBaseMapper().queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addTechnicalStatusEvaluationOrderChange(EamTechnicalStatusEvaluationOrderChange request) { |
| | | //查询工单 |
| | | EamTechnicalStatusEvaluationOrder order = evaluationOrderService.getById(request.getOrderId()); |
| | | if (order == null) { |
| | | throw new JeecgBootException("鉴定工单不存在,操作失败!"); |
| | | } |
| | | //查询设备 |
| | | EamEquipment equipment = equipmentService.getById(request.getEquipmentId()); |
| | | if (equipment == null) { |
| | | throw new JeecgBootException("设备信息不存在,操作失败!"); |
| | | } |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | throw new JeecgBootException("登录用户信息为空,操作失败!"); |
| | | } |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.TECHNICAL_STATUS_EVALUATION_ORDER_CHANG_CODE_RULE); |
| | | request.setChangeOrderNum(codeSeq); |
| | | request.setId(null); |
| | | request.setChangeStatus(TechnicalStatusEvaluationOrderChangeStatusEnum.WAIT_SUBMIT.name()); |
| | | request.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | request.setApplicant(sysUser.getUsername()); |
| | | request.setApplyDate(new Date()); |
| | | request.setFactoryOrgCode(equipment.getFactoryOrgCode()); |
| | | //技术状态鉴定表 |
| | | EamBaseHFCode eamBaseHFCode = hfCodeService.selectByCategory(HfTemplateCategoryEnum.TECHNICAL_STATUS_EVALUATION_ORDER_CHANG.name()); |
| | | if (eamBaseHFCode == null) { |
| | | throw new JeecgBootException("未配置技术状态鉴定变更的HF编码,添加失败!"); |
| | | } |
| | | request.setHfCode(eamBaseHFCode.getHfCode()); |
| | | this.getBaseMapper().insert(request); |
| | | boolean b = evaluationOrderService.updateEvaluationStatus(request.getOrderId(), TechnicalStatusEvaluationOrderStatusEnum.CHANGING.name()); |
| | | if (!b) { |
| | | throw new JeecgBootException("技术状态鉴定工单状态变更失败,无法变更!"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean editTechnicalStatusEvaluationOrderChange(EamTechnicalStatusEvaluationOrderChange request) { |
| | | EamTechnicalStatusEvaluationOrderChange entity = this.getBaseMapper().selectById(request.getId()); |
| | | if(entity == null) { |
| | | throw new JeecgBootException("编辑的数据已删除,请刷新重试!"); |
| | | } |
| | | if(!TechnicalStatusEvaluationOrderChangeStatusEnum.WAIT_SUBMIT.name().equals(entity.getChangeStatus())) { |
| | | throw new JeecgBootException("只有待提交状态才可编辑!"); |
| | | } |
| | | entity.setApplyReason(request.getApplyReason()); |
| | | entity.setDeferredEvaluationDate(request.getDeferredEvaluationDate()); |
| | | this.getBaseMapper().updateById(entity); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void afterFlowHandle(FlowMyBusiness business) { |
| | | business.getTaskNameId();//接下来审批的节点 |
| | | business.getValues();//前端传进来的参数 |
| | | business.getActStatus(); |
| | | } |
| | | |
| | | @Override |
| | | public Object getBusinessDataById(String dataId) { |
| | | return this.getById(dataId); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> flowValuesOfTask(String taskNameId, Map<String, Object> values) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<String> flowCandidateUsernamesOfTask(String taskNameId, Map<String, Object> values) { |
| | | //业务是否干预流程,业务干预,流程干预,指定人员进行处理 |
| | | //获取下一步处理人 |
| | | Object object = values.get("NextAssignee"); |
| | | return (List<String>) object; |
| | | } |
| | | } |