合并打包工具配置
dev
youhong.ai 2023-07-07 16:28:53 +08:00
commit ae3a9b0349
11 changed files with 1919 additions and 0 deletions

View File

@ -0,0 +1,147 @@
package weaver.cssc.formmode;
import aiyh.utils.Util;
import aiyh.utils.httpUtil.HttpArgsType;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.cssc.schedule.util.PushModeDataUtil;
import weaver.cssc.workflow.voucher.util.VoucherConstants;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.zwl.common.ToolUtilNew;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* NC
* @author bleach
* @Date 2023-06-19
*/
public class PushNcModeExpand extends AbstractModeExpandJavaCodeNew {
/**
*
*/
private final Logger logger = Util.getLogger();
/**
*
* @param param
* param()
* user
* importtype () 1 2,3(int)param.get("importtype")
* ()a=1param.get("a")
* b=2,param.get("b")
* @return
*/
@Override
public Map<String, String> doModeExpand(Map<String, Object> param) {
logger.info("-----------PushNcModeExpand Begin ------");
Map<String, String> result = new HashMap<>();
try {
User user = (User)param.get("user");
int billId = -1;//数据id
int modeId = -1;//模块id
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
if(requestInfo != null) {
billId = Util.getIntValue(requestInfo.getRequestid());
modeId = Util.getIntValue(requestInfo.getWorkflowid());
logger.info("modeId:[" + modeId + "],billId:[" + billId + "]");
if (billId > 0 && modeId > 0) {
//------请在下面编写业务逻辑代码------
PushModeDataUtil dataUtil = new PushModeDataUtil();
//获取当前模块对应配置
Map<String,Object> configMap = dataUtil.getConfigurationByModeId(modeId);
logger.info("配置信息:[" + JSONUtil.toJsonPrettyStr(dataUtil) + "]");
//获取标识字段ID
int flagFieldId = Util.getIntValue(configMap.get("flagField").toString(),0);
//外键字段
int foreignKeyId = Util.getIntValue(configMap.get("foreignKeyField").toString(),0);
if(flagFieldId > 0){
String flagFieldName = ToolUtilNew.getFieldNameByFieldIdStatic(flagFieldId);
String foreignKeyName = "";
if(foreignKeyId > 0){
foreignKeyName = ToolUtilNew.getFieldNameByFieldIdStatic(foreignKeyId);
}
//获取该模块对应的表名称
String billTableName = (String) configMap.get("tableName");
//接口请求地址
String requestURL = (String) configMap.get("requestURL");
if(StringUtils.isNotBlank(requestURL)){
Map<String,Object> dataMap = dataUtil.getModeDataByKeyId(billTableName,flagFieldName,billId);
logger.info("当前数据信息:[" + JSONUtil.toJsonPrettyStr(dataMap) + "]");
if(!dataMap.isEmpty()){
List<Map<String,Object>> fieldList = (List<Map<String, Object>>) configMap.get("fieldList");
JSONObject jsonObject = dataUtil.generateJSONObject(fieldList,dataMap);
HttpUtils httpUtils = new HttpUtils();
Map<String,String> headerMap = new HashMap<>();
headerMap.put("Content-Type", HttpArgsType.APPLICATION_JSON);
ResponeVo responeVo = httpUtils.apiPostObject(requestURL,jsonObject,headerMap);
if(responeVo.getCode() == VoucherConstants.REQUEST_SUCCESS_CODE){
//接口返回信息转成Map对象
Map<String,Object> resultMap = responeVo.getResponseMap();
int code = Util.getIntValue(Util.null2String(resultMap.get("code")),-1);
boolean writeStatus;
if(code == 0){//成功
String foreignKeyValue = (String) resultMap.get("pk");
writeStatus = dataUtil.writeBackStatus(true, billTableName, flagFieldName, foreignKeyName, foreignKeyValue, billId);
} else {
writeStatus = dataUtil.writeBackStatus(false,billTableName,flagFieldName,foreignKeyName,"",billId);
}
logger.info("接口调用结果回写表单结果:[" + writeStatus + "]");
} else {
logger.info("接口请求失败,失败状态码:[" + responeVo.getCode() + "]");
}
} else {
logger.info("当前记录:[" + billId + "]不满足条件!");
}
}
} else {
logger.info("推送标识字段未配置!");
}
}
}
result.put("flag", "true");
} catch (Exception e) {
logger.info(Util.getErrString(e));
result.put("errmsg","自定义出错信息");
result.put("flag", "false");
}
logger.info("-----------PushNcModeExpand End ------");
return result;
}
}

View File

@ -0,0 +1,106 @@
package weaver.cssc.schedule.cron;
import aiyh.utils.Util;
import aiyh.utils.httpUtil.HttpArgsType;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.cssc.schedule.sqlmapper.PushDataSqlMapper;
import weaver.cssc.workflow.voucher.util.VoucherConstants;
import weaver.general.TimeUtil;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.zwl.common.ToolUtilNew;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* NC
* @author bleach
* @Date 2023-06-25
*/
public class PushEmployeeCronJob extends BaseCronJob {
/**
*
*/
private final Logger logger = Util.getLogger();
/**
* SQL
*/
private final PushDataSqlMapper sqlMapper = Util.getMapper(PushDataSqlMapper.class);
/**
*
*
*/
@Override
public void execute() {
//获取上一次同步时间戳
String lastSyncTs = ToolUtilNew.getStaticSystemParamValue("LastEmployeeSyncTimeStamp");
if(StringUtils.isBlank(lastSyncTs)){
lastSyncTs = "2000-01-01 00:00:01";
}
//获取接口地址
String pushEmployeeRequestURL = ToolUtilNew.getStaticSystemParamValue("EmployeePushRequestURL");
if(StringUtils.isBlank(pushEmployeeRequestURL)){
logger.error("人员推送接口地址配置不存在!配置参数标识:[EmployeePushRequestURL]");
}
//获取当前库中需要推送的人员信息
String selectSqL = "select id as code,lastName as name,certificateNum as id from hrmresource h where status in (0,1,2,3) and created >= '" + lastSyncTs + "' or modified >= '" + lastSyncTs + "'";
List<Map<String,Object>> employeeList = sqlMapper.getEmployeeInfo(selectSqL);
//发送Http请求工具类
HttpUtils httpUtils = new HttpUtils();
if(employeeList != null && employeeList.size() > 0){//遍历结果集
for(Map<String,Object> employeeMap : employeeList){
int keyId = (int) employeeMap.get("code");
Map<String,String> header = new HashMap<>();
header.put("Content-Type", HttpArgsType.APPLICATION_JSON);
try {
ResponeVo responeVo = httpUtils.apiPostObject(pushEmployeeRequestURL,employeeMap,header);
if(responeVo.getCode() == VoucherConstants.REQUEST_SUCCESS_CODE){
Map<String,Object> resultMap = responeVo.getResponseMap();
if(!resultMap.isEmpty()){
int code = (int) resultMap.get("code");
if(code == 1){
String pk = (String) resultMap.get("pk");
sqlMapper.writeBackKeyToEmployee(pk,keyId);
}
}
} else {
//人员接口推送失败
logger.error("人员接口推送失败,失败状态码:[" + responeVo.getCode() + "]");
return;
}
} catch (IOException e) {
logger.info(Util.getErrString(e));
throw new RuntimeException(e);
}
}
}
//获取当前时间戳
String currentTs = TimeUtil.getCurrentTimeString();
//更新时间戳至配置表中
sqlMapper.updateTimeStampToConfig(currentTs);
}
}

View File

@ -0,0 +1,88 @@
package weaver.cssc.schedule.cron;
import aiyh.utils.Util;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.conn.constant.DBConstant;
import weaver.cssc.schedule.sqlmapper.PushDataSqlMapper;
import weaver.cssc.schedule.util.PushModeDataUtil;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.zwl.common.ToolUtilNew;
import java.util.List;
import java.util.Map;
/**
*
* NC
* @author bleach
* @Date 2023-06-19
*/
public class PushModeDataCronJob extends BaseCronJob {
/**
*
*/
private final Logger logger = Util.getLogger();
/**
* ID
*/
private String configId;
/**
*
*/
private final PushDataSqlMapper sqlMapper = Util.getMapper(PushDataSqlMapper.class);
/**
*
*/
@Override
public void execute() {
logger.info("-------------- PushModeDataCronJob BEGIN ---------------");
logger.info("configId:[" + configId + "]");
PushModeDataUtil dataUtil = new PushModeDataUtil();
//配置集合
Map<String,Object> configMap = dataUtil.getConfigurationByKeyId(configId);
if(configMap != null && configMap.size() > 0){
//模块表名称
String modeTable = Util.null2String(configMap.get("tableName"));
//获取标识字段
int flagField = (int) configMap.get("flagField");
if(flagField > 0){
//获取标识字段名称
String flagFieldName = Util.null2String(ToolUtilNew.getFieldNameByFieldIdStatic(flagField));
if(StringUtils.isNotBlank(flagFieldName) && StringUtils.isNotBlank(modeTable)){
//查询表中已数据集
String selectSQL = "select * from " + modeTable + " where " + flagFieldName + " is null or " + flagFieldName + " in (0,2)";
//待推送数据集合
List<Map<String,Object>> dataList = sqlMapper.getTodoPushModeDataList(selectSQL);
}
}
}
logger.info("-------------- PushModeDataCronJob END ---------------");
}
public String getConfigId() {
return configId;
}
public void setConfigId(String configId) {
this.configId = configId;
}
}

View File

@ -0,0 +1,119 @@
package weaver.cssc.schedule.sqlmapper;
import aiyh.utils.annotation.recordset.*;
import java.util.List;
import java.util.Map;
/**
*
*
* NCSQL
*/
@SqlMapper
public interface PushDataSqlMapper {
/**
* NC
* @param keyId ID
* @return
*/
@CaseConversion(value = false)
@Select("select wb.tableName,u.* from uf_modeToNc u inner join modeInfo m on u.modeId = m.id \n" +
"inner join workflow_bill wb on m.formid = wb.id where u.id = #{keyId}")
Map<String,Object> getPushDataConfiguration(@ParamMapper("keyId") String keyId);
/**
* ID
* @param modeId ID
* @return
*/
@Select("select wb.tableName from modeInfo m inner join workflow_bill wb on m.formid = wb.id where m.id = #{modeId}")
String getTableNameByModeId(@ParamMapper("modeId") int modeId);
/**
* NC
* @param modeId ID
* @return
*/
@CaseConversion(value = false)
@Select("select wb.tableName,u.* from uf_modeToNc u inner join modeInfo m on u.modeId = m.id \n" +
"inner join workflow_bill wb on m.formid = wb.id where u.modeId = #{modeId}")
Map<String,Object> getPushDataConfigurationByModeId(@ParamMapper("modeId") int modeId);
/**
* NC
* @param mainId ID
* @return
*/
@CaseConversion(value = false)
@Select("select dt.*,wb.fieldName from uf_modeToNc_dt1 dt left join workflow_billfield wb on dt.mField = wb.id where mainId = #{mainId}")
List<Map<String,Object>> getPushDataDetailConfiguration(@ParamMapper("mainId") int mainId);
/**
*
* @param sql SQL
* @return
*/
@CaseConversion(value = false)
@Select(custom = true)
Map<String,Object> getTodoPushModeDataInfo(@SqlString String sql);
/**
*
* @param sql SQL
* @return
*/
@CaseConversion(value = false)
@Select(custom = true)
List<Map<String,Object>> getTodoPushModeDataList(@SqlString String sql);
/**
*
* @param billTable
* @param flagFieldName
* @param foreignKeyName
* @param foreignKeyValue
* @param keyId ID
* @return
*/
@Update("update $t{billTable} set $t{flagFieldName} = 1,$t{foreignKeyName}=#{foreignKeyValue} where id = #{keyId}")
boolean writeBackSuccess(@ParamMapper("billTable") String billTable,@ParamMapper("flagFieldName") String flagFieldName,@ParamMapper("foreignKeyName") String foreignKeyName,@ParamMapper("foreignKeyValue") String foreignKeyValue,@ParamMapper("keyId") int keyId);
/**
*
* @param billTable
* @param flagFieldName
* @param keyId ID
* @return
*/
@Update("update $t{billTable} set $t{flagFieldName} = 2 where id = #{keyId}")
boolean writeBackFailure(@ParamMapper("billTable") String billTable,@ParamMapper("flagFieldName") String flagFieldName,@ParamMapper("keyId") int keyId);
/**
*
* @param sql SQL
* @return
*/
@CaseConversion(value = false)
@Select(custom = true)
List<Map<String,Object>> getEmployeeInfo(@SqlString String sql);
/**
* 5
* @param pk
* @param keyId ID
*/
@Update("update hrmresource set textField5 = #{pk} where id = #{keyId}")
void writeBackKeyToEmployee(@ParamMapper("pk") String pk,@ParamMapper("keyId") int keyId);
/**
*
* @param timeStamp
*/
@Update("update uf_systemConfig set paramValue = #{timeStamp} where uuid = 'LastEmployeeSyncTimeStamp'")
void updateTimeStampToConfig(@ParamMapper("timeStamp") String timeStamp);
}

View File

@ -0,0 +1,144 @@
package weaver.cssc.schedule.util;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import weaver.cssc.schedule.sqlmapper.PushDataSqlMapper;
import weaver.general.TimeUtil;
import weaver.zwl.common.ToolUtilNew;
import java.util.List;
import java.util.Map;
/**
*
* NC
* @author bleach
* @Date 2023-06-19
*/
public class PushModeDataUtil {
/**
*
*/
private final PushDataSqlMapper sqlMapper = Util.getMapper(PushDataSqlMapper.class);
/**
*
* @param keyId ID
* @return
*/
public Map<String,Object> getConfigurationByKeyId(String keyId){
Map<String,Object> configMap = sqlMapper.getPushDataConfiguration(keyId);
if(configMap != null && configMap.size() > 0){
int mainKeyId = (int) configMap.get("id");
List<Map<String, Object>> fieldList = sqlMapper.getPushDataDetailConfiguration(mainKeyId);
configMap.put("fieldList",fieldList);
}
return configMap;
}
/**
*
* @param modeId ID
* @return
*/
public Map<String,Object> getConfigurationByModeId(int modeId){
Map<String,Object> configMap = sqlMapper.getPushDataConfigurationByModeId(modeId);
if(configMap != null && configMap.size() > 0){
int mainKeyId = (int) configMap.get("id");
List<Map<String, Object>> fieldList = sqlMapper.getPushDataDetailConfiguration(mainKeyId);
configMap.put("fieldList",fieldList);
}
return configMap;
}
/**
* JSON
* @param fieldList
* @param dataMap
* @return JSON
*/
public JSONObject generateJSONObject(List<Map<String,Object>> fieldList,Map<String,Object> dataMap){
JSONObject jsonObject = new JSONObject();
for(Map<String,Object> fieldMap : fieldList){
//JSON节点名称
String nodeName = Util.null2String(fieldMap.get("nodeName"));
//建模字段名称
String fieldName = Util.null2String(fieldMap.get("fieldName"));
//转换规则
int changeRule = (int) fieldMap.get("changeRule");
//自定义规则
String cusSQL = Util.null2String(fieldMap.get("cusSQL"));
//字段值
String fieldValue = "";
if(StringUtils.isNotBlank(fieldName) && dataMap.containsKey(fieldName)){
fieldValue = Util.null2String(dataMap.get(fieldName));
}
//数据ID 系统日期 系统日期时间 固定值 自定义规则
switch (changeRule){
case 0 ://不转换
break;
case 1 ://数据ID
fieldValue = Util.null2String(dataMap.get("id"));
break;
case 2 ://系统日期
fieldValue = TimeUtil.getCurrentDateString();
break;
case 3 ://系统日期时间
fieldValue = TimeUtil.getCurrentTimeString();
break;
case 4 ://固定值
fieldValue = cusSQL;
break;
case 5 ://自定义SQL
fieldValue = ToolUtilNew.getStaticValueByChangeRule(cusSQL,fieldValue);
break;
}
jsonObject.put(nodeName,fieldValue);
}
return jsonObject;
}
/**
* ID
* @param keyId ID
* @return
*/
public Map<String,Object> getModeDataByKeyId(String modeTableName,String flagFieldName,int keyId){
//查询表中已数据集
String selectSQL = "select * from " + modeTableName + " where id = " + keyId + " and (" + flagFieldName + " is null or " + flagFieldName + " in (0,2))";
return sqlMapper.getTodoPushModeDataInfo(selectSQL);
}
/**
*
* @param isSuccess
* @param billTableName
* @param flagFieldName
* @param keyId ID
* @return
*/
public boolean writeBackStatus(boolean isSuccess,String billTableName,String flagFieldName,String foreignKeyName,String foreignKeyValue,int keyId){
if(isSuccess){
return sqlMapper.writeBackSuccess(billTableName,flagFieldName,foreignKeyName,foreignKeyValue,keyId);
} else {
return sqlMapper.writeBackFailure(billTableName,flagFieldName,keyId);
}
}
}

View File

