From fccfe7d50f42f5be4c4612d61b7ae852e2ef37cd Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 17 四月 2025 15:26:09 +0800 Subject: [PATCH] 优化指派设备与审签设备的权限校验查询,新增导入电子样板触发审签流程,新增电子样板指派设备功能 --- lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamWeekMaintenanceOrderServiceImpl.java | 187 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 179 insertions(+), 8 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 4cc12f2..c17c420 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,33 +1,39 @@ 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; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; -import org.jeecg.modules.eam.constant.MaintenanceStatusEnum; +import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum; import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; -import org.jeecg.modules.eam.entity.EamEquipment; import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; +import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrderDetail; import org.jeecg.modules.eam.mapper.EamWeekMaintenanceOrderMapper; import org.jeecg.modules.eam.request.EamWeekMaintenanceQuery; 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.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * @Description: 鍛ㄤ繚宸ュ崟 @@ -35,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) @@ -55,7 +66,7 @@ order.setOperator(request.getOperator()); order.setRemark(request.getRemark()); //鐘舵�佸垵濮嬪寲 - order.setMaintenanceStatus(MaintenanceStatusEnum.WAIT_MAINTENANCE.name()); + order.setMaintenanceStatus(WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name()); order.setCreationMethod(OrderCreationMethodEnum.MANUAL.name()); //鍒犻櫎鏍囪 order.setDelFlag(CommonConstant.DEL_FLAG_0); @@ -68,6 +79,34 @@ }); eamWeekMaintenanceOrderDetailService.saveBatch(request.getTableDetailList()); } + //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� + if(StringUtils.isNotBlank(order.getOperator())) { + //鍚姩娴佺▼ + flowCommonService.initActBusiness("宸ュ崟鍙�:" + order.getOrderNum() + ";寮�濮嬭繘琛岃澶囧懆淇�", + order.getId(), "IEamWeekMaintenanceOrderService", "week_maintenance_process", null); + Map<String, Object> variables = new HashMap<>(); + variables.put("dataId", order.getId()); + if (StrUtil.isEmpty(order.getRemark())) { + variables.put("organization", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); + variables.put("comment", "鏂板鍛ㄤ繚宸ュ崟榛樿鍚姩娴佺▼"); + } else { + variables.put("organization", order.getRemark()); + variables.put("comment", order.getRemark()); + } + variables.put("proofreading", true); + List<String> usernames = new ArrayList<>(); + usernames.add(order.getOperator()); + variables.put("NextAssignee", usernames); + Result result = flowDefinitionService.startProcessInstanceByKey("week_maintenance_process", variables); + if(result != null){ + //鏇存柊鍛ㄤ繚鐘舵�� + order.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); + order.setActualStartTime(new Date()); + eamWeekMaintenanceOrderMapper.updateById(order); + return result.isSuccess(); + } + } + return true; } @@ -121,4 +160,136 @@ return eamWeekMaintenanceOrderMapper.queryPageList(page, queryWrapper); } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean editWeekMaintenance(EamWeekMaintenanceRequest request) { + EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(request.getId()); + if(entity == null){ + throw new JeecgBootException("缂栬緫鐨勬暟鎹凡鍒犻櫎锛岃鍒锋柊閲嶈瘯锛�"); + } + if(!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())){ + throw new JeecgBootException("鍙湁寰呬繚鍏荤姸鎬佺殑鏁版嵁鎵嶅彲缂栬緫锛�"); + } + entity.setMaintenanceDate(request.getMaintenanceDate()); + entity.setOperator(request.getOperator()); + entity.setRemark(request.getRemark()); + + eamWeekMaintenanceOrderMapper.updateById(entity); + //澶勭悊璇︽儏 + if(CollectionUtil.isNotEmpty(request.getTableDetailList())) { + List<EamWeekMaintenanceOrderDetail> addList = new ArrayList<>(); + List<EamWeekMaintenanceOrderDetail> updateList = new ArrayList<>(); + request.getTableDetailList().forEach(tableDetail -> { + tableDetail.setOrderId(entity.getId()); + if(tableDetail.getId() == null){ + addList.add(tableDetail); + }else { + updateList.add(tableDetail); + } + }); + if(CollectionUtil.isNotEmpty(addList)){ + eamWeekMaintenanceOrderDetailService.saveBatch(addList); + } + if(CollectionUtil.isNotEmpty(updateList)){ + eamWeekMaintenanceOrderDetailService.updateBatchById(updateList); + } + } + if(CollectionUtil.isNotEmpty(request.getRemoveDetailList())) { + List<String> ids = request.getRemoveDetailList().stream().map(EamWeekMaintenanceOrderDetail::getId).collect(Collectors.toList()); + eamWeekMaintenanceOrderDetailService.removeBatchByIds(ids); + } + //鍒ゆ柇鏄惁瀛樺湪淇濆吇浜� 濡傛灉瀛樺湪鍒欏惎鍔ㄦ祦绋� + if(StringUtils.isNotBlank(entity.getOperator())) { + //鍚姩娴佺▼ + 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){ + //鏇存柊鍛ㄤ繚鐘舵�� + entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); + entity.setActualStartTime(new Date()); + eamWeekMaintenanceOrderMapper.updateById(entity); + return result.isSuccess(); + } + } + return true; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean collect(String id) { + EamWeekMaintenanceOrder entity = eamWeekMaintenanceOrderMapper.selectById(id); + if(entity == null) { + throw new JeecgBootException("瑕侀鍙栫殑宸ュ崟涓嶅瓨鍦紝璇峰埛鏂伴噸璇曪紒"); + } + if(!WeekMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { + throw new JeecgBootException("璇ュ伐鍗曞凡杩涜杩囬鍙栵紒"); + } + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + entity.setOperator(sysUser.getUsername()); + entity.setMaintenanceStatus(WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name()); + entity.setActualStartTime(new Date()); + 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