|
@@ -0,0 +1,833 @@
|
|
|
+package com.jeeplus.modules.businessQuestions.service;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+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.entity.Act;
|
|
|
+import com.jeeplus.modules.act.service.ActTaskService;
|
|
|
+import com.jeeplus.modules.act.utils.ActUtils;
|
|
|
+import com.jeeplus.modules.businessQuestions.dao.BusinessQuestionsDao;
|
|
|
+import com.jeeplus.modules.businessQuestions.entity.BusinessQuestions;
|
|
|
+import com.jeeplus.modules.businessQuestions.entity.BusinessQuestionsAttentionUser;
|
|
|
+import com.jeeplus.modules.businessQuestions.entity.BusinessQuestionsContentsUser;
|
|
|
+import com.jeeplus.modules.businessQuestions.entity.BusinessQuestionsUser;
|
|
|
+import com.jeeplus.modules.oa.entity.OaNotify;
|
|
|
+import com.jeeplus.modules.projectcontentinfo.entity.Projectcontentinfo;
|
|
|
+import com.jeeplus.modules.projectrecord.enums.ProjectStatusEnum;
|
|
|
+import com.jeeplus.modules.ruralprojectrecords.entity.RuralProjectRecords;
|
|
|
+import com.jeeplus.modules.sys.entity.Office;
|
|
|
+import com.jeeplus.modules.sys.entity.User;
|
|
|
+import com.jeeplus.modules.sys.entity.Workattachment;
|
|
|
+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.workprojectnotify.entity.WorkProjectNotify;
|
|
|
+import com.jeeplus.modules.workprojectnotify.service.WorkProjectNotifyService;
|
|
|
+import com.jeeplus.modules.workprojectnotify.util.UtilNotify;
|
|
|
+import org.activiti.engine.IdentityService;
|
|
|
+import org.activiti.engine.RuntimeService;
|
|
|
+import org.activiti.engine.runtime.ProcessInstance;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.management.StringValueExp;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 业务提问service
|
|
|
+ * @author: 徐滕
|
|
|
+ * @create: 2022-03-29 13:37
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+@Transactional(readOnly = true)
|
|
|
+public class BusinessQuestionsService extends CrudService<BusinessQuestionsDao, BusinessQuestions> {
|
|
|
+ @Autowired
|
|
|
+ private WorkattachmentService workattachmentService;
|
|
|
+ @Autowired
|
|
|
+ private OfficeService officeService;
|
|
|
+ @Autowired
|
|
|
+ private IdentityService identityService;
|
|
|
+ @Autowired
|
|
|
+ protected WorkActivityMenuService workActivityMenuService;
|
|
|
+ @Autowired
|
|
|
+ protected WorkProjectNotifyService workProjectNotifyService;
|
|
|
+ @Autowired
|
|
|
+ private RuntimeService runtimeService;
|
|
|
+ @Autowired
|
|
|
+ protected WorkActivityProcessService workActivityProcessService;
|
|
|
+ @Autowired
|
|
|
+ private WorkActivityProcessDao workActivityProcessDao;
|
|
|
+ @Autowired
|
|
|
+ private ActTaskService actTaskService;
|
|
|
+ @Autowired
|
|
|
+ private ActivityService activityService;
|
|
|
+
|
|
|
+ public BusinessQuestions get(String id) {
|
|
|
+ return super.get(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<BusinessQuestions> findList(BusinessQuestions businessQuestions) {
|
|
|
+ return super.findList(businessQuestions);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void queryDetails(BusinessQuestions businessQuestions) {
|
|
|
+ if(businessQuestions==null)return;
|
|
|
+ Workattachment attchment = new Workattachment();
|
|
|
+ attchment.setAttachmentId(businessQuestions.getId());
|
|
|
+ attchment.setAttachmentFlag("182");
|
|
|
+ List<Workattachment> attachments = workattachmentService.findList(attchment);
|
|
|
+ businessQuestions.setWorkAttachments(attachments);
|
|
|
+ for (Workattachment clientAttachment:attachments){
|
|
|
+ if (clientAttachment.getCollectFlag().equals("1")){
|
|
|
+ for (Workattachment workattachment:businessQuestions.getWorkAttachments()){
|
|
|
+ if (clientAttachment.getId().equals(workattachment.getId())){
|
|
|
+ workattachment.setCollectFlag("1");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public Page<BusinessQuestions> findPage(Page<BusinessQuestions> page, BusinessQuestions businessQuestions) {
|
|
|
+ //处理登记人信息
|
|
|
+ if (businessQuestions!=null && StringUtils.isNotBlank(businessQuestions.getSubmitterId())){
|
|
|
+ businessQuestions.setSubmitterName(UserUtils.get(businessQuestions.getSubmitterId()).getName());
|
|
|
+ }
|
|
|
+ int count = dao.queryCount(businessQuestions);
|
|
|
+ page.setCount(count);
|
|
|
+ page.setCountFlag(false);
|
|
|
+ businessQuestions.setPage(page);
|
|
|
+ page.setList(findList(businessQuestions));
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void save(BusinessQuestions businessQuestions) {
|
|
|
+ if(null != businessQuestions.getProject() && StringUtils.isNotBlank(businessQuestions.getProject().getId())){
|
|
|
+ businessQuestions.setProjectId(businessQuestions.getProject().getId());
|
|
|
+ }
|
|
|
+ //添加信息
|
|
|
+ super.save(businessQuestions);
|
|
|
+ //添加处理人信息
|
|
|
+ this.saveBusinessQuestionsUser(businessQuestions);
|
|
|
+ if(StringUtils.isNotBlank(businessQuestions.getHandlingSuggestion())){
|
|
|
+ //添加回复信息(富文本框)
|
|
|
+ this.saveBusinessQuestionsContentsUser(businessQuestions);
|
|
|
+ }
|
|
|
+ //保存附件
|
|
|
+ this.saveAttachments(businessQuestions);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加处理人信息
|
|
|
+ * @param businessQuestions 业务提问信息
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void saveBusinessQuestionsUser(BusinessQuestions businessQuestions){
|
|
|
+ List<User> actorUsers = businessQuestions.getActorUsers();
|
|
|
+ List<BusinessQuestionsUser> businessQuestionsUserList = Lists.newArrayList();
|
|
|
+ for (User info : actorUsers) {
|
|
|
+ BusinessQuestionsUser businessQuestionsUser = new BusinessQuestionsUser();
|
|
|
+ businessQuestionsUser.setBusinessQuestionsId(businessQuestions.getId());
|
|
|
+ businessQuestionsUser.setUserId(info.getId());
|
|
|
+ businessQuestionsUserList.add(businessQuestionsUser);
|
|
|
+ }
|
|
|
+ //根据业务提问id删除业务处理人员信息
|
|
|
+ dao.deleteBusinessQuestionsUserByBusinessQuestionsId(businessQuestions.getId());
|
|
|
+ //添加处理人信息
|
|
|
+ dao.insertBusinessQuestionsUserList(businessQuestionsUserList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加回复信息(富文本框)
|
|
|
+ * @param businessQuestions 业务提问信息
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void saveBusinessQuestionsContentsUser(BusinessQuestions businessQuestions){
|
|
|
+ BusinessQuestionsContentsUser businessQuestionscontentsUser = new BusinessQuestionsContentsUser();
|
|
|
+ businessQuestionscontentsUser.setBusinessQuestionsId(businessQuestions.getId());
|
|
|
+ businessQuestionscontentsUser.setUserId(UserUtils.getUser().getId());
|
|
|
+ businessQuestionscontentsUser.setContents(businessQuestions.getHandlingSuggestion());
|
|
|
+ businessQuestionscontentsUser.preInsert();
|
|
|
+ //添加处理人信息
|
|
|
+ dao.insertBusinessQuestionsContentsUser(businessQuestionscontentsUser);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加附件信息
|
|
|
+ * @param businessQuestions
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void saveAttachments(BusinessQuestions businessQuestions) {
|
|
|
+ List<Workattachment> workattachments = businessQuestions.getWorkAttachments();
|
|
|
+ if (workattachments!=null && workattachments.size()!=0) {
|
|
|
+ for (Workattachment workattachment : workattachments) {
|
|
|
+ if (workattachment.getId() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (workattachment.DEL_FLAG_NORMAL.equals(workattachment.getDelFlag())) {
|
|
|
+ workattachment.setAttachmentId(businessQuestions.getId());
|
|
|
+ workattachment.setAttachmentFlag("182");
|
|
|
+ workattachment.setAttachmentUser(UserUtils.getUser().getId());
|
|
|
+ if (StringUtils.isBlank(workattachment.getId()) || "null".equals(workattachment.getId())) {
|
|
|
+ workattachmentService.insertOnWorkAttachment(workattachment);
|
|
|
+ } else {
|
|
|
+ workattachmentService.updateOnWorkAttachment(workattachment);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ workattachmentService.delete(workattachment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分公司提交存储
|
|
|
+ * @param businessQuestions
|
|
|
+ * @param variables
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public String saveAndSubmit(BusinessQuestions businessQuestions, Map<String, Object> variables, String processInstanceId) {
|
|
|
+ String officeId = UserUtils.getUser().getOffice().getId();
|
|
|
+ Office office = officeService.get(officeId);
|
|
|
+ businessQuestions.setOffice(office);
|
|
|
+ this.save(businessQuestions);
|
|
|
+
|
|
|
+ String title = "标题:"+ businessQuestions.getTitle() +"业务提问申请待审批";
|
|
|
+ String str = "标题:"+ businessQuestions.getTitle() +"业务提问申请待审批,所属项目:"+businessQuestions.getProject().getProjectName();
|
|
|
+
|
|
|
+ // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
|
|
|
+ identityService.setAuthenticatedUserId(UserUtils.getUser().getId());
|
|
|
+ // 启动流程
|
|
|
+ String businessKey = businessQuestions.getId();
|
|
|
+ WorkActivityMenu workActivityMenu = workActivityMenuService.findByParentAndOffice("ggh3125f1f194c82bdea00005c750905",officeService.get(businessQuestions.getOfficeId()));
|
|
|
+ // 启动流程
|
|
|
+ String processType = workActivityMenu.getProcessType();
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ Activity activity = new Activity();
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ null,
|
|
|
+ businessQuestions.getCompanyId(),
|
|
|
+ title,
|
|
|
+ str,
|
|
|
+ "182", //对应之后的判断
|
|
|
+ "0",
|
|
|
+ "待审批",
|
|
|
+ "" //通知角色
|
|
|
+ );
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
+ //根据业务提问查询处理人信息
|
|
|
+ List<User> clrs = dao.getBusinessQuestionsUser(businessQuestions.getId());
|
|
|
+ //将业务提问创建人添加到结案人角色中
|
|
|
+ List<User> jar = Lists.newArrayList();
|
|
|
+ User createBy = UserUtils.get(businessQuestions.getCreateBy().getId());
|
|
|
+ jar.add(createBy);
|
|
|
+
|
|
|
+ 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",businessQuestions.getCreateBy());
|
|
|
+ if (enusers.size()==0){
|
|
|
+ businessQuestions.setStatus("1");//暂存
|
|
|
+ this.save(businessQuestions);
|
|
|
+ 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",businessQuestions.getCreateBy());
|
|
|
+ }
|
|
|
+ //人员审批
|
|
|
+ if (StringUtils.isNotBlank(activity.getUser().getId())) {
|
|
|
+ users.add(activity.getUser());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workProjectNotify.setId("");
|
|
|
+ } else {
|
|
|
+ if (clrs.size()==0 ){
|
|
|
+ businessQuestions.setStatus("1");//暂存
|
|
|
+ this.save(businessQuestions);
|
|
|
+ }
|
|
|
+ if (clrs.size()==0){
|
|
|
+ return "业务问题处理人不能为空,请联系管理员!";
|
|
|
+ }
|
|
|
+ variables.put("clrCount",clrs.size());
|
|
|
+ variables.put("clrList",clrs);
|
|
|
+ processType = "businessQuestions";
|
|
|
+ users.addAll(clrs);
|
|
|
+ }
|
|
|
+ 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","182");
|
|
|
+ UserUtils.pushInfoToApp(title,str,extras,user.getId());
|
|
|
+ UserUtils.pushIm(user.getId(),str);
|
|
|
+ }
|
|
|
+ variables.put("type", processType);
|
|
|
+ variables.put("busId", businessKey);
|
|
|
+ variables.put("title", "业务提问标题:"+ businessQuestions.getTitle());//设置标题;
|
|
|
+ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processType, businessKey, variables);
|
|
|
+ businessQuestions.setProcessInstance(processInstance);
|
|
|
+ if (StringUtils.isNotBlank(processInstanceId)) {
|
|
|
+ workActivityProcessService.updateProcessInstanceId(processInstance.getId(),processInstanceId);
|
|
|
+ workActivityProcessService.deleteProcessInstanceId(processInstanceId);
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(processInstanceId);
|
|
|
+ }
|
|
|
+ // 更新流程实例ID
|
|
|
+ businessQuestions.setProcessInstanceId(processInstance.getId());
|
|
|
+ dao.updateProcessInstanceId(businessQuestions);
|
|
|
+ //通知添加流程实例ID
|
|
|
+ workProjectNotify.setProcessInstanceId(processInstance.getId());
|
|
|
+ workProjectNotifyService.save(workProjectNotify);
|
|
|
+ List<Activity> list = workActivityMenu.getActivities();
|
|
|
+ if (list != null && list.size() != 0) {
|
|
|
+ workActivityProcessService.saveList(list, processInstance.getId());
|
|
|
+ } else {
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
+ workActivityProcess.setProcessKey("businessQuestions");
|
|
|
+ workActivityProcess.setCount(1);
|
|
|
+ workActivityProcess.setProcessInstanceId(processInstance.getId());
|
|
|
+ workActivityProcess.setIsApproval("0");
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcess.setCount(2);
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ workActivityProcessService.save(workActivityProcess);
|
|
|
+ workActivityProcessService.insertAuditsByType(clrs,processInstance.getId(),1,1);
|
|
|
+ workActivityProcessService.insertAuditsByType(jar,processInstance.getId(),2,0);
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询业务提问内容集合(按照时间正序进行查询)
|
|
|
+ * @param businessQuestions
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<BusinessQuestionsContentsUser> getBusinessQuestionsContentsList(BusinessQuestions businessQuestions){
|
|
|
+ List<BusinessQuestionsContentsUser> businessQuestionsContentsList = dao.getBusinessQuestionsContentsList(businessQuestions);
|
|
|
+ return businessQuestionsContentsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除方法
|
|
|
+ * @param businessQuestions
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void delete (BusinessQuestions businessQuestions){
|
|
|
+ dao.delete(businessQuestions);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void cancelProcess(BusinessQuestions businessQuestions) throws Exception {
|
|
|
+ WorkActivityProcess process = new WorkActivityProcess();
|
|
|
+ process.setProcessInstanceId(businessQuestions.getProcessInstanceId());
|
|
|
+ process.setIsApproval("0");
|
|
|
+ WorkActivityProcess workActivityProcess = new WorkActivityProcess();
|
|
|
+ workActivityProcess.setProcessInstanceId(businessQuestions.getProcessInstanceId());
|
|
|
+ List<WorkActivityProcess> processList = workActivityProcessService.findList(workActivityProcess);
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ List<User> userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ if (userList!=null && userList.size()!=0) {
|
|
|
+ for (User u : userList) {
|
|
|
+ User user = UserUtils.get(u.getId());
|
|
|
+ UserUtils.pushIm(u.getId(),"申请人:"+ user.getName()+",业务提问标题:"+businessQuestions.getTitle() +" 强制撤销!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(processList!=null && processList.size()>0){
|
|
|
+ for (int i =0;i<processList.size();i++) {
|
|
|
+ WorkActivityProcess p = processList.get(i);
|
|
|
+ if(StringUtils.isNotBlank(p.getIsApproval()) && "0".equals(p.getIsApproval())){
|
|
|
+ p.setIsApproval("-1");
|
|
|
+ p.setDelFlag("1");
|
|
|
+ workActivityProcessDao.updateDelFlagAndIsApproval(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ WorkActivityProcess pro = new WorkActivityProcess();
|
|
|
+ pro.setId("");
|
|
|
+ pro.setDelFlag("0");
|
|
|
+ pro.preInsert();
|
|
|
+ pro.setRemarks("[强制撤销]");
|
|
|
+ pro.setProcessKey(processList.get(0).getProcessKey());
|
|
|
+ pro.setIsApproval("1");
|
|
|
+ pro.setProcessInstanceId(processList.get(0).getProcessInstanceId());
|
|
|
+ pro.setCount(0);
|
|
|
+ workActivityProcessDao.insert(pro);
|
|
|
+
|
|
|
+ //结束该流程,设为"撤销"状态月
|
|
|
+ BusinessQuestions sendMessage = new BusinessQuestions();
|
|
|
+ sendMessage.setId(businessQuestions.getId());
|
|
|
+ sendMessage.setStatus(String.valueOf(ProjectStatusEnum.RECALL.getValue()));
|
|
|
+ sendMessage.setProcessInstanceId(businessQuestions.getProcessInstanceId());
|
|
|
+ sendMessage.preUpdate();
|
|
|
+ dao.updateProcessIdAndStatus(sendMessage);
|
|
|
+ actTaskService.endProcessInstance(businessQuestions.getProcessInstanceId(), "业务提问-撤回");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 业务提问审批
|
|
|
+ * @param businessQuestions
|
|
|
+ * @param auditUsers
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public String auditSave(BusinessQuestions businessQuestions, List<User> auditUsers) {
|
|
|
+ String status = businessQuestions.getStatus();
|
|
|
+ String taskDefKey = businessQuestions.getAct().getTaskDefKey();
|
|
|
+ if (!"modifyApply".equals(taskDefKey) && !taskDefKey.contains("audit") ) {
|
|
|
+ actTaskService.claim(businessQuestions.getAct().getTaskId(), UserUtils.getUser().getId());
|
|
|
+ if(StringUtils.isNotBlank(businessQuestions.getHandlingSuggestion())) {
|
|
|
+ //添加回复信息(富文本框)
|
|
|
+ this.saveBusinessQuestionsContentsUser(businessQuestions);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ businessQuestions.getAct().setFlag("yes");
|
|
|
+ this.save(businessQuestions);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String comment = "";
|
|
|
+ if ( Integer.parseInt(status) == ProjectStatusEnum.REJECTED.getValue()) {
|
|
|
+ comment = ("yes".equals(businessQuestions.getAct().getFlag())?"[重新申请] ":"[已撤销] ");
|
|
|
+ }else {
|
|
|
+ comment = ("yes".equals(businessQuestions.getAct().getFlag())?"[同意] ":"[驳回] ")+businessQuestions.getAct().getComment();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"yes".equals(businessQuestions.getAct().getFlag())) {
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.REJECTED.getValue()));
|
|
|
+ }
|
|
|
+
|
|
|
+ User createUser = UserUtils.get(businessQuestions.getCreateBy().getId());
|
|
|
+
|
|
|
+ Map<String, Object> vars = Maps.newHashMap();
|
|
|
+ String notifyRole = "";
|
|
|
+ //业务逻辑对应的条件表达式
|
|
|
+ User user = null;
|
|
|
+ List<Activity> activitieList = activityService.getByProcessInstanceId(businessQuestions.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(businessQuestions.getProcessInstanceId());
|
|
|
+ List<WorkActivityProcess> workActivityProcesses = workActivityProcessService.findList(selectProcess);
|
|
|
+ List<Activity> activities = workActivityMenu.getActivities();
|
|
|
+ String taskCount = "1";
|
|
|
+ String enname = "";
|
|
|
+ String notifyStr = "标题:"+ businessQuestions.getTitle() +"业务提问申请待审批";
|
|
|
+ String titleStr = "标题:"+ businessQuestions.getTitle() +"业务提问申请待审批";
|
|
|
+ String str = "标题:"+ businessQuestions.getTitle() +"业务提问申请待审批,所属项目:"+businessQuestions.getProject().getProjectName();
|
|
|
+ int key = 0;
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("businessQuestions")) {
|
|
|
+ key = 1;
|
|
|
+ for (int i = 0; i < workActivityProcesses.size(); i++) {
|
|
|
+ WorkActivityProcess activityProcess = workActivityProcesses.get(i);
|
|
|
+ if (taskDefKey.equals("modifyApply")) {
|
|
|
+ taskCount = "0";
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ workActivityProcess.setCount(0);
|
|
|
+ if (!"yes".equals(businessQuestions.getAct().getFlag())) {
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.RECALL.getValue()));
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ vars.put("pass", false);
|
|
|
+ } else {
|
|
|
+ vars.put("pass", true);
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ taskCount = activityProcess.getCount()+"";
|
|
|
+ workActivityProcess = activityProcess;
|
|
|
+ if (!workActivityProcess.getIsApproval().equals("0")) {
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ }
|
|
|
+ for (Activity activity : activities) {
|
|
|
+ if (activity.getCount() == activityProcess.getCount()) {
|
|
|
+ notifyRole = activity.getName();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!"yes".equals(businessQuestions.getAct().getFlag())) {
|
|
|
+ notifyRole = "调整项目";
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.REJECTED.getValue()));
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ String returnBack = "-1";
|
|
|
+ for (Activity activity : activities) {
|
|
|
+ if (activity.getCount() == activityProcess.getCount()) {
|
|
|
+ returnBack = activity.getReturnBack();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (returnBack.equals("0")) {
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ }
|
|
|
+ vars.put("pass", false);
|
|
|
+ } else {
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ vars.put("pass", true);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ workActivityMenu.setProcessType("businessQuestions");
|
|
|
+ for (int i = 0; i < workActivityProcesses.size(); i++) {
|
|
|
+ WorkActivityProcess activityProcess = workActivityProcesses.get(i);
|
|
|
+ String count = String.valueOf(activityProcess.getCount());
|
|
|
+ workActivityProcess = activityProcess;
|
|
|
+ if (!workActivityProcess.getIsApproval().equals("0")) {
|
|
|
+ workActivityProcess.setId("");
|
|
|
+ }
|
|
|
+ // 审核环节
|
|
|
+ if ("clr".equals(taskDefKey) && "1".equals(count)) {
|
|
|
+ taskCount = count;
|
|
|
+ if ("yes".equals(businessQuestions.getAct().getFlag())) {
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.IN_APRL.getValue()));
|
|
|
+ notifyRole = "处理人处理";
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ enname = "jar";
|
|
|
+ vars.put("jarList", auditUsers);
|
|
|
+ vars.put("jarCount",auditUsers.size());
|
|
|
+ vars.put("pass", true);
|
|
|
+ vars.put("passs", true);
|
|
|
+ } else {
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ vars.put("pass", false);
|
|
|
+ vars.put("passs", false);
|
|
|
+ user = createUser;
|
|
|
+ notifyRole = "调整业务提问";
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if ("jar".equals(taskDefKey) && "2".equals(count)) {
|
|
|
+ taskCount = count;
|
|
|
+ if ("yes".equals(businessQuestions.getAct().getFlag())) {
|
|
|
+ notifyRole = "审批通过";
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ vars.put("pass", true);
|
|
|
+ vars.put("passs", true);
|
|
|
+ } else {
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.IN_APRL.getValue()));
|
|
|
+ vars.put("pass", false);
|
|
|
+ vars.put("passs", false);
|
|
|
+ user = createUser;
|
|
|
+ notifyRole = "调整业务提问";
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ } else if ("modifyApply".equals(taskDefKey) && "0".equals(count)) {
|
|
|
+ notifyRole = "发起人处理";
|
|
|
+ taskCount = "0";
|
|
|
+ enname = "master";
|
|
|
+ workActivityProcess.setCount(0);
|
|
|
+ if("yes".equals(businessQuestions.getAct().getFlag())){
|
|
|
+ workActivityProcess.setIsApproval("1");
|
|
|
+ vars.put("pass",true);
|
|
|
+ vars.put("passs",true);
|
|
|
+ }else{
|
|
|
+ workActivityProcess.setIsApproval("2");
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.RECALL.getValue()));
|
|
|
+ vars.put("pass",false);
|
|
|
+ vars.put("passs",false);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer order = 1;
|
|
|
+ if("jar".equals(taskDefKey)){
|
|
|
+ order = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ workActivityProcessService.updateProcessNew(workActivityProcess,workActivityMenu,key,taskCount,businessQuestions.getProcessInstanceId(),taskDefKey,"modifyApply",businessQuestions.getAct().getFlag(),comment, activities,order);
|
|
|
+ // 设置意见
|
|
|
+ businessQuestions.getAct().setComment(comment);
|
|
|
+ businessQuestions.preUpdate();
|
|
|
+ //判断是否是审核通过
|
|
|
+ if("yes".equals(businessQuestions.getAct().getFlag())){
|
|
|
+ actTaskService.complete(businessQuestions.getAct().getTaskId(), businessQuestions.getAct().getProcInsId(), businessQuestions.getAct().getComment(), vars);
|
|
|
+ }else{
|
|
|
+ //不通过需要查询审核组角色id
|
|
|
+ List<Act> list2 = actTaskService.toMyStartedList(businessQuestions.getProcessInstanceId());
|
|
|
+ // 提交流程任务
|
|
|
+ //如果是驳回,并且审核角色为多个,需要对每个角色的审核流都进行处理
|
|
|
+ for (Act actInfo: list2) {
|
|
|
+ actTaskService.complete(actInfo.getTask().getId(), actInfo.getProcInsId(), businessQuestions.getAct().getComment(), vars);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean state = actTaskService.isProcessEnd(businessQuestions.getAct().getProcInsId());
|
|
|
+ List<User> users = new ArrayList<>();
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ if(!state) {
|
|
|
+ users.add(businessQuestions.getCreateBy());
|
|
|
+ //审核完成提示框
|
|
|
+ String title = "标题:"+ businessQuestions.getTitle() +"业务提问申请已完成";
|
|
|
+ String content = "标题:"+ businessQuestions.getTitle() +"业务提问申请已完成,所属项目:"+businessQuestions.getProject().getProjectName();
|
|
|
+ if ("yes".equals(businessQuestions.getAct().getFlag())) {
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.SIGNED.getValue()));
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ users.add(businessQuestions.getCreateBy());
|
|
|
+ //查询问题关注人员信息
|
|
|
+ List<User> informUserList = dao.getInformUserList(businessQuestions);
|
|
|
+ //将登记人添加进去并进行set处理
|
|
|
+ informUserList.add(UserUtils.get(businessQuestions.getCreateBy().getId()));
|
|
|
+ Set<String> setUserId = new HashSet<>();
|
|
|
+ List<User> informUsers = Lists.newArrayList();
|
|
|
+ for (User userInfo : informUserList) {
|
|
|
+ setUserId.add(userInfo.getId());
|
|
|
+ }
|
|
|
+ String userIds = setUserId.toString();
|
|
|
+ for (User userInfo : informUserList) {
|
|
|
+ if(!userIds.contains(userInfo.getId())){
|
|
|
+ informUsers.add(userInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (User userInfo : informUsers) {
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ userInfo,
|
|
|
+ UserUtils.getSelectCompany().getId(),
|
|
|
+ title,
|
|
|
+ content,
|
|
|
+ "182",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ notifyRole));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ users.add(businessQuestions.getCreateBy());
|
|
|
+ if (Integer.valueOf(businessQuestions.getStatus()) != ProjectStatusEnum.RECALL.getValue()){
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.REJECTED.getValue()));
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ businessQuestions.getCreateBy(),
|
|
|
+ UserUtils.getSelectCompany().getId(),
|
|
|
+ titleStr,
|
|
|
+ notifyStr,
|
|
|
+ "182",
|
|
|
+ "0",
|
|
|
+ "待通知",
|
|
|
+ notifyRole));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ workActivityProcessService.deleteProcessIdAuditUsers(businessQuestions.getProcessInstanceId());
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if (StringUtils.isNotBlank(workActivityMenu.getProcessType()) && !workActivityMenu.getProcessType().equals("businessQuestions")) {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ new User(),
|
|
|
+ UserUtils.getSelectCompany().getId(),
|
|
|
+ titleStr,
|
|
|
+ str,
|
|
|
+ "182",
|
|
|
+ "0",
|
|
|
+ "待审批",
|
|
|
+ notifyRole);
|
|
|
+ String count = taskDefKey.replace("audit","").replace("task","");
|
|
|
+ List<WorkProjectNotify> workProjectNotifys = activityService.getByFlagAndTaskDefKeyList(
|
|
|
+ activities,
|
|
|
+ workProjectNotify,
|
|
|
+ taskDefKey,
|
|
|
+ businessQuestions.getAct().getFlag(),
|
|
|
+ count,
|
|
|
+ businessQuestions.getCreateBy(),
|
|
|
+ businessQuestions.getOffice().getId(),
|
|
|
+ "4");
|
|
|
+ for (WorkProjectNotify workProjectNotify1:workProjectNotifys){
|
|
|
+ users.add(workProjectNotify1.getUser());
|
|
|
+ workProjectNotify1.setId("");
|
|
|
+ workProjectNotify1.setIsNewRecord(false);
|
|
|
+ workProjectNotifyService.save(workProjectNotify1);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (!"yes".equals(businessQuestions.getAct().getFlag())) {//驳回待办提醒
|
|
|
+ if("jar".equals(taskDefKey)){
|
|
|
+ titleStr = "标题:"+ businessQuestions.getTitle() +"业务提问处理被驳回";
|
|
|
+ str = "标题:"+ businessQuestions.getTitle() +"业务提问处理被驳回,请重新进行处理";
|
|
|
+ }else{
|
|
|
+ titleStr = "标题:"+ businessQuestions.getTitle() +"业务提问申请被驳回";
|
|
|
+ str = "标题:"+ businessQuestions.getTitle() +"业务提问申请被驳回,请选择重新申请或删除";
|
|
|
+ }
|
|
|
+ User masterUser = businessQuestions.getCreateBy();
|
|
|
+ List<User> informUserList = Lists.newArrayList();
|
|
|
+ String remarks = "";
|
|
|
+ if("jar".equals(taskDefKey)){
|
|
|
+ informUserList.addAll(auditUsers);
|
|
|
+ users.addAll(auditUsers);
|
|
|
+ remarks = "待审批";
|
|
|
+ }else{
|
|
|
+ informUserList.add(masterUser);
|
|
|
+ users.add(user);
|
|
|
+ remarks = "重新申请";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ users.add(user);
|
|
|
+
|
|
|
+ for (User userInfo: informUserList) {
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ userInfo,
|
|
|
+ UserUtils.getSelectCompany().getId(),
|
|
|
+ titleStr,
|
|
|
+ str,
|
|
|
+ "182",
|
|
|
+ "0",
|
|
|
+ remarks,
|
|
|
+ notifyRole);
|
|
|
+ workProjectNotifyService.save(workProjectNotify);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (StringUtils.isNotBlank(enname)) {//驳回重新申请待办信息
|
|
|
+ titleStr = "标题:"+ businessQuestions.getTitle() +"业务提问申请,待审批";
|
|
|
+ str = "标题:"+ businessQuestions.getTitle() +"业务提问申请,待审批,所属项目:"+businessQuestions.getProject().getProjectName();
|
|
|
+ businessQuestions.setStatus(String.valueOf(ProjectStatusEnum.IN_APRL.getValue()));
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ WorkProjectNotify workProjectNotify = UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ new User(),
|
|
|
+ UserUtils.getSelectCompany().getId(),
|
|
|
+ titleStr,
|
|
|
+ str,
|
|
|
+ "182",
|
|
|
+ "0",
|
|
|
+ "待审批",
|
|
|
+ notifyRole);
|
|
|
+ for (User user1:auditUsers){
|
|
|
+ users.add(user1);
|
|
|
+ workProjectNotify.setUser(user1);
|
|
|
+ workProjectNotify.setId("");
|
|
|
+ workProjectNotify.setIsNewRecord(false);
|
|
|
+ workProjectNotifyService.save(workProjectNotify);
|
|
|
+ Map<String,Object> extras = new HashMap<>();
|
|
|
+ extras.put("type","7003");
|
|
|
+ extras.put("procDefKey","182");
|
|
|
+ extras.put("id",workProjectNotify.getId());
|
|
|
+ UserUtils.pushInfoToApp(titleStr,str,extras,user1.getId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ WorkProjectNotify notify = new WorkProjectNotify();
|
|
|
+ notify.setNotifyId(businessQuestions.getId());
|
|
|
+ userList = workProjectNotifyService.readByNotifyId(notify);
|
|
|
+ users.add(businessQuestions.getCreateBy());
|
|
|
+ workProjectNotifyService
|
|
|
+ .save(UtilNotify
|
|
|
+ .saveNotify(businessQuestions.getId(),
|
|
|
+ businessQuestions.getCreateBy(),
|
|
|
+ UserUtils.getSelectCompany().getId(),
|
|
|
+ titleStr,
|
|
|
+ str,
|
|
|
+ "182",
|
|
|
+ "0",
|
|
|
+ "重新申请",
|
|
|
+ notifyRole));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (users!=null && users.size()!=0) {
|
|
|
+ List<String> userIds = new ArrayList<>(users.size());
|
|
|
+ for (User u : users) {
|
|
|
+ userIds.add(u.getId());
|
|
|
+ }
|
|
|
+ UserUtils.pushIm(userIds,titleStr);
|
|
|
+ }
|
|
|
+ if (userList!=null && userList.size()!=0) {
|
|
|
+ for (User u : userList) {
|
|
|
+ UserUtils.pushMeIm(u.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ businessQuestions.setProjectId(businessQuestions.getProject().getId());
|
|
|
+ dao.update(businessQuestions);
|
|
|
+ return "保存审核意见成功!";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目相应文件批量下载并压缩
|
|
|
+ * @param idList
|
|
|
+ */
|
|
|
+ @Transactional(readOnly = false)
|
|
|
+ public void attentionAll(List<String> idList) {
|
|
|
+ List<BusinessQuestionsAttentionUser> list = Lists.newArrayList();
|
|
|
+ //获取当前登录人
|
|
|
+ User user = UserUtils.getUser();
|
|
|
+ for (String id : idList) {
|
|
|
+ BusinessQuestionsAttentionUser info = new BusinessQuestionsAttentionUser();
|
|
|
+ info.setBusinessQuestionsId(id);
|
|
|
+ info.setUserId(user.getId());
|
|
|
+ list.add(info);
|
|
|
+ }
|
|
|
+ //删除原有收藏信息
|
|
|
+ for (BusinessQuestionsAttentionUser info : list) {
|
|
|
+ dao.deleteNotice(info);
|
|
|
+ }
|
|
|
+ //对问题进行收藏存储
|
|
|
+ dao.insertAttentionAll(list);
|
|
|
+ }
|
|
|
+}
|