@ -0,0 +1,227 @@
package weaver.cssc.workflow.voucher.action;
import aiyh.utils.Util;
import aiyh.utils.action.SafeCusBaseAction;
import aiyh.utils.httpUtil.HttpArgsType;
import aiyh.utils.httpUtil.ResponeVo;
import aiyh.utils.httpUtil.util.HttpUtils;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.cssc.workflow.voucher.sqlmapper.VoucherSqlMapper;
import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao;
import weaver.cssc.workflow.voucher.util.VoucherConstants;
import weaver.cssc.workflow.voucher.util.VoucherUtil;
import weaver.general.TimeUtil;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import weaver.zwl.common.ToolUtilNew;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* NCAction
* @author bleach
* @Date 2023-06-19
*/
public class VoucherPushAction extends SafeCusBaseAction {
/**
*
*/
private final Logger logger = Util.getLogger();
/**
*
*/
private String cusParamValue = "";
/**
*
*/
private final VoucherSqlMapper sqlMapper = Util.getMapper(VoucherSqlMapper.class);
/**
* Action
*
* @param requestId ID
* @param billTable
* @param workflowId ID
* @param user
* @param requestInfo
*/
@SuppressWarnings("unchecked")
@Override
public void doSubmit(String requestId, String billTable, int workflowId, User user, RequestInfo requestInfo) {
logger.info("---------------- VoucherPushAction Begin -------------");
InterfaceLoggerDao interfaceLoggerDao = new InterfaceLoggerDao();
interfaceLoggerDao.setWorkflowId(workflowId);
interfaceLoggerDao.setSourceRequestId(requestId);
interfaceLoggerDao.setOperateDateTime(TimeUtil.getCurrentTimeString());
logger.info("workflowId:[" + workflowId + "],requestId:[" + requestId + "],billTable:[" + billTable + "]");
VoucherUtil voucherUtil = new VoucherUtil();
Map<String,Object> configMap = voucherUtil.getConfigurationByWorkflowId(String.valueOf(workflowId),cusParamValue);
if(configMap != null && configMap.size() > 0){
//获取数据条件
String dataCondition = (String) configMap.get("dataCondition");
RecordSet rs ;
if(StringUtils.isNotBlank(dataCondition)){
dataCondition = ToolUtilNew.staticToDBC(dataCondition);
rs = sqlMapper.getWorkflowMainInfoAndCusWhere(billTable,requestId,dataCondition);
} else {
rs = sqlMapper.getWorkflowMainInfo(billTable,requestId);
}
int mainId = -1;
if(rs.next()){
mainId = Util.getIntValue(rs.getString("id"),-1);
}
if(mainId > -1){
//流程请求标题
String requestName = "";
//流程请求编号
String requestMark = "";
//获取流程基础信息
RecordSetTrans rsts = requestInfo.getRsTrans();
if(rsts == null){
rsts = new RecordSetTrans();
}
try {
if(rsts.executeQuery("select * from workflow_requestBase where requestId = ?",requestId)){
if(rsts.next()){
requestName = Util.null2String(rsts.getString("requestName"));
requestMark = Util.null2String(rsts.getString("requestMark"));
}
}
} catch (Exception e) {
Util.actionFailException(requestInfo.getRequestManager(),"获取流程基本信息异常,异常信息:[" + e.getMessage() + "]");
throw new RuntimeException(e);
}
interfaceLoggerDao.setRequestNo(requestMark);
interfaceLoggerDao.setOperator(user.getUID());
List<Map<String,Object>> fieldList = (List<Map<String, Object>>) configMap.get("fieldList");
List<Map<String,Object>> detailList = (List<Map<String, Object>>) configMap.get("detailList");
voucherUtil.setDetailList(detailList);
voucherUtil.setFieldList(fieldList);
//流程基础信息集合[流程请求ID,流程请求标题,流程请求编号,流程表单名称主表数据ID]
String[] baseArray = new String[]{requestId,requestName,requestMark,billTable,String.valueOf(mainId)};
//根据配置生成JSON对象
JSONObject jsonObject = voucherUtil.recursionGenerateJSONObject(baseArray,rs,null, 0,"",0,0);
logger.info("生成JSON字符串为:[" + jsonObject.toJSONString() + "]");
interfaceLoggerDao.setRequestBody(jsonObject.toJSONString());
//NC凭证接口地址
String voucherRequestURL = ToolUtilNew.getStaticSystemParamValue("NC_VoucherRequestURL");
if(StringUtils.isNotBlank(voucherRequestURL)){
HttpUtils httpUtils = new HttpUtils();
try {
Map<String,String> headerMap = new HashMap<>();
headerMap.put("Content-Type", HttpArgsType.APPLICATION_JSON);
ResponeVo responeVo = httpUtils.apiPostObject(voucherRequestURL,jsonObject,headerMap);
if(responeVo.getCode() == VoucherConstants.REQUEST_SUCCESS_CODE){
//获取返回信息
String result = responeVo.getEntityString();
interfaceLoggerDao.setResponseBody(result);
JSONObject resultObj = JSONObject.parseObject(result);
if(resultObj.containsKey("code")){
int code = resultObj.getIntValue("code");
if(code == 0){
String pk = resultObj.getString("pk");
String backFieldName = (String) configMap.get("backFieldName");
if(StringUtils.isNotBlank(backFieldName)){
sqlMapper.backVoucherNoToBill(billTable,backFieldName,pk,requestId);
}
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_SUCCESS);
interfaceLoggerDao.setDealMessage("接口调用成功!");
} else {
String message = resultObj.getString("msg");
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_FAILURE);
interfaceLoggerDao.setDealMessage("调用NC凭证接口失败失败状态码:[" + message + "]");
interfaceLoggerDao.insertInterfaceLog(interfaceLoggerDao);
//接口调用失败
Util.actionFailException(requestInfo.getRequestManager(),"调用NC凭证接口失败失败状态码:[" + message + "]");
}
} else {
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_FAILURE);
interfaceLoggerDao.setDealMessage("调用NC凭证接口失败接口返回信息为空");
}
} else {
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_FAILURE);
interfaceLoggerDao.setDealMessage("调用NC凭证接口失败失败状态码:[" + responeVo.getCode() + "]");
interfaceLoggerDao.insertInterfaceLog(interfaceLoggerDao);
Util.actionFailException(requestInfo.getRequestManager(),"调用NC凭证接口失败失败状态码:[" + responeVo.getCode() + "]");
}
} catch (IOException e) {
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_FAILURE);
interfaceLoggerDao.setDealMessage("调用NC凭证接口异常异常信息:" + e.getMessage());
interfaceLoggerDao.insertInterfaceLog(interfaceLoggerDao);
logger.error(Util.getErrString(e));
Util.actionFailException(requestInfo.getRequestManager(),"调用NC凭证接口异常");
//throw new RuntimeException(e);
}
} else {
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_NO_DEAL);
interfaceLoggerDao.setDealMessage("NC凭证接口地址未配置");
interfaceLoggerDao.insertInterfaceLog(interfaceLoggerDao);
Util.actionFailException(requestInfo.getRequestManager(),"NC凭证接口地址未配置");
}
} else {
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_NO_DEAL);
interfaceLoggerDao.setDealMessage("当前流程不满足自定义条件:[" + dataCondition + "]");
logger.info("当前流程不满足自定义条件:[" + dataCondition + "]");
}
} else {
interfaceLoggerDao.setDealStatus(VoucherConstants.DEAL_STATUS_NO_DEAL);
interfaceLoggerDao.setDealMessage("该流程自定义参数值[" + cusParamValue + "]对应的配置不存在!");
logger.info("该流程自定义参数值[" + cusParamValue + "]对应的配置不存在!");
}
interfaceLoggerDao.insertInterfaceLog(interfaceLoggerDao);
logger.info("---------------- VoucherPushAction End -------------");
}
public String getCusParamValue() {
return cusParamValue;
}
public void setCusParamValue(String cusParamValue) {
this.cusParamValue = cusParamValue;
}
}

View File

