Commit d95940e8 by 翁国栋

管理员删除附件

parent 11a4da75
...@@ -1355,4 +1355,33 @@ public class SpmkController { ...@@ -1355,4 +1355,33 @@ public class SpmkController {
} }
return ResultUtil.data("添加附件成功"); 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; ...@@ -12,6 +12,7 @@ import java.util.List;
/** /**
* 申请数据工具类 * 申请数据工具类
*
* @author wuqingjun * @author wuqingjun
* @email 284718418@qq.com * @email 284718418@qq.com
* @date 2022-07-13 10:05:49 * @date 2022-07-13 10:05:49
...@@ -44,45 +45,86 @@ public class RequestDataUtils { ...@@ -44,45 +45,86 @@ public class RequestDataUtils {
/** /**
* 审批详情 审批时添加 附件 * 审批详情 审批时添加 附件
*
* @param spmkApproveDetailSummary 审批详情数据 * @param spmkApproveDetailSummary 审批详情数据
* @param fileList 新增数据 * @param fileList 新增数据
* @throws Exception * @throws Exception
*/ */
public static Boolean addFileList(SpmkApproveDetailSummary spmkApproveDetailSummary, List<JSONObject> fileList) throws Exception { public static Boolean addFileList(SpmkApproveDetailSummary spmkApproveDetailSummary, List<JSONObject> fileList) throws Exception {
if(CollectionUtils.isEmpty(fileList)){ if (CollectionUtils.isEmpty(fileList)) {
return false; return false;
} }
log.info("fileList = {}",fileList); log.info("fileList = {}", fileList);
List<JSONObject> forms = jsonObject.parseArray(spmkApproveDetailSummary.getFroms(), JSONObject.class); List<JSONObject> forms = jsonObject.parseArray(spmkApproveDetailSummary.getFroms(), JSONObject.class);
if(CollectionUtils.isEmpty(forms)){ if (CollectionUtils.isEmpty(forms)) {
return false; return false;
} }
String inputId = ""; String inputId = "";
// 找到审批表单对应的附件节点 inputId // 找到审批表单对应的附件节点 inputId
for (JSONObject object:forms) { 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))*/){ 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(); inputId = object.get(FORMS_INPUTID_KEY).toString();
break; break;
} }
} }
if(StringUtils.isEmpty(inputId) || inputId.length() <= 0){ if (StringUtils.isEmpty(inputId) || inputId.length() <= 0) {
log.info("审批详情 >审批时添加附件 forms not file point."); log.info("审批详情 >审批时添加附件 forms not file point.");
return false; return false;
} }
log.info("forms = {}",forms); log.info("forms = {}", forms);
JSONObject requestData = jsonObject.parseObject(spmkApproveDetailSummary.getRequestData(), JSONObject.class); JSONObject requestData = jsonObject.parseObject(spmkApproveDetailSummary.getRequestData(), JSONObject.class);
if(StringUtils.isEmpty(requestData)){ if (StringUtils.isEmpty(requestData)) {
return false; return false;
} }
// 找到 申请数据 对应节点 的数据 // 找到 申请数据 对应节点 的数据
JSONObject value = (JSONObject)requestData.get(inputId); JSONObject value = (JSONObject) requestData.get(inputId);
JSONArray v = (JSONArray)value.get(FORMS_INPUTID_KEY_VALUE); JSONArray v = (JSONArray) value.get(FORMS_INPUTID_KEY_VALUE);
// 添加 申请数据 对应节点 的数据 // 添加 申请数据 对应节点 的数据
v.addAll(fileList); v.addAll(fileList);
log.info("requestData = {}",requestData); log.info("requestData = {}", requestData);
spmkApproveDetailSummary.setRequestData(requestData.toJSONString()); spmkApproveDetailSummary.setRequestData(requestData.toJSONString());
return true; 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