屹宏电梯阶段图节点台账信息开发

main
youHong.ai 2023-02-08 16:22:29 +08:00
parent 1e754843ff
commit 65ebec9fa3
16 changed files with 308 additions and 28 deletions

View File

@ -2603,6 +2603,17 @@ public class Util extends weaver.general.Util {
return mdu.getModeDataNewId(tableName, formModeId, userId, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString());
}
/**
* ID
*
* @param tableName
* @param userId ID
* @return ID
*/
public static int getModeDataId(String tableName, int userId) {
return mdu.getModeDataNewId(tableName, Integer.parseInt(getModeIdByTableName(tableName)), userId, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString());
}
/**
*
*
@ -2614,6 +2625,17 @@ public class Util extends weaver.general.Util {
MODE_RIGHT_INFO.rebuildModeDataShareByEdit(userId, formId, id);
}
/**
*
*
* @param userId ID
* @param tableName
* @param id ID
*/
public static void rebuildModeDataShare(Integer userId, String tableName, Integer id) {
MODE_RIGHT_INFO.rebuildModeDataShareByEdit(userId, Integer.parseInt(getModeIdByTableName(tableName)), id);
}
/**
*
*
@ -2625,6 +2647,17 @@ public class Util extends weaver.general.Util {
threadPool.execute(() -> Util.rebuildModeDataShare(userId, formId, id));
}
/**
*
*
* @param userId ID
* @param tableName
* @param id ID
*/
public static void rebuildModeDataShareByAsync(Integer userId, String tableName, Integer id) {
threadPool.execute(() -> Util.rebuildModeDataShare(userId, Integer.parseInt(getModeIdByTableName(tableName)), id));
}
/**
*
*
@ -2641,6 +2674,22 @@ public class Util extends weaver.general.Util {
}
/**
*
*
* @param userId ID
* @param tableName
* @param idList ID
*/
public static void rebuildModeDataShareByAsyncList(Integer userId, String tableName, List<Integer> idList) {
threadPool.execute(() -> {
for (Integer id : idList) {
Util.rebuildModeDataShare(userId, Integer.parseInt(getModeIdByTableName(tableName)), id);
}
});
}
/**
*
*
@ -3528,7 +3577,7 @@ public class Util extends weaver.general.Util {
key:hah
value:haode*/
// 最终通过反射调用weaver.aiyh_jitu.pushdata.service.GetAssignProcessorProcessorImpl类将参数传递给这个类
//String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
// String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
// "(?<value>(`([\\s():/\\t\\-&*'?$#={ }.\\w\\u4E00-\\u9FA5]*)`|" +
// "((#(\\{|sql\\{))?([():/\\-$#={ }.\\w\\u4E00-\\u9FA5?]+)?}?)))&?";
String pattern = "&?(?<key>([#.\\w\\u4E00-\\u9FA5]+))=" +
@ -3594,9 +3643,11 @@ public class Util extends weaver.general.Util {
}
public static String selectBillTableByFromId(String fromId){
return mapper.selectBillTableByFromId(fromId);
public static String selectBillTableByFromId(String fromId) {
return mapper.selectBillTableByFromId(fromId);
}
public static void deleteModeId(String tableName, Integer dataId) {
mapper.deleteModeId(tableName, dataId);
}
}

View File

@ -0,0 +1,19 @@
package aiyh.utils.annotation.recordset;
import java.lang.annotation.*;
/**
* <h1>sql</h1>
*
* <p>create: 2023-02-07 17:31</p>
*
* @author youHong.ai
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface SqlDbFieldAnn {
String value();
}

View File

@ -138,15 +138,18 @@ public interface UtilMapper {
@ParamMapper("configTableName") String configTableName);
/**
*
* <h2>selectBillTableByFromId fromIdbillTable</h2>
* <i>2023/2/6 13:40</i>
*************************************************************
* @author youHong.ai
*******************************************
* ************************************************************
*
* @param fromId fromId
* @return String
* @author youHong.ai
* ******************************************
*/
@Select("select * from workflow_bill where id = #{fromId}")
String selectBillTableByFromId(@ParamMapper("fromId") String fromId);
@Delete("delete from $t{tableName} where id = #{dataId}")
void deleteModeId(@ParamMapper("tableName") String tableName, @ParamMapper("dataId") Integer dataId);
}

View File

