Browse Source

[feat]:物料信息增加流程审批功能

dev
youjianchi 10 months ago
parent
commit
ce4135f51b
  1. 27
      ruoyi-activiti/src/main/java/com/ruoyi/config/ActivitiConfig.java
  2. 31
      ruoyi-activiti/src/main/java/com/ruoyi/process/general/controller/ProcessController.java
  3. 21
      ruoyi-activiti/src/main/java/com/ruoyi/process/general/service/IProcessService.java
  4. 117
      ruoyi-activiti/src/main/java/com/ruoyi/process/general/service/impl/ProcessServiceImpl.java
  5. 61
      ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/domain/BizTodoItem.java
  6. 21
      ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/mapper/BizTodoItemMapper.java
  7. 2
      ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/service/IBizTodoItemService.java
  8. 58
      ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/service/impl/BizTodoItemServiceImpl.java
  9. 32
      ruoyi-activiti/src/main/resources/mapper/process/BizTodoItemMapper.xml
  10. 16
      ruoyi-activiti/src/main/resources/static/js/activiti.js
  11. 4
      ruoyi-activiti/src/main/resources/templates/process/general/historyList.html
  12. 113
      ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java
  13. 49
      ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java
  14. 81
      ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterialVo.java
  15. 7
      ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpMaterialMapper.java
  16. 15
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpMaterialService.java
  17. 145
      ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java
  18. 47
      ruoyi-admin/src/main/resources/mapper/erp/ErpMaterialMapper.xml
  19. 66
      ruoyi-admin/src/main/resources/templates/erp/material/material.html
  20. 292
      ruoyi-admin/src/main/resources/templates/erp/material/taskGcjlVerify.html
  21. 292
      ruoyi-admin/src/main/resources/templates/erp/material/taskGczgVerify.html
  22. 311
      ruoyi-admin/src/main/resources/templates/erp/material/taskModifyApply.html
  23. 292
      ruoyi-admin/src/main/resources/templates/erp/material/taskYfzjVerify.html

27
ruoyi-activiti/src/main/java/com/ruoyi/config/ActivitiConfig.java

@ -0,0 +1,27 @@
package com.ruoyi.config;
import com.ruoyi.common.config.ICustomProcessDiagramGenerator;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ActivitiConfig implements ProcessEngineConfigurationConfigurer {
@Autowired
private ICustomProcessDiagramGenerator customProcessDiagramGenerator;
/**
* 解決工作流生成图片乱码问题
*
* @param processEngineConfiguration
*/
@Override
public void configure(SpringProcessEngineConfiguration processEngineConfiguration) {
processEngineConfiguration.setActivityFontName("宋体");
processEngineConfiguration.setAnnotationFontName("宋体");
processEngineConfiguration.setLabelFontName("宋体");
processEngineConfiguration.setProcessDiagramGenerator(customProcessDiagramGenerator);
}
}

31
ruoyi-activiti/src/main/java/com/ruoyi/process/general/controller/ProcessController.java

@ -4,6 +4,7 @@ package com.ruoyi.process.general.controller;
import com.ruoyi.common.config.ICustomProcessDiagramGenerator; import com.ruoyi.common.config.ICustomProcessDiagramGenerator;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.WorkflowConstants; import com.ruoyi.common.core.domain.WorkflowConstants;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.process.general.domain.HistoricActivity; import com.ruoyi.process.general.domain.HistoricActivity;
import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.general.service.IProcessService;
@ -23,8 +24,8 @@ import org.activiti.engine.repository.ProcessDefinitionQuery;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -60,43 +61,27 @@ public class ProcessController extends BaseController {
/** /**
* 加载审批历史弹窗 * 加载审批历史弹窗
*/ */
/*@GetMapping("/historyList/{instanceId}") @GetMapping("/historyList/{instanceId}")
public String historyList(@PathVariable("instanceId") String instanceId, ModelMap mmap) public String historyList(@PathVariable("instanceId") String instanceId, ModelMap mmap)
{ {
mmap.put("instanceId", instanceId); mmap.put("instanceId", instanceId);
return prefix + "/historyList"; return prefix + "/historyList";
}*/ }
/** /**
* 审批历史列表 * 审批历史列表
* @param instanceId * @param instanceId
* @return * @return
*/ */
/*@RequiresPermissions("process:leave:list") // @RequiresPermissions("process:leave:list")
@PostMapping("/listHistory") @PostMapping("/listHistory")
@ResponseBody @ResponseBody
public TableDataInfo listHistory(String instanceId, HistoricActivity historicActivity) { public TableDataInfo listHistory(String instanceId, HistoricActivity historicActivity) {
startPage(); startPage();
List<HistoricActivity> list = processService.selectHistoryList(instanceId, historicActivity); List<HistoricActivity> list = processService.selectHistoryList(instanceId, historicActivity);
return getDataTable(list); return getDataTable(list);
}*/
@RequestMapping("/listHistory")
@ResponseBody
public Map<String, Object> getContractFormList(HttpServletRequest request) {
String instanceId = request.getParameter("instanceId");
HistoricActivity historicActivity = new HistoricActivity();
//办理人ID
historicActivity.setAssignee(request.getParameter("assignee"));
//任务名称
historicActivity.setActivityName(request.getParameter("activityName"));
List<HistoricActivity> list = processService.selectHistoryList(instanceId, historicActivity);
Map<String, Object> result = new HashMap<String, Object>();
result.put("rows", list);
result.put("total", list.size());
return result;
} }
/** /**
* 获取流程图资源 * 获取流程图资源
* @param pProcessInstanceId * @param pProcessInstanceId
@ -287,10 +272,10 @@ public class ProcessController extends BaseController {
* @param mmap * @param mmap
* @return * @return
*/ */
/*@GetMapping("/processImg/{instanceId}") @GetMapping("/processImg/{instanceId}")
public String processImg(@PathVariable("instanceId") String instanceId, ModelMap mmap) { public String processImg(@PathVariable("instanceId") String instanceId, ModelMap mmap) {
mmap.put("instanceId", instanceId); mmap.put("instanceId", instanceId);
return prefix + "/processImg"; return prefix + "/processImg";
}*/ }
} }

21
ruoyi-activiti/src/main/java/com/ruoyi/process/general/service/IProcessService.java