@ -0,0 +1,120 @@
package weaver.cssc.workflow.voucher.sqlmapper;
import aiyh.utils.annotation.recordset.*;
import weaver.conn.RecordSet;
import weaver.cssc.workflow.voucher.util.InterfaceLoggerDao;
import java.util.List;
import java.util.Map;
/**
*
* NC SQL
*/
@SqlMapper
public interface VoucherSqlMapper {
/**
* ID
* @param allWorkflowId ID
* @return
*/
@CaseConversion(value = false)
@Select("select * from uf_wfDataToNCVoucher where wfId in ($t{allWorkflowId})")
Map<String,Object> getConfigurationByWorkflowId(@ParamMapper("allWorkflowId") String allWorkflowId);
/**
* ID
* @param allWorkflowId ID
* @param cusParamValue
* @return
*/
@CaseConversion(value = false)
@Select("select * from uf_wfDataToNCVoucher where wfId in ($t{allWorkflowId}) and cusParamValue = #{cusParamValue}")
Map<String,Object> getConfigurationByWorkflowIdAndParam( @ParamMapper("allWorkflowId") String allWorkflowId,@ParamMapper("cusParamValue") String cusParamValue);
/**
* 1
* @param mainId ID
* @return 1
*/
@CaseConversion(value = false)
@Select("select dt.* from uf_wfDataToNCVoucher_dt1 dt where dt.mainId = #{mainId}")
List<Map<String,Object>> getFirstDetailConfiguration(@ParamMapper("mainId") int mainId);
/**
* 2
* @param mainId ID
* @return 2
*/
@CaseConversion(value = false)
@Select("select dt.*,wb.fieldName,wb.viewType,wb.detailTable from uf_wfDataToNCVoucher_dt2 dt left join workflow_billField wb on dt.wfFieldId = wb.id where dt.mainId = #{mainId}")
List<Map<String,Object>> getSecondDetailConfiguration( @ParamMapper("mainId") int mainId);
/**
*
* @param billTable
* @param requestId ID
* @return
*/
@CaseConversion(value = false)
@Select("select * from $t{billTable} where requestId = #{requestId}")
RecordSet getWorkflowMainInfo(@ParamMapper("billTable") String billTable, @ParamMapper("requestId") String requestId);
/**
*
* @param billTable
* @param requestId ID
* @param sqlWhere
* @return
*/
@CaseConversion(value = false)
@Select("select * from $t{billTable} where requestId = #{requestId} and $t{sqlWhere}")
RecordSet getWorkflowMainInfoAndCusWhere( @ParamMapper("billTable") String billTable,@ParamMapper("requestId") String requestId,@ParamMapper("sqlWhere") String sqlWhere);
/**
*
* @param detailBillTable
* @param mainId ID
* @return
*/
@CaseConversion(value = false)
@Select("select * from $t{detailBillTable} where mainId = #{mainId}")
RecordSet getWorkflowDetailInfo(@ParamMapper("detailBillTable") String detailBillTable, @ParamMapper("mainId") String mainId);
/**
*
* @param detailBillTable
* @param mainId ID
* @param sqlWhere
* @return
*/
@CaseConversion(value = false)
@Select("select * from $t{detailBillTable} where mainId = #{mainId} and $t{sqlWhere}")
RecordSet getWorkflowDetailInfoAndCusWhere(@ParamMapper("detailBillTable") String detailBillTable, @ParamMapper("mainId") String mainId,@ParamMapper("sqlWhere") String sqlWhere);
/**
* U8
*
* @param billTable
* @param backFieldName
* @param backFieldValue
* @param requestId ID
*/
@CaseConversion(value = false)
@Update("update $t{billTable} set $t{backFieldName} = #{backFieldValue} where requestId = #{requestId}")
void backVoucherNoToBill(@ParamMapper("billTable") String billTable,@ParamMapper("backFieldName") String backFieldName,@ParamMapper("backFieldValue") String backFieldValue,@ParamMapper("requestId") String requestId);
/**
*
* @param loggerDao
*/
@Update("update uf_interfaceLog set sourceRequestId = #{sourceRequestId},requestNo = #{requestNo},workflowId = #{workflowId}," +
"operator = #{operator},operateDateTime = #{operateDateTime},dealStatus = #{dealStatus},dealMessage = #{dealMessage}," +
"requestBody = #{requestBody},responseBody = #{responseBody},interfaceType = #{interfaceType} where id = #{newDataId}")
boolean insertInterfaceLog(InterfaceLoggerDao loggerDao);
}

View File

@ -0,0 +1,81 @@
package weaver.cssc.workflow.voucher.util;
import aiyh.utils.Util;
import lombok.Data;
import weaver.cssc.workflow.voucher.sqlmapper.VoucherSqlMapper;
/**
*
*
*/
@Data
public class InterfaceLoggerDao {
/**
* ID
*/
private int newDataId;
/**
* ID
*/
private String sourceRequestId;
/**
*
*/
private String requestNo;
/**
* ID
*/
private int workflowId;
/**
*
*/
private int interfaceType;
/**
* ID
*/
private int operator;
/**
*
*/
private String operateDateTime;
/**
*
*/
private int dealStatus;
/**
*
*/
private String dealMessage;
/**
*
*/
private String requestBody;
/**
*
*/
private String responseBody;
/**
*
* @param loggerDao
*/
public void insertInterfaceLog(InterfaceLoggerDao loggerDao){
VoucherSqlMapper sqlMapper = Util.getMapper(VoucherSqlMapper.class);
if(sqlMapper.insertInterfaceLog(loggerDao)){
Util.rebuildModeDataShare(1,"uf_interfaceLog",loggerDao.getNewDataId());
}
}
}

View File

@ -0,0 +1,94 @@
package weaver.cssc.workflow.voucher.util;
/**
*
* NC
*
* @author bleach
* @Date 2023-06-19
*/
public class VoucherConstants {
/**
* JSON -
*/
public final static int JSON_NODE_TYPE_COMMON_TEXT = 0;
/**
* JSON -
*/
public final static int JSON_NODE_TYPE_ARRAY_TEXT = 1;
/**
* JSON -
*/
public final static int JSON_NODE_TYPE_COMMON_OBJECT = 2;
/**
* JSON -
*/
public final static int JSON_NODE_TYPE_ARRAY_OBJECT = 3;
/**
* -
*/
public final static String VOUCHER_ENTRY_NO_VOUCHER = "0";
/**
* -
*/
public final static String VOUCHER_ENTRY_COMMON_DEBIT = "1";
/**
* -
*/
public final static String VOUCHER_ENTRY_TAX_DEBIT = "2";
/**
* -
*/
public final static String VOUCHER_ENTRY_COMMON_CREDIT = "3";
/**
* -
*/
public final static String VOUCHER_ENTRY_WRITE_OFF_CREDIT = "4";
/**
* -
*/
public final static int FIELD_SPECIAL_COMMON = 0;
/**
* -
*/
public final static int FIELD_SPECIAL_AMOUNT = 1;
/**
*
*/
public final static int REQUEST_SUCCESS_CODE = 200;
/**
* -
*/
public final static int DEAL_STATUS_NO_DEAL = 0;
/**
* -
*/
public final static int DEAL_STATUS_SUCCESS = 1;
/**
* -
*/
public final static int DEAL_STATUS_FAILURE = 2;
}

View File

@ -0,0 +1,367 @@
package weaver.cssc.workflow.voucher.util;
import aiyh.utils.Util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.cssc.workflow.voucher.sqlmapper.VoucherSqlMapper;
import weaver.general.TimeUtil;
import weaver.workflow.workflow.WorkflowVersion;
import weaver.zwl.common.ToolUtilNew;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
*
* NC
*
* @author bleach
* @Date 2023-06-19
*/
public class VoucherUtil {
/**
*
*/
private List<Map<String,Object>> detailList = new ArrayList<>();
/**
*
*/
private List<Map<String,Object>> fieldList = new ArrayList<>();
private final VoucherSqlMapper sqlMapper = Util.getMapper(VoucherSqlMapper.class);
/**
* JSON
* @param baseArray IDID
* @param rs
* @param rs_detail
* @param voucherDirection
* @param parentNode
* @param dtIndex
* @param rowNum
* @return JSON
*/
public JSONObject recursionGenerateJSONObject(String[] baseArray,RecordSet rs,RecordSet rs_detail,int voucherDirection,String parentNode,int dtIndex,int rowNum){
JSONObject jsonObject = new JSONObject();
if(fieldList != null && fieldList.size() > 0){
for(Map<String,Object> fieldMap : fieldList){
//节点名称
String _nodeName = (String) fieldMap.get("nodeName");
//父节点名称
String _parentNode = (String) fieldMap.get("parentNode");
if(!_parentNode.equals(parentNode)){//若当前字段配置与传入的父节点名称不一致直接跳过
continue;
}
//字段所属 0-主表 1-明细表
int _viewType = Util.getIntValue(Util.null2String(fieldMap.get("viewType")),0);
//获取明细表表名称
String _detailTable = (String) fieldMap.get("detailTable");
if(_viewType == 1 && StringUtils.isNotBlank(_detailTable)){//明细记录
int _dtIndex = Util.getIntValue(_detailTable.substring(_detailTable.indexOf("_dt") + 3),-1);
if(_dtIndex != dtIndex){
continue;
}
}
String _voucherDirection = (String) fieldMap.get("voucherDirection");
if(voucherDirection > 0 && !_voucherDirection.contains(String.valueOf(voucherDirection))) {//说明为会计分录 ,且当前字段的所属分录与传入的分录不一致
continue;
}
//节点类型
int _nodeType = (int) fieldMap.get("nodeType");
switch (_nodeType){
case VoucherConstants.JSON_NODE_TYPE_COMMON_TEXT :
String fieldValue = getFieldValue(baseArray,fieldMap,rs,rs_detail,rowNum);
int specialAttr = (int) fieldMap.get("specialAttr");
if(VoucherConstants.FIELD_SPECIAL_AMOUNT == specialAttr){
double amount = Util.getDoubleValue(fieldValue,0.0);
if(amount == 0.0){
return null;
}
}
jsonObject.put(_nodeName,fieldValue);
break;
case VoucherConstants.JSON_NODE_TYPE_ARRAY_TEXT :
String arrayFieldValue = getFieldValue(baseArray,fieldMap,rs,rs_detail,rowNum);
JSONArray fieldArray = new JSONArray();
String[] fieldVal = Util.TokenizerString2(arrayFieldValue,",");
fieldArray.addAll(Arrays.asList(fieldVal));
jsonObject.put(_nodeName,fieldArray);
break;
case VoucherConstants.JSON_NODE_TYPE_COMMON_OBJECT :
JSONObject _detailObj = recursionGenerateJSONObject(baseArray,rs,rs_detail,voucherDirection,_nodeName,dtIndex,rowNum);
jsonObject.put(_nodeName,_detailObj);
break;
case VoucherConstants.JSON_NODE_TYPE_ARRAY_OBJECT:
//获取该数组对应的明细映射配置
if(detailList != null && detailList.size() > 0){
JSONArray itemArray = new JSONArray();
int _rowNum = 0;
for(Map<String,Object> detailMap :detailList){
//对象/数组节点名称
String _arrayNode = (String) detailMap.get("arrayNode");
if(!_arrayNode.equals(_nodeName)){
continue;
}
//是否凭证分录
int _isVoucher = (int) detailMap.get("isVoucher");
//明细序列
int _dtIndex = (int) detailMap.get("dtIndex");
//借贷方向
String _dtItemDirection = (String) detailMap.get("dtItemDirection");
if(_dtIndex > 0){//明细表
//明细条件
String _dtCondition = (String) detailMap.get("dtCondition");
String detailBillTable = baseArray[3] + "_dt" + _dtIndex;
RecordSet _rs_detail;
if(StringUtils.isNotBlank(_dtCondition)){
_dtCondition = ToolUtilNew.staticToDBC(_dtCondition);
_rs_detail = sqlMapper.getWorkflowDetailInfoAndCusWhere(detailBillTable,baseArray[4],_dtCondition);
} else {
_rs_detail = sqlMapper.getWorkflowDetailInfo(detailBillTable,baseArray[4]);
}
while(_rs_detail.next()){
if(_isVoucher == 0){//非凭证分录
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,_rs_detail,Util.getIntValue(VoucherConstants.VOUCHER_ENTRY_NO_VOUCHER,0),_nodeName,_dtIndex,_rowNum++);
itemArray.add(detailObj);
} else {
for(int k = 1; k <= 4;k++){
if(_dtItemDirection.contains(String.valueOf(k))) {
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,_rs_detail,k,_nodeName,_dtIndex,_rowNum++);
if(detailObj != null && detailObj.size() > 0){
itemArray.add(detailObj);
}
}
}
}
}
} else {//主表
if(_isVoucher == 1){
for(int k = 1; k <= 4;k++){
if(_dtItemDirection.contains(String.valueOf(k))) {
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,null,k,_nodeName,_dtIndex,_rowNum++);
if(detailObj != null && detailObj.size() > 0){
itemArray.add(detailObj);
}
}
}
/*
//判断是否存在借方
if(_dtItemDirection.contains(VoucherConstants.VOUCHER_ENTRY_COMMON_DEBIT)){
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,null,Util.getIntValue(VoucherConstants.VOUCHER_ENTRY_COMMON_DEBIT,0),_nodeName,_dtIndex,rowNum++);
if(detailObj != null && detailObj.size() > 0){
itemArray.add(detailObj);
}
}
//税额借方
if(_dtItemDirection.contains(VoucherConstants.VOUCHER_ENTRY_TAX_DEBIT)){
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,null,Util.getIntValue(VoucherConstants.VOUCHER_ENTRY_TAX_DEBIT,0),_nodeName,_dtIndex,rowNum++);
if(detailObj != null && detailObj.size() > 0){
itemArray.add(detailObj);
}
}
//普通贷方
if(_dtItemDirection.contains(VoucherConstants.VOUCHER_ENTRY_COMMON_CREDIT)){
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,null,Util.getIntValue(VoucherConstants.VOUCHER_ENTRY_COMMON_CREDIT,0),_nodeName,_dtIndex,rowNum++);
if(detailObj != null && detailObj.size() > 0){
itemArray.add(detailObj);
}
}
//冲销贷方
if(_dtItemDirection.contains(VoucherConstants.VOUCHER_ENTRY_WRITE_OFF_CREDIT)){
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,null,Util.getIntValue(VoucherConstants.VOUCHER_ENTRY_WRITE_OFF_CREDIT,0),_nodeName,_dtIndex,rowNum++);
if(detailObj != null && detailObj.size() > 0){
itemArray.add(detailObj);
}
}
*/
} else {
JSONObject detailObj = recursionGenerateJSONObject(baseArray,rs,null,Util.getIntValue(VoucherConstants.VOUCHER_ENTRY_NO_VOUCHER,0),_nodeName,_dtIndex,_rowNum++);
itemArray.add(detailObj);
}
}
}
jsonObject.put(_nodeName,itemArray);
}
break;
}
}
}
return jsonObject;
}
/**
*
* @param baseArray
* @param fieldMap
* @param rs
* @param rs_detail
* @param rowNum
* @return
*/
private String getFieldValue(String[] baseArray,Map<String,Object> fieldMap,RecordSet rs,RecordSet rs_detail,int rowNum){
String fieldValue = "";
//System.out.println("字段配置:[" + JSONObject.toJSONString(fieldMap) + "]");
//字段名称
String fieldName = Util.null2String(fieldMap.get("fieldName"));
//字段所属
int viewType = Util.getIntValue(Util.null2String(fieldMap.get("viewType")),0);
//转换规则
int changeRule = Util.getIntValue(Util.null2String(fieldMap.get("changeRule")),0);
//自定义转换
String cusSQL = (String) fieldMap.get("cusSQL");
if(!"".equals(fieldName)){
if(viewType == 0){
fieldValue = Util.null2String(rs.getString(fieldName));
} else if (viewType == 1 && rs_detail != null) {
fieldValue = Util.null2String(rs_detail.getString(fieldName));
}
}
switch (changeRule){
case 0 : //不转换
break;
case 1 : //流程请求ID
fieldValue = baseArray[0];
break;
case 2 : //流程请求标题
fieldValue = baseArray[1];
break;
case 3 : //流程请求编号
fieldValue = baseArray[2];
break;
case 4 : //系统日期
fieldValue = TimeUtil.getCurrentDateString();
break;
case 5 : //系统时间
fieldValue = TimeUtil.getCurrentTimeString();
break;
case 6 : //固定值
fieldValue = cusSQL;
break;
case 7 : //明细序列
fieldValue = String.valueOf(rowNum);
break;
case 8 : //自定义转换
int detailKey = -1;
if(cusSQL.contains("{?dt.id}") && rs_detail != null){
detailKey = Util.getIntValue(rs_detail.getString("id"),0);
}
fieldValue = ToolUtilNew.getStaticValueByChangeRule(cusSQL,fieldValue,baseArray[0],detailKey);
break;
}
//System.out.println("fieldValue:" + fieldValue);
return fieldValue;
}
/**
*
* @param workflowId ID
* @param cusParamValue
* @return
*/
public Map<String,Object> getConfigurationByWorkflowId(String workflowId,String cusParamValue){
Map<String,Object> configMap ;
//获取该流程类型对应的所有版本ID
String allWfIds = WorkflowVersion.getAllVersionStringByWFIDs(workflowId);
if(StringUtils.isNotBlank(cusParamValue)){
configMap = sqlMapper.getConfigurationByWorkflowIdAndParam(allWfIds,cusParamValue);
} else {
configMap = sqlMapper.getConfigurationByWorkflowId(allWfIds);
}
if(configMap != null && configMap.size() > 0){
int mainId = (int) configMap.get("id");
//获取明细表1配置集合
List<Map<String,Object>> detailList = sqlMapper.getFirstDetailConfiguration(mainId);
List<Map<String,Object>> fieldList = sqlMapper.getSecondDetailConfiguration(mainId);
configMap.put("detailList",detailList);
configMap.put("fieldList",fieldList);
}
return configMap;
}
public List<Map<String, Object>> getDetailList() {
return detailList;
}
public void setDetailList(List<Map<String, Object>> detailList) {
this.detailList = detailList;
}
public List<Map<String, Object>> getFieldList() {
return fieldList;
}
public void setFieldList(List<Map<String, Object>> fieldList) {
this.fieldList = fieldList;
}
}

View File

@ -0,0 +1,426 @@
package weaver.zwl.common;
import com.google.common.base.Strings;
import com.weaver.general.TimeUtil;
import org.apache.log4j.*;
import org.h2.util.StringUtils;
import weaver.conn.ConnStatementDataSource;
import weaver.conn.RecordSet;
import weaver.formmode.data.ModeDataIdUpdate;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.Util;
import java.io.File;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
@SuppressWarnings("ALL")
public class ToolUtilNew extends ToolUtil{
/**
*
*/
public static final ModeRightInfo MODE_RIGHT_INFO = new ModeRightInfo();
/**
* ID
*/
public static final ModeDataIdUpdate mdu = ModeDataIdUpdate.getInstance();
/**
*
*/
public static final int modeDataDefaultUserId = 1;
/**
*
*/
private static volatile Logger log = null;
/**
*
*/
private static final Map<String, Logger> otherLog = new HashMap<>(8);
/**
*
* log4j
* @return
*/
@SuppressWarnings("deprecation")
public static Logger getLogger() {
if (log == null) {
synchronized (ToolUtilNew.class) {
if (log == null) {
DailyRollingFileAppender appender = new DailyRollingFileAppender();
log = Logger.getLogger("ayh_cus");
appender.setName("ayh_cus");
appender.setEncoding("UTF-8");
appender.setDatePattern("'_'yyyyMMdd'.log'");
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + "util_cus" + File.separator + "cus.log");
appender.setThreshold(Priority.DEBUG);
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n"));
appender.setAppend(true);
appender.activateOptions();
log.addAppender(appender);
log.setLevel(Level.INFO);
}
}
}
return log;
}
/**
* log4j
* @param name
* @return
*/
public static Logger getLogger(String name) {
if (otherLog.containsKey(name)) {
return otherLog.get(name);
}
if (!otherLog.containsKey(name)) {
synchronized (ToolUtilNew.otherLog) {
if (otherLog.containsKey(name)) {
return otherLog.get(name);
}
DailyRollingFileAppender appender = new DailyRollingFileAppender();
Logger cusLog = Logger.getLogger("cus_" + name);
appender.setName("cus_" + name);
appender.setEncoding("UTF-8");
appender.setDatePattern("'_'yyyyMMdd'.log'");
appender.setFile(weaver.general.GCONST.getLogPath() + "cus" + File.separator + name + File.separator + "cus.log");
appender.setThreshold(Priority.DEBUG);
appender.setLayout(new PatternLayout("[%-5p] [%d{yyyy-MM-dd HH:mm:ss,SSS}] [%r] [Thread:%t][%F.%M:%L] ==> : %m %x %n"));
appender.setAppend(true);
appender.activateOptions();
cusLog.addAppender(appender);
cusLog.setLevel(Level.INFO);
otherLog.put(name, cusLog);
return cusLog;
}
}
return null;
}
/**
* ID
*
* @param tableName
* @return ID
*/
public static int getModeIdByTableName(String tableName) {
int modeId = 0;
String querySql = "select id from modeinfo where formid = (select id from workflow_bill where tablename = ?)";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(querySql, tableName);
if (recordSet.next()) {
modeId = Util.getIntValue(recordSet.getString("id"),0);
}
return modeId;
}
/**
* ID
*
* @param tableName
* @param formModeId ID
* @return ID
*/
public static int getModeDataNewId(String tableName, int formModeId) {
return getModeDataNewId(tableName, formModeId,modeDataDefaultUserId);
}
/**
* ID
*
* @param tableName
* @param formModeId ID
* @param userId ID
* @return ID
*/
public static int getModeDataNewId(String tableName, int formModeId, int userId) {
return mdu.getModeDataNewId(tableName, formModeId, userId, 0, TimeUtil.getCurrentDateString(), TimeUtil.getOnlyCurrentTimeString());
}
/**
*
*
* @param formId ID
* @param id ID
* @param userId ID
*/
public static void rebuildModeDataShare(Integer formId, Integer id) {
rebuildModeDataShare(formId, id,modeDataDefaultUserId);
}
/**
*
*
* @param formId ID
* @param id ID
* @param userId ID
*/
public static void rebuildModeDataShare(Integer formId, Integer id,Integer userId) {
MODE_RIGHT_INFO.rebuildModeDataShareByEdit(userId, formId, id);
}
/**
*
* @param likestr
* @return
*/
public static Map<String,String> getSystemParamList(String likestr){
return getSystemParamList(likestr,"uf_systemConfig");
}
/**
*
* @param uuid
* @return
*/
public static String getStaticSystemParamValue(String uuid){
return getStaticSystemParamValue(uuid,"uf_systemConfig");
}
/**
*
* @param uuid
* @param configTable
* @return
*/
public static String getStaticSystemParamValue(String uuid,String configTable){
String querySQL = "select paramValue from " + configTable + " where uuid = ?";
RecordSet rs = new RecordSet();
if(rs.executeQuery(querySQL,uuid) && rs.next()){
return Util.null2String(rs.getString(1));
}
return "";
}
/**
*
* @param likestr
* @param configTable
* @return
*/
public static Map<String,String> getSystemParamList(String likestr,String configTable){
Map<String,String> param_map = new HashMap<String, String>();
String select_sql = "select uuid,paramValue from " + configTable;
RecordSet rs = new RecordSet();
if(!"".equals(likestr)){
select_sql += " where uuid like '%" + likestr + "%'";
}
if(rs.execute(select_sql)){
while(rs.next()){
String uuid = Util.null2String(rs.getString(1));
String paramvalue = Util.null2String(rs.getString(2));
param_map.put(uuid, paramvalue);
}
}
return param_map;
}
/**
* ID
* @param fieldId ID
* @return
*/
public static String getFieldNameBySingleFieldId(int fieldId){
String fieldname = "";
if(fieldId != 0){
String querySql = "select fieldname from workflow_billfield where id=?";
RecordSet rs = new RecordSet();
if(rs.executeQuery(querySql,fieldId)){
while(rs.next()){
fieldname = Util.null2String(rs.getString(1));
}
}
}
return fieldname;
}
/**
* /
* @param workflowId ID
* @param docField /
* @param tableName
* @return ID
*/
public static String getDocCategorysByTable(String workflowId, String docField, String tableName) {
String formId = "";
RecordSet rs = new RecordSet();
if(rs.executeQuery("select formid from workflow_base where id = ?", workflowId)){
if(rs.next()){
formId = Util.null2String(rs.getString(1));
}
}
String query = "select doccategory from workflow_fileupload where fieldid in (select id from workflow_billfield where fieldname = ? and billid = ? and (detailtable = ? or detailtable is null))";
if (!Strings.isNullOrEmpty(tableName) && tableName.contains("_dt")) {
query = "select doccategory from workflow_fileupload where fieldid in (select id from workflow_billfield where fieldname = ? and billid = ? and detailtable = ?)";
}
String docCategorys = "";
if(rs.executeQuery(query, docField, formId, tableName)){
if(rs.next()){
docCategorys = Util.null2String(rs.getString(1));
}
}
if (StringUtils.isNullOrEmpty(docCategorys)) {
query = "select doccategory from workflow_base where id = ?";
rs.executeQuery(query, workflowId);
rs.next();
docCategorys = Util.null2String(rs.getString(1));
}
if (StringUtils.isNullOrEmpty(docCategorys)) {
docCategorys = ",,1";
}
return docCategorys;
}
/**
* ID
* @param fieldId ID
* @return
*/
public static String getFieldNameByFieldIdStatic(int fieldId){
String fieldname = "";
if(fieldId > 0){
String select_sql = "select fieldname from workflow_billfield where id = ?";
RecordSet rs = new RecordSet();
if(rs.executeQuery(select_sql,fieldId)){
while(rs.next()){
fieldname = Util.null2String(rs.getString(1));
}
}
}
return fieldname;
}
/**
*
* @param cus_sql SQL
* @param value
* @return
*/
public static String getStaticValueByChangeRule(String cus_sql,String value){
return getStaticValueByChangeRule(cus_sql,value,"");
}
/**
*
* @param cus_sql SQL
* @param value
* @param requestid ID
* @return
*/
public static String getStaticValueByChangeRule(String cus_sql,String value,String requestid){
return getStaticValueByChangeRule(cus_sql,value,requestid,0);
}
/**
*
* @param cus_sql SQL
* @param value
* @param requestid ID
* @param detailKeyvalue
* @return
*/
public static String getStaticValueByChangeRule(String cus_sql,String value,String requestid,int detailKeyvalue){
return getStaticValueByChangeRule(cus_sql,value,requestid,detailKeyvalue,null);
}
/**
*
* @param cusSQL SQL
* @param value
* @param requestid ID
* @param detailKeyvalue
* @pram datasourceid ID
* @return
*/
public static String getStaticValueByChangeRule(String cusSQL,String value,String requestid,int detailKeyvalue,String datasourceid){
String endValue = "";
cusSQL = cusSQL.replace("&nbsp;", " ");
cusSQL = cusSQL.replace("{?dt.id}", String.valueOf(detailKeyvalue));
//参数进行替换
String sqlString = cusSQL.replace("{?requestid}", requestid);
sqlString = sqlString.replace("?", value);
sqlString = staticToDBC(sqlString);
try {
if(datasourceid != null && !"".equals(datasourceid)){
ConnStatementDataSource csds = new ConnStatementDataSource(datasourceid);
csds.setStatementSql(sqlString);
csds.executeQuery();
if(csds.next()){
endValue = Util.null2String(csds.getString(1));
}
csds.close();
}else{
RecordSet rs = new RecordSet();
if(rs.executeQuery(sqlString)){
rs.next();
endValue = Util.null2String(rs.getString(1));
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return endValue;
}
/**
*
* @param input
* @return
*/
public static String staticToDBC(String input) {
char c[] = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == '\u3000') {
c[i] = ' ';
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
c[i] = (char) (c[i] - 65248);
}
}
String returnString = new String(c);
return returnString;
}
}