@ -18,9 +18,11 @@ import java.lang.reflect.Field;
public class BooleanTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
return getBoolean(declaredField, rs.getString(fieldName));
return getBoolean(declaredField, GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
}
@Override
public Object getValue(RecordSet rs, int index, Field declaredField) {
return getBoolean(declaredField, rs.getString(index));
@ -28,7 +30,7 @@ public class BooleanTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
return getBoolean(declaredField, rs.getString(fieldName));
return getBoolean(declaredField, GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
}
@Override

View File

@ -26,7 +26,7 @@ public class DataTypeHandler implements TypeHandler {
if (annotation != null) {
String value = annotation.value();
try {
date = new SimpleDateFormat(value).parse(rs.getString(fieldName));
date = new SimpleDateFormat(value).parse(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
} catch (ParseException e) {
e.printStackTrace();
throw new TypeNonsupportException("Failed to convert [" + rs.getString(fieldName) + "] to a Date object as [" + value + "]!!");
@ -64,7 +64,7 @@ public class DataTypeHandler implements TypeHandler {
if (annotation != null) {
String value = annotation.value();
try {
date = new SimpleDateFormat(value).parse(rs.getString(fieldName));
date = new SimpleDateFormat(value).parse(GetRsValueUtil.getRsValue(rs, fieldName, declaredField));
} catch (ParseException e) {
e.printStackTrace();
throw new TypeNonsupportException("Failed to convert [" + rs.getString(fieldName) + "] to a Date object as [" + value + "]!!");
@ -91,4 +91,6 @@ public class DataTypeHandler implements TypeHandler {
}
return date;
}
}

View File

@ -16,7 +16,7 @@ import java.lang.reflect.Field;
public class FloatTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(fieldName), "0.0");
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
return Float.parseFloat(string);
}
@ -28,7 +28,7 @@ public class FloatTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(fieldName), "0.0");
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "0.0");
return Float.parseFloat(string);
}
@ -37,4 +37,5 @@ public class FloatTypeHandler implements TypeHandler {
String string = Util.null2DefaultStr(rs.getString(index), "0.0");
return Float.parseFloat(string);
}
}

View File

@ -0,0 +1,44 @@
package aiyh.utils.recordset;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import org.h2.util.StringUtils;
import org.jetbrains.annotations.Nullable;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import java.lang.reflect.Field;
/**
* <h1>rs</h1>
*
* <p>create: 2023-02-07 17:36</p>
*
* @author youHong.ai
*/
public class GetRsValueUtil {
@Nullable
public static String getRsValue(RecordSet rs, String fieldName, Field declaredField) {
String value = rs.getString(fieldName);
if(StringUtils.isNullOrEmpty(value) && declaredField != null){
SqlDbFieldAnn annotation = declaredField.getAnnotation(SqlDbFieldAnn.class);
if (annotation != null){
value = rs.getString(annotation.value());
}
}
return value;
}
@Nullable
public static String getRsValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String value = rs.getString(fieldName);
if(StringUtils.isNullOrEmpty(value) && declaredField != null){
SqlDbFieldAnn annotation = declaredField.getAnnotation(SqlDbFieldAnn.class);
if (annotation != null){
value = rs.getString(annotation.value());
}
}
return value;
}
}

View File

@ -14,7 +14,7 @@ import java.lang.reflect.Field;
public class IntegerTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(fieldName), "-1");
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "-1");
if (string.contains(".")) {
string = string.substring(0, string.indexOf("."));
}
@ -32,7 +32,7 @@ public class IntegerTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
String string = Util.null2DefaultStr(rs.getString(fieldName), "-1");
String string = Util.null2DefaultStr(GetRsValueUtil.getRsValue(rs, fieldName, declaredField), "-1");
if (string.contains(".")) {
string = string.substring(0, string.indexOf("."));
}

View File