@ -2,8 +2,11 @@ package com.ruoyi.process.general.service;
import com.ruoyi.process.general.domain.HistoricActivity; import com.ruoyi.process.general.domain.HistoricActivity;
import org.activiti.engine.runtime.ProcessInstance;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map;
public interface IProcessService { public interface IProcessService {
@ -21,4 +24,22 @@ public interface IProcessService {
* @return * @return
*/ */
String selectLastActName(String processInstanceId); String selectLastActName(String processInstanceId);
/**
* 提交申请
* @param applyUserId 申请人
* @param businessKey 业务表 id
* @param key 流程定义 key
* @param variables 流程变量
* @return
*/
ProcessInstance submitApply(String applyUserId, String businessKey, String itemName, String itemConent, String key, Map<String, Object> variables);
void complete(String taskId, String instanceId, String itemName, String itemContent, String module, Map<String, Object> variables, HttpServletRequest request);
/**
* 判断流程是否结束
* @return
*/
boolean judgeProcessIsFinish(String instanceId);
} }

117
ruoyi-activiti/src/main/java/com/ruoyi/process/general/service/impl/ProcessServiceImpl.java

@ -2,28 +2,44 @@ package com.ruoyi.process.general.service.impl;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.process.general.domain.HistoricActivity; import com.ruoyi.process.general.domain.HistoricActivity;
import com.ruoyi.process.general.mapper.ProcessMapper; import com.ruoyi.process.general.mapper.ProcessMapper;
import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.domain.BizTodoItem;
import com.ruoyi.process.todoitem.service.IBizTodoItemService;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import org.activiti.engine.HistoryService; import org.activiti.engine.HistoryService;
import org.activiti.engine.IdentityService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService; import org.activiti.engine.TaskService;
import org.activiti.engine.history.HistoricActivityInstance; import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricActivityInstanceQuery; import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Comment; import org.activiti.engine.task.Comment;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.BooleanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
@Transactional @Transactional
public class ProcessServiceImpl implements IProcessService { public class ProcessServiceImpl implements IProcessService {
protected final Logger logger = LoggerFactory.getLogger(ProcessServiceImpl.class);
@Autowired @Autowired
private TaskService taskService; private TaskService taskService;
@ -36,6 +52,15 @@ public class ProcessServiceImpl implements IProcessService {
private ProcessMapper processMapper; private ProcessMapper processMapper;
@Autowired
private IdentityService identityService;
@Autowired
private IBizTodoItemService bizTodoItemService;
@Autowired
private RuntimeService runtimeService;
@Override @Override
public List<HistoricActivity> selectHistoryList(String processInstanceId, HistoricActivity historicActivity) { public List<HistoricActivity> selectHistoryList(String processInstanceId, HistoricActivity historicActivity) {
List<HistoricActivity> activityList = new ArrayList<>(); List<HistoricActivity> activityList = new ArrayList<>();
@ -82,4 +107,96 @@ public class ProcessServiceImpl implements IProcessService {
return list.get(0).getActivityName(); return list.get(0).getActivityName();
} }
@Override
public ProcessInstance submitApply(String applyUserId, String businessKey, String itemName, String itemConent, String module, Map<String, Object> variables) {
// 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
identityService.setAuthenticatedUserId(applyUserId);
// 启动流程时设置业务 key
ProcessInstance instance = runtimeService.startProcessInstanceByKey(module, businessKey, variables);
// 下一节点处理人待办事项
bizTodoItemService.insertTodoItem(instance.getProcessInstanceId(), itemName, itemConent, module);
return instance;
}
@Override
public void complete(String taskId, String instanceId, String itemName, String itemContent, String module, Map<String, Object> variables, HttpServletRequest request) {
Enumeration<String> parameterNames = request.getParameterNames();
String comment = null; // 批注
boolean agree = true;
try {
while (parameterNames.hasMoreElements()) {
String parameterName = parameterNames.nextElement();
if (parameterName.startsWith("p_")) {
// 参数结构:p_B_name,p为参数的前缀,B为类型,name为属性名称
String[] parameter = parameterName.split("_");
if (parameter.length == 3) {
String paramValue = request.getParameter(parameterName);
Object value = paramValue;
if (parameter[1].equals("B")) {
value = BooleanUtils.toBoolean(paramValue);
agree = (boolean) value;
} else if (parameter[1].equals("DT")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
value = sdf.parse(paramValue);
} else if (parameter[1].equals("COM")) {
comment = paramValue;
}
variables.put(parameter[2], value);
} else {
throw new RuntimeException("invalid parameter for activiti variable: " + parameterName);
}
}
}
if (StringUtils.isNotEmpty(comment)) {
identityService.setAuthenticatedUserId(ShiroUtils.getLoginName());
comment = agree ? "【同意】" + comment : "【拒绝】" + comment;
taskService.addComment(taskId, instanceId, comment);
}
// 被委派人处理完成任务
// p.s. 被委托的流程需要先 resolved 这个任务再提交。
// 所以在 complete 之前需要先 resolved
// resolveTask() 要在 claim() 之前,不然 act_hi_taskinst 表的 assignee 字段会为 null
taskService.resolveTask(taskId, variables);
// 只有签收任务,act_hi_taskinst 表的 assignee 字段才不为 null
taskService.claim(taskId, ShiroUtils.getLoginName());
taskService.complete(taskId, variables);
// 更新待办事项状态
BizTodoItem query = new BizTodoItem();
query.setTaskId(taskId);
// 考虑到候选用户组(或签,多个待办只要一人审批通过就行),会有多个 todoitem 办理同个 task
List<BizTodoItem> updateList = CollectionUtils.isEmpty(bizTodoItemService.selectBizTodoItemList(query)) ? null : bizTodoItemService.selectBizTodoItemList(query);
for (BizTodoItem update: updateList) {
// 找到当前登录用户的 todoitem,置为已办
if (update.getTodoUserId().equals(ShiroUtils.getLoginName())) {
update.setIsView("1");
update.setIsHandle("1");
update.setHandleUserId(ShiroUtils.getLoginName());
update.setHandleUserName(ShiroUtils.getSysUser().getUserName());
update.setHandleTime(DateUtils.getNowDate());
bizTodoItemService.updateBizTodoItem(update);
} else {
bizTodoItemService.deleteBizTodoItemById(update.getId()); // 删除候选用户组其他 todoitem
}
}
// 下一节点处理人待办事项
bizTodoItemService.insertTodoItem(instanceId, itemName, itemContent, module);
} catch (Exception e) {
logger.error("error on complete task {}, variables={}", new Object[]{taskId, variables, e});
}
}
@Override
public boolean judgeProcessIsFinish(String instanceId) {
boolean result = false;
List<Task> taskList = taskService.createTaskQuery()
.processInstanceId(instanceId)
.list();
if (CollectionUtils.isEmpty(taskList)) {
result = true;
}
return result;
}
} }

61
ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/domain/BizTodoItem.java

@ -1,18 +1,19 @@
package com.ruoyi.process.todoitem.domain; package com.ruoyi.process.todoitem.domain;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date; import java.util.Date;
/** /**
* 待办已办biz_todo_item * 待办事项对象 biz_todo_item
* *
* @author Xianlu Tech * @author Xianlu Tech
* @date 2019-11-08 * @date 2019-11-08
*/ */
public class BizTodoItem{ public class BizTodoItem extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键 ID */ /** 主键 ID */
@ -26,7 +27,7 @@ public class BizTodoItem{
@Excel(name = "事项内容") @Excel(name = "事项内容")
private String itemContent; private String itemContent;
/** 模块名称ID (必须以 uri 一致) */ /** 模块名称 (必须以 uri 一致) */
@Excel(name = "模块名称") @Excel(name = "模块名称")
private String module; private String module;
@ -78,15 +79,6 @@ public class BizTodoItem{
@Excel(name = "处理时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "处理时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date handleTime; private Date handleTime;
/** 模块名称 */
private String moduleName;
/** 模块地址 */
private String moduleUrl;
/** 工程名称 */
private String projectName;
private String keyNo;
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
@ -115,18 +107,7 @@ public class BizTodoItem{
public String getModule() { public String getModule() {
return module; return module;
} }
public void setTaskId(String taskId) {
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
public void setTaskId(String taskId) {
this.taskId = taskId; this.taskId = taskId;
} }
@ -213,43 +194,13 @@ public class BizTodoItem{
this.instanceId = instanceId; this.instanceId = instanceId;
} }
@Override
public String getModuleUrl() {
return moduleUrl;
}
public void setModuleUrl(String moduleUrl) {
this.moduleUrl = moduleUrl;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getKeyNo() {
return keyNo;
}
public void setKeyNo(String keyNo) {
this.keyNo = keyNo;
}
@Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("itemName", getItemName()) .append("itemName", getItemName())
.append("itemContent", getItemContent()) .append("itemContent", getItemContent())
.append("module", getModule()) .append("module", getModule())
.append("moduleName", getModuleName())
.append("moduleUrl", getModuleUrl())
.append("keyNo", getKeyNo())
.append("instanceId", getInstanceId()) .append("instanceId", getInstanceId())
.append("taskId", getTaskId()) .append("taskId", getTaskId())
.append("taskName", getTaskName()) .append("taskName", getTaskName())

21
ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/mapper/BizTodoItemMapper.java

@ -2,6 +2,7 @@ package com.ruoyi.process.todoitem.mapper;
import com.ruoyi.process.todoitem.domain.BizTodoItem; import com.ruoyi.process.todoitem.domain.BizTodoItem;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -61,9 +62,6 @@ public interface BizTodoItemMapper {
*/ */
public int deleteBizTodoItemByIds(String[] ids); public int deleteBizTodoItemByIds(String[] ids);
//@Select("select * from biz_todo_item where task_id = #{taskId}")
//BizTodoItem selectTodoItemByTaskId(@Param(value = "taskId")String taskId);
public List<BizTodoItem> getTodoItemList(Map<String, Object> paraMap); public List<BizTodoItem> getTodoItemList(Map<String, Object> paraMap);
public long getTodoItemTotal(Map<String, Object> paraMap); public long getTodoItemTotal(Map<String, Object> paraMap);
public String getCurrentFlowUser(Map<String, Object> paraMap); public String getCurrentFlowUser(Map<String, Object> paraMap);
@ -72,4 +70,21 @@ public interface BizTodoItemMapper {
public String selectTodoItemTaskId(@Param(value = "instanceId")String instanceId,@Param(value = "todoUserId")String todoUserId,@Param(value = "isHandle")String isHandle); public String selectTodoItemTaskId(@Param(value = "instanceId")String instanceId,@Param(value = "todoUserId")String todoUserId,@Param(value = "isHandle")String isHandle);
public List<BizTodoItem> getTodoItemListNoPaging(Map<String, Object> paraMap); public List<BizTodoItem> getTodoItemListNoPaging(Map<String, Object> paraMap);
@Select("SELECT USER_ID_ FROM ACT_ID_MEMBERSHIP WHERE GROUP_ID_ = (SELECT GROUP_ID_ FROM ACT_RU_IDENTITYLINK WHERE TASK_ID_ = #{taskId})")
List<String> selectTodoUserListByTaskId(@Param(value = "taskId") String taskId);
@Select("SELECT * FROM BIZ_TODO_ITEM WHERE TASK_ID = #{taskId} AND TODO_USER_ID = #{todoUserId}")
BizTodoItem selectTodoItemByCondition(@Param(value = "taskId") String taskId, @Param(value = "todoUserId") String todoUserId);
@Select("SELECT USER_ID_ FROM ACT_ID_MEMBERSHIP WHERE USER_ID_ = (SELECT USER_ID_ FROM ACT_RU_IDENTITYLINK WHERE TASK_ID_ = #{taskId})")
String selectTodoUserByTaskId(String id);
/**
* 任务未处理的用户id集合
* @param taskId
* @return
*/
@Select("SELECT todo_user_id FROM BIZ_TODO_ITEM WHERE TASK_ID = #{taskId} and is_handle = '0'")
List<String> selectUndealTodoUserList(@Param(value = "taskId") String taskId);
} }

2
ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/service/IBizTodoItemService.java

@ -71,4 +71,6 @@ public interface IBizTodoItemService {
public String selectTodoItemTaskId(String instanceId,String todoUserId,String isHandle); public String selectTodoItemTaskId(String instanceId,String todoUserId,String isHandle);
public List<BizTodoItem> getTodoItemListNoPaging(Map<String, Object> paraMap); public List<BizTodoItem> getTodoItemListNoPaging(Map<String, Object> paraMap);
int insertTodoItem(String instanceId, String itemName, String itemContent, String module);
} }

58
ruoyi-activiti/src/main/java/com/ruoyi/process/todoitem/service/impl/BizTodoItemServiceImpl.java

@ -16,6 +16,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -149,6 +150,63 @@ public class BizTodoItemServiceImpl implements IBizTodoItemService {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return bizTodoItemMapper.getTodoItemListNoPaging(paraMap); return bizTodoItemMapper.getTodoItemListNoPaging(paraMap);
} }
@Override
public int insertTodoItem(String instanceId, String itemName, String itemContent, String module) {
BizTodoItem todoItem = new BizTodoItem();
todoItem.setItemName(itemName);
todoItem.setItemContent(itemContent);
todoItem.setIsView("0");
todoItem.setIsHandle("0");
todoItem.setModule(module);
todoItem.setTodoTime(DateUtils.getNowDate());
List<Task> taskList = taskService.createTaskQuery().processInstanceId(instanceId).active().list();
int counter = 0;
for (Task task: taskList) {
// todoitem 去重
BizTodoItem bizTodoItem = bizTodoItemMapper.selectTodoItemByTaskId(task.getId(),null);
if (bizTodoItem != null) continue;
BizTodoItem newItem = new BizTodoItem();
BeanUtils.copyProperties(todoItem, newItem);
newItem.setInstanceId(instanceId);
newItem.setTaskId(task.getId());
newItem.setTaskName("task" + task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1));
newItem.setNodeName(task.getName());
String assignee = task.getAssignee();
// 代理人
if (StringUtils.isNotBlank(assignee)) {
newItem.setTodoUserId(assignee);
SysUser user = userMapper.selectUserByLoginName(assignee);
newItem.setTodoUserName(user.getUserName());
bizTodoItemMapper.insertBizTodoItem(newItem);
counter++;
} else {
// 查询候选用户组,系统用户角色视图,group是角色
List<String> todoUserIdList = bizTodoItemMapper.selectTodoUserListByTaskId(task.getId());
if (!CollectionUtils.isEmpty(todoUserIdList)) {
for (String todoUserId: todoUserIdList) {
SysUser todoUser = userMapper.selectUserByLoginName(todoUserId);
newItem.setTodoUserId(todoUser.getLoginName());
newItem.setTodoUserName(todoUser.getUserName());
bizTodoItemMapper.insertBizTodoItem(newItem);
counter++;
}
} else {
// 查询候选用户,用户id匹配的上
String todoUserId = bizTodoItemMapper.selectTodoUserByTaskId(task.getId());
SysUser todoUser = userMapper.selectUserByLoginName(todoUserId);
newItem.setTodoUserId(todoUser.getLoginName());
newItem.setTodoUserName(todoUser.getUserName());
bizTodoItemMapper.insertBizTodoItem(newItem);
counter++;
}
}
}
return counter;
}
@Override @Override
public int insertTodoItem(String instanceId, BizLeaveVo leave, String module) { public int insertTodoItem(String instanceId, BizLeaveVo leave, String module) {
BizTodoItem todoItem = new BizTodoItem(); BizTodoItem todoItem = new BizTodoItem();

32
ruoyi-activiti/src/main/resources/mapper/process/BizTodoItemMapper.xml

@ -9,7 +9,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="itemName" column="item_name" /> <result property="itemName" column="item_name" />
<result property="itemContent" column="item_content" /> <result property="itemContent" column="item_content" />
<result property="module" column="module" /> <result property="module" column="module" />
<result property="moduleName" column="modulename" />
<result property="instanceId" column="instance_id" /> <result property="instanceId" column="instance_id" />
<result property="taskId" column="task_id" /> <result property="taskId" column="task_id" />
<result property="taskName" column="task_name" /> <result property="taskName" column="task_name" />
@ -22,13 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="handleUserName" column="handle_user_name" /> <result property="handleUserName" column="handle_user_name" />
<result property="todoTime" column="todo_time" /> <result property="todoTime" column="todo_time" />
<result property="handleTime" column="handle_time" /> <result property="handleTime" column="handle_time" />
<result property="moduleUrl" column="moduleUrl" />
<result property="keyNo" column="keyNo" />
<result property="projectName" column="projectName" />
</resultMap> </resultMap>
<sql id="selectBizTodoItemVo"> <sql id="selectBizTodoItemVo">
select id, item_name, item_content, module,modulename,instance_id,task_id, task_name, node_name, is_view, is_handle, todo_user_id, todo_user_name, handle_user_id, handle_user_name, todo_time, handle_time from biz_todo_item select id, item_name, item_content, module, instance_id, task_id, task_name, node_name, is_view, is_handle, todo_user_id, todo_user_name, handle_user_id, handle_user_name, todo_time, handle_time from biz_todo_item
</sql> </sql>
<select id="selectBizTodoItemList" parameterType="BizTodoItem" resultMap="BizTodoItemResult"> <select id="selectBizTodoItemList" parameterType="BizTodoItem" resultMap="BizTodoItemResult">
@ -37,8 +33,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="itemName != null and itemName != ''"> and item_name like concat('%', #{itemName}, '%')</if> <if test="itemName != null and itemName != ''"> and item_name like concat('%', #{itemName}, '%')</if>
<if test="itemContent != null and itemContent != ''"> and item_content = #{itemContent}</if> <if test="itemContent != null and itemContent != ''"> and item_content = #{itemContent}</if>
<if test="module != null and module != ''"> and module = #{module}</if> <if test="module != null and module != ''"> and module = #{module}</if>
<if test="moduleName != null and moduleName != ''"> and moduleName = #{moduleName}</if>
<if test="projectName != null and projectName != ''"> and projectName = #{projectName}</if>
<if test="instanceId != null and instanceId != ''"> and instance_id = #{instanceId}</if> <if test="instanceId != null and instanceId != ''"> and instance_id = #{instanceId}</if>
<if test="taskId != null and taskId != ''"> and task_id = #{taskId}</if> <if test="taskId != null and taskId != ''"> and task_id = #{taskId}</if>
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if> <if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
@ -51,16 +45,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="handleUserName != null and handleUserName != ''"> and handle_user_name like concat('%', #{handleUserName}, '%')</if> <if test="handleUserName != null and handleUserName != ''"> and handle_user_name like concat('%', #{handleUserName}, '%')</if>
<if test="todoTime != null "> and todo_time = #{todoTime}</if> <if test="todoTime != null "> and todo_time = #{todoTime}</if>
<if test="handleTime != null "> and handle_time = #{handleTime}</if> <if test="handleTime != null "> and handle_time = #{handleTime}</if>
<if test="params.todoItemStartTime != null and params.todoItemStartTime != ''">开始时间检索 <if test="params.todoItemStartTime != null and params.todoItemStartTime != ''"><!-- 开始时间检索 -->
and date_format(todo_time,'%y%m%d') &gt;= date_format(#{params.todoItemStartTime},'%y%m%d') and date_format(todo_time,'%y%m%d') &gt;= date_format(#{params.todoItemStartTime},'%y%m%d')
</if> </if>
<if test="params.todoItemEndTime != null and params.todoItemEndTime != ''">结束时间检索 <if test="params.todoItemEndTime != null and params.todoItemEndTime != ''"><!-- 结束时间检索 -->
and date_format(todo_time,'%y%m%d') &lt;= date_format(#{params.todoItemEndTime},'%y%m%d') and date_format(todo_time,'%y%m%d') &lt;= date_format(#{params.todoItemEndTime},'%y%m%d')
</if> </if>
<if test="params.handleStartTime != null and params.handleStartTime != ''">开始时间检索 <if test="params.handleStartTime != null and params.handleStartTime != ''"><!-- 开始时间检索 -->
and date_format(handle_time,'%y%m%d') &gt;= date_format(#{params.handleStartTime},'%y%m%d') and date_format(handle_time,'%y%m%d') &gt;= date_format(#{params.handleStartTime},'%y%m%d')
</if> </if>
<if test="params.handleEndTime != null and params.handleEndTime != ''">结束时间检索 <if test="params.handleEndTime != null and params.handleEndTime != ''"><!-- 结束时间检索 -->
and date_format(handle_time,'%y%m%d') &lt;= date_format(#{params.handleEndTime},'%y%m%d') and date_format(handle_time,'%y%m%d') &lt;= date_format(#{params.handleEndTime},'%y%m%d')
</if> </if>
order by todo_time desc order by todo_time desc
@ -192,10 +186,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="itemName != null and itemName != ''">item_name,</if> <if test="itemName != null and itemName != ''">item_name,</if>
<if test="itemContent != null and itemContent != ''">item_content,</if> <if test="itemContent != null and itemContent != ''">item_content,</if>
<if test="module != null and module != ''">module,</if> <if test="module != null and module != ''">module,</if>
<if test="moduleName != null and moduleName != ''">modulename,</if>
<if test="moduleUrl != null and moduleUrl != ''">moduleUrl,</if>
<if test="projectName != null and projectName != ''">projectName,</if>
<if test="keyNo != null and keyNo != ''">keyNo,</if>
<if test="instanceId != null and instanceId != ''">instance_id,</if> <if test="instanceId != null and instanceId != ''">instance_id,</if>
<if test="taskId != null and taskId != ''">task_id,</if> <if test="taskId != null and taskId != ''">task_id,</if>
<if test="taskName != null and taskName != ''">task_name,</if> <if test="taskName != null and taskName != ''">task_name,</if>
@ -213,10 +203,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="itemName != null and itemName != ''">#{itemName},</if> <if test="itemName != null and itemName != ''">#{itemName},</if>
<if test="itemContent != null and itemContent != ''">#{itemContent},</if> <if test="itemContent != null and itemContent != ''">#{itemContent},</if>
<if test="module != null and module != ''">#{module},</if> <if test="module != null and module != ''">#{module},</if>
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
<if test="moduleUrl != null and moduleUrl != ''">#{moduleUrl},</if>
<if test="projectName != null and projectName != ''">#{projectName},</if>
<if test="keyNo != null and keyNo != ''">#{keyNo},</if>
<if test="instanceId != null and instanceId != ''">#{instanceId},</if> <if test="instanceId != null and instanceId != ''">#{instanceId},</if>
<if test="taskId != null and taskId != ''">#{taskId},</if> <if test="taskId != null and taskId != ''">#{taskId},</if>
<if test="taskName != null and taskName != ''">#{taskName},</if> <if test="taskName != null and taskName != ''">#{taskName},</if>
@ -238,10 +224,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="itemName != null and itemName != ''">item_name = #{itemName},</if> <if test="itemName != null and itemName != ''">item_name = #{itemName},</if>
<if test="itemContent != null and itemContent != ''">item_content = #{itemContent},</if> <if test="itemContent != null and itemContent != ''">item_content = #{itemContent},</if>
<if test="module != null and module != ''">module = #{module},</if> <if test="module != null and module != ''">module = #{module},</if>
<if test="moduleName != null and moduleName != ''">modulename = #{moduleName},</if>
<if test="moduleUrl != null and moduleUrl != ''">moduleUrl = #{moduleUrl},</if>
<if test="projectName != null and projectName != ''">projectName = #{projectName},</if>
<if test="keyNo != null and keyNo != ''">keyNo = #{keyNo},</if>
<if test="instanceId != null and instanceId != ''">instance_id = #{instanceId},</if> <if test="instanceId != null and instanceId != ''">instance_id = #{instanceId},</if>
<if test="taskId != null and taskId != ''">task_id = #{taskId},</if> <if test="taskId != null and taskId != ''">task_id = #{taskId},</if>
<if test="taskName != null and taskName != ''">task_name = #{taskName},</if> <if test="taskName != null and taskName != ''">task_name = #{taskName},</if>
@ -270,7 +252,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<select id="selectTodoItemByTaskId" resultMap="BizTodoItemResult"> <select id="selectTodoItemByTaskId" resultMap="BizTodoItemResult">
select * from biz_todo_item where task_id = #{taskId} and is_handle = #{isHandle} select * from biz_todo_item
where task_id = #{taskId}
<if test="isHandle != null and isHandle != ''"> and is_handle = #{isHandle}</if>
</select> </select>
<!-- 查询当前节点用户 --> <!-- 查询当前节点用户 -->

16
ruoyi-activiti/src/main/resources/static/js/activiti.js

@ -28,12 +28,12 @@ function formatTotalDateSub (secondSub) {
/* 查看审批历史 */ /* 查看审批历史 */
function showHistoryDialog(instanceId) { function showHistoryDialog(instanceId) {
var url = ctx + 'process/historyList/' + instanceId; var url = ctx + 'process/general/historyList/' + instanceId;
$.modal.open("查看审批历史", url, null, null, null, true); $.modal.open("查看审批历史", url, null, null, null, true);
} }
function showProcessImgDialog(instanceId) { function showProcessImgDialog(instanceId) {
var url = ctx + 'process/processImg/' + instanceId; var url = ctx + 'process/general/processImg/' + instanceId;
$.modal.open("查看流程图", url, null, null, null, true); $.modal.open("查看流程图", url, null, null, null, true);
} }
@ -47,3 +47,15 @@ function showFormDialog(instanceId, module) {
var url = ctx + module + "/showFormDialog/" + instanceId; var url = ctx + module + "/showFormDialog/" + instanceId;
$.modal.open('申请详情', url, null, null, null, true); $.modal.open('申请详情', url, null, null, null, true);
} }
/**
* 审批弹出框
* @param prefix
* @param taskId
* @param taskName
*/
function showVerifyDialog(prefix,taskId,taskName){
var url = prefix + "/showVerifyDialog/" + taskId;
$.modal.open(taskName, url);
}

4
ruoyi-activiti/src/main/resources/templates/process/general/historyList.html

@ -33,6 +33,7 @@
</div> </div>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "process/general"; var prefix = ctx + "process/general";
@ -49,6 +50,7 @@
showColumns: false, showColumns: false,
clickToSelect: false, clickToSelect: false,
rememberSelected: false, rememberSelected: false,
pagination: false,
columns: [{ columns: [{
field: 'activityId', field: 'activityId',
title: '活动ID', title: '活动ID',
@ -84,7 +86,7 @@
title: '耗时', title: '耗时',
formatter: function(value, row, index) { formatter: function(value, row, index) {
if (!value) return '未知'; if (!value) return '未知';
return $.common.formatTotalDateSub(value / 1000); return formatTotalDateSub(value / 1000);
} }
}] }]
}; };

113
ruoyi-admin/src/main/java/com/ruoyi/erp/controller/ErpMaterialController.java

@ -3,21 +3,37 @@ package com.ruoyi.erp.controller;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.erp.domain.ErpMaterial; import com.ruoyi.erp.domain.ErpMaterial;
import com.ruoyi.erp.domain.ErpMaterialVo;
import com.ruoyi.erp.mapper.ErpMaterialMapper;
import com.ruoyi.erp.service.IErpMaterialService; import com.ruoyi.erp.service.IErpMaterialService;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.system.domain.SysErpMaterialProductItem; import com.ruoyi.system.domain.SysErpMaterialProductItem;
import com.ruoyi.system.service.ISysErpMaterialProductItemService; import com.ruoyi.system.service.ISysErpMaterialProductItemService;
import com.ruoyi.system.service.ISysProductItemService; import com.ruoyi.system.service.ISysProductItemService;
import com.ruoyi.system.service.ISysRoleService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* 物料信息Controller * 物料信息Controller
@ -39,10 +55,26 @@ public class ErpMaterialController extends BaseController
@Autowired @Autowired
private ISysErpMaterialProductItemService erpMaterialProductItemService; private ISysErpMaterialProductItemService erpMaterialProductItemService;
@Autowired
private ISysRoleService roleService;
@Autowired
private TaskService taskService;
@Autowired
private RuntimeService runtimeService;
@Autowired
private IProcessService processService;
@Autowired
private ErpMaterialMapper erpMaterialMapper;
@RequiresPermissions("erp:material:view") @RequiresPermissions("erp:material:view")
@GetMapping() @GetMapping()
public String material() public String material(ModelMap mmap)
{ {
mmap.put("currentUser", ShiroUtils.getSysUser());
return prefix + "/material"; return prefix + "/material";
} }
@ -52,10 +84,17 @@ public class ErpMaterialController extends BaseController
@RequiresPermissions("erp:material:list") @RequiresPermissions("erp:material:list")
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public TableDataInfo list(ErpMaterial erpMaterial) public TableDataInfo list(ErpMaterialVo erpMaterialVo)
{ {
SysUser curUser = ShiroUtils.getSysUser();
Long userId = curUser.getUserId();
Set<String> roleKeys = roleService.selectRoleKeys(userId);
// 工程文员角色只能看到自己创建的数据
if(roleKeys.contains("gcwyRole")){
erpMaterialVo.setCreateBy(curUser.getLoginName());
}
startPage(); startPage();
List<ErpMaterial> list = erpMaterialService.selectErpMaterialList(erpMaterial); List<ErpMaterialVo> list = erpMaterialService.selectErpMaterialList(erpMaterialVo);
return getDataTable(list); return getDataTable(list);
} }
@ -66,10 +105,10 @@ public class ErpMaterialController extends BaseController
@Log(title = "物料信息", businessType = BusinessType.EXPORT) @Log(title = "物料信息", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public AjaxResult export(ErpMaterial erpMaterial) public AjaxResult export(ErpMaterialVo erpMaterialVo)
{ {
List<ErpMaterial> list = erpMaterialService.selectErpMaterialList(erpMaterial); List<ErpMaterialVo> list = erpMaterialService.selectErpMaterialList(erpMaterialVo);
ExcelUtil<ErpMaterial> util = new ExcelUtil<ErpMaterial>(ErpMaterial.class); ExcelUtil<ErpMaterialVo> util = new ExcelUtil<ErpMaterialVo>(ErpMaterialVo.class);
return util.exportExcel(list, "物料信息数据"); return util.exportExcel(list, "物料信息数据");
} }
@ -83,7 +122,7 @@ public class ErpMaterialController extends BaseController
} }
/** /**
* 新增保存物料信息 * 新增并提交物料信息
*/ */
@RequiresPermissions("erp:material:add") @RequiresPermissions("erp:material:add")
@Log(title = "物料信息", businessType = BusinessType.INSERT) @Log(title = "物料信息", businessType = BusinessType.INSERT)
@ -91,7 +130,65 @@ public class ErpMaterialController extends BaseController
@ResponseBody @ResponseBody
public AjaxResult addSave(ErpMaterial erpMaterial) public AjaxResult addSave(ErpMaterial erpMaterial)
{ {
return toAjax(erpMaterialService.insertErpMaterial(erpMaterial)); erpMaterial.setUseStatus("0");
erpMaterial.setAuditStatus("0");
erpMaterialService.submitApply(erpMaterial);
return AjaxResult.success();
}
/**
* 加载审批弹窗
* @param taskId
* @param mmap
* @return
*/
@GetMapping("/showVerifyDialog/{taskId}")
public String showVerifyDialog(@PathVariable("taskId") String taskId, ModelMap mmap) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String processInstanceId = task.getProcessInstanceId();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
ErpMaterialVo erpMaterialVo = erpMaterialService.selectErpMaterialById(new Long(processInstance.getBusinessKey()));
mmap.put("formData", erpMaterialVo);
mmap.put("taskId", taskId);
String verifyName = task.getTaskDefinitionKey().substring(0, 1).toUpperCase() + task.getTaskDefinitionKey().substring(1);
return prefix + "/task" + verifyName;
}
/**
* 完成任务
*
* @return
*/
@RequestMapping(value = "/complete/{taskId}", method = {RequestMethod.POST, RequestMethod.GET})
@ResponseBody
public AjaxResult complete(@PathVariable("taskId") String taskId, @RequestParam(value = "saveEntity", required = false) String saveEntity,
@ModelAttribute("preloadObj") ErpMaterialVo erpMaterialVo, HttpServletRequest request) {
boolean saveEntityBoolean = BooleanUtils.toBoolean(saveEntity);
String instanceId = erpMaterialVo.getInstanceId();
processService.complete(taskId, instanceId, erpMaterialVo.getApplyTitle(), erpMaterialVo.getMaterialNo(), "material", new HashMap<String, Object>(), request);
// 如果任务已结束更新业务表状态
boolean processIsFinish = processService.judgeProcessIsFinish(instanceId);
if (processIsFinish) {
// 审核完成
erpMaterialVo.setAuditStatus("1");
erpMaterialMapper.updateErpMaterial(erpMaterialVo);
}
// 驳回申请后继续申请,可能修改表单
if (saveEntityBoolean) {
erpMaterialService.updateErpMaterial(erpMaterialVo);
}
return success("任务已完成");
}
/**
* 自动绑定页面字段
*/
@ModelAttribute("preloadObj")
public ErpMaterialVo getObj(@RequestParam(value = "id", required = false) Long id, HttpSession session) {
if (id != null) {
return erpMaterialService.selectErpMaterialById(id);
}
return new ErpMaterialVo();
} }
/** /**

49
ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterial.java

@ -6,6 +6,7 @@ import com.ruoyi.system.domain.SysProductItem;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -74,6 +75,22 @@ public class ErpMaterial extends BaseEntity
@Excel(name = "入库部门") @Excel(name = "入库部门")
private String warehouseDept; private String warehouseDept;
/** 流程实例ID */
@Excel(name = "流程实例ID")
private String instanceId;
/** 申请人 */
@Excel(name = "申请标题")
private String applyTitle;
/** 申请人 */
@Excel(name = "申请人")
private String applyUser;
/** 申请时间 */
@Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date applyTime;
private Long photoAttachId; private Long photoAttachId;
private String photoUrl; private String photoUrl;
@ -265,6 +282,38 @@ public class ErpMaterial extends BaseEntity
this.itemName = itemName; this.itemName = itemName;
} }
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
public String getApplyTitle() {
return applyTitle;
}
public void setApplyTitle(String applyTitle) {
this.applyTitle = applyTitle;
}
public String getApplyUser() {
return applyUser;
}
public void setApplyUser(String applyUser) {
this.applyUser = applyUser;
}
public Date getApplyTime() {
return applyTime;
}
public void setApplyTime(Date applyTime) {
this.applyTime = applyTime;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

81
ruoyi-admin/src/main/java/com/ruoyi/erp/domain/ErpMaterialVo.java

@ -0,0 +1,81 @@
package com.ruoyi.erp.domain;
import java.util.Date;
/**
* @Description 物料信息Vo
* @Author youjianchi
* @Date 2024/02/10 13:51
*/
public class ErpMaterialVo extends ErpMaterial {
/** 申请人姓名 */
private String applyUserName;
/** 任务ID */
private String taskId;
/** 任务名称 */
private String taskName;
/** 办理时间 */
private Date doneTime;
/** 创建人 */
private String createUserName;
/** 流程实例状态 1 激活 2 挂起 */
private String suspendState;
/** 待办用户id */
private String todoUserId;
public String getApplyUserName() {
return applyUserName;
}
public void setApplyUserName(String applyUserName) {
this.applyUserName = applyUserName;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public Date getDoneTime() {
return doneTime;
}
public void setDoneTime(Date doneTime) {
this.doneTime = doneTime;
}
public String getCreateUserName() {
return createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public String getSuspendState() {
return suspendState;
}
public void setSuspendState(String suspendState) {
this.suspendState = suspendState;
}
public String getTodoUserId() {
return todoUserId;
}
public void setTodoUserId(String todoUserId) {
this.todoUserId = todoUserId;
}
}

7
ruoyi-admin/src/main/java/com/ruoyi/erp/mapper/ErpMaterialMapper.java

@ -1,6 +1,7 @@
package com.ruoyi.erp.mapper; package com.ruoyi.erp.mapper;
import com.ruoyi.erp.domain.ErpMaterial; import com.ruoyi.erp.domain.ErpMaterial;
import com.ruoyi.erp.domain.ErpMaterialVo;
import java.util.List; import java.util.List;
@ -18,15 +19,15 @@ public interface ErpMaterialMapper
* @param id 物料信息ID * @param id 物料信息ID
* @return 物料信息 * @return 物料信息
*/ */
public ErpMaterial selectErpMaterialById(Long id); public ErpMaterialVo selectErpMaterialById(Long id);
/** /**
* 查询物料信息列表 * 查询物料信息列表
* *
* @param erpMaterial 物料信息 * @param erpMaterialVo 物料信息
* @return 物料信息集合 * @return 物料信息集合
*/ */
public List<ErpMaterial> selectErpMaterialList(ErpMaterial erpMaterial); public List<ErpMaterialVo> selectErpMaterialList(ErpMaterialVo erpMaterialVo);
/** /**
* 新增物料信息 * 新增物料信息

15
ruoyi-admin/src/main/java/com/ruoyi/erp/service/IErpMaterialService.java

@ -1,6 +1,8 @@
package com.ruoyi.erp.service; package com.ruoyi.erp.service;
import com.ruoyi.erp.domain.ErpMaterial; import com.ruoyi.erp.domain.ErpMaterial;
import com.ruoyi.erp.domain.ErpMaterialVo;
import org.activiti.engine.runtime.ProcessInstance;
import java.util.List; import java.util.List;
@ -18,15 +20,15 @@ public interface IErpMaterialService
* @param id 物料信息ID * @param id 物料信息ID
* @return 物料信息 * @return 物料信息
*/ */
public ErpMaterial selectErpMaterialById(Long id); public ErpMaterialVo selectErpMaterialById(Long id);
/** /**
* 查询物料信息列表 * 查询物料信息列表
* *
* @param erpMaterial 物料信息 * @param erpMaterialVo 物料信息
* @return 物料信息集合 * @return 物料信息集合
*/ */
public List<ErpMaterial> selectErpMaterialList(ErpMaterial erpMaterial); public List<ErpMaterialVo> selectErpMaterialList(ErpMaterialVo erpMaterialVo);
/** /**
* 新增物料信息 * 新增物料信息
@ -89,4 +91,11 @@ public interface IErpMaterialService
* 修改物料的关联bom * 修改物料的关联bom
*/ */
public int updateMaterialBomNo( ErpMaterial erpMaterial); public int updateMaterialBomNo( ErpMaterial erpMaterial);
/**
* 提交申请
* @param erpMaterial
* @return
*/
ProcessInstance submitApply(ErpMaterial erpMaterial);
} }

145
ruoyi-admin/src/main/java/com/ruoyi/erp/service/impl/ErpMaterialServiceImpl.java

@ -1,22 +1,34 @@
package com.ruoyi.erp.service.impl; package com.ruoyi.erp.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.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.service.ICommonService; import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.erp.domain.ErpMaterial; import com.ruoyi.erp.domain.ErpMaterial;
import com.ruoyi.erp.domain.ErpMaterialVo;
import com.ruoyi.erp.mapper.ErpMaterialMapper; import com.ruoyi.erp.mapper.ErpMaterialMapper;
import com.ruoyi.erp.service.IErpMaterialService; import com.ruoyi.erp.service.IErpMaterialService;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.system.domain.SysAttach; import com.ruoyi.system.domain.SysAttach;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysAttachFileService; import com.ruoyi.system.service.ISysAttachFileService;
import com.ruoyi.system.service.ISysAttachService; import com.ruoyi.system.service.ISysAttachService;
import com.ruoyi.system.service.ISysRoleService;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Arrays; import java.util.*;
import java.util.Date;
import java.util.List;
/** /**
* 物料信息Service业务层处理 * 物料信息Service业务层处理
@ -39,6 +51,21 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
@Autowired @Autowired
private ICommonService commonService; private ICommonService commonService;
@Autowired
private SysUserMapper userMapper;
@Autowired
private TaskService taskService;
@Autowired
private BizTodoItemMapper todoItemMapper;
@Autowired
private IProcessService processService;
@Autowired
private ISysRoleService roleService;
/** /**
* 查询物料信息 * 查询物料信息
* *
@ -46,21 +73,77 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
* @return 物料信息 * @return 物料信息
*/ */
@Override @Override
public ErpMaterial selectErpMaterialById(Long id) public ErpMaterialVo selectErpMaterialById(Long id)
{ {
return erpMaterialMapper.selectErpMaterialById(id); ErpMaterialVo erpMaterialVo = erpMaterialMapper.selectErpMaterialById(id);
SysUser sysUser = userMapper.selectUserByLoginName(erpMaterialVo.getApplyUser());
if (sysUser != null) {
erpMaterialVo.setApplyUserName(sysUser.getUserName());
}
return erpMaterialVo;
} }
/** /**
* 查询物料信息列表 * 查询物料信息列表
* *
* @param erpMaterial 物料信息 * @param erpMaterialVo 物料信息
* @return 物料信息 * @return 物料信息
*/ */
@Override @Override
public List<ErpMaterial> selectErpMaterialList(ErpMaterial erpMaterial) public List<ErpMaterialVo> selectErpMaterialList(ErpMaterialVo erpMaterialVo)
{ {
return erpMaterialMapper.selectErpMaterialList(erpMaterial); PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
// PageHelper 仅对第一个 List 分页
Page<ErpMaterialVo> list = (Page<ErpMaterialVo>) erpMaterialMapper.selectErpMaterialList(erpMaterialVo);
Page<ErpMaterialVo> returnList = new Page<>();
for (ErpMaterialVo materialVo: list) {
SysUser sysUser = userMapper.selectUserByLoginName(materialVo.getCreateBy());
if (sysUser != null) {
materialVo.setCreateUserName(sysUser.getUserName());
}
SysUser sysUser2 = userMapper.selectUserByLoginName(materialVo.getApplyUser());
if (sysUser2 != null) {
materialVo.setApplyUserName(sysUser2.getUserName());
}
String instanceId = materialVo.getInstanceId();
// 当前环节
if (StringUtils.isNotBlank(instanceId)) {
List<Task> taskList = taskService.createTaskQuery()
.processInstanceId(instanceId)
// .singleResult();
.list(); // 例如请假会签,会同时拥有多个任务
if (!CollectionUtils.isEmpty(taskList)) {
TaskEntityImpl task = (TaskEntityImpl) taskList.get(0);
String taskId = task.getId();
materialVo.setTaskId(taskId);
// 设置待办用户
List<String> todoUserList = todoItemMapper.selectUndealTodoUserList(taskId);
if(!CollectionUtils.isEmpty(taskList)){
materialVo.setTodoUserId(String.join(",",todoUserList));
}
if (task.getSuspensionState() == 2) {
materialVo.setTaskName("已挂起");
materialVo.setSuspendState("2");
} else {
materialVo.setTaskName(task.getName());
materialVo.setSuspendState("1");
}
} else {
// 已办结或者已撤销
materialVo.setTaskName("已结束");
}
} else {
materialVo.setTaskName("未启动");
}
returnList.add(materialVo);
}
returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal());
returnList.setPageNum(pageNum);
returnList.setPageSize(pageSize);
return returnList;
} }
/** /**
@ -91,7 +174,6 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
List<String> fileIdList = Arrays.asList(fileIdStr.split(";")); List<String> fileIdList = Arrays.asList(fileIdStr.split(";"));
attachFileService.updateAttachIdByIdList(attachId,fileIdList); attachFileService.updateAttachIdByIdList(attachId,fileIdList);
} }
erpMaterial.setCreateTime(DateUtils.getNowDate());
return result; return result;
} }
@ -128,7 +210,6 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
attachFileService.updateAttachIdByIdList(photoAttachId, fileIdList); attachFileService.updateAttachIdByIdList(photoAttachId, fileIdList);
} }
erpMaterial.setUpdateBy(loginName); erpMaterial.setUpdateBy(loginName);
erpMaterial.setUpdateTime(DateUtils.getNowDate());
return erpMaterialMapper.updateErpMaterial(erpMaterial); return erpMaterialMapper.updateErpMaterial(erpMaterial);
} }
@ -190,4 +271,48 @@ public class ErpMaterialServiceImpl implements IErpMaterialService
public int updateMaterialBomNo(ErpMaterial erpMaterial) { public int updateMaterialBomNo(ErpMaterial erpMaterial) {
return erpMaterialMapper.updateMaterialBomNo(erpMaterial); return erpMaterialMapper.updateMaterialBomNo(erpMaterial);
} }
/**
* 提交申请
* @param erpMaterial
* @return
*/
@Override
public ProcessInstance submitApply(ErpMaterial erpMaterial) {
String applyUser = ShiroUtils.getLoginName();
SysUser user = ShiroUtils.getSysUser();
erpMaterial.setApplyUser(user.getLoginName());
erpMaterial.setApplyTime(DateUtils.getNowDate());
insertErpMaterial(erpMaterial);
String businessKey = erpMaterial.getId().toString(); // 实体类 ID,作为流程的业务 key
String key = "material";
Map<String,Object> variables = new HashMap<>();
Set<String> roleKeys = roleService.selectRoleKeys(user.getUserId());
// 角色不同审核人不同
if(roleKeys.contains("yfzjRole")){
variables.put("authority",4);
}else if(roleKeys.contains("gczgRole")){
variables.put("authority",3);
}else if(roleKeys.contains("gcjlRole")){
variables.put("authority",2);
}else if(roleKeys.contains("gcwyRole")){
variables.put("authority",1);
}
// 启动流程
String applyTitle = user.getUserName()+"发起了物料信息审批-"+DateUtils.dateTimeNow();
erpMaterial.setApplyTitle(applyTitle);
ProcessInstance processInstance = processService.submitApply(applyUser, businessKey, applyTitle, erpMaterial.getMaterialNo(), key, variables);
String processInstanceId = processInstance.getId();
erpMaterial.setInstanceId(processInstanceId); // 建立双向关系
// 存在提交完就流程结束的情况
boolean processIsFinish = processService.judgeProcessIsFinish(processInstanceId);
if(processIsFinish){
// 审核完成
erpMaterial.setAuditStatus("1");
}
erpMaterialMapper.updateErpMaterial(erpMaterial);
return processInstance;
}
} }

47
ruoyi-admin/src/main/resources/mapper/erp/ErpMaterialMapper.xml

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.erp.mapper.ErpMaterialMapper"> <mapper namespace="com.ruoyi.erp.mapper.ErpMaterialMapper">
<resultMap type="ErpMaterial" id="ErpMaterialResult"> <resultMap type="ErpMaterialVo" id="ErpMaterialResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="delFlag" column="del_flag" /> <result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@ -27,16 +27,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="warehouseDept" column="warehouse_dept" /> <result property="warehouseDept" column="warehouse_dept" />
<result property="photoAttachId" column="photo_attach_id" /> <result property="photoAttachId" column="photo_attach_id" />
<result property="photoUrl" column="photo_url" /> <result property="photoUrl" column="photo_url" />
<result property="instanceId" column="instance_id" />
<result property="applyTitle" column="apply_title" />
<result property="applyUser" column="apply_user" />
<result property="applyTime" column="apply_time" />
</resultMap> </resultMap>
<sql id="selectErpMaterialVo"> <sql id="selectErpMaterialVo">
select id, del_flag, create_by, create_time, update_by, update_time, remark,bomNo, material_no, material_name, audit_status, use_status, hava_product_tem,product_item,itemName, material_type, process_method, unit, brand, `describe`, warehouse_dept from erp_material select id, del_flag, create_by, create_time, update_by, update_time, remark,bomNo, material_no, material_name, audit_status, use_status, hava_product_tem,product_item,itemName, material_type, process_method, unit, brand, `describe`, warehouse_dept,instance_id,apply_title,apply_user,apply_time from erp_material
</sql> </sql>
<select id="selectErpMaterialList" parameterType="ErpMaterial" resultMap="ErpMaterialResult"> <select id="selectErpMaterialList" parameterType="ErpMaterialVo" resultMap="ErpMaterialResult">
select erp.id, erp.del_flag, erp.create_by, erp.create_time, erp.update_by, erp.update_time, erp.remark,erp.bomNo, erp.material_no select erp.id, erp.del_flag, erp.create_by, erp.create_time, erp.update_by, erp.update_time, erp.remark,erp.bomNo, erp.material_no
, erp.material_name, erp.audit_status, erp.use_status, erp.hava_product_tem, erp.product_item,erp.`itemName`, erp.material_type, erp.process_method , erp.material_name, erp.audit_status, erp.use_status, erp.hava_product_tem, erp.product_item,erp.`itemName`, erp.material_type, erp.process_method
, erp.unit, erp.brand, erp.`describe`, erp.warehouse_dept , erp.unit, erp.brand, erp.`describe`, erp.warehouse_dept
,erp.instance_id,erp.apply_title,erp.apply_user,erp.apply_time
,file.url as photo_url ,file.url as photo_url
from erp_material as erp from erp_material as erp
left join ( left join (
@ -69,13 +74,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null and brand != ''"> and erp.brand = #{brand}</if> <if test="brand != null and brand != ''"> and erp.brand = #{brand}</if>
<if test="describe != null and describe != ''"> and erp.`describe` = #{describe}</if> <if test="describe != null and describe != ''"> and erp.`describe` = #{describe}</if>
<if test="warehouseDept != null and warehouseDept != ''"> and erp.warehouse_dept = #{warehouseDept}</if> <if test="warehouseDept != null and warehouseDept != ''"> and erp.warehouse_dept = #{warehouseDept}</if>
<if test="instanceId != null and instanceId != ''"> and erp.instance_id = #{instanceId}</if>
<if test="applyTitle != null and applyTitle != ''"> and erp.apply_title = #{applyTitle}</if>
<if test="applyUser != null and applyUser != ''"> and erp.apply_user = #{applyUser}</if>
<if test="applyTime != null "> and erp.apply_time = #{applyTime}</if>
</where> </where>
order by erp.update_time desc
</select> </select>
<select id="selectErpMaterialById" parameterType="Long" resultMap="ErpMaterialResult"> <select id="selectErpMaterialById" parameterType="Long" resultMap="ErpMaterialResult">
select erp.id, erp.del_flag, erp.create_by, erp.create_time, erp.update_by, erp.update_time, erp.remark,erp.bomNo, erp.material_no select erp.id, erp.del_flag, erp.create_by, erp.create_time, erp.update_by, erp.update_time, erp.remark,erp.bomNo, erp.material_no
, erp.material_name, erp.audit_status, erp.use_status, erp.hava_product_tem,erp.product_item,erp.itemName, erp.material_type , erp.material_name, erp.audit_status, erp.use_status, erp.hava_product_tem,erp.product_item,erp.itemName, erp.material_type
, erp.process_method, erp.unit, erp.brand, erp.describe, erp.warehouse_dept , erp.process_method, erp.unit, erp.brand, erp.describe, erp.warehouse_dept
,erp.instance_id,erp.apply_title,erp.apply_user,erp.apply_time
,att.id as photo_attach_id ,att.id as photo_attach_id
from erp_material erp from erp_material erp
left join sys_attach att left join sys_attach att
@ -90,8 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertErpMaterial" parameterType="ErpMaterial" useGeneratedKeys="true" keyProperty="id"> <insert id="insertErpMaterial" parameterType="ErpMaterial" useGeneratedKeys="true" keyProperty="id">
insert into erp_material insert into erp_material
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="materialNo != null">material_no,</if> <if test="materialNo != null">material_no,</if>
<if test="materialName != null">material_name,</if> <if test="materialName != null">material_name,</if>
@ -105,15 +116,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null">brand,</if> <if test="brand != null">brand,</if>
<if test="describe != null">`describe`,</if> <if test="describe != null">`describe`,</if>
<if test="warehouseDept != null">warehouse_dept,</if> <if test="warehouseDept != null">warehouse_dept,</if>
<if test="createBy != null">create_by,</if> <if test="auditStatus != null">audit_status,</if>
<if test="useStatus != null">use_status,</if>
<if test="instanceId != null">instance_id,</if>
<if test="applyTitle != null">apply_title,</if>
<if test="applyUser != null">apply_user,</if>
<if test="applyTime != null">apply_time,</if>
del_flag, del_flag,
audit_status, create_time,
use_status, update_time,
create_time
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="materialNo != null">#{materialNo},</if> <if test="materialNo != null">#{materialNo},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName},</if>
@ -127,11 +142,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null">#{brand},</if> <if test="brand != null">#{brand},</if>
<if test="describe != null">#{describe},</if> <if test="describe != null">#{describe},</if>
<if test="warehouseDept != null">#{warehouseDept},</if> <if test="warehouseDept != null">#{warehouseDept},</if>
<if test="createBy != null">#{createBy},</if> <if test="auditStatus != null">#{auditStatus},</if>
0, <if test="useStatus != null">#{useStatus},</if>
0, <if test="instanceId != null">#{instanceId},</if>
<if test="applyTitle != null">#{applyTitle},</if>
<if test="applyUser != null">#{applyUser},</if>
<if test="applyTime != null">#{applyTime},</if>
0, 0,
now(), now(),
now(),
</trim> </trim>
</insert> </insert>
@ -157,6 +176,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="brand != null">brand = #{brand},</if> <if test="brand != null">brand = #{brand},</if>
<if test="describe != null">`describe` = #{describe},</if> <if test="describe != null">`describe` = #{describe},</if>
<if test="warehouseDept != null">warehouse_dept = #{warehouseDept},</if> <if test="warehouseDept != null">warehouse_dept = #{warehouseDept},</if>
<if test="instanceId != null">instance_id = #{instanceId},</if>
<if test="applyTitle != null">apply_title = #{applyTitle},</if>
<if test="applyUser != null">apply_user = #{applyUser},</if>
<if test="applyTime != null">apply_time = #{applyTime},</if>
update_time = now() update_time = now()
</trim> </trim>
where id = #{id} where id = #{id}

66
ruoyi-admin/src/main/resources/templates/erp/material/material.html

@ -401,6 +401,7 @@
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" /> <th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:src="@{/ajax/libs/vue/vue.js}"></script> <script th:src="@{/ajax/libs/vue/vue.js}"></script>
<script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script> <script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script>
<script th:inline="javascript"> <script th:inline="javascript">
@ -418,6 +419,8 @@
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var commonCurrencyDatas = [[${@dict.getType('commonCurrentcy')}]]; var commonCurrencyDatas = [[${@dict.getType('commonCurrentcy')}]];
var userName = [[${@permission.getPrincipalProperty('userName')}]]; var userName = [[${@permission.getPrincipalProperty('userName')}]];
var currentUser = [[${currentUser}]];
var loginName = currentUser.loginName;
var productItems = []; var productItems = [];
var prefix = ctx + "erp/material"; var prefix = ctx + "erp/material";
$(function() { $(function() {
@ -442,6 +445,44 @@
title: '主键ID', title: '主键ID',
visible: false visible: false
}, },
{
field: 'instanceId',
title: '流程实例ID'
},
{
field: 'applyUser',
title: '申请人ID',
visible: false
},
{
field: 'applyUserName',
title: '<span style="color: red;">申请人</span>',
formatter: function(value, row, index) {
return '<span style="color: red;">' + (value ? value : "-") + '</span>';
}
},
{
field: 'applyTime',
title: '申请时间'
},
{
field: 'taskId',
title: '当前任务ID',
visible: false
},
{
field: 'todoUserId',
title: '待办用户ID',
visible: false
},
{
field: 'taskName',
title: '当前任务名称',
align: 'center',
formatter: function(value, row, index) {
return '<span class="badge badge-primary">' + value + '</span>';
}
},
{ {
field: 'auditStatus', field: 'auditStatus',
title: '审核状态', title: '审核状态',
@ -552,14 +593,35 @@
align: 'center', align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> '); if (row.instanceId) {
// 有待办人展示审批按钮,
if (row.todoUserId) {
var todoUserIdList = row.todoUserId.split(",");
if(todoUserIdList.includes(loginName)){
var nodeName = row.taskName=='驳回调整'?' 调整申请':' 审批';
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="showVerifyDialog(\'' + prefix + '\',\'' + row.taskId + '\', \'' + row.taskName + '\')"><i class="fa fa-edit"></i> '+nodeName+'</a> ');
}
}
// 详情
actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-eye"></i> 详情</a> ');
// 审批历史
actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="showHistoryDialog(\'' + row.instanceId + '\')"><i class="fa fa-list"></i> 审批历史</a> ');
// 进度查看
actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="showProcessImgDialog(\'' + row.instanceId + '\')"><i class="fa fa-image"></i> 进度查看</a> ');
} else {
// 编辑
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
// 删除
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
}
/*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="showdetails(\'' + index + '\')"><i class="fa fa-eye"></i>详情</a> '); actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="showdetails(\'' + index + '\')"><i class="fa fa-eye"></i>详情</a> ');
actions.push('<a class="btn btn-success btn-xs ' + auditFlag + '" href="javascript:void(0)" onclick="showMaterial(\'' + index + '\')"><i class="fa fa-file-o"></i>审核</a> '); actions.push('<a class="btn btn-success btn-xs ' + auditFlag + '" href="javascript:void(0)" onclick="showMaterial(\'' + index + '\')"><i class="fa fa-file-o"></i>审核</a> ');
if(row.delFlag == '0'){ if(row.delFlag == '0'){
actions.push('<a class="btn btn-danger btn-xs ' + cancelFlag + '" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a>'); actions.push('<a class="btn btn-danger btn-xs ' + cancelFlag + '" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a>');
}else{ }else{
actions.push('<a class="btn btn-success btn-xs ' + restoreFlag + '" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.id + '\')"><i class="fa fa-window-restore"></i>恢复</a>'); actions.push('<a class="btn btn-success btn-xs ' + restoreFlag + '" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.id + '\')"><i class="fa fa-window-restore"></i>恢复</a>');
} }*/
return actions.join(''); return actions.join('');
} }
}] }]

292
ruoyi-admin/src/main/resources/templates/erp/material/taskGcjlVerify.html

@ -0,0 +1,292 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('工程经理审核')" />
<th:block th:include="include :: select2-css" />
<link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input type="hidden" name="p_COM_comment" />
<div class="form-group">
<label class="col-sm-3 control-label">申请人:</label>
<div class="col-sm-8">
<input name="applyUserName" th:field="*{applyUserName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">申请时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8">
<input id="materialNo" name="materialNo" th:field="*{materialNo}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料名称:</label>
<div class="col-sm-8">
<input name="materialName" th:field="*{materialName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否有生产团队:</label>
<div class="col-sm-8">
<select name="haveProductTem" class="form-control m-b" th:with="type=${@dict.getType('havaProductTem')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队id:</label>
<div class="col-sm-8">
<select name="productItem" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" disabled>
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.id}" th:text="${product.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队名称:</label>
<div class="col-sm-8">
<select name="itemName" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" disabled>
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.productItem}" th:text="${product.productItem}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料类型:</label>
<div class="col-sm-8">
<select id="selectMaterialType" class="form-control m-b select2-multiple" th:with="childList=${@category.getChildByCode('materialType')}" disabled>
<optgroup>
<option value="">请选择</option>
</optgroup>
<optgroup th:each="child: ${childList}" th:label="${child.name}">
<option th:each="childSon: ${child.children}" th:value="${childSon.code}" th:text="${#strings.concat(child.name,'-',childSon.name)}"></option>
</optgroup>
</select>
</div>
<input type="text" id="materialType" name="materialType" th:field="*{materialType}" readonly hidden />
</div>
<div class="form-group">
<label class="col-sm-3 control-label">加工方式:</label>
<div class="col-sm-8">
<select name="processMethod" class="form-control m-b" th:with="type=${@dict.getType('processMethod')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{processMethod}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">单位:</label>
<div class="col-sm-8">
<select name="unit" class="form-control m-b" th:with="type=${@dict.getType('sys_unit_class')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{unit}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">品牌:</label>
<div class="col-sm-8">
<input name="brand" th:field="*{brand}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">描述:</label>
<div class="col-sm-8">
<textarea name="describe" class="form-control" readonly>[[*{describe}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">入库部门:</label>
<div class="col-sm-8">
<select name="warehouseDept" class="form-control m-b" th:with="type=${@dict.getType('warehouseDept')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{warehouseDept}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">照片:</label>
<div class="col-sm-8">
<el-upload
:disabled="true"
:action="fileUploadUrl"
:on-success="uploadSuccess"
:on-remove="uploadRemove"
:file-list="fileList"
list-type="picture"
accept=".jpg,.png"
multiple>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,第一张图片为主图</div>
</el-upload>
</div>
<input id="photoAttachId" name = "photoAttachId" th:field="*{photoAttachId}" hidden readonly>
<input id="fileIdStr" type="text" name="fileIdStr" th:field="*{fileIdStr}" hidden readonly>
<input id="removeFileIdStr" type="text" name="removeFileIdStr" hidden readonly>
</div>
<hr />
<div class="form-group">
<label class="col-sm-3 control-label" for="gcjlVerifyApproved"><span style="color: red; ">*</span>审批意见:</label>
<div class="col-sm-8">
<select name="p_B_gcjlVerifyApproved" id="gcjlVerifyApproved" class="form-control m-b" required>
<option value=""></option>
<option value="true">同意</option>
<option value="false">拒绝</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">批注:</label>
<div class="col-sm-8">
<textarea name="comment" class="form-control"></textarea>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:src="@{/ajax/libs/vue/vue.js}"></script>
<script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script>
<script type="text/javascript">
new Vue({
el: '#app',
data: function() {
return {
fileList: [],
fileUploadUrl: ctx + "common/uploadSingleFile",
fileDeleteUrl: ctx + "common/deleteFile",
getListByAttachIdUrl: ctx + "system/attach/file/getListByAttachId",
fileIdList:[],
removeFileIdList:[],
}
},
mounted() {
// 控制下拉框选中
var materialType = $("#materialType").val();
$("#selectMaterialType").val(materialType).trigger("change");
var that = this;
// 页面渲染完成,可以执行需要的操作
console.log('页面已渲染完成');
console.log($("#id").val());
console.log($("#photoAttachId").val());
var attachId = $("#photoAttachId").val();
if(attachId){
$.ajax({
type: "get",
url: that.getListByAttachIdUrl,
data: {attachId:attachId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
result.data.forEach((item) => {
that.fileIdList.push(item.id);
that.fileList.push({name: item.name, url: item.url, attachFileId: item.id,isBind:true});
});
} else {
$.modal.msgError(result.msg);
}
},
error: function(error) {
$.modal.msgError("获取附件失败。");
}
});
}
},
methods: {
uploadSuccess(response, file, fileList) {
console.log(response);
if(response.code == web_status.SUCCESS){
var attachFileId = response.data.id;
file.attachFileId = attachFileId;
file.isBind = false;
this.fileIdList.push(attachFileId);
$("#fileIdStr").val(this.fileIdList.join(";"));
$.modal.msgSuccess("上传成功");
}else{
$.modal.alertError(response.msg);
}
},
uploadRemove(file, fileList) {
console.log(file, fileList);
var attachFileId = file.attachFileId;
var isBind = file.isBind;
if(isBind==false){
$.ajax({
type: "get",
url: this.fileDeleteUrl,
data: {id:attachFileId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
}
$.modal.msgSuccess("删除附件成功。");
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertError("删除附件失败。");
}
});
}else{
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
// 保存的时候才删除
this.removeFileIdList.push(attachFileId);
$("#removeFileIdStr").val(this.removeFileIdList.join(";"));
}
}
},
}
})
var prefix = ctx + "erp/material";
$("#form-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
if ($('textarea[name="comment"]').val()) {
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
}
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-edit').serialize());
}
}
</script>
</body>
</html>

292
ruoyi-admin/src/main/resources/templates/erp/material/taskGczgVerify.html

@ -0,0 +1,292 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('工程主管审核')" />
<th:block th:include="include :: select2-css" />
<link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input type="hidden" name="p_COM_comment" />
<div class="form-group">
<label class="col-sm-3 control-label">申请人:</label>
<div class="col-sm-8">
<input name="applyUserName" th:field="*{applyUserName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">申请时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8">
<input id="materialNo" name="materialNo" th:field="*{materialNo}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料名称:</label>
<div class="col-sm-8">
<input name="materialName" th:field="*{materialName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否有生产团队:</label>
<div class="col-sm-8">
<select name="haveProductTem" class="form-control m-b" th:with="type=${@dict.getType('havaProductTem')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队id:</label>
<div class="col-sm-8">
<select name="productItem" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" disabled>
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.id}" th:text="${product.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队名称:</label>
<div class="col-sm-8">
<select name="itemName" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" disabled>
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.productItem}" th:text="${product.productItem}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料类型:</label>
<div class="col-sm-8">
<select id="selectMaterialType" class="form-control m-b select2-multiple" th:with="childList=${@category.getChildByCode('materialType')}" disabled>
<optgroup>
<option value="">请选择</option>
</optgroup>
<optgroup th:each="child: ${childList}" th:label="${child.name}">
<option th:each="childSon: ${child.children}" th:value="${childSon.code}" th:text="${#strings.concat(child.name,'-',childSon.name)}"></option>
</optgroup>
</select>
</div>
<input type="text" id="materialType" name="materialType" th:field="*{materialType}" readonly hidden />
</div>
<div class="form-group">
<label class="col-sm-3 control-label">加工方式:</label>
<div class="col-sm-8">
<select name="processMethod" class="form-control m-b" th:with="type=${@dict.getType('processMethod')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{processMethod}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">单位:</label>
<div class="col-sm-8">
<select name="unit" class="form-control m-b" th:with="type=${@dict.getType('sys_unit_class')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{unit}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">品牌:</label>
<div class="col-sm-8">
<input name="brand" th:field="*{brand}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">描述:</label>
<div class="col-sm-8">
<textarea name="describe" class="form-control" readonly>[[*{describe}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">入库部门:</label>
<div class="col-sm-8">
<select name="warehouseDept" class="form-control m-b" th:with="type=${@dict.getType('warehouseDept')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{warehouseDept}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">照片:</label>
<div class="col-sm-8">
<el-upload
v-if="!isReadOnly"
:action="fileUploadUrl"
:on-success="uploadSuccess"
:on-remove="uploadRemove"
:file-list="fileList"
list-type="picture"
accept=".jpg,.png"
multiple>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,第一张图片为主图</div>
</el-upload>
</div>
<input id="photoAttachId" name = "photoAttachId" th:field="*{photoAttachId}" hidden readonly>
<input id="fileIdStr" type="text" name="fileIdStr" th:field="*{fileIdStr}" hidden readonly>
<input id="removeFileIdStr" type="text" name="removeFileIdStr" hidden readonly>
</div>
<hr />
<div class="form-group">
<label class="col-sm-3 control-label" for="gczgVerifyApproved"><span style="color: red; ">*</span>审批意见:</label>
<div class="col-sm-8">
<select name="p_B_gczgVerifyApproved" id="gczgVerifyApproved" class="form-control m-b" required>
<option value=""></option>
<option value="true">同意</option>
<option value="false">拒绝</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">批注:</label>
<div class="col-sm-8">
<textarea name="comment" class="form-control"></textarea>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:src="@{/ajax/libs/vue/vue.js}"></script>
<script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script>
<script type="text/javascript">
new Vue({
el: '#app',
data: function() {
return {
fileList: [],
fileUploadUrl: ctx + "common/uploadSingleFile",
fileDeleteUrl: ctx + "common/deleteFile",
getListByAttachIdUrl: ctx + "system/attach/file/getListByAttachId",
fileIdList:[],
removeFileIdList:[],
isReadOnly: true // 设置为 true 则隐藏 el-upload
}
},
mounted() {
// 控制下拉框选中
var materialType = $("#materialType").val();
$("#selectMaterialType").val(materialType).trigger("change");
var that = this;
// 页面渲染完成,可以执行需要的操作
console.log('页面已渲染完成');
console.log($("#id").val());
console.log($("#photoAttachId").val());
var attachId = $("#photoAttachId").val();
if(attachId){
$.ajax({
type: "get",
url: that.getListByAttachIdUrl,
data: {attachId:attachId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
result.data.forEach((item) => {
that.fileIdList.push(item.id);
that.fileList.push({name: item.name, url: item.url, attachFileId: item.id,isBind:true});
});
} else {
$.modal.msgError(result.msg);
}
},
error: function(error) {
$.modal.msgError("获取附件失败。");
}
});
}
},
methods: {
uploadSuccess(response, file, fileList) {
console.log(response);
if(response.code == web_status.SUCCESS){
var attachFileId = response.data.id;
file.attachFileId = attachFileId;
file.isBind = false;
this.fileIdList.push(attachFileId);
$("#fileIdStr").val(this.fileIdList.join(";"));
$.modal.msgSuccess("上传成功");
}else{
$.modal.alertError(response.msg);
}
},
uploadRemove(file, fileList) {
console.log(file, fileList);
var attachFileId = file.attachFileId;
var isBind = file.isBind;
if(isBind==false){
$.ajax({
type: "get",
url: this.fileDeleteUrl,
data: {id:attachFileId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
}
$.modal.msgSuccess("删除附件成功。");
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertError("删除附件失败。");
}
});
}else{
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
// 保存的时候才删除
this.removeFileIdList.push(attachFileId);
$("#removeFileIdStr").val(this.removeFileIdList.join(";"));
}
}
},
}
})
var prefix = ctx + "erp/material";
$("#form-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
if ($('textarea[name="comment"]').val()) {
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
}
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-edit').serialize());
}
}
</script>
</body>
</html>

311
ruoyi-admin/src/main/resources/templates/erp/material/taskModifyApply.html

@ -0,0 +1,311 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('驳回调整')" />
<th:block th:include="include :: select2-css" />
<link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<!--驳回调整允许更新内容-->
<input type="hidden" name="saveEntity" value="true" />
<div class="form-group">
<label class="col-sm-3 control-label">申请人:</label>
<div class="col-sm-8">
<input name="applyUserName" th:field="*{applyUserName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">申请时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8">
<input id="materialNo" name="materialNo" th:field="*{materialNo}" class="form-control" type="text" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料名称:</label>
<div class="col-sm-8">
<input name="materialName" th:field="*{materialName}" class="form-control" type="text" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否有生产团队:</label>
<div class="col-sm-8">
<select name="haveProductTem" class="form-control m-b" th:with="type=${@dict.getType('havaProductTem')}" >
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队id:</label>
<div class="col-sm-8">
<select name="productItem" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" >
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.id}" th:text="${product.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队名称:</label>
<div class="col-sm-8">
<select name="itemName" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" >
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.productItem}" th:text="${product.productItem}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料类型:</label>
<div class="col-sm-8">
<select id="selectMaterialType" class="form-control m-b select2-multiple" th:with="childList=${@category.getChildByCode('materialType')}" >
<optgroup>
<option value="">请选择</option>
</optgroup>
<optgroup th:each="child: ${childList}" th:label="${child.name}">
<option th:each="childSon: ${child.children}" th:value="${childSon.code}" th:text="${#strings.concat(child.name,'-',childSon.name)}"></option>
</optgroup>
</select>
</div>
<input type="text" id="materialType" name="materialType" th:field="*{materialType}" hidden />
</div>
<div class="form-group">
<label class="col-sm-3 control-label">加工方式:</label>
<div class="col-sm-8">
<select name="processMethod" class="form-control m-b" th:with="type=${@dict.getType('processMethod')}" >
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{processMethod}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">单位:</label>
<div class="col-sm-8">
<select name="unit" class="form-control m-b" th:with="type=${@dict.getType('sys_unit_class')}" >
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{unit}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">品牌:</label>
<div class="col-sm-8">
<input name="brand" th:field="*{brand}" class="form-control" type="text" >
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">描述:</label>
<div class="col-sm-8">
<textarea name="describe" class="form-control" >[[*{describe}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">入库部门:</label>
<div class="col-sm-8">
<select name="warehouseDept" class="form-control m-b" th:with="type=${@dict.getType('warehouseDept')}" >
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{warehouseDept}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">照片:</label>
<div class="col-sm-8">
<el-upload
:action="fileUploadUrl"
:on-success="uploadSuccess"
:on-remove="uploadRemove"
:file-list="fileList"
list-type="picture"
accept=".jpg,.png"
multiple>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,第一张图片为主图</div>
</el-upload>
</div>
<input id="photoAttachId" name = "photoAttachId" th:field="*{photoAttachId}" hidden >
<input id="fileIdStr" type="text" name="fileIdStr" th:field="*{fileIdStr}" hidden >
<input id="removeFileIdStr" type="text" name="removeFileIdStr" hidden >
</div>
<hr />
<div class="form-group">
<label class="col-sm-3 control-label" for="reApply">是否继续申请:</label>
<div class="col-sm-8">
<select id="reApply" name="p_B_reApply" class="form-control m-b">
<option value="true">重新申请</option>
<option value="false">结束流程</option>
</select>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:src="@{/ajax/libs/vue/vue.js}"></script>
<script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script>
<script type="text/javascript">
new Vue({
el: '#app',
data: function() {
return {
fileList: [],
fileUploadUrl: ctx + "common/uploadSingleFile",
fileDeleteUrl: ctx + "common/deleteFile",
getListByAttachIdUrl: ctx + "system/attach/file/getListByAttachId",
fileIdList:[],
removeFileIdList:[],
}
},
mounted() {
// 控制下拉框选中
var materialType = $("#materialType").val();
$("#selectMaterialType").val(materialType).trigger("change");
var that = this;
// 页面渲染完成,可以执行需要的操作
console.log('页面已渲染完成');
console.log($("#id").val());
console.log($("#photoAttachId").val());
var attachId = $("#photoAttachId").val();
if(attachId){
$.ajax({
type: "get",
url: that.getListByAttachIdUrl,
data: {attachId:attachId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
result.data.forEach((item) => {
that.fileIdList.push(item.id);
that.fileList.push({name: item.name, url: item.url, attachFileId: item.id,isBind:true});
});
} else {
$.modal.msgError(result.msg);
}
},
error: function(error) {
$.modal.msgError("获取附件失败。");
}
});
}
},
methods: {
uploadSuccess(response, file, fileList) {
console.log(response);
if(response.code == web_status.SUCCESS){
var attachFileId = response.data.id;
file.attachFileId = attachFileId;
file.isBind = false;
this.fileIdList.push(attachFileId);
$("#fileIdStr").val(this.fileIdList.join(";"));
$.modal.msgSuccess("上传成功");
}else{
$.modal.alertError(response.msg);
}
},
uploadRemove(file, fileList) {
console.log(file, fileList);
var attachFileId = file.attachFileId;
var isBind = file.isBind;
if(isBind==false){
$.ajax({
type: "get",
url: this.fileDeleteUrl,
data: {id:attachFileId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
}
$.modal.msgSuccess("删除附件成功。");
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertError("删除附件失败。");
}
});
}else{
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
// 保存的时候才删除
this.removeFileIdList.push(attachFileId);
$("#removeFileIdStr").val(this.removeFileIdList.join(";"));
}
}
},
}
})
var prefix = ctx + "erp/material";
$("#form-edit").validate({
onkeyup: false,
rules:{
materialNo:{
isInteger: true,
minlength: 10,
maxlength: 10,
// remote: {
// url: prefix + "/checkMaterialNoUnique",
// type: "post",
// dataType: "json",
// data: {
// "materialNo": function() {
// console.log($("#materialNo").val())
// return $.common.trim($("#materialNo").val());
// }
// },
// dataFilter: function(data, type) {
// return $.validate.unique(data);
// }
// }
},
},
messages: {
"materialNo": {
// remote: "料号已经存在",
minlength: "请输入10位整数",
maxlength: "请输入10位整数",
},
},
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-edit').serialize());
}
}
</script>
</body>
</html>

292
ruoyi-admin/src/main/resources/templates/erp/material/taskYfzjVerify.html

@ -0,0 +1,292 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('研发总监审核')" />
<th:block th:include="include :: select2-css" />
<link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/>
</head>
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden">
<input type="hidden" name="p_COM_comment" />
<div class="form-group">
<label class="col-sm-3 control-label">申请人:</label>
<div class="col-sm-8">
<input name="applyUserName" th:field="*{applyUserName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">申请时间:</label>
<div class="col-sm-8">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">料号:</label>
<div class="col-sm-8">
<input id="materialNo" name="materialNo" th:field="*{materialNo}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料名称:</label>
<div class="col-sm-8">
<input name="materialName" th:field="*{materialName}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">是否有生产团队:</label>
<div class="col-sm-8">
<select name="haveProductTem" class="form-control m-b" th:with="type=${@dict.getType('havaProductTem')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队id:</label>
<div class="col-sm-8">
<select name="productItem" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" disabled>
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.id}" th:text="${product.id}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">生产团队名称:</label>
<div class="col-sm-8">
<select name="itemName" class="form-control m-b" th:with="productList=${@productItems.selectSysProductItemLists()}" disabled>
<option value="">请选择</option>
<option th:each="product:${productList}" th:value="${product.productItem}" th:text="${product.productItem}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">物料类型:</label>
<div class="col-sm-8">
<select id="selectMaterialType" class="form-control m-b select2-multiple" th:with="childList=${@category.getChildByCode('materialType')}" disabled>
<optgroup>
<option value="">请选择</option>
</optgroup>
<optgroup th:each="child: ${childList}" th:label="${child.name}">
<option th:each="childSon: ${child.children}" th:value="${childSon.code}" th:text="${#strings.concat(child.name,'-',childSon.name)}"></option>
</optgroup>
</select>
</div>
<input type="text" id="materialType" name="materialType" th:field="*{materialType}" readonly hidden />
</div>
<div class="form-group">
<label class="col-sm-3 control-label">加工方式:</label>
<div class="col-sm-8">
<select name="processMethod" class="form-control m-b" th:with="type=${@dict.getType('processMethod')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{processMethod}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">单位:</label>
<div class="col-sm-8">
<select name="unit" class="form-control m-b" th:with="type=${@dict.getType('sys_unit_class')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{unit}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">品牌:</label>
<div class="col-sm-8">
<input name="brand" th:field="*{brand}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">描述:</label>
<div class="col-sm-8">
<textarea name="describe" class="form-control" readonly>[[*{describe}]]</textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">入库部门:</label>
<div class="col-sm-8">
<select name="warehouseDept" class="form-control m-b" th:with="type=${@dict.getType('warehouseDept')}" disabled>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{warehouseDept}"></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">照片:</label>
<div class="col-sm-8">
<el-upload
:disabled="true"
:action="fileUploadUrl"
:on-success="uploadSuccess"
:on-remove="uploadRemove"
:file-list="fileList"
list-type="picture"
accept=".jpg,.png"
multiple>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,第一张图片为主图</div>
</el-upload>
</div>
<input id="photoAttachId" name = "photoAttachId" th:field="*{photoAttachId}" hidden readonly>
<input id="fileIdStr" type="text" name="fileIdStr" th:field="*{fileIdStr}" hidden readonly>
<input id="removeFileIdStr" type="text" name="removeFileIdStr" hidden readonly>
</div>
<hr />
<div class="form-group">
<label class="col-sm-3 control-label" for="yfzjVerifyApproved"><span style="color: red; ">*</span>审批意见:</label>
<div class="col-sm-8">
<select name="p_B_yfzjVerifyApproved" id="yfzjVerifyApproved" class="form-control m-b" required>
<option value=""></option>
<option value="true">同意</option>
<option value="false">拒绝</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">批注:</label>
<div class="col-sm-8">
<textarea name="comment" class="form-control"></textarea>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:src="@{/ajax/libs/vue/vue.js}"></script>
<script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script>
<script type="text/javascript">
new Vue({
el: '#app',
data: function() {
return {
fileList: [],
fileUploadUrl: ctx + "common/uploadSingleFile",
fileDeleteUrl: ctx + "common/deleteFile",
getListByAttachIdUrl: ctx + "system/attach/file/getListByAttachId",
fileIdList:[],
removeFileIdList:[],
}
},
mounted() {
// 控制下拉框选中
var materialType = $("#materialType").val();
$("#selectMaterialType").val(materialType).trigger("change");
var that = this;
// 页面渲染完成,可以执行需要的操作
console.log('页面已渲染完成');
console.log($("#id").val());
console.log($("#photoAttachId").val());
var attachId = $("#photoAttachId").val();
if(attachId){
$.ajax({
type: "get",
url: that.getListByAttachIdUrl,
data: {attachId:attachId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
result.data.forEach((item) => {
that.fileIdList.push(item.id);
that.fileList.push({name: item.name, url: item.url, attachFileId: item.id,isBind:true});
});
} else {
$.modal.msgError(result.msg);
}
},
error: function(error) {
$.modal.msgError("获取附件失败。");
}
});
}
},
methods: {
uploadSuccess(response, file, fileList) {
console.log(response);
if(response.code == web_status.SUCCESS){
var attachFileId = response.data.id;
file.attachFileId = attachFileId;
file.isBind = false;
this.fileIdList.push(attachFileId);
$("#fileIdStr").val(this.fileIdList.join(";"));
$.modal.msgSuccess("上传成功");
}else{
$.modal.alertError(response.msg);
}
},
uploadRemove(file, fileList) {
console.log(file, fileList);
var attachFileId = file.attachFileId;
var isBind = file.isBind;
if(isBind==false){
$.ajax({
type: "get",
url: this.fileDeleteUrl,
data: {id:attachFileId},
cache: false,
async: false, // 设置成同步
dataType: 'json',
success: function(result) {
if (result.code == web_status.SUCCESS) {
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
}
$.modal.msgSuccess("删除附件成功。");
} else {
$.modal.alertError(result.msg);
}
},
error: function(error) {
$.modal.alertError("删除附件失败。");
}
});
}else{
var index = this.fileIdList.indexOf(attachFileId);
if(index!=-1){
this.fileIdList.splice(index,1);
$("#fileIdStr").val(this.fileIdList.join(";"));
// 保存的时候才删除
this.removeFileIdList.push(attachFileId);
$("#removeFileIdStr").val(this.removeFileIdList.join(";"));
}
}
},
}
})
var prefix = ctx + "erp/material";
$("#form-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
if ($('textarea[name="comment"]').val()) {
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
}
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-edit').serialize());
}
}
</script>
</body>
</html>
Loading…
Cancel
Save