sap应收未清优化

This commit is contained in:
yuxueliang0813 2025-03-18 12:14:14 +08:00
parent 183f271e38
commit 32b21bf508
4 changed files with 79 additions and 31 deletions

View File

@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils; import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.FormShowParameter; import kd.bos.form.FormShowParameter;
import kd.bos.form.IFormView;
import kd.bos.form.control.Button; import kd.bos.form.control.Button;
import kd.bos.form.control.Control; import kd.bos.form.control.Control;
import kd.bos.form.control.EntryGrid; import kd.bos.form.control.EntryGrid;
@ -52,7 +54,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
} }
/** /**
* 当前页面加载后获取其父页面参数 * 当前页面加载后获取其父页面参数-用于设置控件隐藏和显示
*/ */
@Override @Override
public void afterBindData(EventObject e) { public void afterBindData(EventObject e) {
@ -62,8 +64,22 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){ if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){
this.getView().setVisible(false, SELECTED_BUTTON_KEY); this.getView().setVisible(false, SELECTED_BUTTON_KEY);
} }
this.getModel().setValue("shjh_org",((JSONObject)showParam.getCustomParam("billorg")).getLong("id"));//公司从父页面带过来
this.getModel().setValue("shjh_customer",((JSONObject)showParam.getCustomParam("billcustomer")).getLong("id"));//客户从父页面带过来 }
/**
* 当前页面加载后获取其父页面参数-用户设置控件数值
*/
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
FormShowParameter showParam = this.getView().getFormShowParameter();
if(showParam.getCustomParam("billorg") != null){
IFormView parentView = this.getView().getParentView();//获取父表单
IDataModel model = parentView.getModel();//获取父表单模型
this.getModel().setValue("shjh_org",model.getDataEntity().get("org"));//公司从父页面带过来
this.getModel().setValue("shjh_customer",model.getDataEntity().get("shjh_customer"));//客户从父页面带过来
}
} }
/** /**
@ -145,9 +161,15 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
Date postingdate_endda = (Date) this.getModel().getValue("shjh_gzrq_enddate");//SAP应收凭过账日期(结束) Date postingdate_endda = (Date) this.getModel().getValue("shjh_gzrq_enddate");//SAP应收凭过账日期(结束)
JSONArray IT_LIST = new JSONArray(); JSONArray IT_LIST = new JSONArray();
// 添加公司过滤条件 // 添加公司过滤条件
addFilterCondition(IT_LIST, "BUKRS", companyCode, companyCode); if (StringUtils.isNotEmpty(companyCode)) {
addFilterCondition(IT_LIST, "BUKRS", companyCode, companyCode);
}
// 添加客户过滤条件 // 添加客户过滤条件
addFilterCondition(IT_LIST, "KUNNR", customerCode, customerCode); if (StringUtils.isNotEmpty(customerCode)) {
addFilterCondition(IT_LIST, "KUNNR", customerCode, customerCode);
}
// 添加SAP应收凭证号过滤条件 // 添加SAP应收凭证号过滤条件
if (StringUtils.isNotEmpty(shjh_pzh)) { if (StringUtils.isNotEmpty(shjh_pzh)) {
addFilterCondition(IT_LIST, "BELNR", shjh_pzh, shjh_pzh); addFilterCondition(IT_LIST, "BELNR", shjh_pzh, shjh_pzh);

View File

@ -2,7 +2,6 @@ package shjh.jhzj7.fi.fi.plugin.form;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.CloseCallBack; import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter; import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType; import kd.bos.form.ShowType;
@ -15,7 +14,6 @@ import kd.bos.logging.LogFactory;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import java.util.EventObject; import java.util.EventObject;
import java.util.HashMap;
/** /**
* 表单插件-清账明细单-处理sap应收未清按钮 * 表单插件-清账明细单-处理sap应收未清按钮
@ -91,6 +89,16 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
} }
} }
private boolean isSameData(String pzh,String pzhh,String pzyear,DynamicObject currentinfo){
//检查从sap应收未清界面选择的数据与当前清账明细单分录中的数据是否重复
if(pzh.equals(currentinfo.getString("shjh_e_pzh")) &&
pzhh.equals(currentinfo.getString("shjh_e_pzhh")) &&
pzyear.equals(currentinfo.getString("shjh_e_year"))){
return true;
}
return false;
}
/** /**
* 对子页面传过来的参数处理 * 对子页面传过来的参数处理
* @param e 回调事件 * @param e 回调事件
@ -102,30 +110,32 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID); DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID);
if (null != entry) { if (null != entry) {
DynamicObject returnInfo; DynamicObject returnInfo;
int currentRow;
String pzh;//凭证号
String pzhh;//凭证行号
String pzyear;//会计年度
boolean existsflag = false;
for (int i = 0; i < returnData.size(); i++) { for (int i = 0; i < returnData.size(); i++) {
returnInfo = returnData.get(i); returnInfo = returnData.get(i);
//如下进行分录数据唯一判断凭证号+凭证行项目号+会计年度防止重复插入用户所选数据 //如下进行分录数据唯一判断凭证号+凭证行项目号+会计年度防止重复插入用户所选数据
String uniqueValue = returnInfo.getString("uniqueField"); pzh = returnInfo.getString("shjh_e_pzh");
boolean exists = false; pzhh = returnInfo.getString("shjh_e_pzhh");
pzyear = returnInfo.getString("shjh_e_year");
existsflag = false;
for (int j = 0; j < entry.size(); j++) { for (int j = 0; j < entry.size(); j++) {
String entryUniqueValue = entry.get(j).getString("uniqueField"); if (isSameData(pzh,pzhh,pzyear,entry.get(j))) {
if (uniqueValue.equals(entryUniqueValue)) { existsflag = true;
exists = true;
break; break;
} }
} }
//如果已存在则跳过该条数据 //如果已存在则跳过该条数据
if (exists) { if (existsflag) {
continue; continue;
} }
// TODO 这段是为了解决什么 //新增当前行
int rows = returnData.size() - entry.size(); currentRow = this.getModel().createNewEntryRow(entryID);
if (rows > 0) { //设置当前行需要填充的字段
IDataModel model = this.getModel(); setCurrentRows(returnInfo,currentRow);
model.batchCreateNewEntryRow(entryID, rows);
}
// 设置当前行需要填充的字段
setCurrentRows(returnInfo,i);
//更新分录页面显示 //更新分录页面显示
this.getView().updateView(entryID); this.getView().updateView(entryID);
} }

View File

@ -1,10 +1,12 @@
package shjh.jhzj7.fi.fi.plugin.operate; package shjh.jhzj7.fi.fi.plugin.operate;
import com.sap.db.jdbc.packet.ErrorLevel;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.db.DB; import kd.bos.db.DB;
import kd.bos.db.DBRoute; import kd.bos.db.DBRoute;
import kd.bos.entity.operate.result.OperateErrorInfo;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs; import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.entity.plugin.args.BeforeOperationArgs; import kd.bos.entity.plugin.args.BeforeOperationArgs;
@ -149,23 +151,31 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
} }
} }
private void addErrorInfo(DynamicObject bill, String errorMsg) {
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
operateErrorInfo.setMessage(bill.getString("billno") + errorMsg);
operateErrorInfo.setErrorLevel(ErrorLevel.Error.name());
operateErrorInfo.setPkValue(bill.getPkValue());
this.operationResult.addErrorInfo(operateErrorInfo);
}
private void handleSubmit(AfterOperationArgs e){ private void handleSubmit(AfterOperationArgs e){
//提交具体实现 //提交具体实现
DynamicObject[] dos = e.getDataEntities(); DynamicObject[] dos = e.getDataEntities();
DynamicObject prinfo; DynamicObject prinfo;
String result; String result;
for (int i = 0; i < dos.length; i++) { for (int i = 0; i < dos.length; i++) {
prinfo = dos[i]; prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
//将清账明细分录反写至清账单分录清账单收款金额+账扣+尾差本次核销金额合计 //将清账明细分录反写至清账单分录清账单收款金额+账扣+尾差本次核销金额合计
result = reWriteClearBill(prinfo); result = reWriteClearBill(prinfo);
if(!"success".equals(result)){ if(!"success".equals(result)){
this.operationResult.setSuccess(false); addErrorInfo(prinfo,"反写清账单失败,原因是:"+result);
this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
continue; continue;
} }
//清账明细单的OA待办转成已办 //清账明细单的OA待办转成已办
JhzjUtils.handleOA(prinfo,"2", "0"); JhzjUtils.handleOA(prinfo,"2", "0");
//处理完成提示
this.operationResult.addSuccessPkId(prinfo.getPkValue());
} }
} }
@ -308,13 +318,13 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
//删除对应清账单中由明细单反写的表头和分录数据 //删除对应清账单中由明细单反写的表头和分录数据
result = reDeleteClearBill(prinfo); result = reDeleteClearBill(prinfo);
if(!"success".equals(result)){ if(!"success".equals(result)){
this.operationResult.setSuccess(false); addErrorInfo(prinfo,"反写清账单失败,原因是:"+result);
this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
continue; continue;
} }
//清账明细单单据状态变成暂存 //清账明细单单据状态变成暂存
DB.update(DBRoute.of("fi"), updateDetailSave, new Object[]{prinfo.getLong("id")}); DB.update(DBRoute.of("fi"), updateDetailSave, new Object[]{prinfo.getLong("id")});
//处理完成提示
this.operationResult.addSuccessPkId(prinfo.getPkValue());
} }
} }
@ -329,9 +339,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
//驳回时删除对应清账单中由明细单反写的表头和分录数据 //驳回时删除对应清账单中由明细单反写的表头和分录数据
result = reDeleteClearBill(prinfo); result = reDeleteClearBill(prinfo);
if(!"success".equals(result)){ if(!"success".equals(result)){
this.operationResult.setSuccess(false); addErrorInfo(prinfo,"反写清账单失败,原因是:"+result);
this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
continue; continue;
} }
//清账明细单单据状态=驳回 //清账明细单单据状态=驳回
@ -342,6 +350,8 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
JhzjUtils.sendEmail(userinfo.getString("email"),"请登录资金系统操作清账明细单", JhzjUtils.sendEmail(userinfo.getString("email"),"请登录资金系统操作清账明细单",
prinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(prinfo),"清账明细单新增"); prinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(prinfo),"清账明细单新增");
JhzjUtils.handleOA(prinfo,"0", "0"); JhzjUtils.handleOA(prinfo,"0", "0");
//处理完成提示
this.operationResult.addSuccessPkId(prinfo.getPkValue());
} }
} }

View File

@ -159,16 +159,22 @@ public class CostCenterControler {
switch (type){ switch (type){
case "L": case "L":
typevalue = 1l;//管理 typevalue = 1l;//管理
break;
case "E": case "E":
typevalue = 2l;//开发 typevalue = 2l;//开发
break;
case "V": case "V":
typevalue = 3l;//销售 typevalue = 3l;//销售
break;
case "F": case "F":
typevalue = 4l;//生产 typevalue = 4l;//生产
break;
case "H": case "H":
typevalue = 2134881123853953024l;//服务成本中心 typevalue = 2134881123853953024l;//服务成本中心
break;
case "NULL": case "NULL":
typevalue = 0l;// typevalue = 0l;//
break;
default: default:
typevalue = 0l; typevalue = 0l;
} }