OA无流程表单公用删除接口
This commit is contained in:
parent
d6bdd3605f
commit
916a133c0c
|
@ -0,0 +1,51 @@
|
||||||
|
package com.hzya.frame.seeyon.dao;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||||
|
import com.hzya.frame.seeyon.entity.CapFormDefinitionEntity;
|
||||||
|
import com.hzya.frame.seeyon.entity.CtpFileEntity;
|
||||||
|
import com.hzya.frame.seeyon.paybill.entity.PayBillEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content OA字段配置表DAO
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 16:00
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface ICapFormDefinitionDao extends IBaseDao<CapFormDefinitionEntity,String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 通过模版编号获取无流程表单配置信息
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 16:02
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
List<CapFormDefinitionEntity> getFormFiled(CapFormDefinitionEntity fieldInfo);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 通过主键删除单据数据
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 17:04
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
int deleteByKey(CapFormDefinitionEntity fieldInfo);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 通过客户传递的数据值查询古河条件的数据
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 17:05
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
List<CapFormDefinitionEntity> getFormFiledByFileValue(CapFormDefinitionEntity fieldInfo);
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.hzya.frame.seeyon.dao.impl;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||||
|
import com.hzya.frame.seeyon.dao.ICapFormDefinitionDao;
|
||||||
|
import com.hzya.frame.seeyon.dao.ICtpFileDao;
|
||||||
|
import com.hzya.frame.seeyon.entity.CapFormDefinitionEntity;
|
||||||
|
import com.hzya.frame.seeyon.entity.CtpFileEntity;
|
||||||
|
import com.hzya.frame.seeyon.paybill.entity.PayBillEntity;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content OA字段配置表DAO
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 16:00
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Repository(value = "CapFormDefinitionDaoImpl")
|
||||||
|
public class CapFormDefinitionDaoImpl extends MybatisGenericDao<CapFormDefinitionEntity,String> implements ICapFormDefinitionDao {
|
||||||
|
@DS("#fieldInfo.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public List<CapFormDefinitionEntity> getFormFiled(CapFormDefinitionEntity fieldInfo) {
|
||||||
|
return (List<CapFormDefinitionEntity>) selectList("com.hzya.frame.seeyon.entity.CapFormDefinitionEntity.CapFormDefinitionEntity_list_base",fieldInfo);
|
||||||
|
}
|
||||||
|
@DS("#fieldInfo.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public int deleteByKey(CapFormDefinitionEntity fieldInfo) {
|
||||||
|
return super.delete("com.hzya.frame.seeyon.entity.CapFormDefinitionEntity.CapFormDefinitionEntity_delete",fieldInfo);
|
||||||
|
}
|
||||||
|
@DS("#fieldInfo.dataSourceCode")
|
||||||
|
@Override
|
||||||
|
public List<CapFormDefinitionEntity> getFormFiledByFileValue(CapFormDefinitionEntity fieldInfo) {
|
||||||
|
return (List<CapFormDefinitionEntity>) selectList("com.hzya.frame.seeyon.entity.CapFormDefinitionEntity.CapFormDefinitionEntity_list_table_info",fieldInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.hzya.frame.seeyon.entity;
|
||||||
|
|
||||||
|
import com.hzya.frame.web.entity.BaseEntity;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content OA字段配置表
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 15:48
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CapFormDefinitionEntity extends BaseEntity {
|
||||||
|
private String fieldInfo;//字段属性定义
|
||||||
|
private String viewInfo;//视图权限定义
|
||||||
|
private String appbindInfo;//应用绑定定义
|
||||||
|
private String tableName;//表名
|
||||||
|
private String fieldName;//字段名称
|
||||||
|
private String fieldValue;//字段值
|
||||||
|
|
||||||
|
public String getFieldValue() {
|
||||||
|
return fieldValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldValue(String fieldValue) {
|
||||||
|
this.fieldValue = fieldValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTableName() {
|
||||||
|
return tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableName(String tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldName() {
|
||||||
|
return fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldName(String fieldName) {
|
||||||
|
this.fieldName = fieldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldInfo() {
|
||||||
|
return fieldInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldInfo(String fieldInfo) {
|
||||||
|
this.fieldInfo = fieldInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getViewInfo() {
|
||||||
|
return viewInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewInfo(String viewInfo) {
|
||||||
|
this.viewInfo = viewInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppbindInfo() {
|
||||||
|
return appbindInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppbindInfo(String appbindInfo) {
|
||||||
|
this.appbindInfo = appbindInfo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.hzya.frame.seeyon.entity.CapFormDefinitionEntity">
|
||||||
|
<resultMap id="get-CapFormDefinitionEntity-result" type="com.hzya.frame.seeyon.entity.CapFormDefinitionEntity">
|
||||||
|
<!--主键 -->
|
||||||
|
<result property="id" column="id" />
|
||||||
|
<result property="fieldInfo" column="field_info" />
|
||||||
|
<result property="viewInfo" column="view_info" />
|
||||||
|
<result property="appbindInfo" column="appbind_info" />
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<sql id="CapFormDefinitionEntity_sql">
|
||||||
|
id,
|
||||||
|
field_info,
|
||||||
|
view_info,
|
||||||
|
appbind_info
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询 采用==查询 -->
|
||||||
|
<select id="CapFormDefinitionEntity_list_base" resultMap="get-CapFormDefinitionEntity-result" parameterType="com.hzya.frame.seeyon.entity.CapFormDefinitionEntity">
|
||||||
|
select
|
||||||
|
<include refid="CapFormDefinitionEntity_sql"/>
|
||||||
|
from
|
||||||
|
cap_form_definition
|
||||||
|
<trim prefix="where" prefixOverrides="and">
|
||||||
|
<if test="appbindInfo != null and appbindInfo != ''">and APPBIND_INFO like '%${appbindInfo}%'</if>
|
||||||
|
</trim>
|
||||||
|
</select>
|
||||||
|
<!-- 查询 采用==查询 -->
|
||||||
|
<select id="CapFormDefinitionEntity_list_table_info" resultMap="get-CapFormDefinitionEntity-result" parameterType="com.hzya.frame.seeyon.entity.CapFormDefinitionEntity">
|
||||||
|
select id from ${tableName} where ${fieldName} = #{fieldValue}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<delete id="CapFormDefinitionEntity_delete" parameterType="com.hzya.frame.basedao.entity.RequestDisposeEntity">
|
||||||
|
delete from ${tableName} where ${fieldName} = #{id}
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.hzya.frame.seeyon.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 无流程表单公用service
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 14:53
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface INoProcessService {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 无流程删除通用接口
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 15:08
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
JsonResultEntity DeleteProcessField(JSONObject requestData);
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.hzya.frame.seeyon.service.impl;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hzya.frame.seeyon.dao.ICapFormDefinitionDao;
|
||||||
|
import com.hzya.frame.seeyon.entity.CapFormDefinitionEntity;
|
||||||
|
import com.hzya.frame.seeyon.service.INoProcessService;
|
||||||
|
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @content 无流程表单公用service
|
||||||
|
* @className: Administrator
|
||||||
|
* @author laborer
|
||||||
|
* @date 2024-09-09 14:53
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service(value = "NoProcessServiceImpl")
|
||||||
|
public class NoProcessServiceImpl implements INoProcessService {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(NoProcessServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
private ICapFormDefinitionDao capFormDefinitionDao;
|
||||||
|
@Override
|
||||||
|
public JsonResultEntity DeleteProcessField(JSONObject requestData) {
|
||||||
|
List<String>count =new ArrayList<>();
|
||||||
|
JSONObject jsonStrObj = requestData.getJSONObject("jsonStr");
|
||||||
|
String formCode = jsonStrObj.getString("formCode");
|
||||||
|
String fieldName = jsonStrObj.getString("fieldName");
|
||||||
|
String fieldValue = jsonStrObj.getString("fieldValue");
|
||||||
|
if(StrUtil.isEmpty(formCode)){
|
||||||
|
return new JsonResultEntity("表单编码不能为空:formCode",false);
|
||||||
|
}
|
||||||
|
if(StrUtil.isEmpty(fieldName)){
|
||||||
|
return new JsonResultEntity("字段名称不能为空:fieldName",false);
|
||||||
|
}
|
||||||
|
if(StrUtil.isEmpty(fieldValue)){
|
||||||
|
return new JsonResultEntity("字段值不能为空:fieldValue",false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//通过表单编号获取表单字段信息
|
||||||
|
CapFormDefinitionEntity fieldInfo = new CapFormDefinitionEntity();
|
||||||
|
fieldInfo.setAppbindInfo(formCode);
|
||||||
|
fieldInfo.setDataSourceCode("djoatest");
|
||||||
|
List<CapFormDefinitionEntity>capFormDefinitionEntityList = capFormDefinitionDao.getFormFiled(fieldInfo);
|
||||||
|
if(CollectionUtils.isEmpty(capFormDefinitionEntityList)){
|
||||||
|
return new JsonResultEntity("通过表单编号查询表单有误,请检查表单编号:"+formCode,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
capFormDefinitionEntityList.forEach(item->{
|
||||||
|
String appbindInfo = item.getAppbindInfo();
|
||||||
|
//格式化字段信息
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(appbindInfo);
|
||||||
|
boolean queryFlag = false;
|
||||||
|
//如果模版编号相同则继续删除,反正跳过
|
||||||
|
if(formCode.equals(jsonObject.getString("formCode"))){
|
||||||
|
JSONObject field = JSONObject.parseObject(item.getFieldInfo());
|
||||||
|
JSONObject frontFormmain = field.getJSONObject("front_formmain");
|
||||||
|
JSONArray formsons = field.getJSONArray("formsons");
|
||||||
|
JSONArray fieldInfoTable = frontFormmain.getJSONArray("fieldInfo");
|
||||||
|
//验证需要删除的条件字段在表单属性中是否存在
|
||||||
|
for (int i = 0; i < fieldInfoTable.size(); i++) {
|
||||||
|
JSONObject fieldInfoTableObj = fieldInfoTable.getJSONObject(i);
|
||||||
|
String name = fieldInfoTableObj.getString("name");
|
||||||
|
//如果表单属性中存在该字段则验证通过,如果不存在直接返回错误
|
||||||
|
if(name.equals(fieldName)){
|
||||||
|
queryFlag = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//验证通过获取数据库表名称进行数据删除
|
||||||
|
if(queryFlag){
|
||||||
|
String tableName = frontFormmain.getString("tableName");
|
||||||
|
//如果主表名称获取主表的主键进行数据删除
|
||||||
|
fieldInfo.setTableName(tableName);
|
||||||
|
fieldInfo.setFieldName(fieldName);
|
||||||
|
fieldInfo.setFieldValue(fieldValue);
|
||||||
|
List<CapFormDefinitionEntity>dataFormList = capFormDefinitionDao.getFormFiledByFileValue(fieldInfo);
|
||||||
|
if(CollectionUtils.isNotEmpty(dataFormList)){
|
||||||
|
dataFormList.forEach(item1->{
|
||||||
|
String id = item1.getId();
|
||||||
|
count.add(id);
|
||||||
|
fieldInfo.setFieldName("id");
|
||||||
|
fieldInfo.setId(id);
|
||||||
|
capFormDefinitionDao.deleteByKey(fieldInfo);
|
||||||
|
//循环该表单下面的所有子表信息进行子表删除
|
||||||
|
if(CollectionUtils.isNotEmpty(formsons)){
|
||||||
|
formsons.forEach(formsonsItem->{
|
||||||
|
JSONObject jsonObjectBoddy = JSONObject.parseObject(formsonsItem.toString());
|
||||||
|
String bodyTableName = jsonObjectBoddy.getString("tableName");
|
||||||
|
fieldInfo.setTableName(bodyTableName);
|
||||||
|
fieldInfo.setFieldName("formmain_id");
|
||||||
|
fieldInfo.setId(id);
|
||||||
|
capFormDefinitionDao.deleteByKey(fieldInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return new JsonResultEntity("删除成功,删除的数据ID"+ JSON.toJSONString(count),true);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue