Commit d95940e8 by 翁国栋

管理员删除附件

parent 11a4da75
......@@ -1355,4 +1355,33 @@ public class SpmkController {
}
return ResultUtil.data("添加附件成功");
}
@PostMapping(value = "/del_file")
@ApiOperation(value = "添加附件", httpMethod = "POST", notes = "添加附件")
@Log(title = "审批-添加附件", businessType = BusinessType.OTHER)
public Result<Object> delFileList(@CurrentUser UserBean userBean,@RequestBody ApprovingDto approvingDto) {
QyzxEmpEntAsso ent = QyzxEmpEntAsso.builder().build().selectOne(new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode()).eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum()));
if(ent != null) {
if(ent.getUserType() == 2) {
return ResultUtil.error("暂无权限");
}
}
SpmkApproveDetailSummary ad = SpmkApproveDetailSummary.builder().build().selectOne(new QueryWrapper<SpmkApproveDetailSummary>()
.lambda()
.select(SpmkApproveDetailSummary::getId,
SpmkApproveDetailSummary::getRequestData,
SpmkApproveDetailSummary::getFroms,
SpmkApproveDetailSummary::getFlowChildren)
.eq(SpmkApproveDetailSummary::getId, approvingDto.getAsId()));
// 审批详情 审批时添加 附件
try {
if(RequestDataUtils.delFileList(ad,approvingDto.getFileList())){
ad.updateById();
}
} catch (Exception e) {
e.printStackTrace();
}
return ResultUtil.data("删除附件成功");
}
}
......@@ -12,6 +12,7 @@ import java.util.List;
/**
* 申请数据工具类
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-07-13 10:05:49
......@@ -19,70 +20,111 @@ import java.util.List;
@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";
/**
* 表单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();
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;
}
/**
* 审批详情 审批时添加 附件
*
* @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;
}
/**
* 审批详情 审批时添加 附件
*
* @param spmkApproveDetailSummary 审批详情数据
* @param fileList 新增数据
* @throws Exception
*/
public static Boolean delFileList(SpmkApproveDetailSummary spmkApproveDetailSummary, List<JSONObject> fileList) throws Exception {
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.clear();
if(fileList.size()>=0) {
v.addAll(fileList);
}
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