清账相关界面和操作插件

This commit is contained in:
yuxueliang0813 2025-03-07 18:27:54 +08:00
parent edd1da2f61
commit aaf9521419
8 changed files with 149 additions and 69 deletions

View File

@ -1,6 +1,8 @@
package shjh.jhzj7.fi.fi.common;
import com.alibaba.fastjson.JSONObject;
import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
import kd.bos.login.thirdauth.UserAuthResult;
import kd.bos.login.thirdauth.UserProperType;
@ -19,6 +21,8 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
private static final String client_id = "61513465e938cd47abe8";//应用注册ID 由认证系统提供
private static final String client_secret = "ee0f3e7e1e931343bc28d63cf69a616f2842";//应用注册密码 由认证系统提供
private final static Log logger = LogFactory.getLog(JHSSOAuthHandler.class);
private String callBackUrl = System.getProperty("domain.contextUrl");
@Override
@ -26,7 +30,8 @@ public class JHSSOAuthHandler implements ThirdSSOAuthHandler {
//backUrl 系统已构建好回调地址二开无需处理
//实现用户没有登录的时候跳转认证中心的登录地址
//第一步认证中心的登录地址注意拼接参数和回调地址转义,注意正式地址切换
// backUrl = "http://172.20.42.104:8881/iserp/auth/callbackTrdSSO.do?tenantNo=jahwa-uatenv&sandboxNo=2102993326188790784";
// backUrl = https://fm-test.jahwa.com.cn/ierp/auth/callbackTrdSSO.do?tenantNo=ierp-uatenv&sandboxNo=2102993326188790784;
logger.info("测试环境回调地址:"+backUrl);
callBackUrl = backUrl;
StringBuffer ssoURL = new StringBuffer();
ssoURL.append(ssologinUrl);

View File

@ -5,6 +5,7 @@ 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.events.PropertyChangedArgs;
import kd.bos.form.FormShowParameter;
import kd.bos.form.control.Button;
import kd.bos.form.control.Control;
@ -29,9 +30,9 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
private final static Log logger = LogFactory.getLog(ASParbillFormPlugin.class);
private final static String entryID = "shjh_details";//分录标识
private final static String apiurl = "shjh_details";//接口地址
private final static String clearBillName = "shjh_details";//清账单插件名称
private static final String QUERY_BUTTON_KEY = "shjh_btnquery";//查询按钮
private static final String SELECTED_BUTTON_KEY = "shjh_btnok";//确认勾选按钮
private static final String RESET_BUTTON_KEY = "shjh_btnreset";//重置按钮
private DynamicObjectCollection PARAM_LIST = new DynamicObjectCollection();//返回给父页面的值集合
/**
@ -44,8 +45,11 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
Button queryButton = this.getView().getControl(QUERY_BUTTON_KEY);
//确认勾选按钮
Button selectedButton = this.getView().getControl(SELECTED_BUTTON_KEY);
//重置按钮
Button resetButton = this.getView().getControl(RESET_BUTTON_KEY);
queryButton.addClickListener(this);
selectedButton.addClickListener(this);
resetButton.addClickListener(this);
}
/**
@ -56,49 +60,60 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
super.afterBindData(e);
FormShowParameter showParam = this.getView().getFormShowParameter();
//如果是清账单过来的只能进行查询不能确认勾选
if(clearBillName.equals(showParam.getCustomParam("Apikey"))){
if("clearBillForm".equals(showParam.getCustomParam("Apikey"))){
this.getView().setVisible(false, SELECTED_BUTTON_KEY);
}
}
/**
* 控件值改变事件实现方法
*/
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
}
/**
* 按钮点击实现方法
*/
@Override
public void click(EventObject evt) {
try {
// 校验和获取过滤条件
DynamicObject org = (DynamicObject) this.getModel().getValue("shjh_orgfield");
if (org == null) {
this.getView().showMessage("请选择公司!");
return;
}
Date startDate = (Date) this.getModel().getValue("shjh_startdate");
if (startDate == null) {
this.getView().showMessage("请选择开始日期!");
return;
}
Date endDate = (Date) this.getModel().getValue("shjh_enddate");
if (endDate == null) {
this.getView().showMessage("请选择结束日期!");
return;
}
String companyCode = org.getString("number");
Control source = (Control) evt.getSource();
String key = source.getKey();
if (StringUtils.equals(QUERY_BUTTON_KEY, key)) {
// 校验和获取过滤条件
DynamicObject org = (DynamicObject) this.getModel().getValue("shjh_orgfield");
if (org == null) {
this.getView().showMessage("请选择公司!");
return;
}
Date startDate = (Date) this.getModel().getValue("shjh_startdate");
if (startDate == null) {
this.getView().showMessage("请选择开始日期!");
return;
}
Date endDate = (Date) this.getModel().getValue("shjh_enddate");
if (endDate == null) {
this.getView().showMessage("请选择结束日期!");
return;
}
String companyCode = org.getString("number");
// 点击查询按钮
handleQueryButtonClick(companyCode, startDate, endDate);
} else if (StringUtils.equals(SELECTED_BUTTON_KEY, key)) {
// 点击选择按钮
handleSelectedButton();
} else if (StringUtils.equals(RESET_BUTTON_KEY, key)) {
// 点击重置按钮
this.getModel().setValue("shjh_textfield",null);
}
} catch (Exception e) {
logger.error("Error in click method: " + e.getMessage(), e);
logger.error("按钮处理异常:"+e.getMessage());
this.getView().showMessage("按钮处理异常"+e.getMessage());
}
}
@ -117,7 +132,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
handleSAPApi(companyCode, startDate, endDate, billNumber);
this.getView().updateView(entryID);
} catch (Exception e) {
logger.error("Error in handleQueryButtonClick: " + e.getMessage());
logger.error("查询操作失败: " + e.getMessage());
this.getView().showMessage("查询操作失败"+e.getMessage());
}
}
@ -154,7 +169,7 @@ public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
}
}
} catch (Exception e) {
logger.error("Error in handlePaymentApi: "+e.getMessage());
logger.error("处理SAP应收未清接口时发生错误: "+e.getMessage());
this.getView().showMessage("处理SAP应收未清接口时发生错误"+e.getMessage());
}
}

View File

@ -3,7 +3,6 @@ package shjh.jhzj7.fi.fi.plugin.form;
import kd.bos.bill.BillShowParameter;
import kd.bos.bill.OperationStatus;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.EntryGrid;
@ -25,15 +24,15 @@ import java.util.HashMap;
public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
private final static Log logger = LogFactory.getLog(ClearBillFormPlugin.class);
private final static String SAPFormID = "shjh_sapyswq";//sap动态表单标识
private final static String DetailFormID = "shjh_sapyswq";//清账明细单标识
private final static String DetailFormID = "shjh_clear_acctdetail";//清账明细单标识
private final static String entryID = "shjh_details";//分录标识
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
//监听整个工具栏
// Toolbar toolbar = getControl("tbmain");
// toolbar.addItemClickListener(this);
Toolbar toolbar = getControl("tbmain");
toolbar.addItemClickListener(this);
}
@Override
@ -41,7 +40,7 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
try {
if ("shjh_sap".equals(evt.getItemKey())) {
//点击SAP应收未清按钮
FormShowParameter showParameter = createASPParam(this.getPluginName());
FormShowParameter showParameter = createASPParam("clearBillForm");
this.getView().showForm(showParameter);
}else if("shjh_viewdetail".equals(evt.getItemKey())){
//点击查看清账明细按钮
@ -99,7 +98,7 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
//需要打开单据的标识
showParameter.setFormId(DetailFormID);
//打开方式
showParameter.getOpenStyle().setShowType(ShowType.Floating);
showParameter.getOpenStyle().setShowType(ShowType.Modal);
//单据状态
showParameter.setStatus(OperationStatus.VIEW);
//单据ID
@ -107,7 +106,7 @@ public class ClearBillFormPlugin extends AbstractFormPlugin implements Plugin {
//pageid
// showParameter.setPageId();
//传到目标页面的自定义参数
// showParameter.setCustomParams(map);
showParameter.setCustomParam("Apikey","viewDetailFromClear");
//回调方法
// showParameter.setCloseCallBack();
return showParameter;

View File

@ -1,9 +1,12 @@
package shjh.jhzj7.fi.fi.plugin.form;
import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.AfterDoOperationEventArgs;
import kd.bos.form.events.BeforeDoOperationEventArgs;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.list.BillList;
import kd.bos.list.plugin.AbstractListPlugin;
@ -30,12 +33,12 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
try {
if ("shjh_unclearacctount".equals(evt.getItemKey())) {
//点击反清账按钮
FormShowParameter showParameter = createParam(evt.getItemKey(),unClearFormID);
this.getView().showForm(showParameter);
// FormShowParameter showParameter = createParam(evt.getItemKey(),unClearFormID);
// this.getView().showForm(showParameter);
}else if("shjh_changestatus".equals(evt.getItemKey())){
//点击修改清账单状态按钮
FormShowParameter showParameter = createParam(evt.getItemKey(),updateStatusFormID);
this.getView().showForm(showParameter);
// FormShowParameter showParameter = createParam(evt.getItemKey(),updateStatusFormID);
// this.getView().showForm(showParameter);
}
} catch (Exception e) {
logger.error("按钮处理异常:"+e.getMessage());
@ -43,6 +46,27 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
}
}
@Override
public void beforeDoOperation(BeforeDoOperationEventArgs e) {
super.beforeDoOperation(e);//第一步 然后到操作插件的beforeExecuteOperationTransaction 最后到itemClick中
}
@Override
public void afterDoOperation(AfterDoOperationEventArgs e) {
super.afterDoOperation(e);
String okey = e.getOperateKey();
if("unclearacctount_check".equals(okey) && e.getOperationResult().isSuccess()){
//点击反清账按钮
FormShowParameter showParameter = createParam(okey,unClearFormID);
this.getView().showForm(showParameter);
}else if("updatestatus_check".equals(okey) && e.getOperationResult().isSuccess()){
//点击修改清账单状态按钮
//弹框填写修改原因填写后可由待清账改为已清账单据状态改为已审核
FormShowParameter showParameter = createParam(okey,updateStatusFormID);
this.getView().showForm(showParameter);
}
}
/**
* 构建表单之间的传参 弹框展示SAP应收未清列表
* @param apiKey 按钮来源的区分标识
@ -63,7 +87,7 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
//传到子页面参数
showParameter.setCustomParams(map);
//回调方法
// showParameter.setCloseCallBack();
showParameter.setCloseCallBack(new CloseCallBack(this, apiKey));
return showParameter;
}
@ -75,10 +99,14 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
public void closedCallBack(ClosedCallBackEvent e) {
super.closedCallBack(e);
try {
//回调id
//回调id-来源于弹窗之前注册的回调事件
String callBackId = e.getActionId();
if (callBackId.equals(this.getPluginName())) {
handleReturnData(e);
if("unclearacctount_check".equals(callBackId) && "btnok".equals(e.getReturnData())){
//反清账后续操作
this.getView().invokeOperation("unclearacctount");
}else if("updatestatus_check".equals(callBackId) && "btnok".equals(e.getReturnData())){
//修改清账单状态后续操作
this.getView().invokeOperation("updatestatus");
}
} catch (Exception ex) {
logger.error("回调父页面异常:"+ex.getMessage());

View File

@ -25,36 +25,37 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
private final static Log logger = LogFactory.getLog(ClearDetailFormPlugin.class);
private final static String destFormID = "shjh_sapyswq";//目标表单标识
private final static String entryID = "shjh_details";//分录标识
private final static String SAP_BUTTON_KEY = "shjh_sap";//sap按钮标识
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
//监听整个工具栏
// Toolbar toolbar = getControl("tbmain");
// toolbar.addItemClickListener(this);
Toolbar toolbar = getControl("tbmain");
toolbar.addItemClickListener(this);
}
@Override
public void itemClick(ItemClickEvent evt) {
try {
//点击SAP应收未清按钮
if ("shjh_sap".equals(evt.getItemKey())) {
FormShowParameter showParameter = createFormParameter(this.getPluginName());
if (SAP_BUTTON_KEY.equals(evt.getItemKey())) {
FormShowParameter showParameter = createFormParameter();
this.getView().showForm(showParameter);
}
} catch (Exception e) {
logger.error("SAP应收未清按钮处理异常"+e.getMessage());
this.getView().showMessage("SAP应收未清按钮处理异常"+e.getMessage());
}
}
/**
* 构建表单之间的传参 弹框展示SAP应收未清列表
* @param apiKey 按钮来源的区分标识
*/
private FormShowParameter createFormParameter(String apiKey) {
private FormShowParameter createFormParameter() {
HashMap<String, Object> map = new HashMap<>(2);
//按钮区分标识
map.put("Apikey",apiKey);
// map.put("Apikey",SAP_BUTTON_KEY);
//清账明细单单号
map.put("billNumber",this.getModel().getValue("billno"));
FormShowParameter showParameter = new FormShowParameter();
@ -65,7 +66,7 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
//传到子页面参数
showParameter.setCustomParams(map);
//回调方法
showParameter.setCloseCallBack(new CloseCallBack(this, apiKey));
showParameter.setCloseCallBack(new CloseCallBack(this, SAP_BUTTON_KEY));
return showParameter;
}
@ -78,12 +79,12 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
super.closedCallBack(e);
try {
//回调id
String callBackId = e.getActionId();
if (callBackId.equals(this.getPluginName())) {
if (SAP_BUTTON_KEY.equals(e.getActionId())) {
handleReturnData(e);
}
} catch (Exception ex) {
logger.error("SAP应收未清回调子页面参数异常"+ex.getMessage());
this.getView().showMessage("SAP应收未清回调子页面参数异常"+ex.getMessage());
}
}
@ -147,4 +148,17 @@ public class ClearDetailFormPlugin extends AbstractFormPlugin implements Plugin
this.getModel().setValue("shjh_e_year",returnInfo.getString("shjh_e_year"), i);//会计年度
this.getModel().setValue("shjh_e_qzpztext",returnInfo.getString("shjh_e_qzpztext"), i);// 清账凭证文本
}
/**
* 当前页面加载后获取其父页面参数
*/
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
FormShowParameter showParam = this.getView().getFormShowParameter();
//如果是清账单过来的只能进行查看
if("viewDetailFromClear".equals(showParam.getCustomParam("Apikey"))){
this.getView().setVisible(false, "tbmain");
}
}
}

View File

@ -1,5 +1,6 @@
package shjh.jhzj7.fi.fi.plugin.form;
import com.alibaba.fastjson.JSONArray;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.db.DB;
import kd.bos.db.DBRoute;
@ -12,8 +13,10 @@ import kd.bos.logging.Log;
import kd.bos.logging.LogFactory;
import kd.sdk.plugin.Plugin;
import java.util.ArrayList;
import java.util.Date;
import java.util.EventObject;
import java.util.List;
public class UnclearAndUpdateStatusFormPlugin extends AbstractFormPlugin implements Plugin {
@ -47,20 +50,37 @@ public class UnclearAndUpdateStatusFormPlugin extends AbstractFormPlugin impleme
if (StringUtils.equals(OK_BUTTON_KEY, key)) {
// 点击确认按钮
FormShowParameter showParameter = this.getView().getFormShowParameter();
String apiKey = showParameter.getCustomParam("Apikey");
Object[] srcBillids = showParameter.getCustomParam("srcBillids");
String apiKey = showParameter.getCustomParam("Apikey");//父页面按钮的区分标识
JSONArray srcBillids = showParameter.getCustomParam("srcBillids");//父页面传入的参数
//根据用户填写的内容以及父页面传入的id参数更新
if("shjh_unclearacctount".equals(apiKey)){
if("unclearacctount_check".equals(apiKey)){
//反清账页面
Date uncleardate = (Date) this.getModel().getValue("shjh_uncleardate");//反清账日期
String unclearway = (String) this.getModel().getValue("shjh_unclearway");//反清后处理方式
DB.update(DBRoute.of("fi"), updateDateWay, new Object[]{uncleardate,unclearway,getids(srcBillids)});
}else if("shjh_changestatus".equals(apiKey)){
StringBuffer sqlsb = new StringBuffer();
sqlsb.append("update tk_shjh_clear_account set fk_shjh_uncleardate=?,fk_shjh_unclearway=? where fid in (");
for (int i = 0; i < srcBillids.size(); i++) {
sqlsb.append(srcBillids.get(i));
sqlsb.append(",");
}
sqlsb.setLength(sqlsb.length()-1);
sqlsb.append(");");
DB.update(DBRoute.of("fi"), sqlsb.toString(), new Object[]{uncleardate,unclearway});
this.getView().returnDataToParent(key);
}else if("updatestatus_check".equals(apiKey)){
//修改状态页面
String changereason = (String) this.getModel().getValue("shjh_changereason");//清账状态修改原因
DB.update(DBRoute.of("fi"), updateReason, new Object[]{changereason,getids(srcBillids)});
StringBuffer sqlsb = new StringBuffer();
sqlsb.append("update tk_shjh_clear_account set fk_shjh_changereason=?,fk_shjh_clearstatus='A',fbillstatus='C' where fid in (");
for (int i = 0; i < srcBillids.size(); i++) {
sqlsb.append(srcBillids.get(i));
sqlsb.append(",");
}
sqlsb.setLength(sqlsb.length()-1);
sqlsb.append(");");
DB.update(DBRoute.of("fi"), sqlsb.toString(), new Object[]{changereason});
this.getView().returnDataToParent(key);
}
this.getView().close();
}
} catch (Exception e) {
@ -69,13 +89,13 @@ public class UnclearAndUpdateStatusFormPlugin extends AbstractFormPlugin impleme
}
}
private String getids(Object[] srcBillids){
if(srcBillids == null){
private String getids(JSONArray srcBillids){
if(srcBillids == null || srcBillids.isEmpty()){
return "666";
}else {
StringBuffer sqlsb = new StringBuffer();
for (int i = 0; i < srcBillids.length; i++) {
sqlsb.append(srcBillids[i]);
for (int i = 0; i < srcBillids.size(); i++) {
sqlsb.append(srcBillids.get(i));
sqlsb.append(",");
}
sqlsb.append(666);

View File

@ -55,7 +55,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
billno = prinfo.getString("billno");
billstatus = prinfo.getString("billstatus");
clearstatus = prinfo.getString("shjh_clearstatus");
if ("unclearacctount".equals(eok)) {
if ("unclearacctount_check".equals(eok)) {
//清账单单据状态=已审核 and清账状态=已清账 andSAP凭证号不为空 and 收款单编号不为多个才允许点击反清账按钮
if (!"C".equals(billstatus) || !"A".equals(clearstatus) || JhzjUtils.isEmpty(prinfo.getString("shjh_pzh"))
|| JhzjUtils.isReceBillNums(prinfo.getString("shjh_recebillno"))) {
@ -81,7 +81,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
e.setCancelMessage(billno + "【单据状态】=作废 and【清账状态】=反清账 and【反清后处理方式】=收款信息变更 and【是否被复制】=否,才允许复制");
e.setCancel(true);
}
} else if ("updatestatus".equals(eok)) {
} else if ("updatestatus_check".equals(eok)) {
//清账单单据状态=暂存 and清账状态=待清账才允许点击修改清账单状态
if (!"A".equals(billstatus) || !"B".equals(clearstatus)) {
e.setCancelMessage(billno + "【单据状态】=暂存 and【清账状态】=待清账,才允许修改清账单状态");
@ -130,7 +130,6 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
DynamicObject prinfo;
for (int i = 0; i < dos.length; i++) {
prinfo = dos[i];
//TODO 点击此按钮弹框填写修改原因填写后可由待清账改为已清账单据状态改为已审核
//TODO 反写上游收款单分录行清账状态=已清账
//下游清账明细单单据状态=作废若清账信息有误需在SAP反清账后修改
DB.update(DBRoute.of("fi"), updateDetailStatusByBill, new Object[]{prinfo.getString("id")});
@ -239,12 +238,12 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
DynamicObject prinfo;//清账单
String fqzpzh;//反清账凭证号
for (int i = 0; i < dos.length; i++) {
prinfo = dos[i];
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
//TODO 调用SAP反清账接口更新清账单中反清状态和反清凭证号
fqzpzh = null;
if (fqzpzh == null) {
this.operationResult.setSuccess(false);
this.operationResult.setMessage("反清账失败,原因是");//前端界面提示内容
this.operationResult.setMessage("反清账失败,原因是未获取到SAP反清凭证号");//前端界面提示内容
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
continue;
}

View File

@ -122,7 +122,7 @@ public class JhzjUtils {
message.setType("notice_wx");//消息类型的编号
StringBuilder notifyType = new StringBuilder();
// notifyType.append(MessageChannels.EMAIL).append(",");
notifyType.append(MessageChannels.WEIXINQY);
notifyType.append(MessageChannels.WEIXINQY.getNumber());
message.setNotifyType(notifyType.toString());
long result = MessageCenterServiceHelper.sendMessage(message);
logger.info("微信消息返回"+result);//2163947346411418624