清账优化

This commit is contained in:
yuxueliang0813 2025-04-21 16:21:08 +08:00
parent 95c9ab67e4
commit 6f00c5a869
3 changed files with 68 additions and 37 deletions

View File

@ -31,20 +31,20 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
@Override
public void itemClick(ItemClickEvent evt) {
super.itemClick(evt);
try {
if ("shjh_unclearacctount".equals(evt.getItemKey())) {
//点击反清账按钮
FormShowParameter showParameter = createParam(evt.getItemKey(),unClearFormID);
this.getView().showForm(showParameter);
}else if("shjh_changestatus".equals(evt.getItemKey())){
//点击修改清账单状态按钮
// try {
// if ("shjh_unclearacctount".equals(evt.getItemKey())) {
// //点击反清账按钮
// 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);
}
} catch (Exception e) {
logger.error("按钮处理异常:"+e.getMessage());
this.getView().showMessage("按钮处理异常"+e.getMessage());
}
// }
// } catch (Exception e) {
// logger.error("按钮处理异常:"+e.getMessage());
// this.getView().showMessage("按钮处理异常"+e.getMessage());
// }
}
@Override
@ -57,7 +57,7 @@ public class ClearBillListPlugin extends AbstractListPlugin implements Plugin {
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()){

View File

@ -35,7 +35,10 @@ import java.util.*;
*/
public class ClearAccountBillOperation extends AbstractOperationServicePlugIn implements Plugin {
private static final String updateClearStatus = "update tk_shjh_clear_account set fbillstatus='D' where fid=?;";
//更新单据状态为作废
private static final String updateInvalidStatus = "update tk_shjh_clear_account set fbillstatus='D' where fid=?;";
//更新单据状态为已提交
private static final String updateSubmitStatus = "update tk_shjh_clear_account set fbillstatus='B' where fid=?;";
//手动修改清账状态
private static final String hadleClearStatusByID = "update tk_shjh_clear_account set fk_shjh_changereason='手工清账',fk_shjh_clearstatus='A',fbillstatus='C' where fid=?;";
private static final String updateSap = "update tk_shjh_clear_account set fk_shjh_clearstatus='A',fk_shjh_pzh=?,fk_shjh_year=? where fid=?;";
@ -326,8 +329,11 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
detailinfo = newDetailBill(prinfo, userinfo);
//发送清账明细单的OA待办
JhzjUtils.handleOA(detailinfo, "0", "0");
JhzjUtils.sendEmail(userinfo.getString("email"), "请登录资金系统操作清账明细单",
detailinfo.getString("billno") + "\n 详情页面" + JhzjUtils.getBillPCURL(detailinfo), "清账明细单新增");
receivers.clear();
receivers.add(userinfo.getLong("id"));
String pcurl = JhzjUtils.getBillPCURL(detailinfo);
JhzjUtils.sendEmail("请登录资金系统操作清账明细单", detailinfo.getString("billno") +
"<br> 详情页面 <a href='"+pcurl+"' target='_blank'>"+pcurl+"</a>", receivers, detailinfo);
}
}else{
//根据客户公司是否可用找到对应的被通知人员可能多个
@ -619,7 +625,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
private void handleAudit(AfterOperationArgs e) {
//审核具体实现
DynamicObject[] dos = e.getDataEntities();
DynamicObject prinfo;//清账单
DynamicObject prinfo = null;//清账单
DynamicObject detailinfo;//清账明细单
DynamicObject[] ddos;
String billstatus;
@ -632,12 +638,16 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
resultData = sapTransactionVoucher(prinfo);
if(resultData == null){
addErrorInfo(prinfo,"调用SAP清账接口失败详见接口日志");
//审核后续操作失败需要更新清账单的单据状态为已提交
DB.update(DBRoute.of("fi"), updateSubmitStatus, new Object[]{prinfo.getPkValue()});
continue;
}else{
//解析sap凭证接口返回值
respdata = ApiUtils.getResponseData(resultData);
if(respdata == null){
addErrorInfo(prinfo,"SAP清账接口返回值为空详见接口日志");
//审核后续操作失败需要更新清账单的单据状态为已提交
DB.update(DBRoute.of("fi"), updateSubmitStatus, new Object[]{prinfo.getPkValue()});
continue;
}
//反写清账状态清账凭证号会计年度字段至清账单中
@ -664,25 +674,28 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
}
//如果清账明细单单据状态=已审核发送审核通过的邮件通知
if (!detailList.isEmpty()) {
Map<String, String> userBill = new HashMap<>();
Map<Long, String> userBill = new HashMap<>();
String billno;
String useremail;
Long userid;
DynamicObject userinfo;
for (int i = 0; i < detailList.size(); i++) {
detailinfo = detailList.get(i);
userinfo = BusinessDataServiceHelper.loadSingleFromCache(
detailinfo.getDynamicObject("modifier").getLong("id"), userName);
useremail = userinfo.getString("email");
if (userBill.containsKey(useremail)) {
billno = userBill.get(useremail);
userBill.put(useremail, billno + "," + detailinfo.getString("billno"));
userid = userinfo.getLong("id");
if (userBill.containsKey(userid)) {
billno = userBill.get(userid);
userBill.put(userid, billno + "," + detailinfo.getString("billno"));
} else {
userBill.put(useremail, detailinfo.getString("billno"));
userBill.put(userid, detailinfo.getString("billno"));
}
}
//遍历map给每个人发邮件
for (Map.Entry<String, String> entry : userBill.entrySet()) {
JhzjUtils.sendEmail(entry.getKey(), "清账完成通知:", entry.getValue() + "已清账完成", "清账单审核");
List<Long> receivers = new ArrayList<>(1);
for (Map.Entry<Long, String> entry : userBill.entrySet()) {
receivers.clear();
receivers.add(entry.getKey());
JhzjUtils.sendEmail("清账完成通知", entry.getValue() + "上述清账明细单已完成清账", receivers, prinfo);
}
}
}
@ -694,7 +707,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
DynamicObject prinfo;
for (int i = 0; i < dos.length; i++) {
prinfo = dos[i];
DB.update(DBRoute.of("fi"), updateClearStatus, new Object[]{prinfo.getLong("id")});
DB.update(DBRoute.of("fi"), updateInvalidStatus, new Object[]{prinfo.getLong("id")});
DB.update(DBRoute.of("fi"), updateDetailStatusByBill, new Object[]{prinfo.getString("id")});
//处理完成提示
this.operationResult.addSuccessPkId(prinfo.getPkValue());

View File

@ -15,7 +15,9 @@ import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@ -253,18 +255,28 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
BigDecimal q3 =clearBillInfo.getBigDecimal("shjh_receamount");
//获取清账单的本次核销金额合计
BigDecimal entrytotal = BigDecimal.ZERO;
BigDecimal entrynegatetotal = BigDecimal.ZERO;//获取清账单中对应的已认领收款金额
for (int i = 0; i < cleardoc.size(); i++) {
clearEntryInfo = cleardoc.get(i);
entrytotal = entrytotal.add(clearEntryInfo.getBigDecimal("shjh_e_cursettle"));
if(clearEntryInfo.getBigDecimal("shjh_e_cursettle").signum() == -1){
entrynegatetotal = entrynegatetotal.add(clearEntryInfo.getBigDecimal("shjh_e_cursettle"));
}
}
//清账单的收款金额+账扣+尾差=本次核销金额合计即可提交
if(entrytotal.compareTo(q1.add(q2).add(q3)) == 0){
clearBillInfo.set("billstatus","B");
}
//已认领收款金额=本次核销金额合计-账扣-尾差
clearBillInfo.set("shjh_claimamount", entrytotal.subtract(q1).subtract(q2));
// //清账单的收款金额+账扣+尾差=本次核销金额合计即可提交
// if(entrytotal.compareTo(q1.add(q2).add(q3)) == 0){
// clearBillInfo.set("billstatus","B");
// }
// //已认领收款金额=本次核销金额合计-账扣-尾差
// clearBillInfo.set("shjh_claimamount", entrytotal.subtract(q1).subtract(q2));
//已认领收款金额
clearBillInfo.set("shjh_claimamount", entrynegatetotal.abs());
//未认领收款金额=收款金额-已认领收款金额
clearBillInfo.set("shjh_unclaimamount", q3.subtract(clearBillInfo.getBigDecimal("shjh_claimamount")));
//未认领收款金额为0即清账单可以提交
if(clearBillInfo.getBigDecimal("shjh_unclaimamount").signum() == 0){
clearBillInfo.set("billstatus","B");
}
SaveServiceHelper.save(new DynamicObject[]{clearBillInfo});
//解除清账单互斥锁
JhzjUtils.unLockBill(clearBillInfo);
@ -353,9 +365,10 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
private void handleReject(AfterOperationArgs e){
//驳回具体实现
DynamicObject[] dos = e.getDataEntities();
DynamicObject prinfo;
DynamicObject prinfo;//清账明细单
DynamicObject userinfo;
String result;
String result;//反写清账单结果
List<Long> receivers = new ArrayList<>(1);
for (int i = 0; i < dos.length; i++) {
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName());
//驳回时删除对应清账单中由明细单反写的表头和分录数据
@ -369,8 +382,13 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
userinfo = BusinessDataServiceHelper.loadSingle(prinfo.getDynamicObject("modifier").getLong("id"),
userName);
//驳回时对清账明细单修改人发送邮件通知OA待办 业务员可修改后再次提交
JhzjUtils.sendEmail(userinfo.getString("email"),"请登录资金系统操作清账明细单",
prinfo.getString("billno")+"\n 详情页面 <a href='"+JhzjUtils.getBillPCURL(prinfo)+"' target='_blank'>请点击此次</a>","清账明细单新增");
// JhzjUtils.sendEmail(userinfo.getString("email"),"请登录资金系统操作清账明细单",
// prinfo.getString("billno")+"\n 详情页面 <a href='"+JhzjUtils.getBillPCURL(prinfo)+"' target='_blank'>请点击此次</a>","清账明细单新增");
receivers.clear();
receivers.add(userinfo.getLong("id"));
String pcurl = JhzjUtils.getBillPCURL(prinfo);
JhzjUtils.sendEmail("请登录资金系统操作清账明细单", prinfo.getString("billno") +
"<br> 详情页面 <a href='"+pcurl+"' target='_blank'>"+pcurl+"</a>", receivers, prinfo);
JhzjUtils.handleOA(prinfo,"0", "0");
//处理完成提示
this.operationResult.addSuccessPkId(prinfo.getPkValue());