Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
de37339a5b
|
|
@ -7,9 +7,13 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.coderule.CodeRuleServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -37,12 +41,10 @@ public class MaterialinbillToNoContractBotpPlugin extends AbstractConvertPlugIn
|
|||
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
||||
Map<String,Long> invoiceEntryMap = new HashMap<String, Long>();//发票信息分录
|
||||
Map<String,Long> expensEntryMap = new HashMap<String, Long>();//费用明细分录
|
||||
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||
for (DynamicObject invoice : invoiceentry) {
|
||||
String invoiceno = invoice.getString("invoiceno");
|
||||
long aLong = invoice.getLong("id");
|
||||
invoiceEntryMap.put(invoiceno, aLong);
|
||||
}
|
||||
Map<String,DynamicObject> invoiceDataEntryMap = new HashMap<String, DynamicObject>();//费用明细分录
|
||||
Map<String,DynamicObject> rimInvoiceDataEntryMap = new HashMap<String, DynamicObject>();//费用明细分录
|
||||
|
||||
//费用明细信息分录
|
||||
DynamicObjectCollection expenseentryentity = dataEntity.getDynamicObjectCollection("expenseentryentity");
|
||||
for (DynamicObject expenseentry : expenseentryentity) {
|
||||
String invoiceno = expenseentry.getString("invoiceno_entry");
|
||||
|
|
@ -50,17 +52,82 @@ public class MaterialinbillToNoContractBotpPlugin extends AbstractConvertPlugIn
|
|||
long aLong = expenseentry.getLong("id");
|
||||
for (String invoiceNo : invoiceNos) {
|
||||
expensEntryMap.put(invoiceNo, aLong);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//发票信息分录
|
||||
DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");
|
||||
for (DynamicObject invoice : invoiceentry) {
|
||||
String invoiceno = invoice.getString("invoiceno");
|
||||
long aLong = invoice.getLong("id");
|
||||
invoiceEntryMap.put(invoiceno, aLong);
|
||||
invoiceDataEntryMap.put(invoiceno, invoice);
|
||||
String serialno = invoice.getString("serialno");
|
||||
DynamicObject rimInvoice = BusinessDataServiceHelper.loadSingle("rim_invoice", "id,unitprice,invoice_amount,total_tax_amount,deduction_flag",
|
||||
new QFilter[]{new QFilter("serial_no","=",serialno)});
|
||||
if(rimInvoice != null){
|
||||
rimInvoiceDataEntryMap.put(invoiceno, rimInvoice);
|
||||
String deductionFlag = rimInvoice.getString("deduction_flag");
|
||||
if("1".equals(deductionFlag)){//可抵扣
|
||||
//是否抵扣 invoiceitemoffset 发票信息-是否抵扣 offset_invoice
|
||||
invoice.set("offset_invoice",true);
|
||||
}else{
|
||||
invoice.set("offset_invoice",false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发票明细分录
|
||||
DynamicObjectCollection invoiceitementry = dataEntity.getDynamicObjectCollection("invoiceitementry");
|
||||
for (String invoiceno : expensEntryMap.keySet()) {
|
||||
for (String invoiceno : invoiceEntryMap.keySet()) {//以发票信息为主
|
||||
Long itemid = expensEntryMap.get(invoiceno);//费用明细分录id
|
||||
Long invoiceId = invoiceEntryMap.get(invoiceno);//发票信息分录id
|
||||
DynamicObject dynamicObject = invoiceitementry.addNew();//发票明细,费用明细和发票信息关联关系
|
||||
dynamicObject.set("itementryid", itemid);
|
||||
dynamicObject.set("invoiceheadentryid", invoiceId);
|
||||
DynamicObject invoiceData = invoiceDataEntryMap.get(invoiceno);
|
||||
DynamicObject rimInvoice = rimInvoiceDataEntryMap.get(invoiceno);
|
||||
if(rimInvoice!=null){
|
||||
BigDecimal invoiceAmount = rimInvoice.getBigDecimal("invoice_amount");//发票金额-不含税金额
|
||||
|
||||
//不含税单价 unitprice
|
||||
dynamicObject.set("unitprice", invoiceAmount);
|
||||
|
||||
//不含税金额 excludeamount
|
||||
dynamicObject.set("excludeamount", invoiceAmount);
|
||||
|
||||
//税额 invoiceitemtaxamout 发票信息
|
||||
BigDecimal totalTaxAmount = rimInvoice.getBigDecimal("total_tax_amount");//发票税额
|
||||
dynamicObject.set("invoiceitemtaxamout", totalTaxAmount);
|
||||
|
||||
//税率 invoiceitemtaxrate = 税额 ÷ 不含税金额
|
||||
if(invoiceAmount.compareTo(BigDecimal.ZERO)!=0){
|
||||
BigDecimal taxRate = totalTaxAmount.divide(invoiceAmount, 2, RoundingMode.HALF_UP);
|
||||
dynamicObject.set("invoiceitemtaxrate", taxRate);
|
||||
}
|
||||
String deductionFlag = rimInvoice.getString("deduction_flag");
|
||||
if("1".equals(deductionFlag)){//可抵扣
|
||||
//是否抵扣 invoiceitemoffset 发票信息-是否抵扣 offset_invoice
|
||||
dynamicObject.set("invoiceitemoffset",true);
|
||||
//发票抵扣 invoicecloudoffset 发票信息-是否抵扣 offset_invoice
|
||||
dynamicObject.set("invoicecloudoffset",true);
|
||||
}else{
|
||||
//是否抵扣 invoiceitemoffset 发票信息-是否抵扣 offset_invoice
|
||||
dynamicObject.set("invoiceitemoffset",false);
|
||||
//发票抵扣 invoicecloudoffset 发票信息-是否抵扣 offset_invoice
|
||||
dynamicObject.set("invoicecloudoffset",false);
|
||||
}
|
||||
}
|
||||
|
||||
//商品名称 goodsname 发票信息-商品名称 invoicegoodsname
|
||||
String invoicegoodsname = invoiceData.getString("invoicegoodsname");
|
||||
dynamicObject.set("goodsname", invoicegoodsname);
|
||||
//税收分类编码 goodscode - 通过发票信息invoicealltaxcode 税收分类编码 查询 税收分类编码基础资料-合并编码er_taxclasscode-mergecode
|
||||
//发票来源 invoicefrom1 发票信息-发票来源 1-发票云,2-OCR识别,3-商旅月结,5-采购商城
|
||||
dynamicObject.set("invoicefrom1",invoiceData.getString("invoicefrom"));
|
||||
|
||||
}
|
||||
SaveServiceHelper.save(new DynamicObject[]{dataEntity});
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ public class OutContractFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i
|
|||
}
|
||||
filter1.and(new QFilter("zcgj_isbind", "=", false));
|
||||
ListShowParameter param = ShowFormHelper.createShowListForm("ec_in_invoice_f7", true);
|
||||
// param.getListFilterParameter().setFilter(filter.or(filter1));
|
||||
param.getListFilterParameter().setFilter(filter.or(filter1));
|
||||
param.setMultiSelect(true);
|
||||
param.setCloseCallBack(new CloseCallBack(this, entryType));
|
||||
param.getOpenStyle().setShowType(ShowType.Modal);
|
||||
|
|
@ -351,26 +351,6 @@ public class OutContractFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i
|
|||
public void bindInvoice(List<DynamicObject> invArr,String status){
|
||||
Object pkValue = this.getModel().getDataEntity(true).getPkValue();
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:发票绑定-"+pkValue);
|
||||
/*for (DynamicObject invoiceData : invArr) {
|
||||
|
||||
}
|
||||
Object billno = this.getModel().getValue("billno");
|
||||
String par = "{" +
|
||||
" \"messageType\": \"billSave\"," +
|
||||
" \"messageId\": \"202511051701\"," +
|
||||
" \"data\": {\n" +
|
||||
" \"billId\": "+pkValue+"," +
|
||||
" \"billNo\": "+billno+"," +
|
||||
" \"billType\": \"zcgj_ec_out_finaceconfirm\"," +
|
||||
" \"status\": \"60\"," +
|
||||
" \"resource\": \"4\"," +
|
||||
" \"invoiceData\": [" +
|
||||
" {" +
|
||||
" \"serialNo\": "+invArr.get(0).getString("serialno") +
|
||||
" }" +
|
||||
" ]" +
|
||||
" }" +
|
||||
"}";*/
|
||||
StringBuilder invoiceDataBuilder = new StringBuilder("[");
|
||||
for (int i = 0; i < invArr.size(); i++) {
|
||||
DynamicObject invoiceData = invArr.get(i);
|
||||
|
|
@ -398,7 +378,6 @@ public class OutContractFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i
|
|||
+ "\"invoiceData\": " + invoiceDataBuilder
|
||||
+ "}"
|
||||
+ "}";
|
||||
|
||||
Gson gson = new Gson();
|
||||
//String json = gson.toJson(balanceQueryParamApi);
|
||||
Map<String, Object> params = gson.fromJson(par,
|
||||
|
|
@ -407,47 +386,6 @@ public class OutContractFinaceConfirmeInvoicePlugin extends AbstractBillPlugIn i
|
|||
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/rim/message/service", params);
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:发票绑定-"+balanceData.getMessage());
|
||||
System.out.println();
|
||||
//当前单据id
|
||||
/*Object pkValue = this.getModel().getDataEntity(true).getPkValue();
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:发票绑定-"+pkValue);
|
||||
Object billno = this.getModel().getValue("billno");
|
||||
for (DynamicObject invoiceData : invArr) {
|
||||
|
||||
DynamicObject bindData = BusinessDataServiceHelper.newDynamicObject("rim_expense_relation");
|
||||
bindData.set("resource","4");//报销单来源
|
||||
bindData.set("view_page","zcgj_ec_out_finaceconfirm");//详情页面
|
||||
bindData.set("entityid","zcgj_ec_out_finaceconfirm");//报销单实体id
|
||||
bindData.set("expense_id",pkValue);//报销单id
|
||||
bindData.set("expense_num",billno);//报销单编号
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:发票绑定- billno-"+billno);
|
||||
bindData.set("serial_no",invoiceData.getString("serialno"));//发票流水号
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:发票绑定- serialno-"+invoiceData.getString("serialno"));
|
||||
if(invoiceData.getBoolean("candeduct")){
|
||||
bindData.set("deduction_flag",1);//是否可抵扣
|
||||
bindData.set("effective_tax_amount",invoiceData.getBigDecimal("totaltax"));//可抵扣税额-税额
|
||||
}else{
|
||||
bindData.set("deduction_flag",0);
|
||||
}
|
||||
|
||||
bindData.set("deduction_amount",invoiceData.getBigDecimal("totaltax"));//入账税额-税额
|
||||
bindData.set("expense_amount",invoiceData.getBigDecimal("totaloftaxamount"));//报销金额-价税合计
|
||||
bindData.set("status","60");//报销单状态
|
||||
bindData.set("output_amount",invoiceData.getBigDecimal("totaltax"));//转出金额-税额
|
||||
bindData.set("use_type",1);//使用类型
|
||||
bindData.set("billtaxamount",invoiceData.getBigDecimal("totaltax"));//本次报账税额
|
||||
SaveServiceHelper.saveOperate("rim_expense_relation", new DynamicObject[]{bindData}, null);//支出合同实体
|
||||
}*/
|
||||
}
|
||||
|
||||
public void deleteInvoiceBind(DynamicObject[] invArr){
|
||||
/*Long pkValue = (Long)this.getModel().getDataEntity(true).getPkValue();
|
||||
for (DynamicObject invData : invArr) {
|
||||
String serialno = invData.getString("serialno");
|
||||
QFilter idFilter = new QFilter("expense_id", QCP.equals,pkValue);
|
||||
QFilter serialnoFilter = new QFilter("serial_no", QCP.equals,serialno);
|
||||
//DynamicObject[] loadInvoiceData = BusinessDataServiceHelper.load("rim_expense_relation", "serial_no", new QFilter[]{idFilter,serialnoFilter});
|
||||
DeleteServiceHelper.delete("rim_expense_relation", new QFilter[]{idFilter.and(serialnoFilter)});
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.form;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
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.db.tx.TX;
|
||||
import kd.bos.db.tx.TXHandle;
|
||||
import kd.bos.entity.EntityMetadataCache;
|
||||
import kd.bos.entity.MainEntityType;
|
||||
import kd.bos.ext.fi.ai.AbstractDapWriteBackImpl;
|
||||
|
|
@ -9,11 +15,16 @@ import kd.bos.ext.fi.ai.Voucher;
|
|||
import kd.bos.ext.fi.ai.VoucherOperation;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.openapi.common.result.OpenApiResult;
|
||||
import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 支出合同财务确认凭证反写插件
|
||||
|
|
@ -54,7 +65,7 @@ public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBack
|
|||
@Override
|
||||
public void writeBack(VoucherOperation operation, String billEntityNumber, Map<Long, Voucher> billToVch) {
|
||||
MainEntityType mt = EntityMetadataCache.getDataEntityType(billEntityNumber);
|
||||
Set<Long> keySet = billToVch.keySet();
|
||||
Set<Long> keySet = billToVch.keySet();//业务单据id set集合
|
||||
log.info("AbstractDapWriteBackImpl#keySet:" + keySet);
|
||||
if (VoucherOperation.Create.equals(operation)) {
|
||||
log.info("AbstractDapWriteBackImpl#开始执行生成凭证反写:" + operation);
|
||||
|
|
@ -64,6 +75,7 @@ public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBack
|
|||
log.info("AbstractDapWriteBackImpl#生成凭证的单据ID:" + me);
|
||||
Voucher voucher=billToVch.get(me);//凭证
|
||||
String voucherNo = voucher.getVoucherNo();
|
||||
long voucherId = voucher.getId();
|
||||
//这里处理的是一个单据只有一个凭证的时候,如果是多个凭证,可以先获取已经生成的凭证号,再拼接上字符串。
|
||||
Object[] param = new Object[] { vchStatusField,voucherNo, me };//
|
||||
params.add(param);
|
||||
|
|
@ -76,6 +88,9 @@ public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBack
|
|||
log.info("AbstractDapWriteBackImpl#结束执行生成凭证反写SQL");
|
||||
params.clear();
|
||||
}
|
||||
|
||||
//反写凭证号到发票全票池
|
||||
updateInvoice(me,voucher,operation);
|
||||
}
|
||||
log.info("AbstractDapWriteBackImpl#最后#开始执行生成凭证反写SQL");
|
||||
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
|
||||
|
|
@ -103,6 +118,9 @@ public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBack
|
|||
params.clear();
|
||||
log.info("AbstractDapWriteBackImpl#结束执行删除凭证反写SQL");
|
||||
}
|
||||
|
||||
Voucher voucher=billToVch.get(me);//凭证
|
||||
updateInvoice(me,voucher,operation);
|
||||
}
|
||||
log.info("AbstractDapWriteBackImpl#最后#开始执行删除凭证反写SQL");
|
||||
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
|
||||
|
|
@ -132,6 +150,7 @@ public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBack
|
|||
log.info("AbstractDapWriteBackImpl#结束执行提交凭证反写SQL");
|
||||
params.clear();
|
||||
}
|
||||
updateInvoice(me,voucher,operation);
|
||||
}
|
||||
log.info("AbstractDapWriteBackImpl#最后#开始执行提交凭证反写SQL");
|
||||
log.info("AbstractDapWriteBackImpl#最后#mt.getAlias()" + mt.getAlias());
|
||||
|
|
@ -144,4 +163,112 @@ public class OutContractFinaceConfirmeVoucherPlugin extends AbstractDapWriteBack
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 反写凭证号到发票全票池
|
||||
* @param billId 业务单据id
|
||||
* @param voucher 生成的凭证
|
||||
* @param operation 操作
|
||||
*/
|
||||
public void updateInvoice(Long billId, Voucher voucher,VoucherOperation operation){
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String voucherNo = voucher.getVoucherNo();
|
||||
long voucherId = voucher.getId();
|
||||
|
||||
DynamicObject outFinaceconfirm = BusinessDataServiceHelper.loadSingle("zcgj_ec_out_finaceconfirm", "id,unitprice,zcgj_entryentity,zcgj_entryentity.zcgj_invoice",
|
||||
new QFilter[]{new QFilter("id","=",billId)});
|
||||
DynamicObjectCollection invoiceentryentity = outFinaceconfirm.getDynamicObjectCollection("zcgj_entryentity");
|
||||
List<String> serialnoList = new ArrayList<>();
|
||||
if(invoiceentryentity != null){
|
||||
for (DynamicObject dynamicObject : invoiceentryentity) {
|
||||
DynamicObject zcgjInvoice = dynamicObject.getDynamicObject("zcgj_invoice");
|
||||
if(zcgjInvoice != null){
|
||||
Long invoiceId = zcgjInvoice.getLong("id");
|
||||
DynamicObject inInvoice = BusinessDataServiceHelper.loadSingle("ec_in_invoice", "id,serialno",
|
||||
new QFilter[]{new QFilter("id","=",invoiceId)});
|
||||
if(inInvoice != null){
|
||||
serialnoList.add(inInvoice.getString("serialno"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//vouch_no 凭证号
|
||||
if(!serialnoList.isEmpty()){
|
||||
DynamicObject voucherData = QueryServiceHelper.queryOne("gl_voucher", "id,bookeddate,bizdate",
|
||||
new QFilter[]{new QFilter("id", "=", voucherId)});
|
||||
|
||||
try (TXHandle tx = TX.requiresNew("updateInvoice")) {
|
||||
try{
|
||||
StringBuilder invoiceDataBuilder = new StringBuilder("[");
|
||||
for (int i = 0; i < serialnoList.size(); i++) {
|
||||
String serialNo = serialnoList.get(i);;
|
||||
invoiceDataBuilder.append(" \"").append(serialNo).append("\"");
|
||||
if (i < serialnoList.size() - 1) {
|
||||
invoiceDataBuilder.append(",");
|
||||
}
|
||||
}
|
||||
invoiceDataBuilder.append("],");
|
||||
log.info("OutContractFinaceConfirmeVoucherPlugin:反写发票池-"+billId);
|
||||
if(voucherData != null){
|
||||
String par = "";
|
||||
if(VoucherOperation.Submit.equals(operation) || VoucherOperation.Create.equals(operation)){
|
||||
par = "{" +
|
||||
" \"messageType\": \"voucherSave\"," +
|
||||
" \"messageId\": \""+System.currentTimeMillis()+"\"," +
|
||||
" \"data\": {" +
|
||||
" \"vouchId\": \""+voucherId+"\"," +
|
||||
" \"vouchNo\": \""+voucherNo+"\"," +
|
||||
" \"accountDate\": \""+dateToLocalDate(voucherData.getDate("bookeddate")).format(formatter)+"\"," +
|
||||
" \"accountTime\": \""+dateToLocalDate(voucherData.getDate("bookeddate")).format(formatter)+"\"," +
|
||||
" \"businessDate\": \""+dateToLocalDate(voucherData.getDate("bizdate")).format(formatter)+"\"," +
|
||||
" \"resource\": \""+voucherId+"4\"," +
|
||||
" \"serialNoArray\": " +invoiceDataBuilder+
|
||||
" \"expenseIdArray\": [\""+billId+"\"]" +
|
||||
" }" +
|
||||
"}";
|
||||
}
|
||||
log.info("OutContractFinaceConfirmeVoucherPlugin:反写发票池-par"+par);
|
||||
Gson gson = new Gson();
|
||||
Map<String, Object> params1 = gson.fromJson(par,
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/rim/message/service", params1);
|
||||
log.info("OutContractFinaceConfirmeVoucherPlugin:反写发票池-"+balanceData.getMessage());
|
||||
}else{
|
||||
String par = "";
|
||||
if(VoucherOperation.Delete.equals(operation)){
|
||||
par = "{" +
|
||||
" \"messageType\": \"voucherDel\"," +
|
||||
" \"messageId\": \""+System.currentTimeMillis()+"\"," +
|
||||
" \"data\": {" +
|
||||
" \"vouchId\": \""+voucherId+"\"," +
|
||||
" \"resource\": \""+voucherId+"4\"" +
|
||||
" }" +
|
||||
"}";
|
||||
|
||||
log.info("OutContractFinaceConfirmeVoucherPlugin:反写发票池-删除-par"+par);
|
||||
Gson gson = new Gson();
|
||||
Map<String, Object> params1 = gson.fromJson(par,
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/rim/message/service", params1);
|
||||
log.info("OutContractFinaceConfirmeVoucherPlugin:反写发票池-删除-"+balanceData.getMessage());
|
||||
}
|
||||
}
|
||||
}catch (Exception ee){
|
||||
tx.markRollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static LocalDate dateToLocalDate(Date date) {
|
||||
if (date == null) {
|
||||
throw new IllegalArgumentException("日期不能为 null");
|
||||
}
|
||||
return date.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package zcgj.zcdev.zcdev.pr.plugin.operate;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.dataentity.entity.LocaleString;
|
||||
import kd.bos.db.tx.TX;
|
||||
import kd.bos.db.tx.TXHandle;
|
||||
import kd.bos.entity.operate.OperateOptionConst;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
|
|
@ -15,6 +19,8 @@ import kd.bos.message.api.MessageChannels;
|
|||
import kd.bos.metadata.dao.MetaCategory;
|
||||
import kd.bos.metadata.dao.MetadataDao;
|
||||
import kd.bos.metadata.form.FormMetadata;
|
||||
import kd.bos.openapi.common.result.OpenApiResult;
|
||||
import kd.bos.openapi.common.util.OpenApiSdkUtil;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
|
@ -26,6 +32,7 @@ import kd.bos.workflow.engine.msg.info.MessageInfo;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支出财务确认单删除时删除发票绑定关系
|
||||
|
|
@ -36,6 +43,7 @@ public class OutFinaceconfirmDelInvoiceBindOp extends AbstractOperationServicePl
|
|||
//OperationResult result = OperationServiceHelper.executeOperate("submit", "ec_out_contract_settle", new DynamicObject[]{outContractSettle}, option);
|
||||
//
|
||||
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
||||
e.getFieldKeys().add("billno"); //支出财务确认单编号
|
||||
e.getFieldKeys().add("zcgj_ec_out_contractid"); //支出结算单id
|
||||
e.getFieldKeys().add("zcgj_entryentity"); //发票分录
|
||||
e.getFieldKeys().add("zcgj_entryentity.zcgj_invoice"); //发票
|
||||
|
|
@ -59,6 +67,7 @@ public class OutFinaceconfirmDelInvoiceBindOp extends AbstractOperationServicePl
|
|||
public void deleteInvoiceBind(DynamicObject[] dataEntities){
|
||||
for (DynamicObject dataEntity : dataEntities) {
|
||||
long pkValue = dataEntity.getLong("id");//支出合同确认单id
|
||||
String billno = dataEntity.getString("billno");//支出合同确认单id
|
||||
|
||||
List<Long> delInvoiceIds = new ArrayList<>();
|
||||
DynamicObjectCollection invoiceCollection = dataEntity.getDynamicObjectCollection("zcgj_entryentity");
|
||||
|
|
@ -68,28 +77,50 @@ public class OutFinaceconfirmDelInvoiceBindOp extends AbstractOperationServicePl
|
|||
delInvoiceIds.add( zcgjInvoice.getLong("id"));
|
||||
}
|
||||
}
|
||||
// StringBuilder invoiceDataBuilder = new StringBuilder("[");
|
||||
|
||||
DynamicObject[] invoices = BusinessDataServiceHelper.load("ec_in_invoice", "isinvoiceclaim,isclaimed,contract,project,connecttype,serialno,zcgj_isbind",
|
||||
new QFilter[]{new QFilter("id", "in", delInvoiceIds)});
|
||||
List<String> invoiceserialno = new ArrayList<>();
|
||||
for (DynamicObject invData : invoices) {
|
||||
//for (DynamicObject invData : invoices) {
|
||||
for (int i = 0; i < invoices.length; i++) {
|
||||
DynamicObject invData = invoices[i];
|
||||
invData.set("isclaimed", false);
|
||||
invData.set("contract", (Object)null);
|
||||
invData.set("project", (Object)null);
|
||||
invData.set("connecttype", "null");
|
||||
invData.set("zcgj_isbind", false);
|
||||
String serialno = invData.getString("serialno");
|
||||
invoiceserialno.add(serialno);
|
||||
|
||||
}
|
||||
if(!delInvoiceIds.isEmpty()){
|
||||
//
|
||||
SaveServiceHelper.save(invoices);
|
||||
try (TXHandle tx = TX.requiresNew("clearInvoice")) {
|
||||
try{
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:单据删除-"+pkValue);
|
||||
String par ="{\n" +
|
||||
" \"messageType\": \"billDel\"," +
|
||||
" \"messageId\": \""+System.currentTimeMillis()+"\"," +
|
||||
" \"data\": {" +
|
||||
" \"billId\": \"" + pkValue + "\"," +
|
||||
" \"resource\": \"4\"" +
|
||||
" }" +
|
||||
"}";
|
||||
Gson gson = new Gson();
|
||||
//String json = gson.toJson(balanceQueryParamApi);
|
||||
Map<String, Object> params = gson.fromJson(par,
|
||||
new TypeToken<Map<String, Object>>() {
|
||||
}.getType());
|
||||
OpenApiResult balanceData = OpenApiSdkUtil.invoke("/v2/rim/message/service", params);
|
||||
log.info("OutContractFinaceConfirmeInvoicePlugin:单据删除-"+balanceData.getMessage());
|
||||
System.out.println();
|
||||
}catch (Exception ee){
|
||||
tx.markRollback();
|
||||
}
|
||||
|
||||
QFilter idFilter = new QFilter("expense_id", QCP.equals,pkValue);
|
||||
QFilter serialnoFilter = new QFilter("serial_no", QCP.in,invoiceserialno);
|
||||
//DynamicObject[] loadInvoiceData = BusinessDataServiceHelper.load("rim_expense_relation", "serial_no", new QFilter[]{idFilter,serialnoFilter});
|
||||
DeleteServiceHelper.delete("rim_expense_relation", new QFilter[]{idFilter.and(serialnoFilter)});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue