diff --git a/ruoyi-admin/src/main/java/com/ruoyi/main.java b/ruoyi-admin/src/main/java/com/ruoyi/main.java index c4303173..6573fde3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/main.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/main.java @@ -1,7 +1,7 @@ package com.ruoyi; import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.manufacture.controller.MaterialRequisitionInfoController; + import java.util.Scanner; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java index 2a094ca6..0d82cc73 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java @@ -168,9 +168,11 @@ public class PurchaseOrderController extends BaseController purchaseOrder.setAuditStatus("0"); purchaseOrder.setUseStatus("0"); purchaseOrder.setDelFlag("0"); - purchaseOrderService.insertPurchaseOrder(purchaseOrder); - purchaseOrderService.addPurchaseOrderPayable(purchaseOrder); + purchaseOrderService.submitApply(purchaseOrder); +// purchaseOrderService.insertPurchaseOrder(purchaseOrder); + +// purchaseOrderService.addPurchaseOrderPayable(purchaseOrder); // 数据校验,确保前端传入数据格式正确 // 执行主表插入操作 return AjaxResult.success(); // 假设toAjax方法处理成功逻辑 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java index 27dd340f..a0bb4549 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java @@ -76,7 +76,6 @@ public interface IPurchaseOrderService Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder); - @Transactional(rollbackFor = Exception.class) ProcessInstance submitApply(PurchaseOrder purchaseOrder); @Transactional(rollbackFor = Exception.class) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java index 0030d17c..ac9a8acc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java @@ -1,11 +1,15 @@ package com.ruoyi.purchase.service.impl; +import com.github.pagehelper.Page; import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.service.ICommonService; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.financial.domain.FinancialAccountsPayable; import com.ruoyi.financial.service.IFinancialAccountsPayableService; @@ -32,7 +36,9 @@ import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper; import com.ruoyi.warehouse.mapper.WarehouseStorageOrderMapper; import lombok.extern.slf4j.Slf4j; import org.activiti.engine.TaskService; +import org.activiti.engine.impl.persistence.entity.TaskEntityImpl; import org.activiti.engine.runtime.ProcessInstance; +import org.activiti.engine.task.Task; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -128,7 +134,58 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService @Override public List selectPurchaseOrderList(PurchaseOrder purchaseOrder) { - return purchaseOrderMapper.selectPurchaseOrderList(purchaseOrder); + PageDomain pageDomain = TableSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + + //PageHelper 仅对第一List分页有效 + Page list = (Page) purchaseOrderMapper.selectPurchaseOrderList(purchaseOrder);; + Page returnList = new Page<>(); + for(PurchaseOrderVo purchaseOrderVo : list){ + SysUser sysUser = userMapper.selectUserByLoginName(purchaseOrderVo.getCreateBy()); + if (sysUser != null) { + purchaseOrderVo.setCreateBy(sysUser.getUserName()); + } + SysUser sysUser2 = userMapper.selectUserByLoginName(purchaseOrderVo.getApplyUser()); + if (sysUser2!=null){ + purchaseOrderVo.setApplyUserName(sysUser2.getUserName()); + } + String instanceId = purchaseOrderVo.getInstanceId(); + // 当前环节 + if (StringUtils.isNotBlank(instanceId)) { + List taskList = taskService.createTaskQuery() + .processInstanceId(instanceId) +// .singleResult(); + .list(); // 例如请假会签,会同时拥有多个任务 + if (!CollectionUtils.isEmpty(taskList)) { + TaskEntityImpl task = (TaskEntityImpl) taskList.get(0); + String taskId = task.getId(); + purchaseOrderVo.setTaskId(taskId); + // 设置待办用户 + List todoUserList = todoItemMapper.selectUndealTodoUserList(taskId); + if(!CollectionUtils.isEmpty(taskList)){ + purchaseOrderVo.setTodoUserId(String.join(",",todoUserList)); + } + if (task.getSuspensionState() == 2) { + purchaseOrderVo.setTaskName("已挂起"); + purchaseOrderVo.setSuspendState("2"); + } else { + purchaseOrderVo.setTaskName(task.getName()); + purchaseOrderVo.setSuspendState("1"); + } + } else { + // 已办结或者已撤销 + purchaseOrderVo.setTaskName("已结束"); + } + } else { + purchaseOrderVo.setTaskName("未启动"); + } + returnList.add(purchaseOrderVo); + } + returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal()); + returnList.setPageNum(pageNum); + returnList.setPageSize(pageSize); + return returnList; } /** @@ -303,8 +360,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService purchaseOrder.setNoRmbSum(materialNoRmbSum); purchaseOrder.setRmbSum(materialRmbSum); purchaseOrder.setDelFlag("0"); - purchaseOrder.setAuditStatus("1"); - purchaseOrder.setUseStatus("1"); purchaseOrder.setEceiptStatus("0"); purchaseOrder.setPaymentStatus("0"); purchaseOrder.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer()); @@ -627,7 +682,15 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService private void buildAuthority(SysUser user, Map variables) { Set roleKeys = roleService.selectRoleKeys(user.getUserId()); // 角色不同审核人不同 - + if(roleKeys.contains("cgyRole")){ + variables.put("authority",1); + }else if(roleKeys.contains("cgjlRole")){ + variables.put("authority",2); + }else if(roleKeys.contains("cgzgRole")){ + variables.put("authority",3); + }else if(roleKeys.contains("fzjlRole")){ + variables.put("authority",4); + } } } diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml index 20c78c11..b623c2f1 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml @@ -71,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" close_case_no, close_case_name, close_case_time,confirm_no,confirm_time,confirm_name, del_flag, stock_no, stock_name, stock_address, stock_contact, stock_phone, approve_time, standby_one, standby_two,create_time, create_by, update_time, update_by, - instance_id, instance_type, instance_type_name, submit_instance_id, cancel_instance_id, + instance_id, instance_type, submit_instance_id, cancel_instance_id, restore_instance_id, apply_title, apply_user, apply_time from purchase_order @@ -171,7 +171,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" apply_title, apply_user, apply_time, - audit_user, del_flag, diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html index df77cf87..255f1018 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html @@ -134,12 +134,15 @@ +