sap应收未清优化
This commit is contained in:
parent
183f271e38
commit
32b21bf508
|
|
@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.utils.StringUtils;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.IFormView;
|
||||
import kd.bos.form.control.Button;
|
||||
import kd.bos.form.control.Control;
|
||||
import kd.bos.form.control.EntryGrid;
|
||||
|
|
@ -52,7 +54,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* 当前页面加载后获取其父页面参数
|
||||
* 当前页面加载后获取其父页面参数-用于设置控件隐藏和显示
|
||||
*/
|
||||
@Override
|
||||
public void afterBindData(EventObject e) {
|
||||
|
|
@ -62,8 +64,22 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
|
|||
if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){
|
||||
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应收凭过账日期(结束)
|
||||
JSONArray IT_LIST = new JSONArray();
|
||||
// 添加公司过滤条件
|
||||
if (StringUtils.isNotEmpty(companyCode)) {
|
||||
addFilterCondition(IT_LIST, "BUKRS", companyCode, companyCode);
|
||||
}
|
||||
|
||||
// 添加客户过滤条件
|
||||
if (StringUtils.isNotEmpty(customerCode)) {
|
||||
addFilterCondition(IT_LIST, "KUNNR", customerCode, customerCode);
|
||||
}
|
||||
|
||||
// 添加SAP应收凭证号过滤条件
|
||||
if (StringUtils.isNotEmpty(shjh_pzh)) {
|
||||
addFilterCondition(IT_LIST, "BELNR", shjh_pzh, shjh_pzh);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package shjh.jhzj7.fi.fi.plugin.form;
|
|||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.IDataModel;
|
||||
import kd.bos.form.CloseCallBack;
|
||||
import kd.bos.form.FormShowParameter;
|
||||
import kd.bos.form.ShowType;
|
||||
|
|
@ -15,7 +14,6 @@ import kd.bos.logging.LogFactory;
|
|||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 表单插件-清账明细单-处理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 回调事件
|
||||
|
|
@ -102,30 +110,32 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
|
|||
DynamicObjectCollection entry = this.getModel().getEntryEntity(entryID);
|
||||
if (null != entry) {
|
||||
DynamicObject returnInfo;
|
||||
int currentRow;
|
||||
String pzh;//凭证号
|
||||
String pzhh;//凭证行号
|
||||
String pzyear;//会计年度
|
||||
boolean existsflag = false;
|
||||
for (int i = 0; i < returnData.size(); i++) {
|
||||
returnInfo = returnData.get(i);
|
||||
//如下进行分录数据唯一判断(凭证号+凭证行项目号+会计年度),防止重复插入用户所选数据
|
||||
String uniqueValue = returnInfo.getString("uniqueField");
|
||||
boolean exists = false;
|
||||
pzh = returnInfo.getString("shjh_e_pzh");
|
||||
pzhh = returnInfo.getString("shjh_e_pzhh");
|
||||
pzyear = returnInfo.getString("shjh_e_year");
|
||||
existsflag = false;
|
||||
for (int j = 0; j < entry.size(); j++) {
|
||||
String entryUniqueValue = entry.get(j).getString("uniqueField");
|
||||
if (uniqueValue.equals(entryUniqueValue)) {
|
||||
exists = true;
|
||||
if (isSameData(pzh,pzhh,pzyear,entry.get(j))) {
|
||||
existsflag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果已存在,则跳过该条数据
|
||||
if (exists) {
|
||||
if (existsflag) {
|
||||
continue;
|
||||
}
|
||||
// TODO 这段是为了解决什么?
|
||||
int rows = returnData.size() - entry.size();
|
||||
if (rows > 0) {
|
||||
IDataModel model = this.getModel();
|
||||
model.batchCreateNewEntryRow(entryID, rows);
|
||||
}
|
||||
// 设置当前行需要填充的字段
|
||||
setCurrentRows(returnInfo,i);
|
||||
//新增当前行
|
||||
currentRow = this.getModel().createNewEntryRow(entryID);
|
||||
//设置当前行需要填充的字段
|
||||
setCurrentRows(returnInfo,currentRow);
|
||||
//更新分录页面显示
|
||||
this.getView().updateView(entryID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
import com.sap.db.jdbc.packet.ErrorLevel;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
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){
|
||||
//提交具体实现
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
String result;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
|
||||
//将清账明细分录反写至清账单分录,清账单【收款金额】+【账扣】+【尾差】≥【本次核销金额合计】
|
||||
result = reWriteClearBill(prinfo);
|
||||
if(!"success".equals(result)){
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容
|
||||
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
|
||||
addErrorInfo(prinfo,"反写清账单失败,原因是:"+result);
|
||||
continue;
|
||||
}
|
||||
//清账明细单的OA待办转成已办
|
||||
JhzjUtils.handleOA(prinfo,"2", "0");
|
||||
//处理完成提示
|
||||
this.operationResult.addSuccessPkId(prinfo.getPkValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -308,13 +318,13 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
//删除对应清账单中由明细单反写的表头和分录数据
|
||||
result = reDeleteClearBill(prinfo);
|
||||
if(!"success".equals(result)){
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容
|
||||
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
|
||||
addErrorInfo(prinfo,"反写清账单失败,原因是:"+result);
|
||||
continue;
|
||||
}
|
||||
//清账明细单,单据状态变成暂存
|
||||
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);
|
||||
if(!"success".equals(result)){
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("反写清账单失败,原因是:"+result);//前端界面提示内容
|
||||
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
|
||||
addErrorInfo(prinfo,"反写清账单失败,原因是:"+result);
|
||||
continue;
|
||||
}
|
||||
//清账明细单【单据状态】=驳回
|
||||
|
|
@ -342,6 +350,8 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
JhzjUtils.sendEmail(userinfo.getString("email"),"请登录资金系统操作清账明细单",
|
||||
prinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(prinfo),"清账明细单新增");
|
||||
JhzjUtils.handleOA(prinfo,"0", "0");
|
||||
//处理完成提示
|
||||
this.operationResult.addSuccessPkId(prinfo.getPkValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -159,16 +159,22 @@ public class CostCenterControler {
|
|||
switch (type){
|
||||
case "L":
|
||||
typevalue = 1l;//管理
|
||||
break;
|
||||
case "E":
|
||||
typevalue = 2l;//开发
|
||||
break;
|
||||
case "V":
|
||||
typevalue = 3l;//销售
|
||||
break;
|
||||
case "F":
|
||||
typevalue = 4l;//生产
|
||||
break;
|
||||
case "H":
|
||||
typevalue = 2134881123853953024l;//服务成本中心
|
||||
break;
|
||||
case "NULL":
|
||||
typevalue = 0l;//无
|
||||
break;
|
||||
default:
|
||||
typevalue = 0l;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue