|
|
|
@ -1,26 +1,12 @@ |
|
|
|
package apelet.common.online.plugin.pre; |
|
|
|
package apelet.common.online.plugin.pre; |
|
|
|
|
|
|
|
|
|
|
|
import apelet.common.core.exception.MyRuntimeException; |
|
|
|
|
|
|
|
import apelet.common.core.object.ObjectCollection; |
|
|
|
|
|
|
|
import apelet.common.core.object.ObjectValue; |
|
|
|
|
|
|
|
import apelet.common.core.util.ApplicationContextHolder; |
|
|
|
import apelet.common.core.util.ApplicationContextHolder; |
|
|
|
import apelet.common.generator.model.*; |
|
|
|
import apelet.common.generator.service.IOnlFormHeadService; |
|
|
|
import apelet.common.generator.service.*; |
|
|
|
|
|
|
|
import apelet.common.generator.service.impl.ReverseWritingBusinessServiceImpl; |
|
|
|
|
|
|
|
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
|
|
|
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
|
|
|
import apelet.common.online.plugin.BeginOperationTransactionArgs; |
|
|
|
|
|
|
|
import apelet.common.online.plugin.OperationServicePlugIn; |
|
|
|
import apelet.common.online.plugin.OperationServicePlugIn; |
|
|
|
import apelet.common.online.plugin.OperationServicePlugInArgs; |
|
|
|
import apelet.common.online.plugin.OperationServicePlugInArgs; |
|
|
|
import apelet.common.online.service.OnlineFormService; |
|
|
|
|
|
|
|
import apelet.common.online.service.OnlineOperationService; |
|
|
|
|
|
|
|
import apelet.common.online.service.impl.OnlineFormServiceImpl; |
|
|
|
import apelet.common.online.service.impl.OnlineFormServiceImpl; |
|
|
|
import apelet.common.online.util.Jexl3Util; |
|
|
|
import apelet.common.online.util.Jexl3Util; |
|
|
|
import apelet.common.orm.impl.Selector; |
|
|
|
|
|
|
|
import apelet.common.orm.impl.SelectorItem; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Soon |
|
|
|
* @author Soon |
|
|
|
@ -30,9 +16,9 @@ import java.util.*; |
|
|
|
public class AuditOperationServicePlugIn extends OperationServicePlugIn { |
|
|
|
public class AuditOperationServicePlugIn extends OperationServicePlugIn { |
|
|
|
|
|
|
|
|
|
|
|
private OnlineFormServiceImpl onlineFormService; |
|
|
|
private OnlineFormServiceImpl onlineFormService; |
|
|
|
private IReverseWritingRulesService reverseWritingRulesService; |
|
|
|
// private IReverseWritingRulesService reverseWritingRulesService;
|
|
|
|
private IReverseWritingBusinessService businessService; |
|
|
|
// private IReverseWritingBusinessService businessService;
|
|
|
|
private IReverseWritingFormulaService formulaService; |
|
|
|
// private IReverseWritingFormulaService formulaService;
|
|
|
|
private OrmGenDataSourceUtil ormGenDataSourceUtil; |
|
|
|
private OrmGenDataSourceUtil ormGenDataSourceUtil; |
|
|
|
private IOnlFormHeadService onlFormHeadService; |
|
|
|
private IOnlFormHeadService onlFormHeadService; |
|
|
|
private Jexl3Util jexl3Util; |
|
|
|
private Jexl3Util jexl3Util; |
|
|
|
@ -40,9 +26,9 @@ public class AuditOperationServicePlugIn extends OperationServicePlugIn { |
|
|
|
|
|
|
|
|
|
|
|
public AuditOperationServicePlugIn() { |
|
|
|
public AuditOperationServicePlugIn() { |
|
|
|
onlineFormService = ApplicationContextHolder.getBean("onlineFormService"); |
|
|
|
onlineFormService = ApplicationContextHolder.getBean("onlineFormService"); |
|
|
|
reverseWritingRulesService = ApplicationContextHolder.getBean("reverseWritingRulesServiceImpl"); |
|
|
|
// reverseWritingRulesService = ApplicationContextHolder.getBean("reverseWritingRulesServiceImpl");
|
|
|
|
businessService = ApplicationContextHolder.getBean("reverseWritingBusinessServiceImpl"); |
|
|
|
// businessService = ApplicationContextHolder.getBean("reverseWritingBusinessServiceImpl");
|
|
|
|
formulaService = ApplicationContextHolder.getBean("reverseWritingFormulaServiceImpl"); |
|
|
|
// formulaService = ApplicationContextHolder.getBean("reverseWritingFormulaServiceImpl");
|
|
|
|
ormGenDataSourceUtil = ApplicationContextHolder.getBean("ormGenDataSourceUtil"); |
|
|
|
ormGenDataSourceUtil = ApplicationContextHolder.getBean("ormGenDataSourceUtil"); |
|
|
|
onlFormHeadService = ApplicationContextHolder.getBean("onlFormHeadServiceImpl"); |
|
|
|
onlFormHeadService = ApplicationContextHolder.getBean("onlFormHeadServiceImpl"); |
|
|
|
jexl3Util = ApplicationContextHolder.getBean("jexl3Util"); |
|
|
|
jexl3Util = ApplicationContextHolder.getBean("jexl3Util"); |
|
|
|
@ -55,103 +41,103 @@ public class AuditOperationServicePlugIn extends OperationServicePlugIn { |
|
|
|
e.addFiledKey("billstatus"); |
|
|
|
e.addFiledKey("billstatus"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
// @Override
|
|
|
|
public void beginOperationTransaction(BeginOperationTransactionArgs e) { |
|
|
|
// public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
|
|
|
|
|
|
//
|
|
|
|
ObjectValue objectValue = e.getModel(); |
|
|
|
// ObjectValue objectValue = e.getModel();
|
|
|
|
if (!objectValue.get("billstatus").equals("B")) { |
|
|
|
// if (!objectValue.get("billstatus").equals("B")) {
|
|
|
|
throw new RuntimeException("只有提交状态才能审核"); |
|
|
|
// throw new RuntimeException("只有提交状态才能审核");
|
|
|
|
} |
|
|
|
// }
|
|
|
|
try { |
|
|
|
// try {
|
|
|
|
objectValue.put("billstatus", "C"); |
|
|
|
// objectValue.put("billstatus", "C");
|
|
|
|
Selector selector = new Selector(); |
|
|
|
// Selector selector = new Selector();
|
|
|
|
selector.getList().add(new SelectorItem("billstatus")); |
|
|
|
// selector.getList().add(new SelectorItem("billstatus"));
|
|
|
|
ormGenDataSourceUtil().update(objectValue.getTableName(), objectValue, selector); |
|
|
|
// ormGenDataSourceUtil().update(objectValue.getTableName(), objectValue, selector);
|
|
|
|
|
|
|
|
//
|
|
|
|
OnlFormHead onlFormHead = onlFormHeadService.getOne(new LambdaQueryWrapper<OnlFormHead>().eq(OnlFormHead::getTableName, objectValue.getTableName())); |
|
|
|
// OnlFormHead onlFormHead = onlFormHeadService.getOne(new LambdaQueryWrapper<OnlFormHead>().eq(OnlFormHead::getTableName, objectValue.getTableName()));
|
|
|
|
List<ReverseWritingRules> list = reverseWritingRulesService.list( |
|
|
|
// List<ReverseWritingRules> list = reverseWritingRulesService.list(
|
|
|
|
new LambdaQueryWrapper<ReverseWritingRules>() |
|
|
|
// new LambdaQueryWrapper<ReverseWritingRules>()
|
|
|
|
.eq(ReverseWritingRules::getTargetDoc, onlFormHead.getId()) |
|
|
|
// .eq(ReverseWritingRules::getTargetDoc, onlFormHead.getId())
|
|
|
|
.eq(ReverseWritingRules::getTriggerTiming, 2) |
|
|
|
// .eq(ReverseWritingRules::getTriggerTiming, 2)
|
|
|
|
.eq(ReverseWritingRules::getEnable, 1) |
|
|
|
// .eq(ReverseWritingRules::getEnable, 1)
|
|
|
|
); |
|
|
|
// );
|
|
|
|
if (list.isEmpty()) { |
|
|
|
// if (list.isEmpty()) {
|
|
|
|
return; |
|
|
|
// return;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
objectValue = ormGenDataSourceUtil.queryOne(objectValue.getTableName(), objectValue.getLong("id")); |
|
|
|
// objectValue = ormGenDataSourceUtil.queryOne(objectValue.getTableName(), objectValue.getLong("id"));
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
for (ReverseWritingRules rules : list) { |
|
|
|
// for (ReverseWritingRules rules : list) {
|
|
|
|
List<ReverseWritingBusiness> businesses = businessService.list( |
|
|
|
// List<ReverseWritingBusiness> businesses = businessService.list(
|
|
|
|
new LambdaQueryWrapper<ReverseWritingBusiness>() |
|
|
|
// new LambdaQueryWrapper<ReverseWritingBusiness>()
|
|
|
|
.eq(ReverseWritingBusiness::getRulesId, rules.getId()) |
|
|
|
// .eq(ReverseWritingBusiness::getRulesId, rules.getId())
|
|
|
|
.eq(ReverseWritingBusiness::getEnable, 1) |
|
|
|
// .eq(ReverseWritingBusiness::getEnable, 1)
|
|
|
|
); |
|
|
|
// );
|
|
|
|
List<ReverseWritingFormula> formulaList = formulaService.list( |
|
|
|
// List<ReverseWritingFormula> formulaList = formulaService.list(
|
|
|
|
new LambdaQueryWrapper<ReverseWritingFormula>() |
|
|
|
// new LambdaQueryWrapper<ReverseWritingFormula>()
|
|
|
|
.eq(ReverseWritingFormula::getRulesId, rules.getId()) |
|
|
|
// .eq(ReverseWritingFormula::getRulesId, rules.getId())
|
|
|
|
.eq(ReverseWritingFormula::getEnable, 1) |
|
|
|
// .eq(ReverseWritingFormula::getEnable, 1)
|
|
|
|
); |
|
|
|
// );
|
|
|
|
OnlFormHead srcForm = onlFormHeadService.getOne( |
|
|
|
// OnlFormHead srcForm = onlFormHeadService.getOne(
|
|
|
|
new LambdaQueryWrapper<OnlFormHead>().eq(OnlFormHead::getId, rules.getSourceDocuments()) |
|
|
|
// new LambdaQueryWrapper<OnlFormHead>().eq(OnlFormHead::getId, rules.getSourceDocuments())
|
|
|
|
); |
|
|
|
// );
|
|
|
|
if (objectValue.getValues().containsKey("srcbillid")) { |
|
|
|
// if (objectValue.getValues().containsKey("srcbillid")) {
|
|
|
|
|
|
|
|
//
|
|
|
|
} else { |
|
|
|
// } else {
|
|
|
|
Map map = objectValue.getValues(); |
|
|
|
// Map map = objectValue.getValues();
|
|
|
|
for (Object key : map.keySet()) { |
|
|
|
// for (Object key : map.keySet()) {
|
|
|
|
if (map.get(key) instanceof ObjectCollection) { |
|
|
|
// if (map.get(key) instanceof ObjectCollection) {
|
|
|
|
ObjectCollection entryList = (ObjectCollection) map.get(key); |
|
|
|
// ObjectCollection entryList = (ObjectCollection) map.get(key);
|
|
|
|
Iterator iterator = entryList.iterator(); |
|
|
|
// Iterator iterator = entryList.iterator();
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
// while (iterator.hasNext()) {
|
|
|
|
ObjectValue next = (ObjectValue) iterator.next(); |
|
|
|
// ObjectValue next = (ObjectValue) iterator.next();
|
|
|
|
if (next.containsKey("srcbillid")) { |
|
|
|
// if (next.containsKey("srcbillid")) {
|
|
|
|
ObjectValue srcObjectValue = ormGenDataSourceUtil.queryOne(srcForm.getTableName(), next.getLong("srcbillid")); |
|
|
|
// ObjectValue srcObjectValue = ormGenDataSourceUtil.queryOne(srcForm.getTableName(), next.getLong("srcbillid"));
|
|
|
|
ObjectValue finalObjectValue = objectValue; |
|
|
|
// ObjectValue finalObjectValue = objectValue;
|
|
|
|
businesses.forEach(b -> { |
|
|
|
// businesses.forEach(b -> {
|
|
|
|
try { |
|
|
|
// try {
|
|
|
|
boolean bool = (boolean) onlineFormService.func(b.getPreconditionsEnglish(), JSON.parseObject(b.getPreconditionsJson()), finalObjectValue); |
|
|
|
// boolean bool = (boolean) onlineFormService.func(b.getPreconditionsEnglish(), JSON.parseObject(b.getPreconditionsJson()), finalObjectValue);
|
|
|
|
String expressionTransl = bool ? b.getEstablishedEnglish() : b.getNotEstablishedEnglish(); |
|
|
|
// String expressionTransl = bool ? b.getEstablishedEnglish() : b.getNotEstablishedEnglish();
|
|
|
|
String jsonObj = bool ? b.getEstablishedJson() : b.getNotEstablishedJson(); |
|
|
|
// String jsonObj = bool ? b.getEstablishedJson() : b.getNotEstablishedJson();
|
|
|
|
List<String> split = Arrays.asList(expressionTransl.split("=")); |
|
|
|
// List<String> split = Arrays.asList(expressionTransl.split("="));
|
|
|
|
String fun = ""; |
|
|
|
// String fun = "";
|
|
|
|
for (String s : split) { |
|
|
|
// for (String s : split) {
|
|
|
|
s = s.trim(); |
|
|
|
// s = s.trim();
|
|
|
|
if (s.startsWith("$") && s.endsWith("$")) { |
|
|
|
// if (s.startsWith("$") && s.endsWith("$")) {
|
|
|
|
fun = s; |
|
|
|
// fun = s;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
fun = jexl3Util.getMySplit("\\$(.*?)\\$", fun); |
|
|
|
// fun = jexl3Util.getMySplit("\\$(.*?)\\$", fun);
|
|
|
|
List<String> funParam = Arrays.asList(jexl3Util.getMySplit("\\((.*?)\\)", fun).split(",")); |
|
|
|
// List<String> funParam = Arrays.asList(jexl3Util.getMySplit("\\((.*?)\\)", fun).split(","));
|
|
|
|
Object[] objects = jexl3Util.getFunParam(funParam, finalObjectValue); |
|
|
|
// Object[] objects = jexl3Util.getFunParam(funParam, finalObjectValue);
|
|
|
|
Object o = onlineFormService.executeFunction(JSON.parseObject(jsonObj), fun, objects); |
|
|
|
// Object o = onlineFormService.executeFunction(JSON.parseObject(jsonObj), fun, objects);
|
|
|
|
ormGenDataSourceUtil.update(srcObjectValue.getTableName(), srcObjectValue, null); |
|
|
|
// ormGenDataSourceUtil.update(srcObjectValue.getTableName(), srcObjectValue, null);
|
|
|
|
} catch (Exception ex) { |
|
|
|
// } catch (Exception ex) {
|
|
|
|
throw new RuntimeException(ex); |
|
|
|
// throw new RuntimeException(ex);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
formulaList.forEach(f -> { |
|
|
|
// formulaList.forEach(f -> {
|
|
|
|
|
|
|
|
//
|
|
|
|
try { |
|
|
|
// try {
|
|
|
|
ormGenDataSourceUtil.update(srcObjectValue.getTableName(), srcObjectValue, null); |
|
|
|
// ormGenDataSourceUtil.update(srcObjectValue.getTableName(), srcObjectValue, null);
|
|
|
|
} catch (Exception ex) { |
|
|
|
// } catch (Exception ex) {
|
|
|
|
throw new RuntimeException(ex); |
|
|
|
// throw new RuntimeException(ex);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// 审核反写规则
|
|
|
|
// // 审核反写规则
|
|
|
|
|
|
|
|
//
|
|
|
|
} catch (Exception e1) { |
|
|
|
// } catch (Exception e1) {
|
|
|
|
throw new MyRuntimeException(e1); |
|
|
|
// throw new MyRuntimeException(e1);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|