Merge remote-tracking branch 'origin/main'

This commit is contained in:
wenlukang1 2025-07-01 17:52:10 +08:00
commit 478c78d798
3 changed files with 199 additions and 20 deletions

View File

@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.form;
import dm.jdbc.util.StringUtil;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.data.BusinessDataReader;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.IDataEntityType;
@ -20,6 +21,7 @@ import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.datamodel.events.ChangeData;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.form.IPageCache;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.field.BasedataEdit;
@ -31,9 +33,12 @@ import kd.bos.form.operate.AbstractOperate;
import kd.bos.form.operate.botp.Push;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.list.ListShowParameter;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.ConvertServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.bos.util.StringUtils;
import kd.fi.cas.enums.SettleMentTypeEnum;
@ -48,6 +53,8 @@ import java.util.*;
*/
public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7SelectListener {
private static final Log logger = LogFactory.getLog(CasRecbillFormPlugin.class);
public static final List<String> update_fk = Arrays.asList("payername","payeracctbanknum","f7_payerbank","payerbankname");//拉单需要更新的付款方
public static final List<String> update_sk = Arrays.asList("org", "payeebank", "accountbank");//拉单需要更新的收款方
public static final List<String> update_qt = Arrays.asList("receivingtype");//拉单需要更新的其他字段
@ -98,12 +105,45 @@ public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7
Object oldValue = changeData[0].getOldValue();
if ("shkd_ywcl".equals(name)){
if (newValue != oldValue&&newValue!=null) {
DynamicObject dynamicObject=(DynamicObject)newValue;
IPageCache iPageCache =this.getPageCache();
iPageCache.put("shkd_ywclid",dynamicObject.getString("id"));
this.getView().invokeOperation("drawauto");
if (newValue != oldValue) {
if (newValue!=null){
if(oldValue!=null){
DynamicObject cdm_drafttradebill=(DynamicObject)oldValue;
List<Long> ids = new ArrayList<>();
ids.add(cdm_drafttradebill.getLong("id"));
OperationResult operationResult = OperationServiceHelper.executeOperate("canceldrawbill",
"cdm_drafttradebill",
ids.toArray(new Object[]{}), OperateOption.create());//取消完成
if (operationResult.isSuccess()){
//成功
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成成功");
}else {
//失败
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成失败");
this.getView().showSuccessNotification("单据编号"+cdm_drafttradebill.getString("billno")+"取消确认完成失败,请检查并手动取消完成");
}
this.getModel().setValue("draftbill",null);
this.getModel().setValue("settletnumber",null);
}
this.getView().invokeOperation("drawauto");
}else {
DynamicObject cdm_drafttradebill=(DynamicObject)oldValue;
List<Long> ids = new ArrayList<>();
ids.add(cdm_drafttradebill.getLong("id"));
OperationResult operationResult = OperationServiceHelper.executeOperate("canceldrawbill",
"cdm_drafttradebill",
ids.toArray(new Object[]{}), OperateOption.create());//取消完成
if (operationResult.isSuccess()){
//成功
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成成功");
}else {
//失败
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成失败");
this.getView().showSuccessNotification("单据编号"+cdm_drafttradebill.getString("billno")+"取消确认完成失败,请检查并手动取消完成");
}
this.getModel().setValue("draftbill",null);
this.getModel().setValue("settletnumber",null);
}
}
}
@ -221,7 +261,7 @@ public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7
row.setRowKey(0);
row.setPageIndex(0);
srcRows.add(row);
doDraw(convertOpParameter,srcRows);
doDraw(convertOpParameter,srcRows,(DynamicObject)this.getModel().getValue("shkd_ywcl"));
args.setCancel(true);
}
@ -292,7 +332,7 @@ public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7
}
public void doDraw(ConvertOpParameter opParameter, ListSelectedRowCollection srcRows) {
public void doDraw(ConvertOpParameter opParameter, ListSelectedRowCollection srcRows,DynamicObject cdm_drafttradebill) {
if (srcRows != null && srcRows.size() != 0) {
String sourceEntityNumber = opParameter.getDefSourceBill();
String ruleId = opParameter.getDefRuleId();
@ -317,8 +357,7 @@ public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7
};
List<DynamicObject> dataEntitys = result.loadTargetDataObjects(refProvider,this.getView().getModel().getDataEntityType());
DynamicObject dynamicObject = dataEntitys.get(0);
if (!StringUtil.isEmpty(iPageCache.get("shkd_ywclid"))){
DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle(Long.parseLong(iPageCache.get("shkd_ywclid")), "cdm_drafttradebill");
if (cdm_drafttradebill!=null){
dynamicObject.set("shkd_ywcl",cdm_drafttradebill);
}
for (int i = 0; i < update_fk.size(); i++) {
@ -348,6 +387,23 @@ public class CasRecbillFormPlugin extends AbstractBillPlugIn implements BeforeF7
this.getView().updateView();
result.release(refProvider, this.getView().getModel().getDataEntityType());
logger.info("单据编号"+this.getModel().getValue("billno")+"拉单成功,正在对编号"+cdm_drafttradebill.getString("billno")+"业务处理进行交易成功");
if (cdm_drafttradebill!=null){
List<Long> ids = new ArrayList<>();
ids.add(cdm_drafttradebill.getLong("id"));
OperationResult operationResult = OperationServiceHelper.executeOperate("drawbillsave",
"cdm_drafttradebill",
ids.toArray(new Object[]{}), OperateOption.create());//确认完成
if (operationResult.isSuccess()){
//成功
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"确认完成成功");
}else {
//失败
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"确认完成失败");
// this.getView().showSuccessNotification("取消确认完成失败,请检查并手动取消完成");
}
}
SaveServiceHelper.save(new DynamicObject[]{this.getView().getModel().getDataEntity()});
} else {
Push.showReport(this.getView(), args, result);

View File

@ -3,6 +3,7 @@ package shkd.sys.sys.plugin.form;
import dm.jdbc.util.StringUtil;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.data.BusinessDataReader;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.metadata.IDataEntityType;
@ -37,9 +38,11 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.botp.ConvertServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import kd.fi.cas.util.EmptyUtil;
import kd.sdk.plugin.Plugin;
import kd.tmc.cdm.common.constant.CdmEntityConst;
import shkd.sys.sys.mservice.ApiService;
import java.util.*;
@ -152,12 +155,45 @@ public class PaymentProcessingBillPlugin extends AbstractBillPlugIn implements P
}
if ("shkd_ywcl".equals(key)){
if (newValue != oldValue&&newValue!=null) {
DynamicObject dynamicObject=(DynamicObject)newValue;
IPageCache iPageCache =this.getPageCache();
iPageCache.put("shkd_ywclid",dynamicObject.getString("id"));
this.getView().invokeOperation("drawauto");
if (newValue != oldValue) {
if (newValue!=null){
if(oldValue!=null){
DynamicObject cdm_drafttradebill=(DynamicObject)oldValue;
List<Long> ids = new ArrayList<>();
ids.add(cdm_drafttradebill.getLong("id"));
OperationResult operationResult = OperationServiceHelper.executeOperate("canceldrawbill",
"cdm_drafttradebill",
ids.toArray(new Object[]{}), OperateOption.create());//取消完成
if (operationResult.isSuccess()){
//成功
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成成功");
}else {
//失败
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成失败");
this.getView().showSuccessNotification("单据编号"+cdm_drafttradebill.getString("billno")+"取消确认完成失败,请检查并手动取消完成");
}
this.getModel().setValue("draftbill",null);
this.getModel().setValue("settletnumber",null);
}
this.getView().invokeOperation("drawauto");
}else {
DynamicObject cdm_drafttradebill=(DynamicObject)oldValue;
List<Long> ids = new ArrayList<>();
ids.add(cdm_drafttradebill.getLong("id"));
OperationResult operationResult = OperationServiceHelper.executeOperate("canceldrawbill",
"cdm_drafttradebill",
ids.toArray(new Object[]{}), OperateOption.create());//取消完成
if (operationResult.isSuccess()){
//成功
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成成功");
}else {
//失败
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"取消完成失败");
this.getView().showSuccessNotification("单据编号"+cdm_drafttradebill.getString("billno")+"取消确认完成失败,请检查并手动取消完成");
}
this.getModel().setValue("draftbill",null);
this.getModel().setValue("settletnumber",null);
}
}
}
}
@ -209,13 +245,13 @@ public class PaymentProcessingBillPlugin extends AbstractBillPlugIn implements P
row.setRowKey(0);
row.setPageIndex(0);
srcRows.add(row);
doDraw(convertOpParameter,srcRows);
doDraw(convertOpParameter,srcRows,(DynamicObject)this.getModel().getValue("shkd_ywcl"));
args.setCancel(true);
}
}
public void doDraw(ConvertOpParameter opParameter, ListSelectedRowCollection srcRows) {
public void doDraw(ConvertOpParameter opParameter, ListSelectedRowCollection srcRows,DynamicObject cdm_drafttradebill) {
if (srcRows != null && srcRows.size() != 0) {
String sourceEntityNumber = opParameter.getDefSourceBill();
String ruleId = opParameter.getDefRuleId();
@ -240,8 +276,7 @@ public class PaymentProcessingBillPlugin extends AbstractBillPlugIn implements P
};
List<DynamicObject> dataEntitys = result.loadTargetDataObjects(refProvider,this.getView().getModel().getDataEntityType());
DynamicObject dynamicObject = dataEntitys.get(0);
if (!StringUtil.isEmpty(iPageCache.get("shkd_ywclid"))){
DynamicObject cdm_drafttradebill = BusinessDataServiceHelper.loadSingle(Long.parseLong(iPageCache.get("shkd_ywclid")), "cdm_drafttradebill");
if (cdm_drafttradebill!=null){
dynamicObject.set("shkd_ywcl",cdm_drafttradebill);
}
for (int i = 0; i < update_fk.size(); i++) {
@ -271,6 +306,23 @@ public class PaymentProcessingBillPlugin extends AbstractBillPlugIn implements P
this.getView().updateView();
result.release(refProvider, this.getView().getModel().getDataEntityType());
logger.info("单据编号"+this.getModel().getValue("billno")+"拉单成功,正在对编号"+cdm_drafttradebill.getString("billno")+"业务处理进行交易成功");
if (cdm_drafttradebill!=null){
List<Long> ids = new ArrayList<>();
ids.add(cdm_drafttradebill.getLong("id"));
OperationResult operationResult = OperationServiceHelper.executeOperate("drawbillsave",
"cdm_drafttradebill",
ids.toArray(new Object[]{}), OperateOption.create());//确认完成
if (operationResult.isSuccess()){
//成功
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"确认完成成功");
}else {
//失败
logger.info("单据编号"+cdm_drafttradebill.getString("billno")+"确认完成失败");
// this.getView().showSuccessNotification("取消确认完成失败,请检查并手动取消完成");
}
}
SaveServiceHelper.save(new DynamicObject[]{this.getView().getModel().getDataEntity()});
} else {
Push.showReport(this.getView(), args, result);

View File

@ -0,0 +1,71 @@
package shkd.sys.sys.plugin.task;
import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.exception.KDException;
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.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import java.util.Map;
public class ElectronicRecDealTaskPlugin extends AbstractTask {
private static final Log logger = LogFactory.getLog(ElectronicRecDealTaskPlugin.class);
@Override
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
QFilter filter = new QFilter("querydrafttype", QCP.equals, "hold");//在手票据
filter.and(new QFilter("tradetype", QCP.equals, "notesignin"));//签收
filter.and(new QFilter("ebstatus", QCP.equals, "BANK_SUCCESS"));//交易成功
QFilter filter1 = new QFilter("backinfoseries", QCP.not_equals, false);//在手票据
filter1.or(new QFilter("serieschecktimes", QCP.not_equals, 0));
filter=filter.and(filter1);
DynamicObject[] cdm_electronic_rec_deal = BusinessDataServiceHelper.load("cdm_electronic_rec_deal", "id,billno,draftaccount,entryentity,backinfoseries,serieschecktimes,entryentity.businesscode,entryentity.endorsee,entryentity.endorsedate", filter.toArray());
for (DynamicObject dynamicObject : cdm_electronic_rec_deal) {
//背面信息
DynamicObjectCollection entryentity = dynamicObject.getDynamicObjectCollection("entryentity");
if (entryentity.size()==0){
dynamicObject.set("backinfoseries",false);
dynamicObject.set("serieschecktimes",0);
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
}else {
//是否包含背书转让
boolean hasBizcode10 = entryentity.stream()
.anyMatch(dynamicObject1 -> "10".equals(dynamicObject1.getString("businesscode")));
if (!hasBizcode10){
//不存在背书转让
dynamicObject.set("backinfoseries",false);
dynamicObject.set("serieschecktimes",0);
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
}else {
//存在背书转让
String name = dynamicObject.getString("draftaccount.name");//票据账户.账户名称
//获取背面信息中最新的行数据
DynamicObject latestDynamicObject = entryentity.stream()
.max((dynamicObject1, dynamicObject2) -> dynamicObject1.getDate("endorsedate").compareTo(dynamicObject2.getDate("endorsedate"))) // 比较日期找出最新的
.orElse(null); // 如果集合为空返回 null
if (latestDynamicObject != null) {
logger.info("最新的一天的 DynamicObject: " + latestDynamicObject);
if (name.equals(latestDynamicObject.getString("endorsee"))){
dynamicObject.set("backinfoseries",false);
dynamicObject.set("serieschecktimes",0);
SaveServiceHelper.save(new DynamicObject[]{dynamicObject});
}
} else {
logger.info("没有找到日期数据!");
}
}
}
}
}
}