@ -13,7 +13,7 @@ import java.lang.reflect.Field;
public class StringTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSet rs, String fieldName, Field declaredField) {
return rs.getString(fieldName);
return GetRsValueUtil.getRsValue(rs, fieldName, declaredField);
}
@Override
@ -23,7 +23,7 @@ public class StringTypeHandler implements TypeHandler {
@Override
public Object getValue(RecordSetTrans rs, String fieldName, Field declaredField) {
return rs.getString(fieldName);
return GetRsValueUtil.getRsValue(rs, fieldName, declaredField);
}
@Override

View File

@ -4,7 +4,7 @@ import aiyh.utils.Util;
import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper;
import weaver.youhong.ai.yihong.formmode.stagediagram.service.ModeExpandSaveService;
import java.util.HashMap;
import java.util.Map;
@ -21,15 +21,17 @@ public class ModeExpandSaveAction extends AbstractModeExpandJavaCodeNew {
private final Logger log = Util.getLogger();
private final ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class);
@Override
public Map<String, String> doModeExpand(Map<String, Object> param) {
Map<String, String> result = new HashMap<>();
Map<String, String> result = new HashMap<>(8);
ModeExpandSaveService service = new ModeExpandSaveService();
try {
log.info("自定义接口保存动作参数: " + JSON.toJSONString(param));
}catch (Exception e){
result.put("errmsg",e.getMessage());
service.updateStageDiagramView(param,
"STAGE_DIAGRAM_AMOUNT_TABLE", "STAGE_DIAGRAM_PROJECT_ID_FIELD",
"STAGE_DIAGRAM_AMOUNT_FIELD");
} catch (Exception e) {
result.put("errmsg", e.getMessage());
result.put("flag", "false");
log.error("建模自定义保存接口错误:" + e.getMessage() + Util.getErrString(e));
}

View File

@ -0,0 +1,38 @@
package weaver.youhong.ai.yihong.formmode.stagediagram.dto;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* <h1></h1>
*
* <p>create: 2023/2/8 10:53</p>
*
* @author youHong.ai
*/
@Setter
@Getter
@ToString
public class StageNodeInfo {
/**
* id
*/
private Integer id;
/**
* id
*/
private String projectId;
/**
*
*/
private String amount;
/**
*
*/
private String currentNode;
}

View File

@ -1,6 +1,12 @@
package weaver.youhong.ai.yihong.formmode.stagediagram.mapper;
import aiyh.utils.annotation.recordset.ParamMapper;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import aiyh.utils.annotation.recordset.Update;
import weaver.youhong.ai.yihong.formmode.stagediagram.dto.StageNodeInfo;
import java.util.Map;
/**
* <h1></h1>
@ -11,6 +17,47 @@ import aiyh.utils.annotation.recordset.SqlMapper;
*/
@SqlMapper
public class ModeExpandSaveActionMapper {
public interface ModeExpandSaveActionMapper {
/**
* <h2></h2>
*
* @param projectId id
* @return
*/
@Select("select * from uf_stage_node_info where project_id = #{projectId}")
StageNodeInfo selectStageNodeInfoByProjectId(@ParamMapper("projectId") String projectId);
/**
* <h2>ID </h2>
*
* @param onlyMark
* @return id
*/
@Select("select id from uf_yh_stage_diagram where only_mark = #{onlyMark}")
Integer selectConfigMainId(@ParamMapper("onlyMark") String onlyMark);
/**
* <h2></h2>
*
* @param formId id
* @return id
*/
// @Select("select * from uf_yh_stage_diagram_dt1 where mainid = #{mainId} and model_table = #{formId]")
// Map<String, Object> selectDetailConfig(@ParamMapper("mainId") Integer mainId, @ParamMapper("formId") String formId);
@Select("select * from uf_yh_stage_diagram_dt1 where model_table = #{formId}")
Map<String, Object> selectDetailConfig(@ParamMapper("formId") String formId);
@Select("select $t{amountField} from $t{amountTable} where $t{projectIdField} = #{projectId}")
String selectAmountByProjectId(@ParamMapper("projectId") String projectId,
@ParamMapper("projectIdField") String projectIdField,
@ParamMapper("amountTable") String amountTable,
@ParamMapper("amountField") String amountField);
@Update("update uf_stage_node_info set project_id = #{projectId}, amount = #{amount}, " +
"current_node = #{nodeName} where id = #{dataId}")
boolean updateStageNodeInfo(@ParamMapper("dataId") Integer dataId,
@ParamMapper("projectId") String projectId,
@ParamMapper("nodeName") String nodeName,
@ParamMapper("amount") String amount);
}

View File

@ -2,15 +2,18 @@ package weaver.youhong.ai.yihong.formmode.stagediagram.service;
import aiyh.utils.Util;
import cn.hutool.core.lang.Assert;
import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import weaver.youhong.ai.yihong.formmode.stagediagram.dto.StageNodeInfo;
import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* <h1>service</h1>
@ -26,15 +29,56 @@ public class ModeExpandSaveService {
private final ModeExpandSaveActionMapper mapper = Util.getMapper(ModeExpandSaveActionMapper.class);
public void updateStageDiagramView(String projectFieldMark, Map<String, Object> param){
public void updateStageDiagramView(Map<String, Object> param,
String amountTable,
String projectIdField,
String amountField) {
/* ******************* 查询当前节点对应的projectId ******************* */
String stageDiagramProjectFieldName = Util.getCusConfigValue(projectFieldMark);
String formId = Util.null2String(param.get("formId"));
Map<String, Object> currentNodeConfig = mapper.selectDetailConfig(formId);
// String stageDiagramProjectFieldName = Util.getCusConfigValue(projectFieldMark);
String stageDiagramProjectFieldName = Util.null2String(currentNodeConfig.get("projectFieldName"));
Assert.notBlank(stageDiagramProjectFieldName, "cna not find projectFieldMark from uf_cus_dev_config! the config can not be null!");
RequestInfo requestInfo = (RequestInfo) param.get("RequestInfo");
Map<String, String> mainTableValue = getMainTableValue(requestInfo);
String projectId = mainTableValue.get(stageDiagramProjectFieldName);
log.info("主表数据:" + JSON.toJSONString(mainTableValue));
// 获取当前模块id
/* ******************* 查询台账中对应的project是否存在, 台账中不存在则插入,存在则更新 ******************* */
StageNodeInfo nodeInfo = mapper.selectStageNodeInfoByProjectId(projectId);
log.info("查询到的nodeINFo数据:" + JSON.toJSONString(nodeInfo));
if (Objects.isNull(nodeInfo)) {
// 不存在项目信息在台账中插入项目信息到台账信息中
Integer dataId = Util.getModeDataId("uf_stage_node_info", 1);
// 查询配置表信息
// Integer mainId = mapper.selectConfigMainId(Util.getCusConfigValue(onlyMarkCusMark));
// Map<String, Object> currentNodeConfig = mapper.selectDetailConfig(mainId, formId);
String nodeName = (String) currentNodeConfig.get("nodeName");
log.info("节点名称: " + nodeName);
String amount = mapper.selectAmountByProjectId(projectId,
Util.getCusConfigValueNullOrEmpty(projectIdField, ""),
Util.getCusConfigValueNullOrEmpty(amountTable, ""),
Util.getCusConfigValueNullOrEmpty(amountField, ""));
boolean update = mapper.updateStageNodeInfo(dataId, projectId, nodeName, amount);
if (!update) {
Util.deleteModeId("uf_stage_node_info", dataId);
} else {
Util.rebuildModeDataShare(1, Integer.parseInt(Util.getModeIdByTableName("uf_stage_node_info")),
dataId);
}
} else {
// 存在,更新当前项目的节点信息
Integer dataId = nodeInfo.getId();
// Integer mainId = mapper.selectConfigMainId(Util.getCusConfigValue(onlyMarkCusMark));
// Map<String, Object> currentNodeConfig = mapper.selectDetailConfig(mainId, formId);
String nodeName = (String) currentNodeConfig.get("nodeName");
String amount = mapper.selectAmountByProjectId(projectId,
Util.getCusConfigValueNullOrEmpty(projectIdField, ""),
Util.getCusConfigValueNullOrEmpty(amountTable, ""),
Util.getCusConfigValueNullOrEmpty(amountField, ""));
mapper.updateStageNodeInfo(dataId, projectId, nodeName, amount);
}
}
@ -54,7 +98,7 @@ public class ModeExpandSaveService {
if (null == propertyArr) {
return Collections.emptyMap();
}
Map<String, String> mainTable = new HashMap<>();
Map<String, String> mainTable = new HashMap<>(8);
for (Property property : propertyArr) {
String fieldName = property.getName();
String value = property.getValue();

View File

@ -72,4 +72,11 @@ public class UtilTest extends BaseTest {
"3\t7738\t看剧方\t加上撒u给你\t真个吧\t736\n" +
"4\t83\t就啊啥地方\t纪念活动\t你先给你\t6383";
}
@Test
public void testResUtil(){
TransTestMapper mapper = Util.getMapper(TransTestMapper.class);
System.out.println(mapper.selectStudent());
}
}

View File

@ -1,6 +1,7 @@
package youhong.ai.pcn.mapper;
import aiyh.utils.annotation.recordset.Insert;
import aiyh.utils.annotation.recordset.Select;
import aiyh.utils.annotation.recordset.SqlMapper;
import youhong.ai.pcn.pojo.Student;
@ -17,4 +18,10 @@ public interface TransTestMapper {
@Insert("insert into test_trans (name,age,sex) values (#{name},#{age},#{sex})")
boolean insertStudent(Student student);
@Select("select id, tablename a, namelabel b, uuid c from workflow_bill where id = -43")
Student selectStudent();
}

View File

@ -1,7 +1,9 @@
package youhong.ai.pcn.pojo;
import aiyh.utils.annotation.recordset.SqlDbFieldAnn;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* <h1></h1>
@ -13,9 +15,20 @@ import lombok.Setter;
@Getter
@Setter
@ToString
public class Student {
private int id;
@SqlDbFieldAnn("a")
private String name;
@SqlDbFieldAnn("b")
private String test;
@SqlDbFieldAnn("c")
private String bcd;
private int age;
private int sex;
}