Commit a2d48c6f by 284718418@qq.com

当前审批人审批时添加附件审批

parent 2649f0ca
......@@ -9,6 +9,7 @@ import cn.timer.api.bean.zzgl.ZzglAuth;
import cn.timer.api.dao.spmk.*;
import cn.timer.api.dto.spmk.*;
import cn.timer.api.utils.redis.RedisUtil;
import cn.timer.api.utils.router.RequestDataUtils;
import com.baomidou.mybatisplus.core.toolkit.SerializationUtils;
import com.mysql.cj.util.StringUtils;
import net.sf.json.JSON;
......@@ -789,6 +790,7 @@ public class SpmkController {
.lambda()
.select(SpmkApproveDetailSummary::getId,
SpmkApproveDetailSummary::getRequestData,
SpmkApproveDetailSummary::getFroms,
SpmkApproveDetailSummary::getFlowChildren)
.eq(SpmkApproveDetailSummary::getApproveSummaryId, asId));
......@@ -846,8 +848,14 @@ public class SpmkController {
approvingDto.getUserList()
);
// 更新 flowChildren
SpmkApproveDetailSummary.builder().id(ad.getId()).flowChildren(JSONArray.fromObject(listFlowChildren).toString()).build().updateById();
SpmkApproveDetailSummary sadsUpdate = SpmkApproveDetailSummary.builder().id(ad.getId()).flowChildren(JSONArray.fromObject(listFlowChildren).toString()).build();
// 审批详情 审批时添加 附件
if(RequestDataUtils.addFileList(ad,approvingDto.getFileList())){
sadsUpdate.setRequestData(ad.getRequestData());
}
sadsUpdate.updateById();
//最后一条数据
FlowChildren fc = CollUtil.getLast(listFlowChildren);
if (fc.getExecute() == "2") {
......
......@@ -3,6 +3,7 @@ package cn.timer.api.dto.spmk;
import javax.validation.constraints.NotNull;
import cn.timer.api.config.exception.ValidationMsg;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
......@@ -45,4 +46,7 @@ public class ApprovingDto {
@ApiModelProperty(value = "被转派人数组 ", example = "数组")
private List<User> userList;
@ApiModelProperty(value = "申请数据 ", example = "申请数据", required = true)
private List<JSONObject> fileList;
}
package cn.timer.api.dto.spmk;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FromsFileValueData implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String file;
private String name;
}
package cn.timer.api.utils.router;
import cn.timer.api.bean.spmk.SpmkApproveDetailSummary;
import cn.timer.api.dto.spmk.FromsFileValueData;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* 申请数据工具类
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-07-13 10:05:49
*/
@Slf4j
public class RequestDataUtils {
/**
* 表单file类型
*/
private final static String FORMS_CLASS_NAME_KEY = "className";
private final static String FORMS_CLASS_NAME_VALUE = "file";
/**
* 表单label类型
*/
private final static String FORMS_DISPLAY_NAME_KEY = "displayName";
private final static String FORMS_DISPLAY_NAME_VALUE = "上传附件";
/**
* 表单inputId
*/
private final static String FORMS_INPUTID_KEY = "inputId";
/**
* 申请数据 file* value
*/
private final static String FORMS_INPUTID_KEY_VALUE = "value";
private static com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
/**
* 审批详情 审批时添加 附件
* @param spmkApproveDetailSummary 审批详情数据
* @param fileList 新增数据
* @throws Exception
*/
public static Boolean addFileList(SpmkApproveDetailSummary spmkApproveDetailSummary, List<JSONObject> fileList) throws Exception {
if(CollectionUtils.isEmpty(fileList)){
return false;
}
log.info("fileList = {}",fileList);
List<JSONObject> forms = jsonObject.parseArray(spmkApproveDetailSummary.getFroms(), JSONObject.class);
if(CollectionUtils.isEmpty(forms)){
return false;
}
String inputId = "";
// 找到审批表单对应的附件节点 inputId
for (JSONObject object:forms) {
if(FORMS_CLASS_NAME_VALUE.equals(object.get(FORMS_CLASS_NAME_KEY)) && FORMS_DISPLAY_NAME_VALUE.equals(object.get(FORMS_DISPLAY_NAME_KEY))){
inputId = object.get(FORMS_INPUTID_KEY).toString();
break;
}
}
if(StringUtils.isEmpty(inputId) || inputId.length() <= 0){
log.info("审批详情 >审批时添加附件 forms not file point.");
return false;
}
log.info("forms = {}",forms);
JSONObject requestData = jsonObject.parseObject(spmkApproveDetailSummary.getRequestData(), JSONObject.class);
if(StringUtils.isEmpty(requestData)){
return false;
}
// 找到 申请数据 对应节点 的数据
JSONObject value = (JSONObject)requestData.get(inputId);
JSONArray v = (JSONArray)value.get(FORMS_INPUTID_KEY_VALUE);
// 添加 申请数据 对应节点 的数据
v.addAll(fileList);
log.info("requestData = {}",requestData);
spmkApproveDetailSummary.setRequestData(requestData.toJSONString());
return true;
}
}
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