From 644f2477e11b663dad53f05e4c52315916265911 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期二, 08 四月 2025 17:30:41 +0800 Subject: [PATCH] art: 设备管理-周保-字段添加,保养状态修改 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java | 86 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 81 insertions(+), 5 deletions(-) diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java index b8e533c..cab053b 100644 --- a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java @@ -1,12 +1,14 @@ package org.jeecg.modules.eam.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.StrUtil; 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 org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; +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; @@ -21,14 +23,16 @@ import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderDetailService; import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +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.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -37,14 +41,19 @@ * @Date: 2025-04-02 * @Version: V1.0 */ -@Service -public class EamWeekMaintenanceOrderServiceImpl extends ServiceImpl<EamWeekMaintenanceOrderMapper, EamWeekMaintenanceOrder> implements IEamWeekMaintenanceOrderService { +@Service("IEamWeekMaintenanceOrderService") +public class EamWeekMaintenanceOrderServiceImpl extends ServiceImpl<EamWeekMaintenanceOrderMapper, EamWeekMaintenanceOrder> implements IEamWeekMaintenanceOrderService, FlowCallBackServiceI { @Resource private EamWeekMaintenanceOrderMapper eamWeekMaintenanceOrderMapper; @Autowired private IEamWeekMaintenanceOrderDetailService eamWeekMaintenanceOrderDetailService; + + @Resource + private FlowCommonService flowCommonService; + @Resource + private IFlowDefinitionService flowDefinitionService; @Override @Transactional(rollbackFor = Exception.class) @@ -70,6 +79,8 @@ }); eamWeekMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); } + //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� + //TODO return true; } @@ -162,6 +173,71 @@ List<String> ids = request.getRemoveDetailList().stream().map(EamWeekMaintenanceOrderDetail::getId).collect(Collectors.toList()); eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids); } + //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� + //TODO return true; } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean collect(String id) { + EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(id); + if(entity == null) { + throw new JeecgBootException("瑕侀鍙栫殑宸ュ崟涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); + } + if(!MaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { + throw new JeecgBootException("璇ュ伐鍗曞凡杩涜杩囬鍙栵紒"); + } + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + entity.setOperator(sysUser.getUsername()); + entity.setMaintenanceStatus(MaintenanceStatusEnum.UNDER_MAINTENANCE.name()); + eamWeekMaintenanceOrderMapper.updateById(entity); + + //鍚姩娴佺▼ + flowCommonService.initActBusiness("宸ュ崟鍙�:" + entity.getOrderNum() + ";寮�濮嬭繘琛岃澶囧懆淇�", + entity.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", entity.getId()); + if (StrUtil.isEmpty(entity.getRemark())) { + variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); + variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); + } else { + variables.put("organization", entity.getRemark()); + variables.put("comment", entity.getRemark()); + } + variables.put("proofreading", true); + List<String> usernames = new ArrayList<>(); + usernames.add(entity.getOperator()); + variables.put("NextAssignee", usernames); + Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); + if(result != null){ + return result.isSuccess(); + } + 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; + } } -- Gitblit v1.9.3