¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | 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.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.EquipmentOperationTagEnum; |
| | | import org.jeecg.modules.eam.constant.InspectionStatus; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamInspectionOrder; |
| | | import org.jeecg.modules.eam.entity.EamInspectionOrderDetail; |
| | | import org.jeecg.modules.eam.mapper.EamInspectionOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderQuery; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamInspectionOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamInspectionOrderService; |
| | | import org.jeecg.modules.eam.service.IEamReportRepairService; |
| | | import org.jeecg.modules.eam.vo.InspectionVo; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCommonService; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.system.service.IMdcUserProductionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description: ç¹æ£å·¥å |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-04-02 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service("IEamInspectionOrderService") |
| | | public class EamInspectionOrderServiceImpl extends ServiceImpl<EamInspectionOrderMapper, EamInspectionOrder> implements IEamInspectionOrderService, FlowCallBackServiceI { |
| | | |
| | | @Resource |
| | | private EamInspectionOrderMapper eamInspectionOrderMapper; |
| | | @Autowired |
| | | private IEamInspectionOrderDetailService eamInspectionOrderDetailService; |
| | | @Resource |
| | | private FlowCommonService flowCommonService; |
| | | @Resource |
| | | private IFlowDefinitionService flowDefinitionService; |
| | | @Autowired |
| | | private IFlowTaskService flowTaskService; |
| | | @Autowired |
| | | private IEamEquipmentService eamEquipmentService; |
| | | @Autowired |
| | | private FlowMyBusinessServiceImpl flowMyBusinessService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private IEamEquipmentService iEamEquipmentService; |
| | | @Autowired |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | @Autowired |
| | | private IEamReportRepairService eamReportRepairService; |
| | | |
| | | @Override |
| | | public IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, EamInspectionOrderQuery query) { |
| | | QueryWrapper<EamInspectionOrder> queryWrapper = new QueryWrapper<>(); |
| | | //ç¨æ·æ°æ®æé |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //éæ©äºè®¾å¤ï¼æ ¹æ®è®¾å¤idè¿æ»¤è®¾å¤ |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没æéæ©è®¾å¤ï¼æ ¹æ®è½¦é´è¿æ»¤è®¾å¤ |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | } |
| | | //æ¥è¯¢æ¡ä»¶è¿æ»¤ |
| | | if (query != null) { |
| | | if (StringUtils.isNotBlank(query.getEquipmentId())) { |
| | | queryWrapper.eq("wmo.equipment_id", query.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getOrderNum())) { |
| | | queryWrapper.like("wmo.order_num", query.getOrderNum()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getInspectionStatus())) { |
| | | queryWrapper.eq("wmo.inspection_status", query.getInspectionStatus()); |
| | | } |
| | | if (query.getInspectionDateBegin() != null && query.getInspectionDateEnd() != null) { |
| | | queryWrapper.between("wmo.inspection_date", query.getInspectionDateBegin(), query.getInspectionDateEnd()); |
| | | } |
| | | //æåº |
| | | 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("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | |
| | | return eamInspectionOrderMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<EamInspectionOrder> selectUnCompleteOrder(String expiredDate) { |
| | | LambdaQueryWrapper<EamInspectionOrder> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.lt(EamInspectionOrder::getInspectionDate, expiredDate); |
| | | List<String> unCompleteStatus = new ArrayList<>(); |
| | | unCompleteStatus.add(InspectionStatus.WAIT_INSPECTION.name()); |
| | | unCompleteStatus.add(InspectionStatus.UNDER_INSPECTION.name()); |
| | | queryWrapper.in(EamInspectionOrder::getInspectionStatus, unCompleteStatus); |
| | | queryWrapper.orderByAsc(EamInspectionOrder::getInspectionDate); |
| | | return eamInspectionOrderMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addInspectionOrder(EamInspectionOrderRequest eamInspectionOrderRequest) { |
| | | EamInspectionOrder eamInspectionOrder = new EamInspectionOrder(); |
| | | BeanUtils.copyProperties(eamInspectionOrderRequest, eamInspectionOrder); |
| | | //ä¿®æ¹ç¶æ |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | | } else { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.WAIT_INSPECTION.name()); |
| | | } |
| | | save(eamInspectionOrder); |
| | | //å¤çæç»æ°æ® |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { |
| | | eamInspectionOrderRequest.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setOrderId(eamInspectionOrder.getId()); |
| | | tableDetail.setId(null); |
| | | }); |
| | | eamInspectionOrderDetailService.saveBatch(eamInspectionOrderRequest.getTableDetailList()); |
| | | } |
| | | //å¤çéä»¶ |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getFileList())) { |
| | | FileUploadResult fileUploadResult = eamInspectionOrderRequest.getFileList().get(0); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResult); |
| | | eamInspectionOrder.setImageFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转æ¢å¤±è´¥ï¼" + e.getMessage(), e); |
| | | } |
| | | } |
| | | if (StrUtil.isNotBlank(eamInspectionOrderRequest.getOperator())) { |
| | | triggerProcess(eamInspectionOrder); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * è§¦åæµç¨ |
| | | * |
| | | * @param eamInspectionOrder |
| | | * @return |
| | | */ |
| | | public boolean triggerProcess(EamInspectionOrder eamInspectionOrder) { |
| | | EamEquipment equipment = eamEquipmentService.getById(eamInspectionOrder.getEquipmentId()); |
| | | if (equipment == null) { |
| | | return false; |
| | | } else { |
| | | eamInspectionOrder.setEquipmentCode(equipment.getEquipmentCode()); |
| | | } |
| | | flowCommonService.initActBusiness("å·¥åå·: " + eamInspectionOrder.getOrderNum() + ";设å¤ç¼å·: " + eamInspectionOrder.getEquipmentCode() + ";å®è£
ä½ç½®: " + equipment.getInstallationPosition(), |
| | | eamInspectionOrder.getId(), "IEamInspectionOrderService", "eam_inspection", null); |
| | | Map<String, Object> variables = new HashMap<>(); |
| | | variables.put("dataId", eamInspectionOrder.getId()); |
| | | if (StrUtil.isEmpty(eamInspectionOrder.getRemark())) { |
| | | variables.put("organization", "æ°å¢ç¹æ£å·¥åé»è®¤å¯å¨æµç¨"); |
| | | variables.put("comment", "æ°å¢ç¹æ£å·¥åé»è®¤å¯å¨æµç¨"); |
| | | } else { |
| | | variables.put("organization", eamInspectionOrder.getRemark()); |
| | | variables.put("comment", eamInspectionOrder.getRemark()); |
| | | } |
| | | variables.put("proofreading", true); |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(eamInspectionOrder.getOperator()); |
| | | variables.put("NextAssignee", usernames); |
| | | Result result = flowDefinitionService.startProcessInstanceByKey("eam_inspection", variables); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean editInspectionOrder(EamInspectionOrderRequest eamInspectionOrderRequest) { |
| | | EamInspectionOrder eamInspectionOrder = new EamInspectionOrder(); |
| | | BeanUtils.copyProperties(eamInspectionOrderRequest, eamInspectionOrder); |
| | | if (StrUtil.isNotEmpty(eamInspectionOrder.getOperator())) { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | | } |
| | | super.updateById(eamInspectionOrder); |
| | | //å¤çæç»æ°æ® |
| | | if (CollectionUtil.isNotEmpty(eamInspectionOrderRequest.getTableDetailList())) { |
| | | eamInspectionOrderRequest.getTableDetailList().forEach(tableDetail -> { |
| | | tableDetail.setOrderId(eamInspectionOrder.getId()); |
| | | tableDetail.setCreateTime(new Date()); |
| | | }); |
| | | //å é¤æç» |
| | | eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", eamInspectionOrder.getId())); |
| | | eamInspectionOrderDetailService.saveBatch(eamInspectionOrderRequest.getTableDetailList()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * é¢åç¹æ£å·¥å |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean takeInspectionOrder(String id) { |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if(user == null || !BusinessCodeConst.PCR0001.equals(user.getPost())) { |
| | | throw new JeecgBootException("䏿¯æä½å·¥ï¼æ æ³é¢åæ¤å·¥åï¼"); |
| | | } |
| | | EamInspectionOrder eamInspectionOrder = this.getById(id); |
| | | if (eamInspectionOrder == null) { |
| | | return false; |
| | | } else { |
| | | eamInspectionOrder.setOperator(user.getUsername()); |
| | | //ä¿®æ¹ç¶æ |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | | this.triggerProcess(eamInspectionOrder); |
| | | this.updateById(eamInspectionOrder); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ä½åºç¹æ£å·¥å |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean cancelInspectionOrder(String id) { |
| | | EamInspectionOrder eamInspectionOrder = this.getById(id); |
| | | if (eamInspectionOrder == null) { |
| | | return false; |
| | | } else { |
| | | eamInspectionOrder.setInspectionStatus(InspectionStatus.ABOLISH.name()); |
| | | return updateById(eamInspectionOrder); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç¹æ£æµç¨ |
| | | * |
| | | * @param eamInspectionOrderRequest |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.POINT_INSPECTION, businessTable = "eam_inspection_order") |
| | | public EamInspectionOrder inspectionProcess(EamInspectionOrderRequest eamInspectionOrderRequest) { |
| | | try { |
| | | // æ£æ¥è¯·æ±åæ° |
| | | if (!isValidRequest(eamInspectionOrderRequest)) { |
| | | throw new JeecgBootException("鿳忰"); |
| | | } |
| | | |
| | | // è·åå½åç»å½ç¨æ· |
| | | LoginUser user = getCurrentUser(); |
| | | if (user == null || StrUtil.isBlank(user.getId())) { |
| | | throw new JeecgBootException("è´¦å·ä¸åå¨"); |
| | | } |
| | | eamInspectionOrderRequest.setAssignee(user.getUsername()); |
| | | |
| | | // è·åç¹æ£å·¥åä¿¡æ¯ |
| | | EamInspectionOrder eamInspectionOrder = getEamInspectionOrder(eamInspectionOrderRequest.getDataId()); |
| | | if (eamInspectionOrder == null) { |
| | | throw new JeecgBootException("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | |
| | | // è·åæµç¨ä¸å¡è®°å½ |
| | | FlowMyBusiness flowMyBusiness = getFlowMyBusiness(eamInspectionOrderRequest.getInstanceId()); |
| | | if (flowMyBusiness == null) { |
| | | throw new JeecgBootException("æµç¨è®°å½ä¸åå¨"); |
| | | } |
| | | |
| | | // æ£æ¥ç¨æ·æ¯å¦ææéæä½ä»»å¡ |
| | | if (!isUserAuthorized(flowMyBusiness, user)) { |
| | | throw new JeecgBootException("ç¨æ·æ ææä½æ¤ä»»å¡"); |
| | | } |
| | | |
| | | // 认é¢ä»»å¡ |
| | | if (!claimTask(flowMyBusiness.getTaskId(), user)) { |
| | | throw new JeecgBootException("ä»»å¡ä¸åå¨ã已宿æå·²è¢«ä»äººè®¤é¢"); |
| | | } |
| | | |
| | | // 设置æµç¨åé |
| | | setupProcessVariables(eamInspectionOrderRequest, eamInspectionOrder, user); |
| | | |
| | | // 宿æµç¨ä»»å¡ |
| | | Result result = flowTaskService.complete(eamInspectionOrderRequest); |
| | | |
| | | // æ ¹æ®ä»»å¡å®æç»ææ´æ°å·¥åç¶æ |
| | | updateOrderStatus(result, eamInspectionOrderRequest, eamInspectionOrder, user); |
| | | |
| | | // æ´æ°å·¥åä¿¡æ¯ |
| | | updateEamInspectionOrder(eamInspectionOrder); |
| | | |
| | | //æ¥è¯¢æ°æ®,è¿è¡è®¾å¤ç»´ä¿®å¤ç |
| | | if (eamInspectionOrder.getInspectionStatus().equals(InspectionStatus.WAIT_CONFIRM.name())) { |
| | | updateEamInspectionOrderDetail(eamInspectionOrder); |
| | | } |
| | | |
| | | return eamInspectionOrder; |
| | | } catch (Exception e) { |
| | | throw new JeecgBootException("æä½å¤±è´¥ï¼" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | private boolean isValidRequest(EamInspectionOrderRequest request) { |
| | | return StrUtil.isNotBlank(request.getTaskId()) && StrUtil.isNotBlank(request.getDataId()); |
| | | } |
| | | |
| | | private LoginUser getCurrentUser() { |
| | | try { |
| | | return (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private EamInspectionOrder getEamInspectionOrder(String dataId) { |
| | | return this.getById(dataId); |
| | | } |
| | | |
| | | private FlowMyBusiness getFlowMyBusiness(String instanceId) { |
| | | List<FlowMyBusiness> businessList = flowMyBusinessService.list( |
| | | new QueryWrapper<FlowMyBusiness>().eq("process_instance_id", instanceId)); |
| | | return businessList.isEmpty() ? null : businessList.get(0); |
| | | } |
| | | |
| | | private boolean isUserAuthorized(FlowMyBusiness flowMyBusiness, LoginUser user) { |
| | | List<String> todoUsers = JSON.parseArray(flowMyBusiness.getTodoUsers(), String.class); |
| | | return todoUsers != null && todoUsers.contains(user.getUsername()); |
| | | } |
| | | |
| | | private boolean claimTask(String taskId, LoginUser user) { |
| | | Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); |
| | | if (task == null) { |
| | | return false; |
| | | } |
| | | if (task.getAssignee() != null && !task.getAssignee().equals(user.getUsername())) { |
| | | return false; |
| | | } |
| | | taskService.claim(taskId, user.getUsername()); |
| | | return true; |
| | | } |
| | | |
| | | private void setupProcessVariables(EamInspectionOrderRequest request, EamInspectionOrder order, LoginUser user) { |
| | | Map<String, Object> values = new HashMap<>(); |
| | | if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && user.getUsername().equals(order.getOperator())) { |
| | | // ç¹æ£äººç¹æ£ç»æ |
| | | String manager = Optional.ofNullable(iEamEquipmentService.getById(order.getEquipmentId())) |
| | | .map(EamEquipment::getEquipmentManager) |
| | | .orElse(null); |
| | | if (manager == null) { |
| | | throw new IllegalArgumentException("设å¤ç®¡çåæªé
ç½®"); |
| | | } |
| | | List<String> usernameList = Collections.singletonList(manager); |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", "ç¹æ£äººç¹æ£ç»æ"); |
| | | values.put("comment", "ç¹æ£äººç¹æ£ç»æ"); |
| | | values.put("NextAssignee", usernameList); |
| | | request.setComment("ç¹æ£äººç¹æ£ç»æ"); |
| | | } else { |
| | | // çç»é¿ç¡®è®¤ |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", request.getConfirmComment()); |
| | | values.put("comment", request.getConfirmComment()); |
| | | values.put("confirmation", request.getConfirmDealType()); |
| | | request.setComment(request.getConfirmComment()); |
| | | if ("2".equals(request.getConfirmDealType())) { |
| | | // çç»é¿é©³å |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(order.getOperator()); |
| | | order.setInspectionStatus(InspectionStatus.UNDER_INSPECTION.name()); |
| | | values.put("NextAssignee", usernames); |
| | | } |
| | | } |
| | | request.setValues(values); |
| | | } |
| | | |
| | | private void updateOrderStatus(Result result, EamInspectionOrderRequest request, EamInspectionOrder order, LoginUser user) { |
| | | if (result.isSuccess()) { |
| | | if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && StrUtil.isEmpty(request.getConfirmDealType())) { |
| | | // ç¹æ£å®æ |
| | | order.setInspectionStatus(InspectionStatus.WAIT_CONFIRM.name()); |
| | | order.setOperateTime(new Date()); |
| | | if (CollectionUtil.isNotEmpty(request.getFileList())) { |
| | | List<FileUploadResult> fileUploadResultList = request.getFileList(); |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | try { |
| | | String referenceFile = mapper.writeValueAsString(fileUploadResultList); |
| | | order.setImageFiles(referenceFile); |
| | | } catch (JsonProcessingException e) { |
| | | log.error("JSON转æ¢å¤±è´¥ï¼" + e.getMessage(), e); |
| | | } |
| | | } |
| | | eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", order.getId())); |
| | | eamInspectionOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getConfirmDealType())) { |
| | | // çç»é¿ç¡®è®¤ä»»å¡ |
| | | order.setInspectionStatus(InspectionStatus.COMPLETE.name()); |
| | | order.setConfirmUser(user.getUsername()); |
| | | order.setConfirmComment(request.getConfirmComment()); |
| | | order.setConfirmDealType(request.getConfirmDealType()); |
| | | order.setConfirmTime(new Date()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void updateEamInspectionOrder(EamInspectionOrder eamInspectionOrder) { |
| | | this.updateById(eamInspectionOrder); |
| | | } |
| | | |
| | | /** |
| | | * è®¾å¤æ¯å¦åå¨å¼å¸¸,å¹¶è¿è¡è®¾å¤ç»´ä¿® |
| | | * |
| | | * @param eamInspectionOrder |
| | | */ |
| | | private void updateEamInspectionOrderDetail(EamInspectionOrder eamInspectionOrder) { |
| | | List<EamInspectionOrderDetail> eamInspectionOrderDetails = eamInspectionOrderDetailService |
| | | .list(new QueryWrapper<EamInspectionOrderDetail>() |
| | | .eq("order_id", eamInspectionOrder.getId()).eq("report_flag", "1").eq("inspection_result", "2")); |
| | | eamReportRepairService.reportRepairFromInspection(eamInspectionOrder.getEquipmentId(), eamInspectionOrder.getOperator(), eamInspectionOrderDetails); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éä½åºä¸é¢å |
| | | * |
| | | * @param ids |
| | | * @param type |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> batchCancelOrTakeInspectionOrder(String ids, String type) { |
| | | if (type == null) { |
| | | return Result.error("è¯·éæ©æä½ç±»å"); |
| | | } |
| | | LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | QueryWrapper<EamInspectionOrder> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("id", list); |
| | | queryWrapper.eq("inspection_status", InspectionStatus.WAIT_INSPECTION.name()); |
| | | List<EamInspectionOrder> eamInspectionOrderList = this.list(queryWrapper); |
| | | if (!eamInspectionOrderList.isEmpty()) { |
| | | eamInspectionOrderList.forEach(eamInspectionOrder -> { |
| | | eamInspectionOrder.setInspectionStatus(type); |
| | | if (InspectionStatus.UNDER_INSPECTION.name().equals(type)) { |
| | | eamInspectionOrder.setOperator(loginUser.getUsername()); |
| | | this.triggerProcess(eamInspectionOrder); |
| | | } else { |
| | | eamInspectionOrder.setOperator(null); |
| | | } |
| | | }); |
| | | this.updateBatchById(eamInspectionOrderList); |
| | | } |
| | | return Result.OK("æä½æå"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Result<?> selectVoById(String id) { |
| | | List<EamInspectionOrder> eamInspectionOrders = this.list(new QueryWrapper<EamInspectionOrder>().eq("id", id)); |
| | | List<EamInspectionOrderRequest> eamInspectionOrderRequestList = new ArrayList<>(); |
| | | eamInspectionOrders.forEach(eamInspectionOrder -> { |
| | | EamInspectionOrderRequest eamInspectionOrderRequest = new EamInspectionOrderRequest(); |
| | | BeanUtils.copyProperties(eamInspectionOrder, eamInspectionOrderRequest); |
| | | List<EamInspectionOrderDetail> eamInspectionOrderDetails = eamInspectionOrderDetailService |
| | | .list(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", eamInspectionOrder.getId())); |
| | | eamInspectionOrderRequest.setTableDetailList(eamInspectionOrderDetails); |
| | | eamInspectionOrderRequestList.add(eamInspectionOrderRequest); |
| | | }); |
| | | return Result.ok(eamInspectionOrderRequestList); |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | |
| | | @Override |
| | | public List<InspectionVo> findInspectionResult(String equipmentId,String itemDemand,String yearMonth) { |
| | | return this.baseMapper.findInspectionResult(equipmentId,itemDemand,yearMonth); |
| | | } |
| | | |
| | | @Override |
| | | public List<InspectionVo> findInspectionUser(String equipmentId,String yearMonth) { |
| | | return this.baseMapper.findInspectionUser(equipmentId,yearMonth); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> findInspectionStandard(String equipmentId) { |
| | | return this.baseMapper.findInspectionStandard(equipmentId); |
| | | } |
| | | } |