diff --git a/src/main/java/com/yem/wm/es/storagetrans/op/StorageTransOp.java b/src/main/java/com/yem/wm/es/storagetrans/op/StorageTransOp.java deleted file mode 100644 index 9c365270..00000000 --- a/src/main/java/com/yem/wm/es/storagetrans/op/StorageTransOp.java +++ /dev/null @@ -1,347 +0,0 @@ -package com.yem.wm.es.storagetrans.op; - -import com.yem.wm.utils.DynamicObjectUtil; -import com.yem.wm.utils.GiftAmount; -import kd.bos.armor.core.util.StringUtil; -import kd.bos.dataentity.entity.DynamicObject; -import kd.bos.dataentity.entity.DynamicObjectCollection; -import kd.bos.entity.plugin.AbstractOperationServicePlugIn; -import kd.bos.entity.plugin.PreparePropertysEventArgs; -import kd.bos.entity.plugin.args.EndOperationTransactionArgs; -import kd.bos.orm.query.QCP; -import kd.bos.orm.query.QFilter; -import kd.bos.servicehelper.BusinessDataServiceHelper; -import kd.bos.servicehelper.operation.SaveServiceHelper; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.List; - -/** - * @author ljw - * @date 2024/12/27 20:51 - * @description StorageTransOp - */ -public class StorageTransOp extends AbstractOperationServicePlugIn { - @Override - public void onPreparePropertys(PreparePropertysEventArgs e) { - super.onPreparePropertys(e); - List fieldKeys = e.getFieldKeys(); - fieldKeys.addAll(this.billEntityType.getAllFields().keySet()); - } - - @Override - public void endOperationTransaction(EndOperationTransactionArgs e) { - - super.endOperationTransaction(e); - DynamicObject[] dataEntities = e.getDataEntities(); - for (DynamicObject dataEntitie : dataEntities) { - dataEntitie = BusinessDataServiceHelper.loadSingle(dataEntitie.getPkValue(), dataEntitie.getDynamicObjectType().getName()); - giftAmount(dataEntitie); - giftSpecialAmount(dataEntitie); - - } - } - - /** - * @description 审核金额反写到客户资金池 普通规则 - * @author power - * @time 2023/10/8 - */ - public void giftAmount(DynamicObject dataEntitie) { - String number = dataEntitie.getString("billno"); -// Long customer = dataEntitie.getLong("yem_customer.id"); - DynamicObject saleorderCustomer = dataEntitie.getDynamicObject("yem_customer"); - Long customer = null;// - if (saleorderCustomer != null) { - DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(saleorderCustomer.getPkValue(), saleorderCustomer.getDynamicObjectType().getName()); - if (dynamicObject != null) { - DynamicObject groupcusfields = dynamicObject.getDynamicObject("yem_groupcustomers"); - if (groupcusfields != null) { - customer = groupcusfields.getLong("id"); - } - } - } - Long org = dataEntitie.getLong("org.id"); - - BigDecimal exrate = dataEntitie.getBigDecimal("yem_giftdecimal"); - DynamicObjectCollection giveamounts = dataEntitie.getDynamicObjectCollection("yem_es_salesorder_l"); - - - for (DynamicObject giveamount : giveamounts) { - - Long products = giveamount.getLong("yem_bd_products.id"); - DynamicObject giftamountss = BusinessDataServiceHelper.loadSingle("yem_im_giftamount", - new QFilter[]{new QFilter("yem_groupcusfields", QCP.equals, customer), - new QFilter("org", QCP.equals, org), - new QFilter("yem_bd_products", QCP.equals, products)}); - - - Long id = giveamount.getLong("id"); - String contractnumbers = giveamount.getString("yem_contractnumbers"); - String shipmentnumbers = giveamount.getString("yem_shipmentnumbers"); - Long giftproactype = giveamount.getLong("yem_giftproactype.id"); - int tsagerqty = giveamount.getInt("yem_tsagerqty"); - BigDecimal giftamt = giveamount.getBigDecimal("yem_giftamt"); - BigDecimal giftamtbase = giveamount.getBigDecimal("yem_giftamtbase"); - if (giftamountss != null) { - DynamicObjectCollection entryentitys = giftamountss.getDynamicObjectCollection("yem_im_giftamount_o"); - int row = 0; - for (DynamicObject entryentity : entryentitys) { - String yem_originno = entryentity.getString("yem_originno"); - if (contractnumbers.equals(yem_originno)) { - String name = dataEntitie.getDynamicObjectType().getName(); - if ("yem_es_storagetrans".equals(name)) { - DynamicObjectCollection enablegiftinfor = entryentity.getDynamicObjectCollection("yem_enablegiftinfor"); - DynamicObject newEntryEntity = enablegiftinfor.addNew(); - - //外销合同号 - newEntryEntity.set("yem_etctnum", contractnumbers); - //出运明细单号 - newEntryEntity.set("yem_stdsnum", shipmentnumbers); - //储运托单订单号 - newEntryEntity.set("yem_sernorrnum", number); - //机型 - newEntryEntity.set("yem_giftproactype", giftproactype); - //台式 - newEntryEntity.set("yem_tsagerqty", tsagerqty); - //可用礼品金额 - newEntryEntity.set("yem_sneygiftenable", giftamt); - //汇率 - newEntryEntity.set("yem_exchangerate", exrate); - //可用礼品本位币金额 - newEntryEntity.set("yem_crsygiftenable", giftamtbase); - //储运分录内码 - newEntryEntity.set("yem_im_giftapplyides", id); - } else if ("yem_es_xstoragetrans".equals(name)) { - String selectfield = DynamicObjectUtil.getSelectfields("yem_im_giftamount", false); - DynamicObject loadedSingle = BusinessDataServiceHelper.loadSingle("yem_es_storagetrans", selectfield - , new QFilter[]{new QFilter("id", QCP.equals, dataEntitie.getLong("yem_masterid"))}); -// String select = DynamicObjectUtil.getSelectfields("yem_im_giftamount", false); -// String selectfields = DynamicObjectUtil.getEntrySelectfields(select, "yem_im_giftamount", "yem_im_giftamount_o", false); -// String selectfieldss = DynamicObjectUtil.getEntrySelectfields(selectfields, "yem_im_giftamount", "yem_enablegiftinfor", false); - DynamicObject loaded = BusinessDataServiceHelper.loadSingle("yem_im_giftamount", "id,billno,yem_im_giftamount_o" + - ",yem_im_giftamount_o.yem_originno,yem_im_giftamount_o.yem_enablegiftinfor,yem_enablegiftinfor.yem_sernorrnum" + - ",yem_enablegiftinfor.yem_sneygiftenable,yem_enablegiftinfor.yem_crsygiftenable,yem_enablegiftinfor.yem_tsagerqty" - , new QFilter[]{new QFilter("yem_im_giftamount_o.yem_enablegiftinfor.yem_sernorrnum", QCP.equals, loadedSingle.getString("billno"))}); - if (loaded != null) { - DynamicObjectCollection dynamicObjectCollection = loaded.getDynamicObjectCollection("yem_im_giftamount_o"); - for (DynamicObject dynamicObject : dynamicObjectCollection) { - String dynamicOb = dynamicObject.getString("yem_originno"); - if (dynamicOb.equals(dataEntitie.getString("yem_totalcontractno"))) { - DynamicObjectCollection dynamicObjectString = dynamicObject.getDynamicObjectCollection("yem_enablegiftinfor"); - for (DynamicObject loadSingle : dynamicObjectString) { - String yemSernorrnum = loadSingle.getString("yem_sernorrnum"); - if (yemSernorrnum.equals(loadedSingle.getString("billno"))) { - loadSingle.set("yem_sneygiftenable", giftamt); - loadSingle.set("yem_crsygiftenable", giftamtbase); - loadSingle.set("yem_tsagerqty", tsagerqty); - } - } - } - } - } - SaveServiceHelper.save(new DynamicObject[]{loaded}); - } - - } - entryentitys.set(row, entryentity); - row++; - } - } - SaveServiceHelper.save(new DynamicObject[]{giftamountss}); - GiftAmount.Calculate(customer, org, products); - } - } - - - /** - * @description 审核金额反写到客户资金池 特殊规则 - * @author power - * @time 2023/10/10 - */ - public void giftSpecialAmount(DynamicObject dataEntitie) { -// Long customer = dataEntitie.getLong("yem_customer.id"); - DynamicObject saleorderCustomer = dataEntitie.getDynamicObject("yem_customer"); - Long customer = null;// - if (saleorderCustomer != null) { - DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(saleorderCustomer.getPkValue(), saleorderCustomer.getDynamicObjectType().getName()); - if (dynamicObject != null) { - DynamicObject groupcusfields = dynamicObject.getDynamicObject("yem_groupcustomers"); - if (groupcusfields != null) { - customer = groupcusfields.getLong("id"); - } - } - } - Long org = dataEntitie.getLong("org.id"); - DynamicObjectCollection materialinfos = dataEntitie.getDynamicObjectCollection("yem_es_materialinfo"); - BigDecimal exrate = dataEntitie.getBigDecimal("yem_giftdecimal"); - Long id = dataEntitie.getLong("id"); - - DynamicObject[] storagetrans = BusinessDataServiceHelper.load("yem_es_storagetrans", - "yem_es_materialinfo.yem_productmodel,yem_es_materialinfo.yem_qty,billno," + - "yem_es_materialinfo.yem_contractnumbers_m", - new QFilter[]{ - new QFilter("billstatus", QCP.equals, "C"), - new QFilter("yem_customer", QCP.equals, customer), - new QFilter("id", QCP.not_equals, id), - new QFilter("org", QCP.equals, org),}); - - Object[] pk = new Object[storagetrans.length]; - int rows = 0; - for (DynamicObject dt : storagetrans) { - pk[rows] = dt.getPkValue(); - rows++; - } - if (materialinfos != null) { - for (int i = 0; i < materialinfos.size(); i++) { - DynamicObject materialinfo = materialinfos.get(i); - - String isgiftgive = materialinfo.getString("yem_isgiftgive"); - if (materialinfo.getDynamicObject("yem_productmodel") != null) { - Long productmodels = materialinfo.getLong("yem_productmodel.yem_products.id"); - Long products = materialinfo.getLong("yem_products.id"); - - - DynamicObject giftamountss = BusinessDataServiceHelper.loadSingle("yem_im_giftamount", - new QFilter[]{new QFilter("yem_groupcusfields", QCP.equals, customer), - new QFilter("org", QCP.equals, org), - new QFilter("yem_bd_products", QCP.equals, products)}); - - - if (giftamountss != null) { - if ("A".equals(isgiftgive)) { - if (StringUtil.isNotEmpty(materialinfo.getString("yem_contractnumbers_m"))) { - String conBillno = materialinfo.getString("yem_contractnumbers_m"); - DynamicObject data = BusinessDataServiceHelper.loadSingle("yem_es_salesorder", "yem_isnewagent", - new QFilter[]{new QFilter("billno", QCP.equals, conBillno),}); - if (data != null) { - String isnewagent = data.getString("yem_isnewagent"); - - DynamicObject giftruless = BusinessDataServiceHelper.loadSingle("yem_bd_giftrules", - new QFilter[]{ - new QFilter("status", QCP.equals, "C"), - new QFilter("yem_classify", QCP.equals, products), - new QFilter("yem_ynnewdealer", QCP.equals, isnewagent) - }); - - //是经销商 - if ("A".equals(isnewagent)) { - if (giftruless != null) { - for (DynamicObject giftrules : giftruless.getDynamicObjectCollection("yem_bd_giftrules_b")) { - BigDecimal sumqty = BigDecimal.ZERO; - BigDecimal masqty = BigDecimal.ZERO; - BigDecimal yem_qtys = BigDecimal.ZERO; - for (DynamicObject giftrule : giftrules.getDynamicObjectCollection("yem_bd_giftrules_c")) { - Long producttypea = giftrule.getLong("yem_producttypea.id"); - if (producttypea.equals(productmodels)) { - yem_qtys = materialinfo.getBigDecimal("yem_qty"); - } - - for (int j = i + 1; j < materialinfos.size(); j++) { - DynamicObject materialinfoj = materialinfos.get(j); - String isgiftgivej = materialinfoj.getString("yem_isgiftgive"); - if ("A".equals(isgiftgivej)) { - Long productsj = materialinfoj.getLong("yem_products.id"); - String conBillnoj = materialinfoj.getString("yem_contractnumbers_m"); - if (materialinfoj.getDynamicObject("yem_productmodel") != null) { - Long productmodelsj = materialinfoj.getLong("yem_productmodel.yem_products.id"); - String name = materialinfoj.getString("yem_productmodel.yem_products.name"); - String names = materialinfo.getString("yem_productmodel.yem_products.name"); - if (conBillno.equals(conBillnoj)) { - if (products.equals(productsj)) { - if (productmodelsj.equals(producttypea)) { - BigDecimal yem_qty = materialinfoj.getBigDecimal("yem_qty"); - masqty = masqty.add(yem_qty); - } - } - } - if (!conBillno.equals(conBillnoj)) { - DynamicObject datafo = BusinessDataServiceHelper.loadSingle("yem_es_salesorder", "yem_isnewagent", - new QFilter[]{new QFilter("billno", QCP.equals, conBillnoj),}); - if (datafo != null) { - String isnewagentfo = data.getString("yem_isnewagent"); - if ("A".equals(isnewagentfo)) { - if (products.equals(productsj)) { - if (productmodelsj.equals(producttypea)) { - BigDecimal yem_qty = materialinfoj.getBigDecimal("yem_qty"); - masqty = masqty.add(yem_qty); - } - } - } - } - } - } - } - } - - - if (storagetrans != null && storagetrans.length > 0) { - DynamicObject[] load = BusinessDataServiceHelper.load(pk, storagetrans[0].getDynamicObjectType()); - for (DynamicObject loads : load) { - DynamicObjectCollection yem_es_materialinfo = loads.getDynamicObjectCollection("yem_es_materialinfo"); - for (DynamicObject yem_es_materialinfos : yem_es_materialinfo) { - if (yem_es_materialinfos.getDynamicObject("yem_productmodel") != null) { - Long maproduct = yem_es_materialinfos.getDynamicObject("yem_productmodel").getLong("yem_products.id"); - if (producttypea.equals(maproduct)) { - String conBillnofo = yem_es_materialinfos.getString("yem_contractnumbers_m"); - DynamicObject datafo = BusinessDataServiceHelper.loadSingle("yem_es_salesorder", "yem_isnewagent", - new QFilter[]{new QFilter("billno", QCP.equals, conBillnofo),}); - if (datafo != null) { - String isnewagentfo = data.getString("yem_isnewagent"); - if ("A".equals(isnewagentfo)) { - - BigDecimal yem_qty = yem_es_materialinfos.getBigDecimal("yem_qty"); - sumqty = sumqty.add(yem_qty); - } - } - } - } - } - } - } - } - BigDecimal yem_qtyb = giftrules.getBigDecimal("yem_qtyb"); -// sumqty =masqty.add(sumqty); - BigDecimal qtys = yem_qtys.add(masqty.add(sumqty)); - if (qtys.compareTo(yem_qtyb) == 1 && masqty.compareTo(yem_qtyb) < 1) { - BigDecimal giveamo = giftrules.getBigDecimal("yem_giveamob"); - BigDecimal giveamobase = giveamo.multiply(exrate); - giveamo = giveamo.setScale(2, RoundingMode.HALF_UP); - giveamobase = giveamobase.setScale(2, RoundingMode.HALF_UP); - if (giftamountss != null) { - DynamicObjectCollection entryentitys = giftamountss.getDynamicObjectCollection("yem_im_giftamount_o"); - int row = 0; - for (DynamicObject entryentity : entryentitys) { - if (giveamo.compareTo(entryentity.getBigDecimal("yem_originamt")) == 0 && "D".equals(entryentity.getString("yem_origintype"))) { - entryentity.set("yem_entrygiftenable", giveamo); - entryentity.set("yem_sneycrgiftenable", giveamobase); - entryentity.set("seq", entryentity.getInt("seq")); - } - entryentity.set("seq", row); -// entryentitys.set(row,entryentity); - row++; - } - } - } - } - } - } - } -// SaveServiceHelper.save(new DynamicObject[] {giftamountss}); -// GiftAmount.Calculate(customer,org,products); - } - } - SaveServiceHelper.save(new DynamicObject[]{giftamountss}); - GiftAmount.Calculate(customer, org, products); - } - } - } - } - for (DynamicObject ma : materialinfos) { - - Long products = ma.getLong("yem_products.id"); - GiftAmount.Calculate(customer, org, products); - } - } -}