Commit 502b1851 authored by 刘凡's avatar 刘凡

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents 3cdd5558 ee0fe21e
package com.yeejoin.amos.boot.module.jg.api.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class TaskModelDto {
private Date flowCreateDate;
private String taskName;
private String taskCode;
private String taskContent;
private String taskDesc;
private String taskType;
private String taskTypeLabel;
private String relationId;
private String executeUserIds;
private Integer taskStatus;
private String taskStatusLabel;
private String startUserId;
private String startUser;
private String startUserCompanyName;
private Date startDate;
private Date createDate;
private String routePath;
/*
** 对象实体
*/
private Object model;
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.aspose.words.SaveFormat; import com.aspose.words.SaveFormat;
...@@ -11,6 +12,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -11,6 +12,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.dto.ByteArrayMultipartFile; import com.yeejoin.amos.boot.module.jg.api.dto.ByteArrayMultipartFile;
import com.yeejoin.amos.boot.module.jg.api.dto.JgEquipTransferDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgEquipTransferDto;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransferService; import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransferService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
...@@ -24,9 +26,13 @@ import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils; ...@@ -24,9 +26,13 @@ import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import com.yeejoin.amos.boot.module.jg.flc.api.fegin.PrivilegeFeginService; import com.yeejoin.amos.boot.module.jg.flc.api.fegin.PrivilegeFeginService;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -37,12 +43,17 @@ import org.springframework.util.CollectionUtils; ...@@ -37,12 +43,17 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.print.Book; import java.awt.print.Book;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URLEncoder;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -579,4 +590,121 @@ public class CommonServiceImpl implements ICommonService { ...@@ -579,4 +590,121 @@ public class CommonServiceImpl implements ICommonService {
jgEnableDisableServiceImpl.saveOrUpdate(jsonObject); jgEnableDisableServiceImpl.saveOrUpdate(jsonObject);
} }
} }
public void deleteTaskModel(String id){
List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(id).getResult();
TaskV2Model model = result.stream().sorted((r1, r2) -> r2.getCreateDate().compareTo(r1.getCreateDate())) // 按时间降序排序
.findFirst()
.orElse(null);
Systemctl.taskV2Client.delete(String.valueOf(model.getSequenceNbr()));
}
/*
* 待办新增接口
**/
public void buildTaskModel(TaskModelDto obj){
TaskV2Model model = new TaskV2Model();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String urlParams = "";
try {
urlParams = "&"+toQueryParams(obj.getModel());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
model.setRoutePath(obj.getRoutePath()+urlParams);
BeanUtil.copyProperties(model,obj);
model.setFlowStatus(0);
model.setFlowInstanceId(model.getRelationId());
model.setTaskTitle(obj.getStartUser()+"发起了"+obj.getTaskName());
model.setTaskSource("workFlow");
model.setExtras(JSON.toJSONString(obj.getModel()));
// model.setTerminal(params.getOrDefault("terminal","WEB").toString());
model.setCreateDate(new Date());
model.setRecUserId(reginParams.getUserModel().getUserId());
Systemctl.taskV2Client.create(model);
}
/*
* 待办编辑接口
*
*
**/
public TaskV2Model updateTaskModel(Map<String, Object> params){
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(params.get("relationId").toString()).getResult();
TaskV2Model model = result.stream().sorted((r1, r2) -> r2.getSequenceNbr().compareTo(r2.getSequenceNbr())) // 按时间降序排序
.findFirst()
.orElse(null);
if (model == null ){
return null;
}
model.setTaskStatus(Integer.valueOf(params.get("taskStatus").toString()));
model.setTaskStatusLabel(params.get("taskStatusLabel").toString());
model.setEndUserId(reginParams.getUserModel().getUserId());
model.setEndDate(new Date());
model.setRoutePath(model.getRoutePath().replace("roleIds","role").replace("edit","look"));
Systemctl.taskV2Client.update(model,model.getSequenceNbr());
//修改model并返回 用于组装新待办
model.setEndUserId(null);
model.setTaskStatus(null);
model.setEndDate(null);
model.setSequenceNbr(null);
model.setCreateDate(new Date());
model.setStartDate(new Date());
return model;
}
public void rollbackTask(String id){
List<TaskV2Model> result =Systemctl.taskV2Client.selectListByRelationId(id).getResult();
List<TaskV2Model> list = result.stream().sorted((r1, r2) -> r2.getCreateDate().compareTo(r1.getCreateDate())).collect(Collectors.toList());
TaskV2Model model = list.get(0);
Systemctl.taskV2Client.delete(String.valueOf(model.getSequenceNbr()));
TaskV2Model lastTaskModel = list.get(1);
model.setEndUserId(null);
model.setEndDate(null);
model.setFlowStatus(0);
model.setRoutePath(model.getRoutePath().replace("role","roleIds").replace("look","edit"));
Systemctl.taskV2Client.update(model,model.getSequenceNbr());
}
public <T> String toQueryParams(T obj) throws UnsupportedEncodingException {
StringBuilder sb = new StringBuilder();
for (Class<?> clazz = obj.getClass(); !clazz.equals(Object.class); clazz = clazz.getSuperclass()) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
if (!Modifier.isStatic(field.getModifiers())) {
field.setAccessible(true);
try {
Object value = field.get(obj);
if (value != null && !"".equals(value)) {
String encodedValue = URLEncoder.encode(value.toString(), "UTF-8");
sb.append(field.getName()).append('=').append(encodedValue).append('&');
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
}
return sb.length() > 0 ? sb.substring(0, sb.length() - 1) : "";
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment