清账单代码调试修改
This commit is contained in:
parent
4351f3bc65
commit
ef4373f88e
|
|
@ -0,0 +1,24 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.form;
|
||||
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.form.plugin.AbstractFormPlugin;
|
||||
|
||||
public class TestDBFormPlugin extends AbstractFormPlugin {
|
||||
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
||||
super.afterDoOperation(e);
|
||||
if("shjh_btnok".equals(e.getOperateKey())){
|
||||
String dbnum = (String) this.getModel().getValue("shjh_dbnum");//标识
|
||||
String sql = (String) this.getModel().getValue("shjh_sql");//sql语句
|
||||
try{
|
||||
DB.update(DBRoute.of(dbnum), sql,null);
|
||||
}catch(Exception ex){
|
||||
this.getView().showMessage("执行失败:" + ex.getMessage());
|
||||
}
|
||||
this.getView().showMessage("执行成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
private static final String updateDetailClearStatus = "update tk_shjh_clear_acctdetail set fbillstatus='D',fk_shjh_clearstatus='C' where fk_shjh_clearbillid=?;";
|
||||
|
||||
private static final String entityName = "shjh_clear_acctdetail";//清账明细单
|
||||
private static final String userName = "bos_user";//用户
|
||||
private static final String pzbName = "shjh_jgqzcust";//结构性清账客户映射表
|
||||
|
||||
/**
|
||||
|
|
@ -43,43 +44,43 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
super.beforeExecuteOperationTransaction(e);
|
||||
//反清账、作废、复制、修改清账单状态增加校验。
|
||||
String eok = e.getOperationKey();
|
||||
if("unclearacctount".equals(eok) || "invalid".equals(eok) || "copyqz".equals(eok) || "updatestatus".equals(eok)){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
if ("unclearacctount".equals(eok) || "invalid".equals(eok) || "copyqz".equals(eok) || "updatestatus".equals(eok)) {
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
String billno;
|
||||
String billstatus;
|
||||
String clearstatus;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
//反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName(),
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName(),
|
||||
"id,billno,billstatus,shjh_clearstatus,shjh_pzh,shjh_recebillno,shjh_unclearway,shjh_iscopy");
|
||||
billno = prinfo.getString("billno");
|
||||
billstatus = prinfo.getString("billstatus");
|
||||
clearstatus = prinfo.getString("shjh_clearstatus");
|
||||
if("unclearacctount".equals(eok)){
|
||||
if ("unclearacctount".equals(eok)) {
|
||||
//清账单【单据状态】=已审核 and【清账状态】=已清账 and【SAP凭证号】不为空 and 收款单编号不为多个,才允许点击反清账按钮。
|
||||
if(!"C".equals(billstatus) || !"A".equals(clearstatus) || JhzjUtils.isEmpty(prinfo.getString("shjh_pzh"))
|
||||
|| isReceBillNums(prinfo.getString("shjh_recebillno"))){
|
||||
e.setCancelMessage(billno+"【单据状态】=已审核 and【清账状态】=已清账 and【清账凭证号】不为空 and 收款单编号不为多个,才允许反清账");
|
||||
if (!"C".equals(billstatus) || !"A".equals(clearstatus) || JhzjUtils.isEmpty(prinfo.getString("shjh_pzh"))
|
||||
|| JhzjUtils.isReceBillNums(prinfo.getString("shjh_recebillno"))) {
|
||||
e.setCancelMessage(billno + "【单据状态】=已审核 and【清账状态】=已清账 and【清账凭证号】不为空 and 收款单编号不为多个,才允许反清账");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}else if("invalid".equals(eok)){
|
||||
} else if ("invalid".equals(eok)) {
|
||||
//清账单【单据状态】=暂存 and【清账状态】=待清账,才允许点作废按钮。
|
||||
if(!"A".equals(billstatus) || !"B".equals(clearstatus)){
|
||||
e.setCancelMessage(billno+"【单据状态】=暂存 and【清账状态】=待清账,才允许作废");
|
||||
if (!"A".equals(billstatus) || !"B".equals(clearstatus)) {
|
||||
e.setCancelMessage(billno + "【单据状态】=暂存 and【清账状态】=待清账,才允许作废");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}else if("copyqz".equals(eok)){
|
||||
} else if ("copyqz".equals(eok)) {
|
||||
//清账单【单据状态】=作废 and【清账状态】=反清账 and【反清后处理方式】=收款信息变更 and【是否被复制】=否,才允许复制按钮。
|
||||
if(!"D".equals(billstatus) || !"C".equals(clearstatus)
|
||||
|| !"B".equals(prinfo.getString("shjh_unclearway")) || prinfo.getBoolean("shjh_iscopy")){
|
||||
e.setCancelMessage(billno+"【单据状态】=作废 and【清账状态】=反清账 and【反清后处理方式】=收款信息变更 and【是否被复制】=否,才允许复制");
|
||||
if (!"D".equals(billstatus) || !"C".equals(clearstatus)
|
||||
|| !"B".equals(prinfo.getString("shjh_unclearway")) || prinfo.getBoolean("shjh_iscopy")) {
|
||||
e.setCancelMessage(billno + "【单据状态】=作废 and【清账状态】=反清账 and【反清后处理方式】=收款信息变更 and【是否被复制】=否,才允许复制");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}else if("updatestatus".equals(eok)){
|
||||
} else if ("updatestatus".equals(eok)) {
|
||||
//清账单【单据状态】=暂存 and【清账状态】=待清账,才允许点击修改清账单状态。
|
||||
if(!"A".equals(billstatus) || !"B".equals(clearstatus)){
|
||||
e.setCancelMessage(billno+"【单据状态】=暂存 and【清账状态】=待清账,才允许修改清账单状态");
|
||||
if (!"A".equals(billstatus) || !"B".equals(clearstatus)) {
|
||||
e.setCancelMessage(billno + "【单据状态】=暂存 and【清账状态】=待清账,才允许修改清账单状态");
|
||||
e.setCancel(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -87,16 +88,6 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isReceBillNums(String recebillnum){
|
||||
//收款单编号为多个
|
||||
if(JhzjUtils.isEmpty(recebillnum)){
|
||||
return false;
|
||||
}else if(recebillnum.indexOf(",") > 1){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作执行完毕,事务提交之后,触发此事件;
|
||||
* 插件可以在此事件,处理操作后续事情,与操作事务无关
|
||||
|
|
@ -105,20 +96,34 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
switch (eok){
|
||||
case "clearacctount": handleClear(e);//清账-下推清账明细单
|
||||
case "unclearacctount": handleUnClear(e);//反清账
|
||||
case "audit": handleAudit(e);//审核
|
||||
case "notice": handleNotice(e);//清账实时通知
|
||||
case "invalid": handleInvalid(e);//作废
|
||||
case "copyqz": handleCopy(e);//复制
|
||||
case "updatestatus": handleUpdateStatus(e);//修改清账单状态
|
||||
switch (eok) {
|
||||
case "clearacctount":
|
||||
handleClear(e);//清账-下推清账明细单
|
||||
break;
|
||||
case "unclearacctount":
|
||||
handleUnClear(e);//反清账
|
||||
break;
|
||||
case "audit":
|
||||
handleAudit(e);//审核
|
||||
break;
|
||||
case "notice":
|
||||
handleNotice(e);//清账实时通知
|
||||
break;
|
||||
case "invalid":
|
||||
handleInvalid(e);//作废
|
||||
break;
|
||||
case "copyqz":
|
||||
handleCopy(e);//复制
|
||||
break;
|
||||
case "updatestatus":
|
||||
handleUpdateStatus(e);//修改清账单状态
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpdateStatus(AfterOperationArgs e){
|
||||
private void handleUpdateStatus(AfterOperationArgs e) {
|
||||
//清账单清账状态支持手工修改,可由待清账转为已清账状态并填写清账原因
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
|
|
@ -131,19 +136,19 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
}
|
||||
}
|
||||
|
||||
private void handleOAUpdate(String clearbillid){
|
||||
DynamicObject[] ddos = BusinessDataServiceHelper.load(entityName,"id,billno,billstatus,shjh_clearbillid,shjh_clearbillno,createtime,creator,modifier",
|
||||
new QFilter[]{new QFilter("shjh_clearbillid","=", clearbillid)});
|
||||
private void handleOAUpdate(String clearbillid) {
|
||||
DynamicObject[] ddos = BusinessDataServiceHelper.load(entityName, "id,billno,billstatus,shjh_clearbillid,shjh_clearbillno,createtime,creator,modifier",
|
||||
new QFilter[]{new QFilter("shjh_clearbillid", "=", clearbillid)});
|
||||
DynamicObject detailinfo;
|
||||
for (int j = 0; j < ddos.length; j++) {
|
||||
detailinfo = ddos[j];
|
||||
//消除OA待办为已办
|
||||
JhzjUtils.handleOA(detailinfo,"2", "0");
|
||||
//将OA待办改为已办
|
||||
JhzjUtils.handleOA(detailinfo, "2", "0");
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCopy(AfterOperationArgs e){
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
private void handleCopy(AfterOperationArgs e) {
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
|
|
@ -152,10 +157,10 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
}
|
||||
}
|
||||
|
||||
private void handleClear(AfterOperationArgs e){
|
||||
private void handleClear(AfterOperationArgs e) {
|
||||
//清账具体实现
|
||||
//根据被通知人(结构性清账客户映射表)挨个生成清账明细单,并发送OA待办
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//清账单
|
||||
String billno;
|
||||
DynamicObject detailinfo;//清账明细单
|
||||
|
|
@ -164,119 +169,119 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
DynamicObject pzbinfo;//配置表
|
||||
DynamicObjectCollection users;//配置表中的被通知人集合
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(), dos[i].getDataEntityType().getName());
|
||||
billno = prinfo.getString("billno");
|
||||
//根据客户、公司、是否可用找到对应的被通知人员(可能多个)
|
||||
qFilter = new QFilter("enable", QCP.equals, "1");
|
||||
qFilter.and("shjh_customer", QCP.equals, prinfo.getDynamicObject("shjh_customer").getLong("id"));
|
||||
qFilter.and("shjh_org", QCP.equals, prinfo.getDynamicObject("org").getLong("id"));
|
||||
pzbs = BusinessDataServiceHelper.load(pzbName, "id", qFilter.toArray(), "desc");
|
||||
if(pzbs.length == 0){
|
||||
pzbs = BusinessDataServiceHelper.load(pzbName, "id", qFilter.toArray(), "modifytime desc");
|
||||
if (pzbs.length == 0) {
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage(billno+"根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单");//前端界面提示内容
|
||||
this.operationResult.setMessage(billno + "根据结构性清账客户映射表未找到对应通知人,无法下推清账明细单");//前端界面提示内容
|
||||
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
|
||||
continue;
|
||||
}
|
||||
pzbinfo = BusinessDataServiceHelper.loadSingleFromCache(pzbs[0].getLong("id"),pzbName);
|
||||
pzbinfo = BusinessDataServiceHelper.loadSingleFromCache(pzbs[0].getLong("id"), pzbName);
|
||||
users = pzbinfo.getDynamicObjectCollection("shjh_users");
|
||||
for (int j = 0; j < users.size(); j++) {
|
||||
users.get(j);
|
||||
for (DynamicObject user : users) {
|
||||
user.getDynamicObject("fbasedataid");//fbasedataid
|
||||
//根据清账单id和创建人id判断清账明细单是否已生成
|
||||
qFilter = new QFilter("shjh_clearbillid", QCP.equals, prinfo.getString("id"));
|
||||
qFilter.and("creator", QCP.equals, users.get(j).getLong("id"));
|
||||
if(!QueryServiceHelper.exists(entityName,qFilter.toArray())){
|
||||
qFilter.and("creator", QCP.equals, user.getDynamicObject("fbasedataid").getLong("id"));
|
||||
if (!QueryServiceHelper.exists(entityName, qFilter.toArray())) {
|
||||
//新增一个清账明细单
|
||||
detailinfo = newDetailBill(prinfo,users.get(j));
|
||||
detailinfo = newDetailBill(prinfo, user.getDynamicObject("fbasedataid"));
|
||||
//发送清账明细单的OA待办
|
||||
JhzjUtils.handleOA(detailinfo,"0", "0");
|
||||
JhzjUtils.sendEmail(users.get(j).getString("email"),"请登录资金系统操作清账明细单",
|
||||
detailinfo.getString("billno")+"\n 详情页面"+JhzjUtils.getBillPCURL(detailinfo),"清账明细单新增");
|
||||
JhzjUtils.handleOA(detailinfo, "0", "0");
|
||||
// JhzjUtils.sendEmail(users.get(j).getString("email"), "请登录资金系统操作清账明细单",
|
||||
// detailinfo.getString("billno") + "\n 详情页面" + JhzjUtils.getBillPCURL(detailinfo), "清账明细单新增");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicObject newDetailBill(DynamicObject prinfo,DynamicObject userinfo){
|
||||
private DynamicObject newDetailBill(DynamicObject prinfo, DynamicObject userinfo) {
|
||||
//根据清账单和被通知人创建清账明细单
|
||||
DynamicObject detailinfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
detailinfo.set("org",prinfo.getDynamicObject("org"));//公司
|
||||
detailinfo.set("shjh_currency",prinfo.getDynamicObject("shjh_currency"));//币别
|
||||
detailinfo.set("shjh_bizdate",prinfo.getDate("shjh_bizdate"));//业务日期
|
||||
detailinfo.set("shjh_clearbillno",prinfo.getString("billno"));//清账单编号
|
||||
detailinfo.set("shjh_clearbillid",prinfo.getString("id"));//清账单ID
|
||||
detailinfo.set("shjh_customer",prinfo.getDynamicObject("shjh_customer"));//客户
|
||||
detailinfo.set("shjh_recebillno",prinfo.getString("shjh_recebillno"));//收款单编号
|
||||
detailinfo.set("shjh_recepzh",prinfo.getString("shjh_recepzh"));//收款单凭证号
|
||||
detailinfo.set("shjh_receamount",prinfo.getBigDecimal("shjh_receamount"));//收款金额
|
||||
detailinfo.set("billstatus","A");//单据状态-暂存
|
||||
detailinfo.set("shjh_clearstatus","B");//清账状态-待清账
|
||||
detailinfo.set("creator",userinfo);//创建人
|
||||
detailinfo.set("createtime",new Date());//创建时间
|
||||
detailinfo.set("modifier",userinfo);//修改人
|
||||
detailinfo.set("modifytime",new Date());//修改时间
|
||||
detailinfo.set("org", prinfo.getDynamicObject("org"));//公司
|
||||
detailinfo.set("shjh_currency", prinfo.getDynamicObject("shjh_currency"));//币别
|
||||
detailinfo.set("shjh_bizdate", prinfo.getDate("shjh_bizdate"));//业务日期
|
||||
detailinfo.set("shjh_clearbillno", prinfo.getString("billno"));//清账单编号
|
||||
detailinfo.set("shjh_clearbillid", prinfo.getString("id"));//清账单ID
|
||||
detailinfo.set("shjh_customer", prinfo.getDynamicObject("shjh_customer"));//客户
|
||||
detailinfo.set("shjh_recebillno", prinfo.getString("shjh_recebillno"));//收款单编号
|
||||
detailinfo.set("shjh_recepzh", prinfo.getString("shjh_recepzh"));//收款单凭证号
|
||||
detailinfo.set("shjh_receamount", prinfo.getBigDecimal("shjh_receamount"));//收款金额
|
||||
detailinfo.set("billstatus", "A");//单据状态-暂存
|
||||
detailinfo.set("shjh_clearstatus", "B");//清账状态-待清账
|
||||
detailinfo.set("creator", userinfo);//创建人
|
||||
detailinfo.set("createtime", new Date());//创建时间
|
||||
detailinfo.set("modifier", userinfo);//修改人
|
||||
detailinfo.set("modifytime", new Date());//修改时间
|
||||
Object[] result = SaveServiceHelper.save(new DynamicObject[]{detailinfo});
|
||||
return (DynamicObject) result[0];
|
||||
}
|
||||
|
||||
private void handleUnClear(AfterOperationArgs e){
|
||||
private void handleUnClear(AfterOperationArgs e) {
|
||||
//反清账具体实现
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//清账单
|
||||
String fqzpzh;//反清账凭证号
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
//TODO 调用SAP反清账接口,更新清账单中反清状态和反清凭证号。
|
||||
fqzpzh = null;
|
||||
if(fqzpzh == null){
|
||||
if (fqzpzh == null) {
|
||||
this.operationResult.setSuccess(false);
|
||||
this.operationResult.setMessage("反清账失败,原因是:");//前端界面提示内容
|
||||
this.operationResult.setShowMessage(true);//前端界面 是否显示提示消息
|
||||
continue;
|
||||
}
|
||||
//若SAP反清成功,清账单【单据状态】=作废,【清账状态】=反清账,反写【反清账凭证号】。
|
||||
DB.update(DBRoute.of("fi"), updateUnClearStatus, new Object[]{fqzpzh,prinfo.getLong("id")});
|
||||
DB.update(DBRoute.of("fi"), updateUnClearStatus, new Object[]{fqzpzh, prinfo.getLong("id")});
|
||||
//更新下游清账明细单【单据状态】=作废;【清账状态】=反清账。
|
||||
DB.update(DBRoute.of("fi"), updateDetailClearStatus, new Object[]{prinfo.getString("id")});
|
||||
//TODO 更新上游收款单分录行【清账状态】=反清账,表头清账状态如何标记?
|
||||
|
||||
//若选择的反清后处理方式=重新清账,则复制原清账单,在新清账单上重新清账
|
||||
if("".equals(prinfo.getString(""))){
|
||||
if ("A".equals(prinfo.getString("shjh_unclearway"))) {
|
||||
handleCopyInfo(prinfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCopyInfo(DynamicObject srcinfo){
|
||||
private void handleCopyInfo(DynamicObject srcinfo) {
|
||||
//根据清账单复制另一个清账单出来
|
||||
//被复制的字段为:公司、币别、收款单编号、收款凭证号、收款金额、客户、业务大类、业务小类
|
||||
DynamicObject destinfo = BusinessDataServiceHelper.newDynamicObject(srcinfo.getDataEntityType().getName());
|
||||
destinfo.set("org",srcinfo.getDynamicObject("org"));//公司
|
||||
destinfo.set("shjh_currency",srcinfo.getDynamicObject("shjh_currency"));//币别
|
||||
destinfo.set("shjh_customer",srcinfo.getDynamicObject("shjh_customer"));//客户
|
||||
destinfo.set("shjh_recebillno",srcinfo.getString("shjh_recebillno"));//收款单编号
|
||||
destinfo.set("shjh_recepzh",srcinfo.getString("shjh_recepzh"));//收款单凭证号
|
||||
destinfo.set("shjh_receamount",srcinfo.getBigDecimal("shjh_receamount"));//收款金额
|
||||
destinfo.set("shjh_bizbig",srcinfo.getDynamicObject("shjh_bizbig"));//业务大类
|
||||
destinfo.set("shjh_bizsmall",srcinfo.getDynamicObject("shjh_bizsmall"));//业务小类
|
||||
destinfo.set("org", srcinfo.getDynamicObject("org"));//公司
|
||||
destinfo.set("shjh_currency", srcinfo.getDynamicObject("shjh_currency"));//币别
|
||||
destinfo.set("shjh_customer", srcinfo.getDynamicObject("shjh_customer"));//客户
|
||||
destinfo.set("shjh_recebillno", srcinfo.getString("shjh_recebillno"));//收款单编号
|
||||
destinfo.set("shjh_recepzh", srcinfo.getString("shjh_recepzh"));//收款单凭证号
|
||||
destinfo.set("shjh_receamount", srcinfo.getBigDecimal("shjh_receamount"));//收款金额
|
||||
destinfo.set("shjh_bizbig", srcinfo.getDynamicObject("shjh_bizbig"));//业务大类
|
||||
destinfo.set("shjh_bizsmall", srcinfo.getDynamicObject("shjh_bizsmall"));//业务小类
|
||||
|
||||
//新清账单需处理的字段为:业务日期为源清账单的反清账日期;单据状态=暂存;清账日期=业务日期,可修改;清账状态=待清账;已认领收款金额=0;
|
||||
//未认领收款金额=收款金额;源清账单号=被复制的清账单单号;【是否被复制】=否
|
||||
destinfo.set("shjh_bizdate",srcinfo.getDate("shjh_uncleardate"));//业务日期
|
||||
destinfo.set("billstatus","A");//单据状态-暂存
|
||||
destinfo.set("",srcinfo.getDate("shjh_uncleardate"));//清账日期=业务日期
|
||||
destinfo.set("shjh_clearstatus","B");//清账状态-待清账
|
||||
destinfo.set("",BigDecimal.ZERO);//已认领收款金额=0
|
||||
destinfo.set("",srcinfo.getBigDecimal("shjh_receamount"));//未认领收款金额=收款金额
|
||||
destinfo.set("",srcinfo.getString("billno"));//源清账单号=被复制的清账单单号
|
||||
destinfo.set("shjh_bizdate", srcinfo.getDate("shjh_uncleardate"));//业务日期
|
||||
destinfo.set("billstatus", "A");//单据状态-暂存
|
||||
destinfo.set("shjh_cleardate", srcinfo.getDate("shjh_uncleardate"));//清账日期=业务日期
|
||||
destinfo.set("shjh_clearstatus", "B");//清账状态-待清账
|
||||
destinfo.set("shjh_claimamount", BigDecimal.ZERO);//已认领收款金额=0
|
||||
destinfo.set("shjh_unclaimamount", srcinfo.getBigDecimal("shjh_receamount"));//未认领收款金额=收款金额
|
||||
destinfo.set("shjh_srcbillno", srcinfo.getString("billno"));//源清账单号=被复制的清账单单号
|
||||
|
||||
SaveServiceHelper.save(new DynamicObject[]{destinfo});
|
||||
//原清账单:【是否被复制】=是
|
||||
DB.update(DBRoute.of("fi"), updateSrcClear, new Object[]{srcinfo.getLong("id")});
|
||||
}
|
||||
|
||||
private void handleAudit(AfterOperationArgs e){
|
||||
private void handleAudit(AfterOperationArgs e) {
|
||||
//审核具体实现
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;//清账单
|
||||
DynamicObject detailinfo;//清账明细单
|
||||
DynamicObject[] ddos;
|
||||
|
|
@ -287,47 +292,47 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
//TODO 调用SAP清账接口,生成清账凭证。
|
||||
|
||||
//若存在(暂存、驳回)的清账明细单,则系统自动处理:清账明细单【单据状态】全标记为作废,并消除被作废明细单的OA待办。
|
||||
ddos = BusinessDataServiceHelper.load(entityName,"id,billno,billstatus,shjh_clearbillid,shjh_clearbillno,createtime,creator,modifier",
|
||||
new QFilter[]{new QFilter("shjh_clearbillid","=",prinfo.getString("id"))});
|
||||
ddos = BusinessDataServiceHelper.load(entityName, "id,billno,billstatus,shjh_clearbillid,shjh_clearbillno,createtime,creator,modifier",
|
||||
new QFilter[]{new QFilter("shjh_clearbillid", "=", prinfo.getString("id"))});
|
||||
for (int j = 0; j < ddos.length; j++) {
|
||||
detailinfo = ddos[j];
|
||||
billstatus = detailinfo.getString("billstatus");
|
||||
if("A".equals(billstatus) || "E".equals(billstatus)){
|
||||
if ("A".equals(billstatus) || "E".equals(billstatus)) {
|
||||
DB.update(DBRoute.of("fi"), updateDetailStatusByID, new Object[]{detailinfo.getLong("id")});
|
||||
//消除OA待办
|
||||
JhzjUtils.handleOA(detailinfo,"2", "0");
|
||||
}else if("C".equals(billstatus)){
|
||||
JhzjUtils.handleOA(detailinfo, "2", "0");
|
||||
} else if ("C".equals(billstatus)) {
|
||||
detailList.add(detailinfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//TODO 如果清账明细单【单据状态】=已审核,发送审核通过的邮件通知,企微通知。
|
||||
if(!detailList.isEmpty()){
|
||||
if (!detailList.isEmpty()) {
|
||||
Map<String, String> userBill = new HashMap<>();
|
||||
String billno;
|
||||
String useremail;
|
||||
for (int i = 0; i < detailList.size(); i++) {
|
||||
detailinfo = detailList.get(i);
|
||||
useremail = detailinfo.getDynamicObject("modifier").getString("email");
|
||||
if(userBill.containsKey(useremail)){
|
||||
if (userBill.containsKey(useremail)) {
|
||||
billno = userBill.get(useremail);
|
||||
userBill.put(useremail,billno+","+detailinfo.getString("billno"));
|
||||
}else{
|
||||
userBill.put(useremail,detailinfo.getString("billno"));
|
||||
userBill.put(useremail, billno + "," + detailinfo.getString("billno"));
|
||||
} else {
|
||||
userBill.put(useremail, detailinfo.getString("billno"));
|
||||
}
|
||||
}
|
||||
//遍历map,给每个人发邮件
|
||||
for (Map.Entry<String, String> entry : userBill.entrySet()) {
|
||||
JhzjUtils.sendEmail(entry.getKey(),"清账完成通知",entry.getValue()+"已清账完成","清账单审核");
|
||||
JhzjUtils.sendEmail(entry.getKey(), "清账完成通知", entry.getValue() + "已清账完成", "清账单审核");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInvalid(AfterOperationArgs e){
|
||||
private void handleInvalid(AfterOperationArgs e) {
|
||||
//作废具体实现
|
||||
//更新清账单【单据状态】=作废,及下游所有清账明细单【单据状态】=作废
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
prinfo = dos[i];
|
||||
|
|
@ -336,7 +341,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im
|
|||
}
|
||||
}
|
||||
|
||||
private void handleNotice(AfterOperationArgs e){
|
||||
private void handleNotice(AfterOperationArgs e) {
|
||||
//通知具体实现
|
||||
//清账单的下游所有清账明细单实时通知被通知人进行清账。发送邮件通知、OA待办。
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,18 +94,24 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
private boolean checkAmount(DynamicObject prinfo){
|
||||
//TODO【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】
|
||||
BigDecimal billtotal = BigDecimal.ZERO;
|
||||
BigDecimal a1 = prinfo.getBigDecimal("");
|
||||
BigDecimal a2 = prinfo.getBigDecimal("");
|
||||
BigDecimal a3 = prinfo.getBigDecimal("");
|
||||
BigDecimal a1 = prinfo.getBigDecimal("shjh_unclaimamount");
|
||||
BigDecimal a2 = prinfo.getBigDecimal("shjh_deductionamount");
|
||||
BigDecimal a3 = prinfo.getBigDecimal("shjh_diffamount");
|
||||
if(a1 != null){
|
||||
billtotal = billtotal.add(a1);
|
||||
}
|
||||
if(a2 != null){
|
||||
billtotal = billtotal.add(a2);
|
||||
}
|
||||
if(a3 != null){
|
||||
billtotal = billtotal.add(a3);
|
||||
}
|
||||
//获取分录本次核销金额合计
|
||||
BigDecimal entrytotal = BigDecimal.ZERO;
|
||||
DynamicObjectCollection doc = prinfo.getDynamicObjectCollection("");//获取分录
|
||||
DynamicObjectCollection doc = prinfo.getDynamicObjectCollection("shjh_details");//获取分录
|
||||
for (int i = 0; i < doc.size(); i++) {
|
||||
if(doc.get(i).getBigDecimal("") != null){
|
||||
entrytotal = entrytotal.add(doc.get(i).getBigDecimal(""));//累计分录本次核销金额
|
||||
if(doc.get(i).getBigDecimal("shjh_e_cursettle") != null){
|
||||
entrytotal = entrytotal.add(doc.get(i).getBigDecimal("shjh_e_cursettle"));//累计分录本次核销金额
|
||||
}
|
||||
}
|
||||
if(billtotal.compareTo(entrytotal) >= 0){
|
||||
|
|
@ -124,9 +130,15 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
switch (eok){
|
||||
case "submit": handleSubmit(e);//提交--业务主动点击
|
||||
case "revoke": handleRevoke(e);//撤销--业务主动点击
|
||||
case "reject": handleReject(e);//驳回--财务人员主动点击
|
||||
case "submit":
|
||||
handleSubmit(e);//提交--业务主动点击
|
||||
break;
|
||||
case "revoke":
|
||||
handleRevoke(e);//撤销--业务主动点击
|
||||
break;
|
||||
case "reject":
|
||||
handleReject(e);//驳回--财务人员主动点击
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -163,47 +175,47 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
return clearBillInfo.getString("billno")+lockresult;
|
||||
}
|
||||
//清账明细单分录
|
||||
DynamicObjectCollection detaildoc = detailBillInfo.getDynamicObjectCollection("");
|
||||
DynamicObjectCollection detaildoc = detailBillInfo.getDynamicObjectCollection("shjh_details");
|
||||
//清账单分录
|
||||
DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection("");
|
||||
DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection("shjh_details");
|
||||
DynamicObject detailEntryInfo;
|
||||
DynamicObject clearEntryInfo;
|
||||
for (int i = 0; i < detaildoc.size(); i++) {
|
||||
detailEntryInfo = detaildoc.get(i);
|
||||
clearEntryInfo = cleardoc.addNew();
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));//凭证号
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));//凭证类型
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));//凭证行项目号
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));//发票号
|
||||
clearEntryInfo.set("",detailEntryInfo.getDate(""));//发票日期
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));// 总账科目
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));// 分配
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));// 参照
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));//参考代码1
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));// 参考代码2
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));// 文本
|
||||
clearEntryInfo.set("",detailEntryInfo.getDate(""));// 过账日期
|
||||
clearEntryInfo.set("",detailEntryInfo.getBigDecimal(""));//未核销金额
|
||||
clearEntryInfo.set("",detailEntryInfo.getBigDecimal(""));//本次核销金额
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));//会计年度
|
||||
clearEntryInfo.set("",detailEntryInfo.getString(""));// 清账凭证文本
|
||||
clearEntryInfo.set("",detailEntryInfo.getString("id"));// 明细单分录ID
|
||||
clearEntryInfo.set("shjh_e_pzh",detailEntryInfo.getString("shjh_e_pzh"));//凭证号
|
||||
clearEntryInfo.set("shjh_e_pzlx",detailEntryInfo.getString("shjh_e_pzlx"));//凭证类型
|
||||
clearEntryInfo.set("shjh_e_pzhh",detailEntryInfo.getString("shjh_e_pzhh"));//凭证行项目号
|
||||
clearEntryInfo.set("shjh_e_fph",detailEntryInfo.getString("shjh_e_fph"));//发票号
|
||||
clearEntryInfo.set("shjh_e_fpdate",detailEntryInfo.getDate("shjh_e_fpdate"));//发票日期
|
||||
clearEntryInfo.set("shjh_e_account",detailEntryInfo.getString("shjh_e_account"));// 总账科目
|
||||
clearEntryInfo.set("shjh_e_fenpei",detailEntryInfo.getString("shjh_e_fenpei"));// 分配
|
||||
clearEntryInfo.set("shjh_e_canzhao",detailEntryInfo.getString("shjh_e_canzhao"));// 参照
|
||||
clearEntryInfo.set("shjh_e_ckdm1",detailEntryInfo.getString("shjh_e_ckdm1"));//参考代码1
|
||||
clearEntryInfo.set("shjh_e_ckdm2",detailEntryInfo.getString("shjh_e_ckdm2"));// 参考代码2
|
||||
clearEntryInfo.set("shjh_e_text",detailEntryInfo.getString("shjh_e_text"));// 文本
|
||||
clearEntryInfo.set("shjh_e_gzdate",detailEntryInfo.getDate("shjh_e_gzdate"));// 过账日期
|
||||
clearEntryInfo.set("shjh_e_unsettle",detailEntryInfo.getBigDecimal("shjh_e_unsettle"));//未核销金额
|
||||
clearEntryInfo.set("shjh_e_cursettle",detailEntryInfo.getBigDecimal("shjh_e_cursettle"));//本次核销金额
|
||||
clearEntryInfo.set("shjh_e_year",detailEntryInfo.getString("shjh_e_year"));//会计年度
|
||||
clearEntryInfo.set("shjh_e_qzpztext",detailEntryInfo.getString("shjh_e_qzpztext"));// 清账凭证文本
|
||||
clearEntryInfo.set("shjh_e_detailentryid",detailEntryInfo.getString("id"));// 明细单分录ID
|
||||
}
|
||||
//处理清账单账扣
|
||||
BigDecimal q1 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal(""),
|
||||
detailBillInfo.getBigDecimal(""));
|
||||
clearBillInfo.set("",q1);
|
||||
BigDecimal q1 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal("shjh_deductionamount"),
|
||||
detailBillInfo.getBigDecimal("shjh_deductionamount"));
|
||||
clearBillInfo.set("shjh_deductionamount",q1);
|
||||
//处理清账单尾差
|
||||
BigDecimal q2 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal(""),
|
||||
detailBillInfo.getBigDecimal(""));
|
||||
clearBillInfo.set("",q2);
|
||||
BigDecimal q2 = JhzjUtils.addTwoAmount(clearBillInfo.getBigDecimal("shjh_diffamount"),
|
||||
detailBillInfo.getBigDecimal("shjh_diffamount"));
|
||||
clearBillInfo.set("shjh_diffamount",q2);
|
||||
//获取清账单收款金额
|
||||
BigDecimal q3 =clearBillInfo.getBigDecimal("");
|
||||
BigDecimal q3 =clearBillInfo.getBigDecimal("shjh_receamount");
|
||||
//获取清账单的本次核销金额合计
|
||||
BigDecimal entrytotal = BigDecimal.ZERO;
|
||||
for (int i = 0; i < cleardoc.size(); i++) {
|
||||
clearEntryInfo = cleardoc.get(i);
|
||||
entrytotal = entrytotal.add(clearEntryInfo.getBigDecimal(""));
|
||||
entrytotal = entrytotal.add(clearEntryInfo.getBigDecimal("shjh_e_cursettle"));
|
||||
}
|
||||
//清账单的收款金额+账扣+尾差=本次核销金额合计,即可提交
|
||||
if(entrytotal.compareTo(q1.add(q2).add(q3)) == 0){
|
||||
|
|
@ -229,7 +241,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
return clearBillInfo.getString("billno")+lockresult;
|
||||
}
|
||||
//清账明细单分录
|
||||
DynamicObjectCollection detaildoc = detailBillInfo.getDynamicObjectCollection("");
|
||||
DynamicObjectCollection detaildoc = detailBillInfo.getDynamicObjectCollection("shjh_details");
|
||||
Set<String> idsets = new HashSet<>(detaildoc.size());
|
||||
DynamicObject detailEntryInfo;
|
||||
for (int i = 0; i < detaildoc.size(); i++) {
|
||||
|
|
@ -238,7 +250,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
}
|
||||
|
||||
//清账单分录
|
||||
DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection("");
|
||||
DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection("shjh_details");
|
||||
DynamicObject clearEntryInfo;
|
||||
for (int i = cleardoc.size()-1; i >=0; i--) {
|
||||
clearEntryInfo = cleardoc.get(i);
|
||||
|
|
@ -247,13 +259,13 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
}
|
||||
}
|
||||
//处理清账单账扣
|
||||
BigDecimal q1 = JhzjUtils.reduceTwoAmount(clearBillInfo.getBigDecimal(""),
|
||||
detailBillInfo.getBigDecimal(""));
|
||||
clearBillInfo.set("",q1);
|
||||
BigDecimal q1 = JhzjUtils.reduceTwoAmount(clearBillInfo.getBigDecimal("shjh_deductionamount"),
|
||||
detailBillInfo.getBigDecimal("shjh_deductionamount"));
|
||||
clearBillInfo.set("shjh_deductionamount",q1);
|
||||
//处理清账单尾差
|
||||
BigDecimal q2 = JhzjUtils.reduceTwoAmount(clearBillInfo.getBigDecimal(""),
|
||||
detailBillInfo.getBigDecimal(""));
|
||||
clearBillInfo.set("",q2);
|
||||
BigDecimal q2 = JhzjUtils.reduceTwoAmount(clearBillInfo.getBigDecimal("shjh_diffamount"),
|
||||
detailBillInfo.getBigDecimal("shjh_diffamount"));
|
||||
clearBillInfo.set("shjh_diffamount",q2);
|
||||
|
||||
SaveServiceHelper.save(new DynamicObject[]{clearBillInfo});
|
||||
//解除清账单互斥锁
|
||||
|
|
|
|||
|
|
@ -238,6 +238,19 @@ public class JhzjUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 判断收款单编号是否由多个组成,如果是多个,其中每个中间以逗号分隔的
|
||||
* */
|
||||
public static boolean isReceBillNums(String recebillnum){
|
||||
//收款单编号为多个
|
||||
if(isEmpty(recebillnum)){
|
||||
return false;
|
||||
}else if(recebillnum.indexOf(",") > 1){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* 两个金额字段相加,如果两个都为null,返回0
|
||||
* 两个有一个为null,返回其中一个值;两个都不为null,则相加
|
||||
|
|
|
|||
Loading…
Reference in New Issue