|
@@ -0,0 +1,775 @@
|
|
|
|
+package com.jeeplus.modules.externalUnit.service;
|
|
|
|
+
|
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
+import com.jeeplus.common.persistence.Page;
|
|
|
|
+import com.jeeplus.common.service.CrudService;
|
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
|
|
+import com.jeeplus.modules.act.service.ActTaskService;
|
|
|
|
+import com.jeeplus.modules.externalUnit.dao.ExternalUnitFeedbackDao;
|
|
|
|
+import com.jeeplus.modules.externalUnit.entity.ExternalUnitCapitalDemand;
|
|
|
|
+import com.jeeplus.modules.externalUnit.entity.ExternalUnitFeedback;
|
|
|
|
+import com.jeeplus.modules.externalUnit.entity.ExternalUnitProjectRecords;
|
|
|
|
+import com.jeeplus.modules.signatureManagement.electronicSignature.entity.DistrictDirectorApplication;
|
|
|
|
+import com.jeeplus.modules.sys.entity.Office;
|
|
|
|
+import com.jeeplus.modules.sys.entity.User;
|
|
|
|
+import com.jeeplus.modules.sys.service.OfficeService;
|
|
|
|
+import com.jeeplus.modules.sys.service.WorkattachmentService;
|
|
|
|
+import com.jeeplus.modules.sys.utils.UserUtils;
|
|
|
|
+import com.jeeplus.modules.workactivity.dao.WorkActivityProcessDao;
|
|
|
|
+import com.jeeplus.modules.workactivity.entity.Activity;
|
|
|
|
+import com.jeeplus.modules.workactivity.entity.WorkActivityProcess;
|
|
|
|
+import com.jeeplus.modules.workactivity.service.ActivityService;
|
|
|
|
+import com.jeeplus.modules.workactivity.service.WorkActivityProcessService;
|
|
|
|
+import com.jeeplus.modules.workactivitymenu.entity.WorkActivityMenu;
|
|
|
|
+import com.jeeplus.modules.workactivitymenu.service.WorkActivityMenuService;
|
|
|
|
+import com.jeeplus.modules.workclientinfo.dao.WorkClientAttachmentDao;
|
|
|
|
+import com.jeeplus.modules.workclientinfo.entity.WorkClientAttachment;
|
|
|
|
+import com.jeeplus.modules.workprojectnotify.entity.WorkProjectNotify;
|
|
|
|
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
|
|
|
|
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
|
|
|
|
+import org.activiti.engine.ActivitiObjectNotFoundException;
|
|
|
|
+import org.activiti.engine.RuntimeService;
|
|
|
|
+import org.activiti.engine.runtime.ProcessInstance;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+@Transactional(readOnly = true)
|
|
|
|
+public class ExternalUnitFeedbackService extends CrudService<ExternalUnitFeedbackDao, ExternalUnitFeedback> {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExternalUnitFeedbackDao feedbackDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExternalUnitProjectRecordsService projectRecordsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private WorkattachmentService workattachmentService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private WorkClientAttachmentDao workClientAttachmentDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ protected WorkActivityMenuService workActivityMenuService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private OfficeService officeService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ protected WorkActivityProcessService workActivityProcessService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ protected WorkProjectNotifyService workProjectNotifyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RuntimeService runtimeService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private WorkActivityProcessDao workActivityProcessDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ActTaskService actTaskService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ActivityService activityService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public ExternalUnitFeedback get(String id) {
|
|
|
|
+ ExternalUnitFeedback capitalDemand = super.get(id);
|
|
|
|
+ if (capitalDemand != null){
|
|
|
|
+ ExternalUnitProjectRecords externalUnitProjectRecords = projectRecordsService.get(capitalDemand.getProjectId());
|
|
|
|
+ capitalDemand.setProject(externalUnitProjectRecords);
|
|
|
|
+ //查询附件
|
|
|
|
+ WorkClientAttachment workClientAttachment = new WorkClientAttachment();
|
|
|
|
+ workClientAttachment.setAttachmentId(capitalDemand.getId());
|
|
|
|
+ workClientAttachment.setAttachmentFlag("160");
|
|
|
|
+ workClientAttachment.setDivIdType("_exterFeedback");
|
|
|
|
+ List<WorkClientAttachment> attachmentList = workattachmentService.getAttachmentList(workClientAttachment);
|
|
|
|
+ capitalDemand.setWorkAttachments(attachmentList);
|
|
|
|
+ //审核人
|
|
|
|
+ ArrayList<String> strings = new ArrayList<>();
|
|
|
|
+ if (StringUtils.isNotBlank(capitalDemand.getExaminer())){
|
|
|
|
+ if (capitalDemand.getExaminer().contains(",")){
|
|
|
|
+ String[] split = capitalDemand.getExaminer().split(",");
|
|
|
|
+ for (String s : split) {
|
|
|
|
+ strings.add(s);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ strings.add(capitalDemand.getExaminer());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ capitalDemand.setExaminerList(strings);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return capitalDemand;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 意见反馈列表页面
|
|
|
|
+ * @param page
|
|
|
|
+ * @param projectRecords
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Page<ExternalUnitFeedback> getFeedbackList(Page<ExternalUnitFeedback> page, ExternalUnitProjectRecords projectRecords) {
|
|
|
|
+ ExternalUnitFeedback feedback = new ExternalUnitFeedback();
|
|
|
|
+ feedback.setProjectId(projectRecords.getId());
|
|
|
|
+ int count = feedbackDao.queryCount(feedback);
|
|
|
|
+ page.setCount(count);
|
|
|
|
+ page.setCountFlag(false);
|
|
|
|
+ feedback.setPage(page);
|
|
|
|
+ List<ExternalUnitFeedback> capitalDemandList = feedbackDao.findByProId(feedback);
|
|
|
|
+ page.setList(capitalDemandList);
|
|
|
|
+ return page;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 暂存 意见反馈
|
|
|
|
+ * @param feedback
|
|
|
|
+
|
|
|
|
+ */
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public void save(ExternalUnitFeedback feedback) {
|
|
|
|
+ //保存审核人
|
|
|
|
+ String ids = "";
|
|
|
|
+ if (feedback.getExaminerList().size() != 0){
|
|
|
|
+ for (String examine : feedback.getExaminerList()) {
|
|
|
|
+ ids += examine + ",";
|
|
|
|
+ }
|
|
|
|
+ String newIds = ids.substring(0,ids.lastIndexOf(","));
|
|
|
|
+ feedback.setExaminer(newIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ super.save(feedback);
|
|
|
|
+ //保存附件
|
|
|
|
+ if (CollectionUtils.isNotEmpty(feedback.getWorkAttachments())){
|
|
|
|
+ for (WorkClientAttachment workClientAttachment : feedback.getWorkAttachments()){
|
|
|
|
+ if (workClientAttachment.getId() == null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())){
|
|
|
|
+ workClientAttachment.setAttachmentId(feedback.getId());
|
|
|
|
+ workClientAttachment.setAttachmentFlag("160");
|
|
|
|
+ workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
|
|
|
|
+ if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())){
|
|
|
|
+ workattachmentService.insertOnWorkClientAttachment(workClientAttachment);
|
|
|
|
+ }else{
|
|
|
|
+ workattachmentService.updateOnWorkClientAttachment(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ workClientAttachmentDao.delete(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存 意见反馈
|
|
|
|
+ * @param feedback
|
|
|
|
+ * @param variables
|
|
|
|
+ * @param processInstanceId
|
|
|
|
+ */
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public String saveBranch(ExternalUnitFeedback feedback, Map<String, Object> variables, String processInstanceId) {
|
|
|
|
+ String officeId = UserUtils.getUser().getOffice().getId();
|
|
|
|
+ Office office = officeService.get(officeId);
|
|
|
|
+ feedback.setOfficeId(officeId);
|
|
|
|
+ String companyId = UserUtils.getUser().getCompany().getId();
|
|
|
|
+ feedback.setCompanyId(companyId);
|
|
|
|
+ //保存审核人
|
|
|
|
+ String ids = "";
|
|
|
|
+ if (feedback.getExaminerList().size() != 0){
|
|
|
|
+ for (String examine : feedback.getExaminerList()) {
|
|
|
|
+ ids += examine + ",";
|
|
|
|
+ }
|
|
|
|
+ String newIds = ids.substring(0,ids.lastIndexOf(","));
|
|
|
|
+ feedback.setExaminer(newIds);
|
|
|
|
+ }
|
|
|
|
+ super.save(feedback);
|
|
|
|
+ String str = "";
|
|
|
|
+ String title = "项目-"+feedback.getProject().getName()+"意见反馈待审批";
|
|
|
|
+ str = "项目-"+feedback.getProject().getName()+"意见反馈待审批";
|
|
|
|
+
|
|
|
|
+ // 启动流程
|
|
|
|
+ String businessKey = feedback.getId().toString();
|
|
|
|
+ WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194c82bdea00005c750905",officeService.get(feedback.getOfficeId()));
|
|
|
|
+ // 启动流程
|
|
|
|
+ String processType = workActivityMenu.getProcessType();
|
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
|
+ Activity activity = new Activity();
|
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
|
+ .saveNotify(feedback.getId(),
|
|
|
|
+ null,
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311", //对应之后的判断
|
|
|
|
+ "0",
|
|
|
|
+ "待审批",
|
|
|
|
+ "" //通知角色
|
|
|
|
+ );
|
|
|
|
+ long s6=System.currentTimeMillis();
|
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
|
+ List<User> jyfk = new ArrayList<>();
|
|
|
|
+ //审核人
|
|
|
|
+ for (String s : feedback.getExaminerList()) {
|
|
|
|
+ User user = UserUtils.get(s);
|
|
|
|
+ jyfk.add(user);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long s7=System.currentTimeMillis();
|
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getId())) {
|
|
|
|
+ workProjectNotify.setNotifyRole("");
|
|
|
|
+ workActivityMenu = workActivityMenuService.get(workActivityMenu.getId());
|
|
|
|
+ List<Activity> activities = workActivityMenu.getActivities();
|
|
|
|
+ for (Activity a : activities) {
|
|
|
|
+ String encount = a.getEncount();
|
|
|
|
+ String enlist = a.getEnlist();
|
|
|
|
+ if (a.getRole()!=null && StringUtils.isNotBlank(a.getRole().getEnname())){
|
|
|
|
+ List enusers = UserUtils.getByRoleActivityEnnames(a.getRole().getEnname(),office.getId(),"5",feedback.getCreateBy());
|
|
|
|
+ if (enusers.size()==0){
|
|
|
|
+ feedback.setStatus("1");//暂存
|
|
|
|
+ this.save(feedback);
|
|
|
|
+ return "流程审批人不能为空,角色"+a.getRole().getName()+"下无用户,请联系管理员!";
|
|
|
|
+ }
|
|
|
|
+ variables.put(enlist, enusers);
|
|
|
|
+ variables.put(encount, enusers.size());
|
|
|
|
+ }
|
|
|
|
+ if (a.getDelFlag().equals("0") && a.getCount() == 1) {
|
|
|
|
+ activity = a;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ buffer.append(activity.getRole().getEnname());
|
|
|
|
+ if (activity != null && StringUtils.isNotBlank(activity.getId())) {
|
|
|
|
+ //角色审批
|
|
|
|
+ if (StringUtils.isNotBlank(activity.getRole().getEnname())) {
|
|
|
|
+ users = UserUtils.getByRoleActivityEnnames(activity.getRole().getEnname(),office.getId(),"5",feedback.getCreateBy());
|
|
|
|
+ }
|
|
|
|
+ //人员审批
|
|
|
|
+ if (StringUtils.isNotBlank(activity.getUser().getId())) {
|
|
|
|
+ users.add(activity.getUser());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ workProjectNotify.setId("");
|
|
|
|
+ } else {
|
|
|
|
+ if (jyfk.size()==0 ){
|
|
|
|
+ feedback.setStatus("1");//暂存
|
|
|
|
+ this.save(feedback);
|
|
|
|
+ }
|
|
|
|
+ if (jyfk.size()==0){
|
|
|
|
+ return "流程审批人不能为空,请联系管理员!";
|
|
|
|
+ }
|
|
|
|
+ variables.put("yjfkCount",jyfk.size());
|
|
|
|
+ variables.put("yjfkList",jyfk);
|
|
|
|
+ processType = "feedback";
|
|
|
|
+ users.addAll(jyfk);
|
|
|
|
+ }
|
|
|
|
+ for (User user : users){
|
|
|
|
+ workProjectNotify.setUser(user);
|
|
|
|
+ workProjectNotify.setId("");
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(workProjectNotify);
|
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
|
+ extras.put("type","7002");
|
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
|
+ extras.put("procDefKey","311");
|
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,user.getId());
|
|
|
|
+ UserUtils.pushIm(user.getId(),str);
|
|
|
|
+ }
|
|
|
|
+ variables.put("type", processType);
|
|
|
|
+ variables.put("busId", businessKey);
|
|
|
|
+ variables.put("title", "项目-"+feedback.getProject().getName()+"意见反馈待审批");//设置标题;
|
|
|
|
+ long s8=System.currentTimeMillis();
|
|
|
|
+ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
|
|
|
|
+ feedback.setProcessInstance(processInstance);
|
|
|
|
+ long s9=System.currentTimeMillis();
|
|
|
|
+ if (StringUtils.isNotBlank(processInstanceId)) {
|
|
|
|
+ workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
|
|
|
|
+ workActivityProcessService.deleteProcessInstanceId(processInstanceId);
|
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
|
|
|
|
+ }
|
|
|
|
+ long s10=System.currentTimeMillis();
|
|
|
|
+ // 更新流程实例ID
|
|
|
|
+ feedback.setProcessInstanceId(processInstance.getId());
|
|
|
|
+ feedbackDao.updateProcessInstanceId(feedback);
|
|
|
|
+ //通知添加流程实例ID
|
|
|
|
+ workProjectNotify.setProcessInstanceId(processInstance.getId());
|
|
|
|
+ workProjectNotify.setWapBeginDate(new Date());
|
|
|
|
+ workProjectNotifyService.save(workProjectNotify);
|
|
|
|
+ List<Activity> list = workActivityMenu.getActivities();
|
|
|
|
+ long s11=System.currentTimeMillis();
|
|
|
|
+ if (list != null && list.size() != 0) {
|
|
|
|
+ workActivityProcessService.saveList(list, processInstance.getId());
|
|
|
|
+ } else {
|
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
|
+ workActivityProcess.setProcessKey("feedback");
|
|
|
|
+ workActivityProcess.setCount(1);
|
|
|
|
+ workActivityProcess.setProcessInstanceId(processInstance.getId());
|
|
|
|
+ workActivityProcess.setIsApproval("0");
|
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
|
+ /*workActivityProcess.setCount(2);
|
|
|
|
+ workActivityProcess.setId("");
|
|
|
|
+ workActivityProcessService.save(workActivityProcess);*/
|
|
|
|
+ workActivityProcessService.insertAuditsByType(jyfk,processInstance.getId(),1,1);
|
|
|
|
+ //workActivityProcessService.insertAuditsByType(fpglys,processInstance.getId(),2,0);
|
|
|
|
+ }
|
|
|
|
+ //保存附件
|
|
|
|
+ if (CollectionUtils.isNotEmpty(feedback.getWorkAttachments())){
|
|
|
|
+ for (WorkClientAttachment workClientAttachment : feedback.getWorkAttachments()){
|
|
|
|
+ if (workClientAttachment.getId() == null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())){
|
|
|
|
+ workClientAttachment.setAttachmentId(feedback.getId());
|
|
|
|
+ workClientAttachment.setAttachmentFlag("160");
|
|
|
|
+ workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
|
|
|
|
+ if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())){
|
|
|
|
+ workattachmentService.insertOnWorkClientAttachment(workClientAttachment);
|
|
|
|
+ }else{
|
|
|
|
+ workattachmentService.updateOnWorkClientAttachment(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ workClientAttachmentDao.delete(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*8
|
|
|
|
+ 审核
|
|
|
|
+ */
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public String auditSaveBranch(ExternalUnitFeedback feedback, List<User> auditUsers) {
|
|
|
|
+ String userName = UserUtils.get(feedback.getCreateBy().getId()).getName();
|
|
|
|
+ Office office = officeService.get(feedback.getOfficeId());
|
|
|
|
+ String str = "意见反馈申请";
|
|
|
|
+ String title = "意见反馈申请";
|
|
|
|
+ // 对不同环节的业务逻辑进行操作
|
|
|
|
+ String taskDefKey = feedback.getAct().getTaskDefKey();
|
|
|
|
+ if (!"modifyApply".equals(taskDefKey)) {
|
|
|
|
+ actTaskService.claim(feedback.getAct().getTaskId(), UserUtils.getUser().getId());
|
|
|
|
+ }else {
|
|
|
|
+ feedback.getAct().setFlag("yes");
|
|
|
|
+ }
|
|
|
|
+ String comment = "";
|
|
|
|
+ if (feedback.getStatus().equals("4")){
|
|
|
|
+ comment = ("yes".equals(feedback.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
|
|
|
|
+ }else {
|
|
|
|
+ comment = ("yes".equals(feedback.getAct().getFlag())?"[同意] ":"[驳回] ")+feedback.getAct().getComment();
|
|
|
|
+ }
|
|
|
|
+ //yes 的时候状态为审核通过 否则为未通过
|
|
|
|
+ feedback.setStatus(("yes".equals(feedback.getAct().getFlag()) ? "2" : "4"));
|
|
|
|
+ Map<String, Object> vars = Maps.newHashMap();
|
|
|
|
+ //业务逻辑对应的条件表达式
|
|
|
|
+ String exp = "";
|
|
|
|
+ String taskCount = "";
|
|
|
|
+ String notifyRole = "";
|
|
|
|
+ int key = 0;
|
|
|
|
+ String enname = "";
|
|
|
|
+ List<Activity> activitieList = activityService.getByProcessInstanceId(feedback.getProcessInstanceId());
|
|
|
|
+ WorkActivityMenu workActivityMenu = new WorkActivityMenu();
|
|
|
|
+ if (activitieList != null && activitieList.size() != 0) {
|
|
|
|
+ workActivityMenu.setProcessType(activitieList.get(0).getProcessKey());
|
|
|
|
+ workActivityMenu.setActivities(activitieList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
|
+ WorkActivityProcess selectProcess = new WorkActivityProcess();
|
|
|
|
+ selectProcess.setProcessInstanceId(feedback.getProcessInstanceId());
|
|
|
|
+ List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
|
|
|
|
+ List<Activity> activities = workActivityMenu.getActivities();
|
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("feedback")) {
|
|
|
|
+ key = 1;
|
|
|
|
+ for (int i = 0; i < workActivityProcesses.size(); i++) {
|
|
|
|
+ WorkActivityProcess activityProcess = workActivityProcesses.get(i);
|
|
|
|
+ if (taskDefKey.equals(activityProcess.getActivityTask()) && !taskDefKey.equals("modifyApply")) {
|
|
|
|
+ taskCount = activityProcess.getCount()+"";
|
|
|
|
+ workActivityProcess = activityProcess;
|
|
|
|
+ if (!workActivityProcess.getIsApproval().equals("0")) {
|
|
|
|
+ workActivityProcess.setId("");
|
|
|
|
+ }
|
|
|
|
+ exp = "pass";
|
|
|
|
+ if (!"yes".equals(feedback.getAct().getFlag())) {
|
|
|
|
+ feedback.setStatus("4");
|
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
|
+ String returnBack = "-1";
|
|
|
|
+ for (Activity activity : activities) {
|
|
|
|
+ if (activity.getCount() == activityProcess.getCount()) {
|
|
|
|
+ notifyRole = activity.getName();
|
|
|
|
+ returnBack = activity.getReturnBack();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (returnBack.equals("0")) {
|
|
|
|
+ workActivityProcess.setId("");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
|
+ }
|
|
|
|
+ }else if(taskDefKey.equals("modifyApply")){
|
|
|
|
+ notifyRole = "调整申请";
|
|
|
|
+ taskCount = "0";
|
|
|
|
+ exp = "pass";
|
|
|
|
+ workActivityProcess.setId("");
|
|
|
|
+ workActivityProcess.setCount(0);
|
|
|
|
+ if (!"yes".equals(feedback.getAct().getFlag())) {
|
|
|
|
+ feedback.setStatus("3");
|
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
|
+ } else {
|
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ workActivityMenu.setProcessType("feedback");
|
|
|
|
+ for (int i = 0; i < workActivityProcesses.size(); i++) {
|
|
|
|
+ WorkActivityProcess activityProcess = workActivityProcesses.get(i);
|
|
|
|
+ String count = activityProcess.getCount() + "";
|
|
|
|
+ workActivityProcess = activityProcess;
|
|
|
|
+ if (!workActivityProcess.getIsApproval().equals("0")) {
|
|
|
|
+ workActivityProcess.setId("");
|
|
|
|
+ }
|
|
|
|
+ // 审核环节
|
|
|
|
+ if ("yjfk".equals(taskDefKey) && count.contains("1")) {
|
|
|
|
+ taskCount = "1";
|
|
|
|
+ exp = "pass";
|
|
|
|
+ if ("yes".equals(feedback.getAct().getFlag())) {
|
|
|
|
+ //审核通过处理
|
|
|
|
+
|
|
|
|
+ notifyRole = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈审核完成";
|
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
|
+ } else {
|
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ } else if ("modifyApply".equals(taskDefKey)&& count.contains("0")) {
|
|
|
|
+ notifyRole = "意见反馈审批";
|
|
|
|
+ taskCount = "0";
|
|
|
|
+ exp = "pass";
|
|
|
|
+ workActivityProcess.setCount(0);
|
|
|
|
+ enname ="yjfk";
|
|
|
|
+ if (!"yes".equals(feedback.getAct().getFlag())) {
|
|
|
|
+ feedback.setStatus("3");
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ } else if ("apply_end".equals(taskDefKey)) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Boolean state = null;
|
|
|
|
+
|
|
|
|
+ WorkProjectNotify nowWorkProjectNotify = workProjectNotifyService.processingInfo(feedback.getProcessInstanceId());
|
|
|
|
+
|
|
|
|
+ // 设置意见
|
|
|
|
+ feedback.getAct().setComment(("yes".equals(feedback.getAct().getFlag()) ? "[同意] " : "[驳回] ") + feedback.getAct().getComment());
|
|
|
|
+ feedback.preUpdate();
|
|
|
|
+
|
|
|
|
+ // 提交流程任务
|
|
|
|
+ vars.put(exp, "yes".equals(feedback.getAct().getFlag()) ? true : false);
|
|
|
|
+ vars.put("passs", true);
|
|
|
|
+
|
|
|
|
+ workActivityProcessService.updateProcess(workActivityProcess,workActivityMenu,key,taskCount,feedback.getProcessInstanceId(),taskDefKey,"modifyApply",feedback.getAct().getFlag(),comment, activities);
|
|
|
|
+ // 提交流程任务
|
|
|
|
+ actTaskService.complete(feedback.getAct().getTaskId(), feedback.getAct().getProcInsId(), feedback.getAct().getComment(), vars);
|
|
|
|
+ state = actTaskService.isProcessEnd(feedback.getAct().getProcInsId());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
|
+ if (!state) {
|
|
|
|
+ str = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈申请成功" ;
|
|
|
|
+ title = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈申请成功";
|
|
|
|
+ users.add(feedback.getCreateBy());
|
|
|
|
+ if ("yes".equals(feedback.getAct().getFlag())) {
|
|
|
|
+ feedback.setStatus("5");
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ notify.setAuditor(UserUtils.getUser().getId());
|
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(UtilNotify
|
|
|
|
+ .saveNewNotify(feedback.getId(),
|
|
|
|
+ feedback.getCreateBy(),
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311",
|
|
|
|
+ "0",
|
|
|
|
+ "待通知",
|
|
|
|
+ notifyRole,
|
|
|
|
+ feedback.getProcessInstanceId(),new Date()));
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ if (StringUtils.isNotBlank(feedback.getStatus()) && !feedback.getStatus().equals("3")){
|
|
|
|
+ feedback.setStatus("4");
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(UtilNotify
|
|
|
|
+ .saveNewNotify(feedback.getId(),
|
|
|
|
+ feedback.getCreateBy(),
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311",
|
|
|
|
+ "0",
|
|
|
|
+ "待通知",
|
|
|
|
+ notifyRole,
|
|
|
|
+ feedback.getProcessInstanceId(),new Date()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(feedback.getProcessInstanceId());
|
|
|
|
+ }else{
|
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("yjfk")) {
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ notify.setAuditor(UserUtils.getUser().getId());
|
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
|
+ .saveNewNotify(feedback.getId(),
|
|
|
|
+ new User(),
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311",
|
|
|
|
+ "0",
|
|
|
|
+ "待审批",
|
|
|
|
+ notifyRole,
|
|
|
|
+ feedback.getProcessInstanceId(),new Date());
|
|
|
|
+ List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
|
|
|
|
+ activities,
|
|
|
|
+ workProjectNotify,
|
|
|
|
+ taskDefKey,
|
|
|
|
+ feedback.getAct().getFlag(),
|
|
|
|
+ taskCount,
|
|
|
|
+ feedback.getCreateBy(),
|
|
|
|
+ feedback.getOfficeId(),
|
|
|
|
+ "5");
|
|
|
|
+ for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
|
|
|
|
+ users.add(workProjectNotify1.getUser());
|
|
|
|
+ workProjectNotify1.setId("");
|
|
|
|
+ workProjectNotify1.setIsNewRecord(false);
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(workProjectNotify1);
|
|
|
|
+ if (!"modifyApply".equals(taskDefKey)){
|
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
|
+ if ("yjfk".equals(taskDefKey) ){
|
|
|
|
+ extras.put("type","7001");
|
|
|
|
+ }else {
|
|
|
|
+ extras.put("type","7002");
|
|
|
|
+ }
|
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
|
+ extras.put("procDefKey","311");
|
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,workProjectNotify1.getUser().getId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ if (!"yes".equals(feedback.getAct().getFlag())) {//驳回待办提醒
|
|
|
|
+ title = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈申请被驳回";
|
|
|
|
+ str = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈申请被驳回,请重新申请";
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(UtilNotify
|
|
|
|
+ .saveNewNotify(feedback.getId(),
|
|
|
|
+ feedback.getCreateBy(),
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311",
|
|
|
|
+ "0",
|
|
|
|
+ "重新申请",
|
|
|
|
+ notifyRole,
|
|
|
|
+ feedback.getProcessInstanceId(),new Date()));
|
|
|
|
+ users.add( feedback.getCreateBy());
|
|
|
|
+ } else {
|
|
|
|
+ if (StringUtils.isNotBlank(enname)) {//驳回重新申请待办
|
|
|
|
+ title = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈重新申请,待审批";
|
|
|
|
+ str = "项目-"+feedback.getProject().getName()+"-发起人:"+userName+"意见反馈重新申请,待审批";
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
|
+ .saveNewNotify(feedback.getId(),
|
|
|
|
+ new User(),
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311",
|
|
|
|
+ "0",
|
|
|
|
+ "待审批",
|
|
|
|
+ notifyRole,
|
|
|
|
+ feedback.getProcessInstanceId(),new Date());
|
|
|
|
+ for (User user1:auditUsers){
|
|
|
|
+ users.add(user1);
|
|
|
|
+ workProjectNotify.setUser(user1);
|
|
|
|
+ workProjectNotify.setId("");
|
|
|
|
+ workProjectNotify.setIsNewRecord(false);
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(workProjectNotify);
|
|
|
|
+ if (!"modifyApply".equals(taskDefKey)){
|
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
|
+ if ("yjfk".equals(taskDefKey)){
|
|
|
|
+ extras.put("type","7001");
|
|
|
|
+ }else {
|
|
|
|
+ extras.put("type","7002");
|
|
|
|
+ }
|
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
|
+ extras.put("procDefKey","311");
|
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,user1.getId());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ users.addAll(userList);
|
|
|
|
+ users.add(feedback.getCreateBy());
|
|
|
|
+ workProjectNotifyService
|
|
|
|
+ .save(UtilNotify
|
|
|
|
+ .saveNewNotify(feedback.getId(),
|
|
|
|
+ feedback.getCreateBy(),
|
|
|
|
+ feedback.getCompanyId(),
|
|
|
|
+ title,
|
|
|
|
+ str,
|
|
|
|
+ "311",
|
|
|
|
+ "0",
|
|
|
|
+ "重新申请",
|
|
|
|
+ notifyRole,
|
|
|
|
+ feedback.getProcessInstanceId(),new Date()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //对数据进行处理
|
|
|
|
+ if(null != nowWorkProjectNotify){
|
|
|
|
+ workProjectNotifyService.updateWpaData(nowWorkProjectNotify);
|
|
|
|
+ }
|
|
|
|
+ if (users!=null && users.size()!=0) {
|
|
|
|
+ for (User u : users) {
|
|
|
|
+ UserUtils.pushIm(u.getId(),str);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (userList!=null && userList.size()!=0) {
|
|
|
|
+ for (User u : userList) {
|
|
|
|
+ UserUtils.pushMeIm(u.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //保存审核人
|
|
|
|
+ String ids = "";
|
|
|
|
+ if (feedback.getExaminerList().size() != 0){
|
|
|
|
+ for (String examine : feedback.getExaminerList()) {
|
|
|
|
+ ids += examine + ",";
|
|
|
|
+ }
|
|
|
|
+ String newIds = ids.substring(0,ids.lastIndexOf(","));
|
|
|
|
+ feedback.setExaminer(newIds);
|
|
|
|
+ }
|
|
|
|
+ dao.update(feedback);
|
|
|
|
+ //保存附件
|
|
|
|
+ if (CollectionUtils.isNotEmpty(feedback.getWorkAttachments())){
|
|
|
|
+ for (WorkClientAttachment workClientAttachment : feedback.getWorkAttachments()){
|
|
|
|
+ if (workClientAttachment.getId() == null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (WorkClientAttachment.DEL_FLAG_NORMAL.equals(workClientAttachment.getDelFlag())){
|
|
|
|
+ workClientAttachment.setAttachmentId(feedback.getId());
|
|
|
|
+ workClientAttachment.setAttachmentFlag("160");
|
|
|
|
+ workClientAttachment.setAttachmentUser(UserUtils.getUser().getId());
|
|
|
|
+ if (StringUtils.isBlank(workClientAttachment.getId()) || "null".equals(workClientAttachment.getId())){
|
|
|
|
+ workattachmentService.insertOnWorkClientAttachment(workClientAttachment);
|
|
|
|
+ }else{
|
|
|
|
+ workattachmentService.updateOnWorkClientAttachment(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ workClientAttachmentDao.delete(workClientAttachment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "保存审核意见成功!";
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 撤回
|
|
|
|
+ * @param feedback
|
|
|
|
+ */
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public void cancelInvalidate(ExternalUnitFeedback feedback) {
|
|
|
|
+ try {
|
|
|
|
+ String invalidateProcessInstanceId = feedback.getProcessInstanceId();
|
|
|
|
+ //将流程图中尚未走到的task的流程追踪信息逻辑删除,添加一条"撤销"流程追踪信息
|
|
|
|
+ WorkActivityProcess process = new WorkActivityProcess();
|
|
|
|
+ process.setProcessInstanceId(feedback.getProcessInstanceId());
|
|
|
|
+ process.setIsApproval("0");
|
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
|
+ workActivityProcess.setProcessInstanceId(feedback.getProcessInstanceId());
|
|
|
|
+ List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
|
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
|
+ notify.setNotifyId(feedback.getId());
|
|
|
|
+ List<User> userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
|
+ if (userList!=null && userList.size()!=0) {
|
|
|
|
+ for (User u : userList) {
|
|
|
|
+ User user = UserUtils.get(u.getId());
|
|
|
|
+ UserUtils.pushMeIm(user.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(processList!=null && processList.size()>0){
|
|
|
|
+ for (int i =0;i<processList.size();i++) {
|
|
|
|
+ WorkActivityProcess p = processList.get(i);
|
|
|
|
+ if(com.jeeplus.common.utils.StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
|
|
|
|
+ p.setDelFlag("1");
|
|
|
|
+ p.setIsApproval("-1");
|
|
|
|
+ workActivityProcessDao.updateDelFlagAndIsApproval(p);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ WorkActivityProcess pro = new WorkActivityProcess();
|
|
|
|
+ pro.setId("");
|
|
|
|
+ pro.preInsert();
|
|
|
|
+ pro.setDelFlag("0");
|
|
|
|
+ pro.setRemarks("[强制撤销]");
|
|
|
|
+ pro.setProcessKey(processList.get(0).getProcessKey());
|
|
|
|
+ pro.setIsApproval("1");
|
|
|
|
+ pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
|
|
|
|
+ pro.setCount(0);
|
|
|
|
+ workActivityProcessDao.insert(pro);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //结束该流程,设为"撤销"状态
|
|
|
|
+ actTaskService.endProcessInstance(invalidateProcessInstanceId,"意见反馈申请-强制撤销");
|
|
|
|
+ feedback.setStatus("3");
|
|
|
|
+ feedback.preUpdate();
|
|
|
|
+ dao.update(feedback);
|
|
|
|
+
|
|
|
|
+ }catch (ActivitiObjectNotFoundException e){
|
|
|
|
+ System.err.println("意见反馈申请撤销异常,因为这个流程已不存在!");
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ logger.error("Exception e:"+e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除操作
|
|
|
|
+ * @param feedback
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Transactional(readOnly = false)
|
|
|
|
+ public void delete(ExternalUnitFeedback feedback){
|
|
|
|
+ //删除数据
|
|
|
|
+ dao.delete(feedback);
|
|
|
|
+ }
|
|
|
|
+}
|