Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
c3be85820f
|
@ -0,0 +1,105 @@
|
|||
package shkd.sys.sys.plugin.list;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.form.ConfirmTypes;
|
||||
import kd.bos.form.MessageBoxOptions;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.botp.BFTrackerServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import kd.tmc.cdm.common.constant.CdmEntityConst;
|
||||
import shkd.sys.sys.plugin.report.FinanceReportPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReceivableListPlugin extends AbstractListPlugin {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ReceivableListPlugin.class);
|
||||
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
|
||||
super.afterDoOperation(afterDoOperationEventArgs);
|
||||
String operateKey = afterDoOperationEventArgs.getOperateKey();
|
||||
if ("autogenrecbill".equals(operateKey)){
|
||||
OperationResult operationResult = afterDoOperationEventArgs.getOperationResult();
|
||||
if (operationResult.getSuccessPkIds().size()!=0){
|
||||
List<Object> successPkIds = operationResult.getSuccessPkIds();
|
||||
for (Object successPkId : successPkIds) {
|
||||
Map<String, HashSet<Long>> cdm_receivablebill = BFTrackerServiceHelper.findTargetBills("cdm_receivablebill", new Long[]{(Long) successPkId});
|
||||
System.out.println(cdm_receivablebill);
|
||||
HashSet<Long> cas_recbill = cdm_receivablebill.get("cas_recbill");
|
||||
QFilter filter = new QFilter("shkd_zdxtid", QCP.equals, "true");
|
||||
filter.and(new QFilter("id", QCP.in, cas_recbill));
|
||||
DynamicObject[] CDM_PAYABLEBILLs = BusinessDataServiceHelper.load("cas_recbill", "id,billno,org", filter.toArray());
|
||||
List<Long> list = new ArrayList<>();
|
||||
for (int i = 0; i < CDM_PAYABLEBILLs.length; i++) {
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(CDM_PAYABLEBILLs[i].get("id"), "cas_recbill");
|
||||
list.add(dynamicObject.getLong("id"));
|
||||
}
|
||||
if (list.size()!=0){
|
||||
StringBuilder Builder = new StringBuilder("");
|
||||
//调用方法执行数据 - 自动兑付下推
|
||||
OperationResult operationResult1 = OperationServiceHelper.executeOperate("submit",
|
||||
"cas_recbill",
|
||||
list.toArray(), OperateOption.create());
|
||||
logger.info("operationResult1:"+operationResult1);
|
||||
// if (operationResult1.getAllErrorInfo().size()!=0){
|
||||
// List<OperateErrorInfo> allErrorInfo = operationResult1.getAllErrorInfo();
|
||||
// for (int i = 0; i < allErrorInfo.size(); i++) {
|
||||
// String message = allErrorInfo.get(i).getMessage();
|
||||
// Builder.append(message+"\n");
|
||||
// }
|
||||
// }
|
||||
|
||||
OperationResult operationResult2=null;
|
||||
if ( operationResult1.getSuccessPkIds().size()!=0){
|
||||
operationResult2 = OperationServiceHelper.executeOperate("audit",
|
||||
"cas_recbill",
|
||||
operationResult1.getSuccessPkIds().toArray(), OperateOption.create());
|
||||
// if (operationResult2.getAllErrorInfo().size()!=0){
|
||||
// List<OperateErrorInfo> allErrorInfo = operationResult2.getAllErrorInfo();
|
||||
// for (int i = 0; i < allErrorInfo.size(); i++) {
|
||||
// String message = allErrorInfo.get(i).getMessage();
|
||||
// Builder.append(message+"\n");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
logger.info("operationResult2:"+operationResult2);
|
||||
|
||||
|
||||
OperationResult operationResult3=null;
|
||||
if (operationResult2!=null && operationResult2.getSuccessPkIds().size()!=0){
|
||||
operationResult3 = OperationServiceHelper.executeOperate("receivingrec",
|
||||
"cas_recbill",
|
||||
operationResult2.getSuccessPkIds().toArray(), OperateOption.create());
|
||||
// if (operationResult3.getAllErrorInfo().size()!=0){
|
||||
// List<OperateErrorInfo> allErrorInfo = operationResult3.getAllErrorInfo();
|
||||
// for (int i = 0; i < allErrorInfo.size(); i++) {
|
||||
// String message = allErrorInfo.get(i).getMessage();
|
||||
// Builder.append(message+"\n");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
logger.info("operationResult3:"+operationResult3);
|
||||
|
||||
// if (StringUtils.isEmpty(Builder.toString())){
|
||||
// this.getView().showConfirm("操作失败",Builder.toString() , MessageBoxOptions.None, ConfirmTypes.Default, null);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,13 +10,11 @@ import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
||||
import kd.bos.entity.plugin.args.ReturnOperationArgs;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.entity.validate.ValidatePriority;
|
||||
import kd.bos.entity.validate.ValidateResult;
|
||||
import kd.bos.entity.validate.ValidateResultCollection;
|
||||
import kd.bos.entity.validate.*;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shkd.sys.sys.plugin.list.ElectronicPayDealListPlugin;
|
||||
import shkd.sys.sys.plugin.operation.domain.TimeValidator;
|
||||
|
||||
import java.time.Duration;
|
||||
|
@ -33,14 +31,14 @@ public class ElectronicPayDealOPPlugin extends AbstractOperationServicePlugIn im
|
|||
@Override
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
super.onPreparePropertys(e);
|
||||
Iterator<Map.Entry<Long, LocalDateTime>> iterator = timemap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<Long, LocalDateTime> entry = iterator.next();
|
||||
Duration duration = Duration.between(entry.getValue(), LocalDateTime.now());
|
||||
if (duration.getSeconds() > 10) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
// Iterator<Map.Entry<Long, LocalDateTime>> iterator = timemap.entrySet().iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// Map.Entry<Long, LocalDateTime> entry = iterator.next();
|
||||
// Duration duration = Duration.between(entry.getValue(), LocalDateTime.now());
|
||||
// if (duration.getSeconds() > 10) {
|
||||
// iterator.remove();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,25 +76,25 @@ public class ElectronicPayDealOPPlugin extends AbstractOperationServicePlugIn im
|
|||
|
||||
@Override
|
||||
public void onReturnOperation(ReturnOperationArgs e) {
|
||||
List<Object> overtime = new ArrayList<>();//存放因连续点击而校验失败的数据
|
||||
super.onReturnOperation(e);
|
||||
ValidateResultCollection validateResult = this.operationResult.getValidateResult();
|
||||
List<ValidateResult> validateErrors = validateResult.getValidateErrors();
|
||||
for (ValidateResult validateError : validateErrors) {
|
||||
List<OperateErrorInfo> allErrorInfo = validateError.getAllErrorInfo();
|
||||
for (OperateErrorInfo operateErrorInfo : allErrorInfo) {
|
||||
String message = operateErrorInfo.getMessage();
|
||||
if (message.contains("当前单据已更新操作结果,请十秒后再更新")){
|
||||
overtime.add(operateErrorInfo.getPkValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Object> successPkIds = e.getOperationResult().getSuccessPkIds();//执行成功的数据
|
||||
Map<Object, String> billNos = ((OperationResult) e.getOperationResult()).getBillNos();
|
||||
billNos.keySet().removeAll(successPkIds);
|
||||
billNos.keySet().removeAll(overtime);
|
||||
for (Object key : billNos.keySet()) {
|
||||
timemap.remove(key);
|
||||
}
|
||||
// List<Object> overtime = new ArrayList<>();//存放因连续点击而校验失败的数据
|
||||
// super.onReturnOperation(e);
|
||||
// ValidateResultCollection validateResult = this.operationResult.getValidateResult();
|
||||
// List<ValidateResult> validateErrors = validateResult.getValidateErrors();
|
||||
// for (ValidateResult validateError : validateErrors) {
|
||||
// List<OperateErrorInfo> allErrorInfo = validateError.getAllErrorInfo();
|
||||
// for (OperateErrorInfo operateErrorInfo : allErrorInfo) {
|
||||
// String message = operateErrorInfo.getMessage();
|
||||
// if (message.contains("当前单据已更新操作结果,请十秒后再更新")){
|
||||
// overtime.add(operateErrorInfo.getPkValue());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// List<Object> successPkIds = e.getOperationResult().getSuccessPkIds();//执行成功的数据
|
||||
// Map<Object, String> billNos = ((OperationResult) e.getOperationResult()).getBillNos();//用于存放要去除的数据
|
||||
// billNos.keySet().removeAll(successPkIds);
|
||||
// billNos.keySet().removeAll(overtime);
|
||||
// for (Object key : billNos.keySet()) {
|
||||
// timemap.remove(key);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import kd.bos.dataentity.entity.DynamicObject;
|
|||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.validate.AbstractValidator;
|
||||
import kd.bos.entity.validate.ErrorLevel;
|
||||
import kd.bos.entity.validate.ValidationErrorInfo;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import shkd.sys.sys.plugin.operation.ElectronicPayDealOPPlugin;
|
||||
|
||||
import java.time.Duration;
|
||||
|
@ -18,18 +20,28 @@ public class TimeValidator extends AbstractValidator {
|
|||
for(ExtendedDataEntity obj :dataEntities){
|
||||
DynamicObject bill = obj.getDataEntity();//获取当前单据的数据包
|
||||
Long id = bill.getLong("id");//进一步获取编码字段
|
||||
Map<Long, LocalDateTime> timemap = ElectronicPayDealOPPlugin.timemap;
|
||||
LocalDateTime localDateTime = timemap.get(id);
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
if (localDateTime!=null){
|
||||
// Map<Long, LocalDateTime> timemap = ElectronicPayDealOPPlugin.timemap;
|
||||
// LocalDateTime localDateTime = timemap.get(id);
|
||||
// LocalDateTime currentTime = LocalDateTime.now();
|
||||
// if (localDateTime!=null){
|
||||
//
|
||||
// Duration duration = Duration.between(localDateTime, currentTime);
|
||||
// // 判断时间差是否超过 10 秒
|
||||
// if (duration.getSeconds() <= 10) {
|
||||
// this.addMessage(obj,"当前单据已更新操作结果,请十秒后再更新", ErrorLevel.Error);//错误消息
|
||||
// timemap.put(id,localDateTime);
|
||||
// }else {
|
||||
// timemap.put(id,currentTime);
|
||||
// }
|
||||
// }else {
|
||||
// timemap.put(id,currentTime);
|
||||
// }
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(id, obj.getDataEntity().getDataEntityType().getName());
|
||||
boolean shkd_lock = dynamicObject.getBoolean("shkd_lock");
|
||||
if (shkd_lock){
|
||||
this.addMessage(obj,"当前单据已锁定", ErrorLevel.Error);//错误消息
|
||||
}
|
||||
|
||||
Duration duration = Duration.between(localDateTime, currentTime);
|
||||
// 判断时间差是否超过 10 秒
|
||||
if (duration.getSeconds() <= 10) {
|
||||
this.addMessage(obj,"当前单据已更新操作结果,请十秒后再更新", ErrorLevel.Error);//错误消息
|
||||
}
|
||||
}
|
||||
timemap.put(id,currentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package shkd.sys.sys.plugin.other;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.BillEntityType;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.ExtendedDataEntitySet;
|
||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
||||
import kd.bos.entity.botp.plugin.args.AfterCreateLinkEventArgs;
|
||||
import kd.bos.entity.botp.plugin.args.AfterCreateTargetEventArgs;
|
||||
import kd.bos.entity.botp.plugin.args.AfterFieldMappingEventArgs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CasRecbillBOTPPlugin extends AbstractConvertPlugIn {
|
||||
|
||||
/**
|
||||
* 创建目标单据数据包后事件
|
||||
*
|
||||
* @param e
|
||||
* @remark
|
||||
* 这个事件,只在下推时触发,把根据分单规则创建好的目标单,传递给插件
|
||||
*/
|
||||
@Override
|
||||
public void afterCreateTarget(AfterCreateTargetEventArgs e) {
|
||||
System.out.println(666);
|
||||
}
|
||||
|
||||
/**
|
||||
* 目标字段赋值完毕后事件
|
||||
*
|
||||
* @param e
|
||||
* @remark
|
||||
* 插件可以在此基础上,继续填写目标字段值
|
||||
*/
|
||||
@Override
|
||||
public void afterFieldMapping(AfterFieldMappingEventArgs e) {
|
||||
System.out.println(666);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 记录关联关系后事件
|
||||
*
|
||||
* @param e
|
||||
* @remark
|
||||
* 根据系统自动记录的关联关系,进行相关数据的同步携带,如携带其他子单据体数据
|
||||
*/
|
||||
@Override
|
||||
public void afterCreateLink(AfterCreateLinkEventArgs e) {
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterConvert(AfterConvertEventArgs e) {
|
||||
super.afterConvert(e);
|
||||
BillEntityType tgtMainType = this.getTgtMainType();
|
||||
ExtendedDataEntitySet targetExtDataEntitySet = e.getTargetExtDataEntitySet();
|
||||
List<ExtendedDataEntity> cas_recbill = targetExtDataEntitySet.getExtDataEntityMap().get("cas_recbill");
|
||||
for (ExtendedDataEntity extendedDataEntity : cas_recbill) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
dataEntity.set("shkd_zdxtid","true");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue