diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/IOfsPassiveorderDetailDao.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/IOfsPassiveorderDetailDao.java new file mode 100644 index 00000000..d6e8cac8 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/IOfsPassiveorderDetailDao.java @@ -0,0 +1,35 @@ +package com.hzya.frame.plugin.lets.ofs.dao; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderDetailEntity; +import com.hzya.frame.basedao.dao.IBaseDao; + +import java.util.List; + +/** + * O无源件订单中台明细表(ofs_passiveorder_detail: table)表数据库访问层 + * + * @author makejava + * @since 2025-03-12 09:40:26 + */ +public interface IOfsPassiveorderDetailDao extends IBaseDao { + /** + * 批量保存/更新 OFS + * + * @author liuyang + */ + void entityInsertOrUpdateBatch(List ofsPassiveorderDetailEntity) throws Exception; + + /** + * 入库、批量保存/更新 OFS + * + * @author liuyang + */ + void entityInsertOrUpdateBatchByStock(List ofsPassiveorderDetailEntity) throws Exception; + + /** + * 退款完成、批量保存/更新 OFS + * + * @author liuyang + */ + void entityInsertOrUpdateBatchByTran(List ofsPassiveorderDetailEntity) throws Exception; +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/IOfsPassiveorderHeaderDao.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/IOfsPassiveorderHeaderDao.java new file mode 100644 index 00000000..07fcdcd0 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/IOfsPassiveorderHeaderDao.java @@ -0,0 +1,21 @@ +package com.hzya.frame.plugin.lets.ofs.dao; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderHeaderEntity; +import com.hzya.frame.basedao.dao.IBaseDao; + +import java.util.List; + +/** + * O无源件订单中台主表(ofs_passiveorder_header: table)表数据库访问层 + * + * @author makejava + * @since 2025-03-12 09:39:53 + */ +public interface IOfsPassiveorderHeaderDao extends IBaseDao { + /** + * 批量插入或者更新到无源件表头 + * + * @author liuyang + */ + void entityInsertOrUpdateBatch(List ofsPassiveorderHeaderEntityList) throws Exception; +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/OfsPassiveorderDetailDaoImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/OfsPassiveorderDetailDaoImpl.java new file mode 100644 index 00000000..d7292515 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/OfsPassiveorderDetailDaoImpl.java @@ -0,0 +1,32 @@ +package com.hzya.frame.plugin.lets.ofs.dao.impl; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderDetailEntity; +import com.hzya.frame.plugin.lets.ofs.dao.IOfsPassiveorderDetailDao; +import org.springframework.stereotype.Repository; +import com.hzya.frame.basedao.dao.MybatisGenericDao; + +import java.util.List; + +/** + * O无源件订单中台明细表(OfsPassiveorderDetail)表数据库访问层 + * + * @author makejava + * @since 2025-03-12 09:40:26 + */ +public class OfsPassiveorderDetailDaoImpl extends MybatisGenericDao implements IOfsPassiveorderDetailDao { + @Override + public void entityInsertOrUpdateBatch(List ofsPassiveorderDetailEntity) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.OfsPassiveorderDetailDaoImpl.entityInsertOrUpdateBatch", ofsPassiveorderDetailEntity); + } + + @Override + public void entityInsertOrUpdateBatchByStock(List ofsPassiveorderDetailEntity) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.OfsPassiveorderDetailDaoImpl.entityInsertOrUpdateBatchV2", ofsPassiveorderDetailEntity); + } + + @Override + public void entityInsertOrUpdateBatchByTran(List ofsPassiveorderDetailEntity) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.OfsPassiveorderDetailDaoImpl.entityInsertOrUpdateBatchV3", ofsPassiveorderDetailEntity); + } +} + diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/OfsPassiveorderHeaderDaoImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/OfsPassiveorderHeaderDaoImpl.java new file mode 100644 index 00000000..4c255d62 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/OfsPassiveorderHeaderDaoImpl.java @@ -0,0 +1,21 @@ +package com.hzya.frame.plugin.lets.ofs.dao.impl; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderHeaderEntity; +import com.hzya.frame.plugin.lets.ofs.dao.IOfsPassiveorderHeaderDao; +import org.springframework.stereotype.Repository; +import com.hzya.frame.basedao.dao.MybatisGenericDao; + +import java.util.List; + +/** + * O无源件订单中台主表(OfsPassiveorderHeader)表数据库访问层 + * + * @author makejava + * @since 2025-03-12 09:39:53 + */ +public class OfsPassiveorderHeaderDaoImpl extends MybatisGenericDao implements IOfsPassiveorderHeaderDao { + @Override + public void entityInsertOrUpdateBatch(List ofsPassiveorderHeaderEntityList) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.OfsPassiveorderHeaderDaoImpl.entityInsertOrUpdateBatch", ofsPassiveorderHeaderEntityList); + } +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderDetailEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderDetailEntity.java new file mode 100644 index 00000000..c28d6fc6 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderDetailEntity.java @@ -0,0 +1,391 @@ +package com.hzya.frame.plugin.lets.ofs.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +/** + * O无源件订单中台明细表(OfsPassiveorderDetail)实体类 + * + * @author makejava + * @since 2025-03-12 09:40:26 + */ +public class OfsPassiveorderDetailEntity extends BaseEntity { + /** + * 关联主表ID[1](@ref) + */ + private String headerid; + /** + * 退货单号(与主表一致)[1](@ref) + */ + private String receiptcode; + /** + * 商品编码(示例值:6973391732529)[1](@ref) + */ + private String skucode; + /** + * 商品全称(示例值:INTO YOU心慕与你干杯唇釉OT02)[1](@ref) + */ + private String skuname; + /** + * 退货数量(示例值:1)[1](@ref) + */ + private String quantity; + /** + * 库存状态(示例值:NOT_AVAILABLE)[1](@ref) + */ + private String inventorysts; + /** + * 创建时间[1](@ref) + */ + private String created; + /** + * 创建人[1](@ref) + */ + private String createdby; + /** + * 最后更新时间[1](@ref) + */ + private String lastupdated; + /** + * 最后更新人[1](@ref) + */ + private String lastupdatedby; + /** + * 业务日期 + */ + private String businessdate; + /** + * 业务类型 + */ + private String businesstype; + /** + * 推送时间-入库 + */ + private String newpushdate; + /** + * 报错详情-入库 + */ + private String newtransmitinfo; + /** + * 推送状态-入库 + */ + private String newstate; + /** + * 下游单号-入库 + */ + private String newsystemnumber; + /** + * 下游主键-入库 + */ + private String newsystemprimary; + /** + * 推送时间-交易成功 + */ + private String newpushdate2; + /** + * 报错详情-交易成功 + */ + private String newtransmitinfo2; + /** + * 推送状态-交易成功 + */ + private String newstate2; + /** + * 下游单号-交易成功 + */ + private String newsystemnumber2; + /** + * 下游主键-交易成功 + */ + private String newsystemprimary2; + + /** + * 根据 id 批量查询 + */ + private String ids; + + private String def1; + + private String def2; + + private String def3; + + private String def4; + + private String def5; + + private String def6; + + private String def7; + + private String def8; + + private String def9; + + private String def10; + + public String getDef1() { + return def1; + } + + public void setDef1(String def1) { + this.def1 = def1; + } + + public String getDef2() { + return def2; + } + + public void setDef2(String def2) { + this.def2 = def2; + } + + public String getDef3() { + return def3; + } + + public void setDef3(String def3) { + this.def3 = def3; + } + + public String getDef4() { + return def4; + } + + public void setDef4(String def4) { + this.def4 = def4; + } + + public String getDef5() { + return def5; + } + + public void setDef5(String def5) { + this.def5 = def5; + } + + public String getDef6() { + return def6; + } + + public void setDef6(String def6) { + this.def6 = def6; + } + + public String getDef7() { + return def7; + } + + public void setDef7(String def7) { + this.def7 = def7; + } + + public String getDef8() { + return def8; + } + + public void setDef8(String def8) { + this.def8 = def8; + } + + public String getDef9() { + return def9; + } + + public void setDef9(String def9) { + this.def9 = def9; + } + + public String getDef10() { + return def10; + } + + public void setDef10(String def10) { + this.def10 = def10; + } + + public String getIds() { + return ids; + } + + public void setIds(String ids) { + this.ids = ids; + } + + public String getHeaderid() { + return headerid; + } + + public void setHeaderid(String headerid) { + this.headerid = headerid; + } + + public String getReceiptcode() { + return receiptcode; + } + + public void setReceiptcode(String receiptcode) { + this.receiptcode = receiptcode; + } + + public String getSkucode() { + return skucode; + } + + public void setSkucode(String skucode) { + this.skucode = skucode; + } + + public String getSkuname() { + return skuname; + } + + public void setSkuname(String skuname) { + this.skuname = skuname; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getInventorysts() { + return inventorysts; + } + + public void setInventorysts(String inventorysts) { + this.inventorysts = inventorysts; + } + + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + public String getCreatedby() { + return createdby; + } + + public void setCreatedby(String createdby) { + this.createdby = createdby; + } + + public String getLastupdated() { + return lastupdated; + } + + public void setLastupdated(String lastupdated) { + this.lastupdated = lastupdated; + } + + public String getLastupdatedby() { + return lastupdatedby; + } + + public void setLastupdatedby(String lastupdatedby) { + this.lastupdatedby = lastupdatedby; + } + + public String getBusinessdate() { + return businessdate; + } + + public void setBusinessdate(String businessdate) { + this.businessdate = businessdate; + } + + public String getBusinesstype() { + return businesstype; + } + + public void setBusinesstype(String businesstype) { + this.businesstype = businesstype; + } + + public String getNewpushdate() { + return newpushdate; + } + + public void setNewpushdate(String newpushdate) { + this.newpushdate = newpushdate; + } + + public String getNewtransmitinfo() { + return newtransmitinfo; + } + + public void setNewtransmitinfo(String newtransmitinfo) { + this.newtransmitinfo = newtransmitinfo; + } + + public String getNewstate() { + return newstate; + } + + public void setNewstate(String newstate) { + this.newstate = newstate; + } + + public String getNewsystemnumber() { + return newsystemnumber; + } + + public void setNewsystemnumber(String newsystemnumber) { + this.newsystemnumber = newsystemnumber; + } + + public String getNewsystemprimary() { + return newsystemprimary; + } + + public void setNewsystemprimary(String newsystemprimary) { + this.newsystemprimary = newsystemprimary; + } + + public String getNewpushdate2() { + return newpushdate2; + } + + public void setNewpushdate2(String newpushdate2) { + this.newpushdate2 = newpushdate2; + } + + public String getNewtransmitinfo2() { + return newtransmitinfo2; + } + + public void setNewtransmitinfo2(String newtransmitinfo2) { + this.newtransmitinfo2 = newtransmitinfo2; + } + + public String getNewstate2() { + return newstate2; + } + + public void setNewstate2(String newstate2) { + this.newstate2 = newstate2; + } + + public String getNewsystemnumber2() { + return newsystemnumber2; + } + + public void setNewsystemnumber2(String newsystemnumber2) { + this.newsystemnumber2 = newsystemnumber2; + } + + public String getNewsystemprimary2() { + return newsystemprimary2; + } + + public void setNewsystemprimary2(String newsystemprimary2) { + this.newsystemprimary2 = newsystemprimary2; + } + +} + diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderDetailEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderDetailEntity.xml new file mode 100644 index 00000000..cf750cf5 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderDetailEntity.xml @@ -0,0 +1,410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + ,headerId + ,receiptCode + ,skuCode + ,skuName + ,quantity + ,inventorySts + ,created + ,createdBy + ,lastUpdated + ,lastUpdatedBy + ,businessDate + ,businessType + ,newPushDate + ,newTransmitInfo + ,newState + ,newsystemnumber + ,newsystemprimary + ,newPushDate2 + ,newTransmitInfo2 + ,newState2 + ,newsystemnumber2 + ,newsystemprimary2 + + + + + + + + + + + + + + + + + insert into ofs_passiveorder_detail( + + id , + headerId , + receiptCode , + skuCode , + skuName , + quantity , + inventorySts , + created , + createdBy , + lastUpdated , + lastUpdatedBy , + businessDate , + businessType , + newPushDate , + newTransmitInfo , + newState , + newsystemnumber , + newsystemprimary , + newPushDate2 , + newTransmitInfo2 , + newState2 , + newsystemnumber2 , + newsystemprimary2 , + sorts, + sts, + + )values( + + #{id} , + #{headerid} , + #{receiptcode} , + #{skucode} , + #{skuname} , + #{quantity} , + #{inventorysts} , + #{created} , + #{createdby} , + #{lastupdated} , + #{lastupdatedby} , + #{businessdate} , + #{businesstype} , + #{newpushdate} , + #{newtransmitinfo} , + #{newstate} , + #{newsystemnumber} , + #{newsystemprimary} , + #{newpushdate2} , + #{newtransmitinfo2} , + #{newstate2} , + #{newsystemnumber2} , + #{newsystemprimary2} , + (select (max(IFNULL( a.sorts, 0 )) + 1) as sort from ofs_passiveorder_detail a WHERE a.sts = 'Y' ), + 'Y', + + ) + + + + + insert into ofs_passiveorder_detail(headerId, receiptCode, skuCode, skuName, quantity, inventorySts, created, createdBy, lastUpdated, lastUpdatedBy, businessDate, businessType, newPushDate, newTransmitInfo, newState, newsystemnumber, newsystemprimary, newPushDate2, newTransmitInfo2, newState2, newsystemnumber2, newsystemprimary2, sts) + values + + (#{entity.headerid},#{entity.receiptcode},#{entity.skucode},#{entity.skuname},#{entity.quantity},#{entity.inventorysts},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby},#{entity.businessdate},#{entity.businesstype},#{entity.newpushdate},#{entity.newtransmitinfo},#{entity.newstate},#{entity.newsystemnumber},#{entity.newsystemprimary},#{entity.newpushdate2},#{entity.newtransmitinfo2},#{entity.newstate2},#{entity.newsystemnumber2},#{entity.newsystemprimary2}, 'Y') + + + + + + insert into ofs_passiveorder_detail(id,headerId, receiptCode, skuCode, skuName, quantity, inventorySts, created, createdBy, lastUpdated, lastUpdatedBy, businessDate, businessType) + values + + (#{entity.id},#{entity.headerid},#{entity.receiptcode},#{entity.skucode},#{entity.skuname},#{entity.quantity},#{entity.inventorysts},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby},#{entity.businessdate},#{entity.businesstype}) + + on duplicate key update + id = values(id), + headerId = values(headerId), + receiptCode = values(receiptCode), + skuCode = values(skuCode), + skuName = values(skuName), + quantity = values(quantity), + inventorySts = values(inventorySts), + created = values(created), + createdBy = values(createdBy), + lastUpdated = values(lastUpdated), + lastUpdatedBy = values(lastUpdatedBy), + businessDate = values(businessDate), + businessType = values(businessType) + + + + + insert into ofs_passiveorder_detail(id,newPushDate, newTransmitInfo, newState, newsystemnumber, newsystemprimary,def1,def2,def3,def4,def5,def6,def7,def8,def9,def10) + values + + (#{entity.id},#{entity.newpushdate},#{entity.newtransmitinfo},#{entity.newstate},#{entity.newsystemnumber},#{entity.newsystemprimary},#{entity.def1},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.def6},#{entity.def7},#{entity.def8},#{entity.def9},#{entity.def10}) + + on duplicate key update + id = values(id), + newPushDate = values(newPushDate), + newTransmitInfo = values(newTransmitInfo), + newState = values(newState), + newsystemnumber = values(newsystemnumber), + newsystemprimary = values(newsystemprimary), + def1 = values(def1), + def2 = values(def2), + def3 = values(def3), + def4 = values(def4), + def5 = values(def5), + def6 = values(def6), + def7 = values(def7), + def8 = values(def8), + def9 = values(def9), + def10 = values(def10) + + + + + insert into ofs_passiveorder_detail(id,newPushDate2, newTransmitInfo2, newState2, newsystemnumber2, newsystemprimary2,def1,def2,def3,def4,def5,def6,def7,def8,def9,def10) + values + + (#{entity.id},#{entity.newpushdate2},#{entity.newtransmitinfo2},#{entity.newstate2},#{entity.newsystemnumber2},#{entity.newsystemprimary2},#{entity.def1},#{entity.def1},#{entity.def2},#{entity.def3},#{entity.def4},#{entity.def5},#{entity.def6},#{entity.def7},#{entity.def8},#{entity.def9},#{entity.def10}) + + on duplicate key update + id = values(id), + newPushDate2 = values(newPushDate2), + newTransmitInfo2 = values(newTransmitInfo2), + newState2 = values(newState2), + newsystemnumber2 = values(newsystemnumber2), + newsystemprimary2 = values(newsystemprimary2), + def1 = values(def1), + def2 = values(def2), + def3 = values(def3), + def4 = values(def4), + def5 = values(def5), + def6 = values(def6), + def7 = values(def7), + def8 = values(def8), + def9 = values(def9), + def10 = values(def10) + + + + +update ofs_passiveorder_detail set + + headerId = #{headerid}, + receiptCode = #{receiptcode}, + skuCode = #{skucode}, + skuName = #{skuname}, + quantity = #{quantity}, + inventorySts = #{inventorysts}, + created = #{created}, + createdBy = #{createdby}, + lastUpdated = #{lastupdated}, + lastUpdatedBy = #{lastupdatedby}, + businessDate = #{businessdate}, + businessType = #{businesstype}, + newPushDate = #{newpushdate}, + newTransmitInfo = #{newtransmitinfo}, + newState = #{newstate}, + newsystemnumber = #{newsystemnumber}, + newsystemprimary = #{newsystemprimary}, + newPushDate2 = #{newpushdate2}, + newTransmitInfo2 = #{newtransmitinfo2}, + newState2 = #{newstate2}, + newsystemnumber2 = #{newsystemnumber2}, + newsystemprimary2 = #{newsystemprimary2}, + +where id = #{id} + + + +update ofs_passiveorder_detail set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id} +where id = #{id} + + + +update ofs_passiveorder_detail set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id} + + and id = #{id} + and headerId = #{headerid} + and receiptCode = #{receiptcode} + and skuCode = #{skucode} + and skuName = #{skuname} + and quantity = #{quantity} + and inventorySts = #{inventorysts} + and created = #{created} + and createdBy = #{createdby} + and lastUpdated = #{lastupdated} + and lastUpdatedBy = #{lastupdatedby} + and businessDate = #{businessdate} + and businessType = #{businesstype} + and newPushDate = #{newpushdate} + and newTransmitInfo = #{newtransmitinfo} + and newState = #{newstate} + and newsystemnumber = #{newsystemnumber} + and newsystemprimary = #{newsystemprimary} + and newPushDate2 = #{newpushdate2} + and newTransmitInfo2 = #{newtransmitinfo2} + and newState2 = #{newstate2} + and newsystemnumber2 = #{newsystemnumber2} + and newsystemprimary2 = #{newsystemprimary2} + and sts='Y' + + + + + delete from ofs_passiveorder_detail where id = #{id} + + + + diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderHeaderEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderHeaderEntity.java new file mode 100644 index 00000000..51d58217 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderHeaderEntity.java @@ -0,0 +1,243 @@ +package com.hzya.frame.plugin.lets.ofs.entity; + +import com.hzya.frame.web.entity.BaseEntity; + +/** + * O无源件订单中台主表(OfsPassiveorderHeader)实体类 + * + * @author makejava + * @since 2025-03-12 09:39:53 + */ +public class OfsPassiveorderHeaderEntity extends BaseEntity { + /** + * 客户端编码(示例值:LETS)[1](@ref) + */ + private String clientcode; + /** + * 公司编码(示例值:SHLZ)[1](@ref) + */ + private String companycode; + /** + * 仓库设施编码(示例值:B2CHA20240033)[1](@ref) + */ + private String facilitycode; + /** + * 店铺编码(示例值:pdd-intoyoucz)[1](@ref) + */ + private String storecode; + /** + * 退货单号(示例值:RH20250220000460)[1](@ref) + */ + private String receiptcode; + /** + * 仓库编码(示例值:LETS2C)[1](@ref) + */ + private String warehousecode; + /** + * 退货运单号(示例值:1376811761602)[1](@ref) + */ + private String returnwaybillcode; + /** + * 源退货单号(示例值:117180732225)[1](@ref) + */ + private String sourcereturncode; + /** + * 源订单号(示例值:250206-088457951590214)[1](@ref) + */ + private String sourceordercode; + /** + * 退货订单号(示例值:LETS-RO2025021500008714)[1](@ref) + */ + private String returnordercode; + /** + * 实际退款金额(示例值:29.9)[1](@ref) + */ + private String actualrefundamount; + /** + * 退货时间(ISO8601格式)[1](@ref) + */ + private String returntime; + /** + * 关联时间(ISO8601格式)[1](@ref) + */ + private String relatedat; + /** + * 状态码(示例值:2)[1](@ref) + */ + private String status; + /** + * 创建时间[1](@ref) + */ + private String created; + /** + * 创建人(示例值:api)[1](@ref) + */ + private String createdby; + /** + * 最后更新时间[1](@ref) + */ + private String lastupdated; + /** + * 最后更新人[1](@ref) + */ + private String lastupdatedby; + + /** + * 根据 id 多次查询 + */ + private String ids; + + public String getIds() { + return ids; + } + + public void setIds(String ids) { + this.ids = ids; + } + + public String getClientcode() { + return clientcode; + } + + public void setClientcode(String clientcode) { + this.clientcode = clientcode; + } + + public String getCompanycode() { + return companycode; + } + + public void setCompanycode(String companycode) { + this.companycode = companycode; + } + + public String getFacilitycode() { + return facilitycode; + } + + public void setFacilitycode(String facilitycode) { + this.facilitycode = facilitycode; + } + + public String getStorecode() { + return storecode; + } + + public void setStorecode(String storecode) { + this.storecode = storecode; + } + + public String getReceiptcode() { + return receiptcode; + } + + public void setReceiptcode(String receiptcode) { + this.receiptcode = receiptcode; + } + + public String getWarehousecode() { + return warehousecode; + } + + public void setWarehousecode(String warehousecode) { + this.warehousecode = warehousecode; + } + + public String getReturnwaybillcode() { + return returnwaybillcode; + } + + public void setReturnwaybillcode(String returnwaybillcode) { + this.returnwaybillcode = returnwaybillcode; + } + + public String getSourcereturncode() { + return sourcereturncode; + } + + public void setSourcereturncode(String sourcereturncode) { + this.sourcereturncode = sourcereturncode; + } + + public String getSourceordercode() { + return sourceordercode; + } + + public void setSourceordercode(String sourceordercode) { + this.sourceordercode = sourceordercode; + } + + public String getReturnordercode() { + return returnordercode; + } + + public void setReturnordercode(String returnordercode) { + this.returnordercode = returnordercode; + } + + public String getActualrefundamount() { + return actualrefundamount; + } + + public void setActualrefundamount(String actualrefundamount) { + this.actualrefundamount = actualrefundamount; + } + + public String getReturntime() { + return returntime; + } + + public void setReturntime(String returntime) { + this.returntime = returntime; + } + + public String getRelatedat() { + return relatedat; + } + + public void setRelatedat(String relatedat) { + this.relatedat = relatedat; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getCreated() { + return created; + } + + public void setCreated(String created) { + this.created = created; + } + + public String getCreatedby() { + return createdby; + } + + public void setCreatedby(String createdby) { + this.createdby = createdby; + } + + public String getLastupdated() { + return lastupdated; + } + + public void setLastupdated(String lastupdated) { + this.lastupdated = lastupdated; + } + + public String getLastupdatedby() { + return lastupdatedby; + } + + public void setLastupdatedby(String lastupdatedby) { + this.lastupdatedby = lastupdatedby; + } + +} + diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderHeaderEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderHeaderEntity.xml new file mode 100644 index 00000000..ccb9c2cb --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/OfsPassiveorderHeaderEntity.xml @@ -0,0 +1,322 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + ,clientCode + ,companyCode + ,facilityCode + ,storeCode + ,receiptCode + ,warehouseCode + ,returnWaybillCode + ,sourceReturnCode + ,sourceOrderCode + ,returnOrderCode + ,actualRefundAmount + ,returnTime + ,relatedAt + ,status + ,created + ,createdBy + ,lastUpdated + ,lastUpdatedBy + + + + + + + + + + + + + + + + insert into ofs_passiveorder_header( + + id , + clientCode , + companyCode , + facilityCode , + storeCode , + receiptCode , + warehouseCode , + returnWaybillCode , + sourceReturnCode , + sourceOrderCode , + returnOrderCode , + actualRefundAmount , + returnTime , + relatedAt , + status , + created , + createdBy , + lastUpdated , + lastUpdatedBy , + sorts, + sts, + + )values( + + #{id} , + #{clientcode} , + #{companycode} , + #{facilitycode} , + #{storecode} , + #{receiptcode} , + #{warehousecode} , + #{returnwaybillcode} , + #{sourcereturncode} , + #{sourceordercode} , + #{returnordercode} , + #{actualrefundamount} , + #{returntime} , + #{relatedat} , + #{status} , + #{created} , + #{createdby} , + #{lastupdated} , + #{lastupdatedby} , + (select (max(IFNULL( a.sorts, 0 )) + 1) as sort from ofs_passiveorder_header a WHERE a.sts = 'Y' ), + 'Y', + + ) + + + + insert into ofs_passiveorder_header(clientCode, companyCode, facilityCode, storeCode, receiptCode, warehouseCode, returnWaybillCode, sourceReturnCode, sourceOrderCode, returnOrderCode, actualRefundAmount, returnTime, relatedAt, status, created, createdBy, lastUpdated, lastUpdatedBy, sts) + values + + (#{entity.clientcode},#{entity.companycode},#{entity.facilitycode},#{entity.storecode},#{entity.receiptcode},#{entity.warehousecode},#{entity.returnwaybillcode},#{entity.sourcereturncode},#{entity.sourceordercode},#{entity.returnordercode},#{entity.actualrefundamount},#{entity.returntime},#{entity.relatedat},#{entity.status},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby}, 'Y') + + + + + + insert into ofs_passiveorder_header(id,clientCode, companyCode, facilityCode, storeCode, receiptCode, warehouseCode, returnWaybillCode, sourceReturnCode, sourceOrderCode, returnOrderCode, actualRefundAmount, returnTime, relatedAt, status, created, createdBy, lastUpdated, lastUpdatedBy) + values + + (#{entity.id},#{entity.clientcode},#{entity.companycode},#{entity.facilitycode},#{entity.storecode},#{entity.receiptcode},#{entity.warehousecode},#{entity.returnwaybillcode},#{entity.sourcereturncode},#{entity.sourceordercode},#{entity.returnordercode},#{entity.actualrefundamount},#{entity.returntime},#{entity.relatedat},#{entity.status},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby}) + + on duplicate key update + id = values(id), + clientCode = values(clientCode), + companyCode = values(companyCode), + facilityCode = values(facilityCode), + storeCode = values(storeCode), + receiptCode = values(receiptCode), + warehouseCode = values(warehouseCode), + returnWaybillCode = values(returnWaybillCode), + sourceReturnCode = values(sourceReturnCode), + sourceOrderCode = values(sourceOrderCode), + returnOrderCode = values(returnOrderCode), + actualRefundAmount = values(actualRefundAmount), + returnTime = values(returnTime), + relatedAt = values(relatedAt), + status = values(status), + created = values(created), + createdBy = values(createdBy), + lastUpdated = values(lastUpdated), + lastUpdatedBy = values(lastUpdatedBy) + + + + +update ofs_passiveorder_header set + + clientCode = #{clientcode}, + companyCode = #{companycode}, + facilityCode = #{facilitycode}, + storeCode = #{storecode}, + receiptCode = #{receiptcode}, + warehouseCode = #{warehousecode}, + returnWaybillCode = #{returnwaybillcode}, + sourceReturnCode = #{sourcereturncode}, + sourceOrderCode = #{sourceordercode}, + returnOrderCode = #{returnordercode}, + actualRefundAmount = #{actualrefundamount}, + returnTime = #{returntime}, + relatedAt = #{relatedat}, + status = #{status}, + created = #{created}, + createdBy = #{createdby}, + lastUpdated = #{lastupdated}, + lastUpdatedBy = #{lastupdatedby}, + +where id = #{id} + + + +update ofs_passiveorder_header set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id} +where id = #{id} + + + +update ofs_passiveorder_header set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id} + + and id = #{id} + and clientCode = #{clientcode} + and companyCode = #{companycode} + and facilityCode = #{facilitycode} + and storeCode = #{storecode} + and receiptCode = #{receiptcode} + and warehouseCode = #{warehousecode} + and returnWaybillCode = #{returnwaybillcode} + and sourceReturnCode = #{sourcereturncode} + and sourceOrderCode = #{sourceordercode} + and returnOrderCode = #{returnordercode} + and actualRefundAmount = #{actualrefundamount} + and returnTime = #{returntime} + and relatedAt = #{relatedat} + and status = #{status} + and created = #{created} + and createdBy = #{createdby} + and lastUpdated = #{lastupdated} + and lastUpdatedBy = #{lastupdatedby} + and sts='Y' + + + + + delete from ofs_passiveorder_header where id = #{id} + + + + diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/IOfsPassiveorderDetailService.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/IOfsPassiveorderDetailService.java new file mode 100644 index 00000000..ade489bc --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/IOfsPassiveorderDetailService.java @@ -0,0 +1,14 @@ +package com.hzya.frame.plugin.lets.ofs.service; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderDetailEntity; +import com.hzya.frame.basedao.service.IBaseService; + +/** + * O无源件订单中台明细表(OfsPassiveorderDetail)表服务接口 + * + * @author makejava + * @since 2025-03-12 09:40:26 + */ +public interface IOfsPassiveorderDetailService extends IBaseService { + +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/IOfsPassiveorderHeaderService.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/IOfsPassiveorderHeaderService.java new file mode 100644 index 00000000..4e1f15cb --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/IOfsPassiveorderHeaderService.java @@ -0,0 +1,14 @@ +package com.hzya.frame.plugin.lets.ofs.service; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderHeaderEntity; +import com.hzya.frame.basedao.service.IBaseService; + +/** + * O无源件订单中台主表(OfsPassiveorderHeader)表服务接口 + * + * @author makejava + * @since 2025-03-12 09:39:53 + */ +public interface IOfsPassiveorderHeaderService extends IBaseService { + +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/impl/OfsPassiveorderDetailServiceImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/impl/OfsPassiveorderDetailServiceImpl.java new file mode 100644 index 00000000..1a2d0703 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/impl/OfsPassiveorderDetailServiceImpl.java @@ -0,0 +1,28 @@ +package com.hzya.frame.plugin.lets.ofs.service.impl; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderDetailEntity; +import com.hzya.frame.plugin.lets.ofs.dao.IOfsPassiveorderDetailDao; +import com.hzya.frame.plugin.lets.ofs.service.IOfsPassiveorderDetailService; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.annotation.Resource; + +import com.hzya.frame.basedao.service.impl.BaseService; + +/** + * O无源件订单中台明细表(OfsPassiveorderDetail)表服务实现类 + * + * @author makejava + * @since 2025-03-12 09:40:26 + */ +public class OfsPassiveorderDetailServiceImpl extends BaseService implements IOfsPassiveorderDetailService { + + private IOfsPassiveorderDetailDao ofsPassiveorderDetailDao; + + @Autowired + public void setOfsPassiveorderDetailDao(IOfsPassiveorderDetailDao dao) { + this.ofsPassiveorderDetailDao = dao; + this.dao = dao; + } +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/impl/OfsPassiveorderHeaderServiceImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/impl/OfsPassiveorderHeaderServiceImpl.java new file mode 100644 index 00000000..571ec6a1 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/service/impl/OfsPassiveorderHeaderServiceImpl.java @@ -0,0 +1,28 @@ +package com.hzya.frame.plugin.lets.ofs.service.impl; + +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderHeaderEntity; +import com.hzya.frame.plugin.lets.ofs.dao.IOfsPassiveorderHeaderDao; +import com.hzya.frame.plugin.lets.ofs.service.IOfsPassiveorderHeaderService; +import org.springframework.stereotype.Service; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.annotation.Resource; + +import com.hzya.frame.basedao.service.impl.BaseService; + +/** + * O无源件订单中台主表(OfsPassiveorderHeader)表服务实现类 + * + * @author makejava + * @since 2025-03-12 09:39:53 + */ +public class OfsPassiveorderHeaderServiceImpl extends BaseService implements IOfsPassiveorderHeaderService { + + private IOfsPassiveorderHeaderDao ofsPassiveorderHeaderDao; + + @Autowired + public void setOfsPassiveorderHeaderDao(IOfsPassiveorderHeaderDao dao) { + this.ofsPassiveorderHeaderDao = dao; + this.dao = dao; + } +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java index 29470da1..041d51d3 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofsvo/QueryOfsSoSaleOutVo.java @@ -60,8 +60,8 @@ public class QueryOfsSoSaleOutVo { private String receivedAt_start; //确认单收货时间-结束 private String receivedAt_end; - //售后入库确认单关联时间-开始 + //无源入库确认单关联时间-开始 private String relatedAt_start; - //售后入库确认单关联时间-结束 + //无源入库确认单关联时间-结束 private String relatedAt_end; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToC.java index c0281023..8d34c349 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToC.java @@ -13,10 +13,15 @@ import com.hzya.frame.beanutil.BeanUtil; import com.hzya.frame.plugin.lets.constant.OverallConstant; import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.plugin.lets.ofs.dao.IOfsPassiveorderDetailDao; +import com.hzya.frame.plugin.lets.ofs.dao.IOfsPassiveorderHeaderDao; import com.hzya.frame.plugin.lets.ofs.dao.ITocofsReturngoodsDao; import com.hzya.frame.plugin.lets.ofs.dao.ITocofsReturngoodsDetailedDao; +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderDetailEntity; +import com.hzya.frame.plugin.lets.ofs.entity.OfsPassiveorderHeaderEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsEntity; +import com.hzya.frame.plugin.lets.ofs.service.IOfsPassiveorderDetailService; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; import com.hzya.frame.plugin.lets.queryvo.StartAndEndVo; import com.hzya.frame.plugin.lets.resultvo.CacheTocMapVoV2; @@ -26,6 +31,7 @@ import com.hzya.frame.split.SplitListByCountUtil; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto; +import com.hzya.frame.ttxofs.dto.passivestorage.PassiveStorageResponse; import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchData; import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchDetails; import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchHeader; @@ -49,7 +55,7 @@ import java.util.stream.Collectors; /** * 2025-03-06 17:33:44 - * 无源入库单(TOC) -> 推送U8C 红字销售订单 + * TOC业务,无源入库单(TOC) -> 推送U8C 红字销售订单、交易成功部分生成红字应收单 * * @Author:liuyang * @Package:com.hzya.frame.plugin.lets.plugin.sales @@ -60,10 +66,9 @@ import java.util.stream.Collectors; */ public class PassiveWarehouseReceiptToC extends PluginBaseEntity { - Logger logger = LoggerFactory.getLogger(SoSaleReturnPluginInitializerToC.class); - -// private static final ReentrantLock LOCK = new ReentrantLock(true); + Logger logger = LoggerFactory.getLogger(PassiveWarehouseReceiptToC.class); + //增加公平锁推送性能会比较差,但目标 U8C 端不支持并发,这样也能确保数据的准确性,避免数据重复推送,基本满足业务需求 private static final ReentrantLock LOCK1 = new ReentrantLock(true); private static final ReentrantLock LOCK2 = new ReentrantLock(true); @@ -83,6 +88,49 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity { @Autowired private QueryAdditionUtil queryAdditionUtil; + @Autowired + private IOfsPassiveorderHeaderDao iOfsPassiveorderHeaderDao; + + @Autowired + private IOfsPassiveorderDetailDao iOfsPassiveorderDetailDao; + + @Autowired + private OfsUnifiedService ofsUnifiedService; + + @Autowired + private QueryBdBusitypeUtil queryBdBusitypeUtil; + + private static final String NOTHING = "无"; + + private static final String ADD = "&"; + + @Autowired + private PassiveComponentsArchivesCacheUtil passiveComponentsArchivesCacheUtil; + + @Autowired + private ITocofsReturngoodsDao iTocofsReturngoodsDao; + +// @Autowired +// private ITocofsReturngoodsDetailedDao iTocofsReturngoodsDetailedDao; + +// @Autowired +// private TocReturnBasicArchivesCacheUtil tocReturnBasicArchivesCacheUtil; + + @Autowired + private ShopTobOrToCUtil shopTobOrToCUtil; + + @Autowired + private OfsStandardUtil ofsStandardUtil; + + @Autowired + private AfterSalesOrderUtil afterSalesOrderUtil; + + @Autowired + private RdclUtil rdclUtil; + + @Autowired + private OfsOrderAfterSalesAmountAllocationUtil ofsOrderAfterSalesAmountAllocationUtil; + @Override public void initialize() { logger.info(getPluginLabel() + "執行初始化方法initialize()"); @@ -100,12 +148,12 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity { @Override public String getPluginName() { - return "OFS售后入库单(TOC)生成U8C红字销售订单"; + return "OFS无源入库单生成U8C红字销售订单或红字应收单"; } @Override public String getPluginLabel() { - return "OFS售后入库单(TOC)生成U8C红字销售订单"; + return "OFS无源入库单生成U8C红字销售订单或红字应收单"; } @Override @@ -115,3118 +163,2928 @@ public class PassiveWarehouseReceiptToC extends PluginBaseEntity { @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { - logger.info("触发调用:{}" + getPluginName()); - try { - String requestJsonParam = String.valueOf(requestJson.get("param")); - - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - long startMillis = System.currentTimeMillis(); - logger.info("executeBusiness方法调用开始:" + getPluginName() + "-插件"); - - try { - String param = String.valueOf(requestJson.get("param")); - String sceneType = String.valueOf(requestJson.get("sceneType"));//sceneType:stock、tran - String pushScenarioType = String.valueOf(requestJson.get("pushScenarioType")); - if (ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type"))) { - //按单号 - if (param != null && !"".equals(param)) { - startImplementByCode(param, sceneType); - } - } else if (ProfilesActiveConstant.TYPE_TIME_FRAME.equals(requestJson.get("type"))) { - //前台页面功能日期推送,或者接口调用也行 - String craeteDateStr = computingTime(param); - if (craeteDateStr != null && !"".equals(craeteDateStr)) { - splitDateAndPush(craeteDateStr, sceneType, pushScenarioType); - } - } else { - if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(PROD_FILED)) { - //默认被定时器执行,每天晚上凌晨0点5分 - //暂定先同步TOC销售库存、再推送TOC销售确认收入 - List startAndEndVos = calculateCalculateEntireDayPeriod(null); - //TODO 1号上线注释掉 -// startImplementStockByTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time(), "0"); -// startImplementByTradeTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time(), "0"); - } - } - } catch (Exception e) { - logger.error("executeBusiness方法异常", e); - } - long endMillis = System.currentTimeMillis(); - logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); -// return null; - } - }, "执行插件:" + getPluginName() + " " + requestJsonParam); - thread.start(); - - if (requestJson != null && requestJson.get("type") != null && ProfilesActiveConstant.TYPE_DETAIL_ERROR.equals(requestJson.get("type"))) { - try { - thread.join(); - } catch (Exception e) { - logger.error("thread.join();抛出异常", e); - } - } - } catch (Exception e) { - logger.error("executeBusiness方法抛出异常", e); - } +// logger.info("触发调用:{}" + getPluginName()); +// try { +// String requestJsonParam = String.valueOf(requestJson.get("param")); +// +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// long startMillis = System.currentTimeMillis(); +// logger.info("executeBusiness方法调用开始:" + getPluginName() + "-插件"); +// +// try { +// String param = String.valueOf(requestJson.get("param")); +// String sceneType = String.valueOf(requestJson.get("sceneType"));//sceneType:stock、tran +// String pushScenarioType = String.valueOf(requestJson.get("pushScenarioType")); +// if (ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type"))) { +// //按单号 +// if (param != null && !"".equals(param)) { +// startImplementByCode(param, sceneType); +// } +// } else if (ProfilesActiveConstant.TYPE_TIME_FRAME.equals(requestJson.get("type"))) { +// //前台页面功能日期推送,或者接口调用也行 +// String craeteDateStr = computingTime(param); +// if (craeteDateStr != null && !"".equals(craeteDateStr)) { +//// splitDateAndPush(craeteDateStr, sceneType, pushScenarioType); +// } +// } else { +// if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(PROD_FILED)) { +// //默认被定时器执行,每天晚上凌晨0点5分 +// //暂定先同步TOC销售库存、再推送TOC销售确认收入 +// List startAndEndVos = calculateCalculateEntireDayPeriod(null); +// //TODO 1号上线注释掉 +//// startImplementStockByTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time(), "0"); +//// startImplementByTradeTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time(), "0"); +// } +// } +// } catch (Exception e) { +// logger.error("executeBusiness方法异常", e); +// } +// long endMillis = System.currentTimeMillis(); +// logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis)); +//// return null; +// } +// }, "执行插件:" + getPluginName() + " " + requestJsonParam); +// thread.start(); +// +// if (requestJson != null && requestJson.get("type") != null && ProfilesActiveConstant.TYPE_DETAIL_ERROR.equals(requestJson.get("type"))) { +// try { +// thread.join(); +// } catch (Exception e) { +// logger.error("thread.join();抛出异常", e); +// } +// } +// } catch (Exception e) { +// logger.error("executeBusiness方法抛出异常", e); +// } return BaseResult.getSuccessMessageEntity("插件执行成功"); } - @Autowired - private OfsUnifiedService ofsUnifiedService; - - @Autowired - private QueryBdBusitypeUtil queryBdBusitypeUtil; - - private static final String NOTHING = "无"; - - private static final String ADD = "&"; - - @Autowired - private ITocofsReturngoodsDao iTocofsReturngoodsDao; - - @Autowired - private ITocofsReturngoodsDetailedDao iTocofsReturngoodsDetailedDao; - - @Autowired - private TocReturnBasicArchivesCacheUtil tocReturnBasicArchivesCacheUtil; - - @Autowired - private ShopTobOrToCUtil shopTobOrToCUtil; - - @Autowired - private OfsStandardUtil ofsStandardUtil; - - @Autowired - private AfterSalesOrderUtil afterSalesOrderUtil; - - @Autowired - private RdclUtil rdclUtil; - - @Autowired - private OfsOrderAfterSalesAmountAllocationUtil ofsOrderAfterSalesAmountAllocationUtil; - - /** - * 库存同步,根据时间范围拉取 - * - * @author liuyang - */ - public void startImplementStockByTime(String startTime, String endTime, String pushScenarioType) throws Exception { - try { - long startMillis = System.currentTimeMillis(); - String threadNameStrStart = StrUtil.format("开始-OFS销售出库(TOC)同步U8C销售订单 开始时间:{} 结束时间:{}", startTime, endTime); - logger.info(threadNameStrStart); - - Assert.notNull(startTime, "开始时间不能为空"); - Assert.notNull(endTime, "结束时间不能为空"); - Assert.notNull(pushScenarioType, "pushScenarioType不能为空"); - List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); - if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) { - String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setRelatedAt_start(startTime); - queryOfsSoSaleOutVo.setRelatedAt_end(endTime); - queryOfsSoSaleOutVo.setClientCode("LETS"); -// queryOfsSoSaleOutVo.setStatus(900L); - queryOfsSoSaleOutVo.setPageNo(1L); - queryOfsSoSaleOutVo.setPageSize(50L); - queryOfsSoSaleOutVo.setStoreCode(tocShop); -// queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); - ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.passive.order.search"); - } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) { - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - if (startTime.length() == 19) { - tocofsReturngoodsDetailedEntity.setBusinessDateStart(startTime); - } else { - tocofsReturngoodsDetailedEntity.setBusinessDateStart(startTime + " 00:00:00"); - } - if (endTime.length() == 19) { - tocofsReturngoodsDetailedEntity.setBusinessDateEnd(endTime); - } else { - tocofsReturngoodsDetailedEntity.setBusinessDateEnd(endTime + " 23:59:59"); - } - tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN"); - returnGoodHeaderDetailsDataDtoArrayList = queryTocofsReturngoodsDetailed(tocofsReturngoodsDetailedEntity); - } else { - Assert.state(false, "未知的场景类型!"); - } - logger.info("TOC退货数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); - if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - returnGoodHeaderDetailsDataDtoArrayList.removeIf(new Predicate() { - @Override - public boolean test(StockinOrderSearchResponse.StockinOrder headerDetailsDto) { - StockinOrderSearchResponse.StockinOrder.StockinH header = headerDetailsDto.getHeader(); - if (header != null && header.getCompanyCode() != null) { - if (ProfilesActiveConstant.FILTER_COMPANY.contains(header.getCompanyCode().trim())) { - return true; - } - } - return false; - } - }); - getSetStock(returnGoodHeaderDetailsDataDtoArrayList, pushScenarioType); - } else { - logger.info("没有查询到任何数据!不需要同步"); - } - long endMillis = System.currentTimeMillis(); - String threadNameStrEnd = StrUtil.format("结束-OFS销售出库(TOC)同步U8C销售订单 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); - logger.info(threadNameStrEnd); - } catch (Exception e) { - logger.error("startImplementStockByTime方法抛出异常", e); - } - } - - /** - * 根据编码、场景类型拉取 - * - * @param code 编码 - * @param sceneType 场景类型 - * @author liuyang - */ - public void startImplementByCode(String code, String sceneType) throws Exception { - long startMillis = System.currentTimeMillis(); - String threadNameStrStart = StrUtil.format("开始-OFS销售出库(TOC)同步U8C销售订单 同步单据号:{} 业务场景:{}", code, sceneType); - logger.info(threadNameStrStart); - - Assert.notNull(code, "code不能为空"); - Assert.notNull(sceneType, "sceneType不能为空"); - - String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); - - List returnGoodHeaderDetailsDataDtoList = new ArrayList<>(); - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setClientCode("LETS"); -// queryOfsSoSaleOutVo.setStatus(900L); - queryOfsSoSaleOutVo.setPageNo(1L); - queryOfsSoSaleOutVo.setPageSize(50L); - queryOfsSoSaleOutVo.setStoreCode(tocShop); - queryOfsSoSaleOutVo.setCode(code); - queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); - ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L, "ofs.receipt.search"); - logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size()); - if (returnGoodHeaderDetailsDataDtoList.size() > 0) { - returnGoodHeaderDetailsDataDtoList.removeIf(new Predicate() { - @Override - public boolean test(StockinOrderSearchResponse.StockinOrder headerDetailsDto) { - StockinOrderSearchResponse.StockinOrder.StockinH header = headerDetailsDto.getHeader(); - if (header != null && header.getCompanyCode() != null) { - if (ProfilesActiveConstant.FILTER_COMPANY.contains(header.getCompanyCode().trim())) { - return true; - } - if (sceneType.equals("tran") && (header.getClosedAt() == null || "".equals(header.getClosedAt().trim()))) { - return true; - } - } - return false; - } - }); - if (sceneType.equals("stock")) { - getSetStock(returnGoodHeaderDetailsDataDtoList, "2"); - } else if (sceneType.equals("tran")) { - getSetTran(returnGoodHeaderDetailsDataDtoList, "2"); - } - } else { - logger.info("没有查询到任何数据!不需要同步"); - } - - long endMillis = System.currentTimeMillis(); - String threadNameStrEnd = StrUtil.format("结束-OFS销售出库(TOC)同步U8C销售订单 同步单据号:{} 业务场景:{} 耗时:{}", code, sceneType, (endMillis - startMillis)); - logger.info(threadNameStrEnd); - } - - /** - * 交易采购,按指定时间拉取 - * - * @author liuyang - */ - public void startImplementByTradeTime(String startTime, String endTime, String pushScenarioType) throws Exception { - try { - long startMillis = System.currentTimeMillis(); - String threadNameStrStart = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{}", startTime, endTime); - logger.info(threadNameStrStart); - - Assert.notNull(startTime, "startTime不能为空"); - Assert.notNull(endTime, "endTime不能为空"); - List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); - - if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) { - //生成一个时间范围 -// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime(); - //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性 - String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setTradeSuccessAt_start(startTime); - queryOfsSoSaleOutVo.setTradeSuccessAt_end(endTime); - queryOfsSoSaleOutVo.setClientCode("LETS"); - queryOfsSoSaleOutVo.setPageNo(1L); - queryOfsSoSaleOutVo.setPageSize(50L); - queryOfsSoSaleOutVo.setStoreCode(tocShop); -// queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); -// queryOfsSoSaleOutVo.setRefundStatus("900"); -// queryOfsSoSaleOutVo.setCode("LETS-RE2024081900000001"); - ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.passive.order.search"); - } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) { - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - if (startTime.length() == 19) { - tocofsReturngoodsDetailedEntity.setRefundedAtStart(startTime); - } else { - tocofsReturngoodsDetailedEntity.setRefundedAtStart(startTime + " 00:00:00"); - } - if (endTime.length() == 19) { - tocofsReturngoodsDetailedEntity.setRefundedAtEnd(endTime); - } else { - tocofsReturngoodsDetailedEntity.setRefundedAtEnd(endTime + " 23:59:59"); - } - tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN"); - returnGoodHeaderDetailsDataDtoArrayList = queryTocofsReturngoodsDetailed(tocofsReturngoodsDetailedEntity); - } else { - Assert.state(false, "未知的场景类型!"); - } - logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); - if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - returnGoodHeaderDetailsDataDtoArrayList.removeIf(new Predicate() { - @Override - public boolean test(StockinOrderSearchResponse.StockinOrder headerDetailsDto) { - StockinOrderSearchResponse.StockinOrder.StockinH header = headerDetailsDto.getHeader(); - if (header != null && header.getCompanyCode() != null) { - //过滤掉不需要的公司 - if (ProfilesActiveConstant.FILTER_COMPANY.contains(header.getCompanyCode().trim())) { - return true; - } - //过滤掉入库日期为空的单据 - if (header.getClosedAt() == null || "".equals(header.getClosedAt().trim())) { - return true; - } - } - return false; - } - }); - getSetTran(returnGoodHeaderDetailsDataDtoArrayList, pushScenarioType); - } else { - logger.info("没有查询到任何数据!不需要同步"); - } - - long endMillis = System.currentTimeMillis(); - String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); - logger.info(threadNameStrEnd); - } catch (Exception e) { - logger.error("startImplementByTradeTime方法抛出异常", e); - } - } - - /** - * 库存同步,预备执行逻辑 - * - * @author liuyang - */ - private void getSetStock(List returnGoodHeaderDetailsDataDtoArrayList, String pushScenarioType) throws Exception { - LOCK1.lock(); - try { - //过滤成功的数据 - List stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList); - //保存到mysql - if (!ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) { - batchInsert(stockinOrderList); - } - //执行推送主逻辑 - implementStock(stockinOrderList, pushScenarioType); - } catch (Exception e) { - logger.error("TOC退货-库存:getSetStock方法抛出异常", e); - } finally { - LOCK1.unlock(); - } - } - - /** - * 确认收入:预备执行逻辑 - * - * @author liuyang - */ - private void getSetTran(List returnGoodHeaderDetailsDataDtoArrayList, String pushScenarioType) throws Exception { - LOCK2.lock(); - try { - //过滤成功的数据 - List stockinOrderList = filterDataTran(returnGoodHeaderDetailsDataDtoArrayList); - //保存到mysql - if (!ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) { - batchInsert(stockinOrderList); - } - //执行推送主逻辑 - implementTran(stockinOrderList, pushScenarioType); - } catch (Exception e) { - logger.error("TOC退货-确认收入:getSetTran方法抛出异常", e); - } finally { - LOCK2.unlock(); - } - } - - /** - * 库存同步,过滤掉成功的数据 - * - * @author liuyang - */ - private List filterDataStock(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { -// List headerDetailsDtoList1 = new ArrayList<>(); - List tocofsReturngoodsDetailedEntityList = new ArrayList<>(); - if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 1000); - for (int i = 0; i < splitListByCount.size(); i++) { - List stockinOrderList = splitListByCount.get(i); - String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList); - List tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr); - tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities); - } - } - return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList); - } - - /** - * 确认收入,过滤掉成功的数据 - * - * @author liuyang - */ - private List filterDataTran(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { - List tocofsReturngoodsDetailedEntityList = new ArrayList<>(); - if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100); - for (int i = 0; i < splitListByCount.size(); i++) { - List stockinOrderList = splitListByCount.get(i); - String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList); - List tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr); - tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities); - } - } - return filterDataRowsAsPushOrFailedTran(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList); - } - - /** - * 逗号拼接字符串主键,作为批处理的一部分,方便下一步的批量查询操作 - * - * @author liuyang - */ - private String commaConcatenatedPrimaryKeyStock(List headerDetailsDtoList2) throws Exception { - StringBuffer idStr = new StringBuffer(); - if (headerDetailsDtoList2 != null && headerDetailsDtoList2.size() > 0) { - for (int i = 0; i < headerDetailsDtoList2.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = headerDetailsDtoList2.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - for (int j = 0; j < details.size(); j++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); - Assert.notNull(stockinB.getId(), "O明细主键不能为空!"); - Assert.state(!"".equals(stockinB.getId()), "O明细主键不能为空!"); - - idStr.append("'"); - idStr.append(stockinB.getId()); - idStr.append("'"); - idStr.append(","); - } - } - } - if (idStr.length() > 0) { - return idStr.substring(0, idStr.length() - 1); - } - return null; - } - - /** - * 批查询toc退货入库日志,查询的量由splitListByCount方法控制 - * - * @author liuyang - */ - private List queryStockTocOutLog(String idStr) throws Exception { - List tocofsReturngoodsDetailedEntities = null; - if (idStr != null && !"".equals(idStr.trim())) { - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - tocofsReturngoodsDetailedEntity.setIds(idStr); - tocofsReturngoodsDetailedEntities = iTocofsReturngoodsDetailedDao.query(tocofsReturngoodsDetailedEntity); - } else { - logger.error("idStr为空,无法查询数据!"); - } - return tocofsReturngoodsDetailedEntities; - } - - /** - * 保存抓取到的数据到mysql底表,如果底表里已经存在,则会忽略 - * - * @param returnGoodHeaderDetailsDataDtoArrayList mysql数据行 - */ - private void batchInsert(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { - if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - List headerDetailsDtoList1 = new ArrayList<>(); - List headerDetailsDtoList2 = new ArrayList<>(); - - for (StockinOrderSearchResponse.StockinOrder index : returnGoodHeaderDetailsDataDtoArrayList) { - StockinOrderSearchResponse.StockinOrder.StockinH header = index.getHeader();// 主表 - List details = index.getDetails();//明细表 - for (int i = 0; i < details.size(); i++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(i); - stockinB.setReturnGoodSearchHeaderDto(header); - } - headerDetailsDtoList1.add(header); - headerDetailsDtoList2.addAll(details); - } - - //每250作为一个批次插入主表,根据主键(id)判断是否重复,如果重复的,则不进行插入 - List> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 100); - for (int i = 0; i < lists.size(); i++) { - List stockinHS = lists.get(i); - long startTime = System.currentTimeMillis(); - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - List tocofsReturngoodsEntities = copyHeaderDto(stockinHS); - if (tocofsReturngoodsEntities.size() > 0) { - logger.info("插入底表{}个对象(表头)", tocofsReturngoodsEntities.size()); - iTocofsReturngoodsDao.entityInsertOrUpdateBatch(tocofsReturngoodsEntities); - } else { - logger.info("tocofsReturngoodsEntities:没有对象被插入表头底表"); - } - } catch (Exception e) { - logger.error("线程保存TOC退货主表抛出异常", e); - } - } - }); - thread.start(); - try { - thread.join(); - } catch (Exception e) { - logger.error("线程保存TOC退货主表抛出异常", e); - } - long endTime = System.currentTimeMillis(); - logger.info("插入或更新TOC退货入库表头-耗时:{}", (endTime - startTime)); - } - - //插入明细表 - List> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 100); - for (int i = 0; i < lists1.size(); i++) { - List stockinBS = lists1.get(i); - List tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS); - long startTime = System.currentTimeMillis(); - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - if (tocofsReturngoodsDetailedEntities.size() > 0) { - logger.info("插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size()); - iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatch(tocofsReturngoodsDetailedEntities); - } else { - logger.info("tocofsReturngoodsDetailedEntities:没有对象被插入表头底表"); - } - } catch (Exception e) { - logger.error("线程保存TOC退货明细抛出异常", e); - } - } - }); - thread.start(); - try { - thread.join(); - } catch (Exception e) { - logger.error("线程保存TOC退货明细抛出异常", e); - } - long endTime = System.currentTimeMillis(); - logger.info("插入或更新TOC退货入库表体-耗时:{}", (endTime - startTime)); - } - } - } - - /** - * 查询OFS售后退货入库单 - * - * @param queryOfsSoSaleOutVo 查询参数 - * @param headerDetailsDtoList 查询结果集 - * @param pageNo 从第pageNo页开始查询 - */ -// private void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo) throws Exception { +// /** +// * 无源件库存同步,根据时间范围拉取 +// * +// * @author liuyang +// */ +// public void startImplementStockByTime(String startTime, String endTime) throws Exception { +// try { +// long startMillis = System.currentTimeMillis(); +// String threadNameStrStart = StrUtil.format("开始-TOC无源入库单同步U8C红字销售订单 关联开始时间:{} 关联结束时间:{}", startTime, endTime); +// logger.info(threadNameStrStart); // -// Long pageSize = 200L; -// queryOfsSoSaleOutVo.setPageNo(pageNo); -// queryOfsSoSaleOutVo.setPageSize(pageSize); +// Assert.notNull(startTime, "开始时间不能为空"); +// Assert.notNull(endTime, "结束时间不能为空"); // -// InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); -// interfaceParamDto.setApi("ofs.receipt.search"); -// interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); -// RertunGoodsRootBean rertunGoodsRootBean = (RertunGoodsRootBean) ofsUnifiedService.unified(interfaceParamDto); -// if (rertunGoodsRootBean != null) { -// if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { -// List returnGoodHeaderDetailsDataDtoList = rertunGoodsRootBean.getData(); -// if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { -// headerDetailsDtoList.addAll(returnGoodHeaderDetailsDataDtoList); +// List passiveStorageResponseDataList = new ArrayList<>(); // -// //OFS没有提供分页字段,等待开发 -// } +// String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setRelatedAt_start(startTime); +// queryOfsSoSaleOutVo.setRelatedAt_end(endTime); +// queryOfsSoSaleOutVo.setClientCode("LETS"); +// queryOfsSoSaleOutVo.setPageNo(1L); +// queryOfsSoSaleOutVo.setPageSize(50L); +//// queryOfsSoSaleOutVo.setStoreCode(tocShop); +// ofsStandardUtil.queryOfsPassiveComponents(queryOfsSoSaleOutVo, passiveStorageResponseDataList, 1L, "ofs.passive.order.search"); +// +// logger.info("TOC退货数据返回行数:{}", passiveStorageResponseDataList.size()); +// if (passiveStorageResponseDataList.size() > 0) { +// passiveStorageResponseDataList.removeIf(new Predicate() { +// @Override +// public boolean test(PassiveStorageResponse.Data headerDetailsDto) { +// PassiveStorageResponse.Header header = headerDetailsDto.getHeader(); +// if (header != null && header.getCompanyCode() != null) { +// if (ProfilesActiveConstant.FILTER_COMPANY.contains(header.getCompanyCode().trim())) { +// return true; +// } +// } +// return false; +// } +// }); +// getSetStock(passiveStorageResponseDataList); // } else { -// logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); +// logger.info("没有查询到任何数据!不需要同步"); // } -// } else { -// logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); +// long endMillis = System.currentTimeMillis(); +// String threadNameStrEnd = StrUtil.format("结束-TOC无源入库单同步U8C红字销售订单 关联开始时间:{} 关联结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); +// logger.info(threadNameStrEnd); +// } catch (Exception e) { +// logger.error("startImplementStockByTime方法抛出异常", e); // } // } - -// public void queryOfsSaleOrder() throws Exception { +// +// /** +// * 根据编码、场景类型拉取 +// * +// * @param code 编码 +// * @param sceneType 场景类型 +// * @author liuyang +// */ +// public void startImplementByCode(String code, String sceneType) throws Exception { +// long startMillis = System.currentTimeMillis(); +// String threadNameStrStart = StrUtil.format("开始-OFS销售出库(TOC)同步U8C销售订单 同步单据号:{} 业务场景:{}", code, sceneType); +// logger.info(threadNameStrStart); +// +// Assert.notNull(code, "code不能为空"); +// Assert.notNull(sceneType, "sceneType不能为空"); +// +// String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); +// +// List returnGoodHeaderDetailsDataDtoList = new ArrayList<>(); // QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); -// queryOfsSoSaleOutVo.setCreated_start("2024-07-05 16:38:00"); -// queryOfsSoSaleOutVo.setCreated_end("2024-07-05 16:40:30"); // queryOfsSoSaleOutVo.setClientCode("LETS"); -//// queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); -// queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); //// queryOfsSoSaleOutVo.setStatus(900L); // queryOfsSoSaleOutVo.setPageNo(1L); // queryOfsSoSaleOutVo.setPageSize(50L); -// queryOfsSoSaleOutVo.setCode("LETS-SH2024070500000003"); +// queryOfsSoSaleOutVo.setStoreCode(tocShop); +// queryOfsSoSaleOutVo.setCode(code); +// queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); +// ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L, "ofs.receipt.search"); +// logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size()); +// if (returnGoodHeaderDetailsDataDtoList.size() > 0) { +// returnGoodHeaderDetailsDataDtoList.removeIf(new Predicate() { +// @Override +// public boolean test(StockinOrderSearchResponse.StockinOrder headerDetailsDto) { +// StockinOrderSearchResponse.StockinOrder.StockinH header = headerDetailsDto.getHeader(); +// if (header != null && header.getCompanyCode() != null) { +// if (ProfilesActiveConstant.FILTER_COMPANY.contains(header.getCompanyCode().trim())) { +// return true; +// } +// if (sceneType.equals("tran") && (header.getClosedAt() == null || "".equals(header.getClosedAt().trim()))) { +// return true; +// } +// } +// return false; +// } +// }); +// if (sceneType.equals("stock")) { +//// getSetStock(returnGoodHeaderDetailsDataDtoList, "2"); +// } else if (sceneType.equals("tran")) { +// getSetTran(returnGoodHeaderDetailsDataDtoList, "2"); +// } +// } else { +// logger.info("没有查询到任何数据!不需要同步"); +// } // -// InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); -// interfaceParamDto.setApi("ofs.shipment.search"); -// interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); -// SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto); -// System.out.println(saleOutReturnMessageDto); +// long endMillis = System.currentTimeMillis(); +// String threadNameStrEnd = StrUtil.format("结束-OFS销售出库(TOC)同步U8C销售订单 同步单据号:{} 业务场景:{} 耗时:{}", code, sceneType, (endMillis - startMillis)); +// logger.info(threadNameStrEnd); // } - - /** - * 库存同步,代码同步逻辑 - * - * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象 - * @param pushScenarioType 推送阶段场景 - * @author liuyang - */ - private void implementStock(List returnGoodHeaderDetailsDataDtoList1, String pushScenarioType) throws Exception { - Assert.notNull(pushScenarioType, "pushScenarioType不能为空"); - if (returnGoodHeaderDetailsDataDtoList1 != null) { - logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size()); - } - if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - try { - // 查询基本档案 - String sceneType = "stock"; - List goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1, sceneType); - // 分组汇总 - String dimension = null; -// dimension = "1001&dy-intoyou&B2CHA20240033&6973391733588&SALES&002"; - Map> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos, dimension); - // 查询U8C业务流程 - BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); - // 查询销售收发类别 -// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); - //初始化所有存货管理档案对应的结存价+采购价 -// List mapList = initAllBalancePricePurchasePrice(); - //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) - List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); - Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); - String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); - //查询存货对应的税目 - Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); - //查询「平台运费」对应的税率 -// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); - //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 - Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); - - if (bdBusitypeEntity != null && summaryDimensionMap != null) { - Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry> entry = iterator.next(); - String keyGroup = entry.getKey(); - List oldValue = entry.getValue(); - - StockinOrderSearchResponse.StockinOrder.StockinH header = oldValue.get(0).getHeader(); - BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司 - BdCorpEntity deliverGoodsCorp = oldValue.get(0).getDeliverGoodsCorp();//发货公司 - BdCalbodyEntity bdCalbodyEntity = oldValue.get(0).getBdCalbodyEntity();//发货仓库组织 - BdStordocEntity bdStordocEntity = oldValue.get(0).getBdStordocEntity();//发货仓库 - BdCalbodyEntity bdCalbodyEntity1 = oldValue.get(0).getBdCalbodyEntity1();//收货库存组织 - BdStordocEntity bdStordocEntity1 = oldValue.get(0).getBdStordocEntity1();//收货仓库 - BdSalestruEntity bdSalestruEntity = oldValue.get(0).getBdSalestruEntity();//销售组织 - BdDeptdocEntity bdDeptdocEntity = oldValue.get(0).getBdDeptdocEntity();//业务部门 - BdCumandocEntity bdCumandocEntity = oldValue.get(0).getBdCumandocEntity();//客商管理档案 - BdCubasdocEntity bdCubasdocEntity = oldValue.get(0).getBdCubasdocEntity();//客商基本档案 - BdDefdocEntity platformArchives = oldValue.get(0).getPlatformArchives();//U8C平台档案 - BdDefdocEntity shopArchives = oldValue.get(0).getShopArchives();//U8C店铺档案 - BdRdclEntity bdRdclEntity = oldValue.get(0).getBdRdclEntity();//U8C收发类别 - - try { -// checkArchives(oldValue.get(0)); - //生成业务日期 - String generateBusinessDate = createGenerateBusinessDate(header); - - SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto(); - SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto(); - saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期 - saleorderRequestParentDto.setBretinvflag("Y");//退货标记 - saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程 - saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织 - saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位 - saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门 - saleorderRequestParentDto.setCemployeeid(null);//业务员 - saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人 - saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位 - saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 - saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织 - saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库 - saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期 - saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣 - saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id - //汇总单号=汇总维度 - saleorderRequestParentDto.setVdef18(keyGroup); - //平台 - saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc()); - saleorderRequestParentDto.setVdef2(platformArchives.getDocname()); - saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统 - - //收发类别 - saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); - saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname()); - - //2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传! - //店铺 - saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc()); - saleorderRequestParentDto.setVdef1(shopArchives.getDocname()); - - //单据红字标识 - saleorderRequestParentDto.setPk_defdoc16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键")); - saleorderRequestParentDto.setVdef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称")); - - saleorderRequestDto.setParentvo(saleorderRequestParentDto); - - List saleorderRequestChildrenDtoList = new ArrayList<>(); - saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); - - //验证是否为指定的店铺,如果为true,则取结存价 - Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); - - //把汇总好的出库单明细行合并成一行 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose); - //存货管理档案:取发货公司的存货管理档案 - BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); - //存货基础档案 - BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity(); - //根据存货基础档案编码,查询当前存货的税率 - BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity(); - //查询收支项目 -// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity); -// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity); - -// String tax = new BigDecimal(bdTaxitemsEntity1.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); // -// BigDecimal noriginalcurprice = null;//无税单价 -// BigDecimal noriginalcurmny = null;//无税金额 -// BigDecimal noriginalcurtaxprice = null;//含税单价 -// BigDecimal noriginalcursummny = null;//价税合计 -// BigDecimal noriginalcurtaxmny = null;//税额=价税合计-无税金额 -// try { -// noriginalcurtaxprice = goodsRertunSonDetailsDto.getGroupTotalPayAmount().divide(goodsRertunSonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); -// noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); -// noriginalcurmny = noriginalcurprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); -// noriginalcursummny = noriginalcurtaxprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); -// noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); -// } catch (Exception e) { -// logger.error("TOC金额计算错误", e); -// Assert.state(false, "U8C红字销售订单,金额计算错误,原因:{}", e.getMessage()); -// } - - //判断是否为赠品 - Boolean isblargessflag = false; - if ("0".equals(goodsRertunSonDetailsDto.getGroupTotalPayAmount().stripTrailingZeros().toPlainString())) { - isblargessflag = true; - } - - SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto(); - saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品 - saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 - saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 - saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 - saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种 - saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id - saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 - saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期 - saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期 - saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率 - saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣 - saleorderRequestChildrenDto.setNnumber("-" + goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量 - saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额 -// saleorderRequestChildrenDto.setNoriginalcurmny("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额 -// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价 -// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价 -// saleorderRequestChildrenDto.setNoriginalcursummny("-" + noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计 - saleorderRequestChildrenDto.setNoriginalcursummny("-" + goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());//价税合计 新逻辑 -// saleorderRequestChildrenDto.setNoriginalcurtaxmny("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额 -// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 -// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 -// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 -// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 -// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); - //如果优惠金额为0,则传0 - if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef4("0"); - } - if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef5("0"); - } - if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef6("0"); - } - if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef7("0"); - } - saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); - - //平台优惠 - if (goodsRertunSonDetailsDto.getVdef4() != null) { - BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4(); - if (vdef4.compareTo(BigDecimal.ZERO) > 0) { - //发货运费-存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01"); - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); - //存货对应的税率 - BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); - //补充:平台优惠-存货 - BigDecimal absAccumulatedPostage = vdef4.abs(); - BigDecimal negativeValue = absAccumulatedPostage.negate(); - queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); - } - } - //达人优惠 - if (goodsRertunSonDetailsDto.getVdef6() != null) { - BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6(); - if (vdef6.compareTo(BigDecimal.ZERO) > 0) { - //发货运费-存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02"); - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); - //存货对应的税率 - BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); - //补充:达人优惠-存货 - BigDecimal absAccumulatedPostage = vdef6.abs(); - BigDecimal negativeValue = absAccumulatedPostage.negate(); - queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); - } - } - //支付优惠 - if (goodsRertunSonDetailsDto.getVdef5() != null) { - BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5(); - if (vdef5.compareTo(BigDecimal.ZERO) > 0) { - //发货运费-存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04"); - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); - //存货对应的税率 - BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); - //补充:支付优惠-存货 - BigDecimal absAccumulatedPostage = vdef5.abs(); - BigDecimal negativeValue = absAccumulatedPostage.negate(); - queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); - } - } - if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) { - //推送u8c - List saleorderRequestDtoList = new ArrayList<>(); - saleorderRequestDtoList.add(saleorderRequestDto); - Map> stringStringMap = new HashMap<>(); - stringStringMap.put("saleorder", saleorderRequestDtoList); - SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); - String vreceiptcode = null; - String pk_corp = null; - String csaleid = null; - if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) { - vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode(); - pk_corp = soSaleResultRootDto.getParentvo().getPk_corp(); - csaleid = soSaleResultRootDto.getParentvo().getCsaleid(); - } - logger.info("TOC销售订单编号:{} 主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); - updateSuccessOrFail1(oldValue, "Y", "success", vreceiptcode, csaleid); - } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) { - //选择暂存等待下次发起 - String vreceiptcode = "暂存"; - String csaleid = "暂存"; - String newstate = "S"; - String newTransmitInfo = "暂存"; - updateSuccessOrFail1(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid); - } else { - Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType); - } - } catch (Exception e) { - //记录失败 - logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e); - String message = e.getMessage(); - if (message == null) { - message = "未知错误"; - } - updateSuccessOrFail1(oldValue, "N", message, null, null); - } - } - } else { - //2024年8月6日 11:28:54此处不记录失败,不认为是错误 - logger.info("summaryDimensionMap变量或者bdBusitypeEntity变量为空,因此主要的推送逻辑不会被执行!"); - } - } catch (Exception e) { - logger.error("外层转换逻辑抛出异常", e); - } - } - } - - /** - * 到账成功:代码同步逻辑 - * - * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象 - * @author liuyang - */ - private void implementTran(List returnGoodHeaderDetailsDataDtoList1, String pushScenarioType) throws Exception { - Assert.notNull(pushScenarioType, "pushScenarioType不能为空"); - if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size()); - - try { - // 查询基本档案 - String sceneType = "tran"; - List goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1, sceneType); - // 分组汇总 - String dimension = null; - Map> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos, dimension); - // 查询U8C业务流程 - BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); - //初始化所有存货管理档案对应的结存价+采购价 -// List mapList = initAllBalancePricePurchasePrice(); - //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) - List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); - Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); - String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); - //查询存货对应的税目 - Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); - //查询「平台运费」对应的税率 -// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); - //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 - Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); - - if (bdBusitypeEntity != null && summaryDimensionMap != null) { - Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry> entry = iterator.next(); - String keyGroup = entry.getKey(); - List oldValue = entry.getValue(); - - StockinOrderSearchResponse.StockinOrder.StockinH header = oldValue.get(0).getHeader(); - BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司 - BdCorpEntity deliverGoodsCorp = oldValue.get(0).getDeliverGoodsCorp();//发货公司 - BdCalbodyEntity bdCalbodyEntity = oldValue.get(0).getBdCalbodyEntity();//发货仓库组织 - BdStordocEntity bdStordocEntity = oldValue.get(0).getBdStordocEntity();//发货仓库 - BdCalbodyEntity bdCalbodyEntity1 = oldValue.get(0).getBdCalbodyEntity1();//收货库存组织 - BdStordocEntity bdStordocEntity1 = oldValue.get(0).getBdStordocEntity1();//收货仓库 - BdSalestruEntity bdSalestruEntity = oldValue.get(0).getBdSalestruEntity();//销售组织 - BdDeptdocEntity bdDeptdocEntity = oldValue.get(0).getBdDeptdocEntity();//业务部门 - BdCumandocEntity bdCumandocEntity = oldValue.get(0).getBdCumandocEntity();//客商管理档案 - BdCubasdocEntity bdCubasdocEntity = oldValue.get(0).getBdCubasdocEntity();//客商基本档案 - BdDefdocEntity platformArchives = oldValue.get(0).getPlatformArchives();//U8C平台档案 - BdDefdocEntity shopArchives = oldValue.get(0).getShopArchives();//U8C店铺档案 - BdRdclEntity bdRdclEntity = oldValue.get(0).getBdRdclEntity();//U8C收发类别 - - try { -// checkArchives(oldValue.get(0)); - //生成业务日期 - String generateBusinessDate = createSuccessFulTradeDate(header); - - SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto(); - SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto(); - saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期 - saleorderRequestParentDto.setBretinvflag("Y");//退货标记 - saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程 - saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织 - saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位 - saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门 - saleorderRequestParentDto.setCemployeeid(null);//业务员 - saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人 - saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位 - saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 - saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织 - saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库 - saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期 - saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣 - saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id - //汇总单号=汇总维度 - saleorderRequestParentDto.setVdef18(keyGroup); - //平台 - saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc()); - saleorderRequestParentDto.setVdef2(platformArchives.getDocname()); - saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统 - - //收发类别 - saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); - saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname()); - - //2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传! - //店铺 - saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc()); - saleorderRequestParentDto.setVdef1(shopArchives.getDocname()); - - //单据红字标识 - saleorderRequestParentDto.setPk_defdoc16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键")); - saleorderRequestParentDto.setVdef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称")); - - saleorderRequestDto.setParentvo(saleorderRequestParentDto); - - List saleorderRequestChildrenDtoList = new ArrayList<>(); - saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); - - //验证是否为指定的店铺,如果为true,则取结存价 - Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); - //把汇总好的出库单明细行合并成一行 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose); - - //存货管理档案:取发货公司的存货管理档案 - BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); - //存货基础档案 - BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity(); - //根据存货基础档案编码,查询当前存货的税率 - BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity(); - //查询收支项目 -// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity); -// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity); - -// String tax = new BigDecimal(bdTaxitemsEntity1.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); +// /** +// * 交易采购,按指定时间拉取 +// * +// * @author liuyang +// */ +// public void startImplementByTradeTime(String startTime, String endTime, String pushScenarioType) throws Exception { +// try { +// long startMillis = System.currentTimeMillis(); +// String threadNameStrStart = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{}", startTime, endTime); +// logger.info(threadNameStrStart); // -// BigDecimal noriginalcurprice = null;//无税单价 -// BigDecimal noriginalcurmny = null;//无税金额 -// BigDecimal noriginalcurtaxprice = null;//含税单价 -// BigDecimal noriginalcursummny = null;//价税合计 -// BigDecimal noriginalcurtaxmny = null;//税额=价税合计-无税金额 -// try { -// noriginalcurtaxprice = goodsRertunSonDetailsDto.getGroupTotalPayAmount().divide(goodsRertunSonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); -// noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); -// noriginalcurmny = noriginalcurprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); -// noriginalcursummny = noriginalcurtaxprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); -// noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); -// } catch (Exception e) { -// logger.error("TOC退货-确认收入,金额计算错误", e); -// Assert.state(false, "U8C红字销售订单,金额计算错误,原因:{}", e.getMessage()); -// } - - //判断是否为赠品 - Boolean isblargessflag = false; - if ("0".equals(goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString())) { - isblargessflag = true; - } - - SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto(); - saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品 - saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 - saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 - saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 - saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种 - saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id - saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 - saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期 - saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期 - saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率 - saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣 - saleorderRequestChildrenDto.setNnumber("-" + goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量 - saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额 -// saleorderRequestChildrenDto.setNoriginalcurmny("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额 -// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价 -// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价 -// saleorderRequestChildrenDto.setNoriginalcursummny("-" + noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计 - saleorderRequestChildrenDto.setNoriginalcursummny("-" + goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());//价税合计 新逻辑 -// saleorderRequestChildrenDto.setNoriginalcurtaxmny("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额 -// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 -// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 -// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 -// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 -// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); - //如果优惠金额为0,则传0 - if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef4("0"); - } - if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef5("0"); - } - if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef6("0"); - } - if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); - } else { - saleorderRequestChildrenDto.setVdef7("0"); - } - saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); - - //退货没有邮费金额,已经向万万确认 - //平台优惠 - if (goodsRertunSonDetailsDto.getVdef4() != null) { - BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4(); - if (vdef4.compareTo(BigDecimal.ZERO) > 0) { - //发货运费-存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01"); - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); - //存货对应的税率 - BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); - //补充:平台优惠-存货 - BigDecimal absAccumulatedPostage = vdef4.abs(); - BigDecimal negativeValue = absAccumulatedPostage.negate(); - queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); - } - } - //达人优惠 - if (goodsRertunSonDetailsDto.getVdef6() != null) { - BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6(); - if (vdef6.compareTo(BigDecimal.ZERO) > 0) { - //发货运费-存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02"); - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); - //存货对应的税率 - BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); - //补充:达人优惠-存货 - BigDecimal absAccumulatedPostage = vdef6.abs(); - BigDecimal negativeValue = absAccumulatedPostage.negate(); - queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); - } - } - //支付优惠 - if (goodsRertunSonDetailsDto.getVdef5() != null) { - BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5(); - if (vdef5.compareTo(BigDecimal.ZERO) > 0) { - //发货运费-存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04"); - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); - //存货对应的税率 - BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); - //补充:支付优惠-存货 - BigDecimal absAccumulatedPostage = vdef5.abs(); - BigDecimal negativeValue = absAccumulatedPostage.negate(); - queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); - } - } - - if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) { - //推送U8C - List saleorderRequestDtoList = new ArrayList<>(); - saleorderRequestDtoList.add(saleorderRequestDto); - Map> stringStringMap = new HashMap<>(); - stringStringMap.put("saleorder", saleorderRequestDtoList); - SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); - String vreceiptcode = null; - String pk_corp = null; - String csaleid = null; - if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) { - vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode(); - pk_corp = soSaleResultRootDto.getParentvo().getPk_corp(); - csaleid = soSaleResultRootDto.getParentvo().getCsaleid(); - } - logger.info("TOC销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); - updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid); - } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) { - //不推送U8C,单据暂存 - String vreceiptcode = "暂存"; - String csaleid = "暂存"; - String newstate = "S"; - String newTransmitInfo = "暂存"; - updateSuccessOrFail2(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid); - } else { - Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType); - } - } catch (Exception e) { - logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e); - //记录失败 - String message = e.getMessage(); - if (message == null) { - message = "未知错误"; - } - updateSuccessOrFail2(oldValue, "N", message, null, null); - } - } - } else { - //2024年8月6日 11:28:54此处不记录失败,不认为是错误 - logger.info("summaryDimensionMap变量或者bdBusitypeEntity变量为空,因此主要的推送逻辑不会被执行!"); - } - } catch (Exception e) { - logger.error("外层转换逻辑抛出异常", e); - } - } - } - - /** - * 2024年8月9日 15:43:13 - * 生成业务日期:取「入库时间」、还是取「结束收货时间」 - * - * @author liuyang - */ - private String createGenerateBusinessDate(StockinOrderSearchResponse.StockinOrder.StockinH header) { - //测试 -// header.setClosedAt("2024-11-29 10:00:12"); - String code = null; - if (header != null && header.getCode() != null) { - code = header.getCode(); - } - if (header != null && header.getClosedAt() != null) { - //TOC以出库日期作为业务日期 - String closedAt = header.getClosedAt(); - String businessFormat = null; - try { - Date dbill = DateUtil.parse(closedAt); - businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); - } catch (Exception e) { - logger.error("业务日期生成失败closedAt(O关单时间)解析异常:{} O售后入库单号:{}", e.getMessage(), code); - Assert.state(false, "业务日期生成失败closedAt(O关单时间)解析异常:{} O售后入库单号:{}", e.getMessage(), code); - } - return businessFormat; - } else { - logger.error("业务日期生成失败closedAt(O关单时间)不能为空 O售后入库单号:{}", code); - Assert.state(false, "业务日期生成失败closedAt(O关单时间)不能为空 O售后入库单号:{}", code); - return null; - } - } - - /** - * 2024年8月28日 17:17:33 - * 生成业务日期,以交易成功时间作为业务日期 - * - * @author liuyang - */ - private String createSuccessFulTradeDate(StockinOrderSearchResponse.StockinOrder.StockinH stockinH) { - String code = null; - if (stockinH != null && stockinH.getCode() != null) { - code = stockinH.getCode(); - } - if (stockinH != null && stockinH.getRefundedAt() != null) { - String refundedAt = stockinH.getRefundedAt(); - - String businessFormat = null; - try { - //2025年1月22日 17:44:55 先暂时还是使用旧逻辑 - Date dbill = DateUtil.parse(refundedAt); -// Date dbill = DateUtil.parse(timeJudgment(stockinH)); - businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); - } catch (Exception e) { - logger.error("业务日期生成失败refundedAt(O退款完成时间)解析异常:{} O售后入库单编码:{}", e.getMessage(), code); - Assert.state(false, "业务日期生成失败refundedAt(O退款完成时间)解析异常:{} O售后入库单编码:{}", e.getMessage(), code); - } - return businessFormat; - } else { - logger.error("业务日期生成失败refundedAt(O退款完成时间)不能为空! O售后入库单编码:{}", code); - Assert.state(false, "业务日期生成失败refundedAt(O退款完成时间)不能为空! O售后入库单编码:{}", code); - return null; - } - } - - /** - * 先退款后退货场景时间判断 - */ - public String timeJudgment(StockinOrderSearchResponse.StockinOrder.StockinH stockinH) throws Exception { - Assert.notNull(stockinH, "stockinH不能为空!"); - Assert.notNull(stockinH.getRefundedAt(), "退款完成时间不能为空 O售后入库单号:{}", stockinH.getCode()); - Assert.notNull(stockinH.getClosedAt(), "入库完成时间(关单时间)不能为空 O售后入库单号:{}", stockinH.getCode()); - //退款完成时间 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date refundedAtDate = sdf.parse(stockinH.getRefundedAt()); - - //入库完成时间 - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date closedAtDate = sdf2.parse(stockinH.getClosedAt()); - - if (refundedAtDate.before(closedAtDate)) { - logger.info("O售后入库单:{} 入库时间:{} 退款完成时间:{} 「先退款」后退货", stockinH.getCode(), stockinH.getClosedAt(), stockinH.getRefundedAt()); - return stockinH.getClosedAt(); - } else { - logger.info("O售后入库单:{} 入库时间:{} 退款完成时间:{} 「先退货」后退款", stockinH.getCode(), stockinH.getClosedAt(), stockinH.getRefundedAt()); - return stockinH.getRefundedAt(); - } - } - - /** - * 档案转换(OFS->U8C) - * - * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单对象 - * @author liuyang - */ - private List queryBasicArchivesStock(List returnGoodHeaderDetailsDataDtoList1, String sceneType) { - Assert.notNull(returnGoodHeaderDetailsDataDtoList1, "returnGoodHeaderDetailsDataDtoList1不能为空"); - Assert.notNull(sceneType, "sceneType不能为空"); - - List sonDetailsDtoList = new ArrayList<>(); - List errorHeaderDetailsDtoDtoList = new ArrayList<>(); - - if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - try { - //初始化档案缓存 - CacheTocMapVoV2 cacheTocMapVoV2 = tocReturnBasicArchivesCacheUtil.initCache(returnGoodHeaderDetailsDataDtoList1); - //查询OFS售后入库单对应的售后订单 - List rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(returnGoodHeaderDetailsDataDtoList1); - findAfterSalesOrder(rerturnGoodsOrderSearchData, returnGoodHeaderDetailsDataDtoList1); - //测试 -// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData2 = rerturnGoodsOrderSearchData.get(0); -// List details2 = rerturnGoodsOrderSearchData2.getDetails(); -// for (int i = 0; i < details2.size(); i++) { -// RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details2.get(i); +// Assert.notNull(startTime, "startTime不能为空"); +// Assert.notNull(endTime, "endTime不能为空"); +// List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); // -// rerturnGoodsOrderSearchDetails.setPlatformDiscounts("1"); -// rerturnGoodsOrderSearchDetails.setMerchantDiscounts("1"); -// rerturnGoodsOrderSearchDetails.setExpertDiscounts("1"); -// rerturnGoodsOrderSearchDetails.setPayDiscounts("1"); +// if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) { +// //生成一个时间范围 +//// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime(); +// //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性 +// String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setTradeSuccessAt_start(startTime); +// queryOfsSoSaleOutVo.setTradeSuccessAt_end(endTime); +// queryOfsSoSaleOutVo.setClientCode("LETS"); +// queryOfsSoSaleOutVo.setPageNo(1L); +// queryOfsSoSaleOutVo.setPageSize(50L); +// queryOfsSoSaleOutVo.setStoreCode(tocShop); +//// queryOfsSoSaleOutVo.setInternalInstructionType("RETURN"); +//// queryOfsSoSaleOutVo.setRefundStatus("900"); +//// queryOfsSoSaleOutVo.setCode("LETS-RE2024081900000001"); +// ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.passive.order.search"); +// } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) { +// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); +// if (startTime.length() == 19) { +// tocofsReturngoodsDetailedEntity.setRefundedAtStart(startTime); +// } else { +// tocofsReturngoodsDetailedEntity.setRefundedAtStart(startTime + " 00:00:00"); // } - //查询OFS售后订单对应的OFS销售订单 - List headerDetailsDtos = queryBatchOfsOrder(returnGoodHeaderDetailsDataDtoList1); - findOfsOrder(headerDetailsDtos, returnGoodHeaderDetailsDataDtoList1); - //计算OFS销售订单优惠金额分摊到明细行 -// ofsOrderAfterSalesAmountAllocationUtil.batchTocSalesAmountAllocation(rerturnGoodsOrderSearchData); - //初始化公司档案对照关系 - Map comparisonCompanyArchives = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll(); - - //测试 -// StockinOrderSearchResponse.StockinOrder stockinOrder1 = returnGoodHeaderDetailsDataDtoList1.get(0); -// List details2 = stockinOrder1.getDetails(); -// for (int i = 0; i < details2.size(); i++) { -// StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details2.get(i); -// stockinB.setReceivedQty(stockinB.getRequestQty()); +// if (endTime.length() == 19) { +// tocofsReturngoodsDetailedEntity.setRefundedAtEnd(endTime); +// } else { +// tocofsReturngoodsDetailedEntity.setRefundedAtEnd(endTime + " 23:59:59"); // } - - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList1.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - - try { - //OFS售后订单 - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData1 = header.getRerturnGoodsOrderSearchData(); - Assert.notNull(header.getCode(), "OFS售后订单对应的code不能为空"); - Assert.notNull(rerturnGoodsOrderSearchData1, "无法关联到OFS售后订单 售后入库单号:{}", header.getCode().trim()); - //OFS销售订单 - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = header.getHeaderDetailsDto(); - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto.getHeader(); - List details1 = headerDetailsDto.getDetails(); - Assert.notNull(headerDetailsDto, "无法关联到OFS销售订单 售后入库单号:{}", header.getCode().trim()); - - //如果不存在,则默认一个 - if (header1.getSubOrderType() == null || "".equals(header1.getSubOrderType())) { - header1.setSubOrderType("SALES"); - } - BdRdclEntity bdRdclEntity = cacheTocMapVoV2.getStringBdRdclEntityMap().get(header1.getSubOrderType().trim()); - Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header1.getSubOrderType().trim()); - - String companyCode = header.getCompanyCode(); - Assert.notNull(companyCode, "O货主编码不能为空"); - //查找是否替换公司 - String targetCorp = comparisonCompanyArchives.get(companyCode); - if (targetCorp != null) { - companyCode = targetCorp; - } - BdCorpEntity bdCorpEntity = cacheTocMapVoV2.getStringBdCorpEntityMap().get(companyCode.trim()); - Assert.notNull(bdCorpEntity, "根据O公司编码(货主编码)({})没有匹配到U8C公司档案", header.getCompanyCode()); - - //发货库存组织 - BdCalbodyEntity bdCalbodyEntity = cacheTocMapVoV2.getStringBdCalbodyEntityMap().get(bdCorpEntity.getPkCorp()); - Assert.notNull(bdCalbodyEntity, "根据公司主键没有查询到发货库存组织 公司主键:{}", bdCorpEntity.getPkCorp()); - - //发货公司,暂时把O表头公司作为发货公司,正常情况下需要把O库存地点对于的公司作为发货公司 - - //发货仓库 - //2024年8月5日 15:06:38 仓库O与U两边仓库编码是一致的,和妮姐确认过了 - String facilityCode = header.getFacilityCode(); - Assert.notNull(facilityCode, "O仓库编码不能为空"); - BdStordocEntity bdStordocEntity = cacheTocMapVoV2.getStringBdStordocEntityMap().get(facilityCode.trim() + bdCalbodyEntity.getPkCalbody()); - Assert.notNull(bdStordocEntity, "没有匹配到发货仓库 O库存地点编码:{} 发货库存组织主键:{} ", facilityCode, bdCalbodyEntity.getPkCalbody()); - - //2024年8月5日 15:25:07 收货库存组织、收货仓库、默认和发货库存组织、发货仓库一致,已经和佳妮确认 - //收货库存组织:速网来看收货库存组织对应表头工具 - //收货仓库:通过收货库存组织+仓库编码,确定收货仓库 - - //销售组织2024年8月5日 15:33:40 和妮姐确认,销售组织和表头公司,作为一对一的关系, - BdSalestruEntity bdSalestruEntity = cacheTocMapVoV2.getStringBdSalestruEntityMap().get(bdCorpEntity.getUnitname()); - Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname()); - - //业务部门:暂定的部门名称:其他,2024年8月5日 15:39:42 已经和妮姐确认 - BdDeptdocEntity bdDeptdocEntity = null; - if (header1.getDepartmentType() == null || "".equals(header1.getDepartmentType().trim())) { - //默认业务部门 - logger.info("OFS销售订单号:{} 不存在部门字段!", header1.getCode()); - bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); - Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp()); - } else { - logger.info("OFS销售订单号:{} 存在部门字段:{}!", header1.getCode(), header1.getDepartmentType()); - String deptCode = header1.getDepartmentType().trim(); - bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMapByDeptCode().get(deptCode); - } - - //客商基本档案 - //2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 -// String custName = "天猫intoyou旗舰店-自营"; - String storeCode = header.getStoreCode(); - Assert.notNull(storeCode, "O店铺编码不能为空,没有办法完成业务逻辑!"); - Assert.state(!"".equals(storeCode.trim()), "O店铺编码不能为空,没有办法完成业务逻辑!"); - BdCubasdocEntity bdCubasdocEntity = cacheTocMapVoV2.getStringBdCubasdocEntityMap().get(storeCode.trim()); - Assert.notNull(bdCubasdocEntity, "无法匹配到客户档案 客商名称:{}", storeCode); - - //客商管理档案:2024年8月5日 15:41:54 TOC店铺名称查询U8C客商档案,已经和妮姐确认 - //2024年8月5日 15:49:49 先根据O店铺编码,得到店铺档案信息,取到名称,通过U8C接口查询出来 - //目前O店铺信息查询接口还没有,等待开发,所以我这里先写所一个名字 - BdCumandocEntity bdCumandocEntity = cacheTocMapVoV2.getStringBdCumandocEntityMap().get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp()); - Assert.notNull(bdCumandocEntity, "无法匹配到客商档案 店铺名称:{}", "天猫intoyou旗舰店-自营"); - - //查找平台 - String sourcePlatformCode = header.getSourcePlatformCode(); - Assert.notNull(sourcePlatformCode, "O平台编码不能为空!"); - BdDefdocEntity bdDefdocEntity = cacheTocMapVoV2.getStringBdDefdocEntityMap().get(sourcePlatformCode.trim()); - Assert.notNull(bdDefdocEntity, "根据O平台编码({})无法匹配到U8C平台档案", header.getSourcePlatformCode()); - - //查找店铺 -// String storeCode2 = header.getStoreCode(); -// Assert.notNull(storeCode2, "O店铺编码不能为空!"); - BdDefdocEntity bdDefdocEntity1 = cacheTocMapVoV2.getStringBdDefdocEntityMap1().get(storeCode.trim()); - Assert.notNull(bdDefdocEntity1, "根据O店铺编码({})无法匹配到U8C店铺档案", storeCode.trim()); - - //字段拷贝 - for (int j = 0; j < details.size(); j++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); - - //存货管理档案,是发货公司的存货档案 - Assert.notNull(stockinB.getSkuCode(), "skucode不能为空"); - BdInvmandocEntity bdInvmandocEntity = cacheTocMapVoV2.getStringBdInvmandocEntityMap().get(stockinB.getSkuCode().trim() + bdCorpEntity.getPkCorp()); - Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 货品sku:{} 公司:{}", stockinB.getSkuCode().trim(), bdCorpEntity.getPkCorp()); - //存货基本档案 - BdInvbasdocEntity bdInvbasdocEntity = cacheTocMapVoV2.getStringBdInvbasdocEntityMap().get(stockinB.getSkuCode().trim()); - Assert.notNull(bdInvbasdocEntity, "无法匹配到存货基本档案 存货编码:{}", stockinB.getSkuCode().trim()); - //存货税率 - BdTaxitemsEntity bdTaxitemsEntity = cacheTocMapVoV2.getStringBdTaxitemsEntityMap().get(bdInvmandocEntity.getInvcode()); - Assert.notNull(bdTaxitemsEntity, "无法匹配到存货税率 存货编码:{}", bdInvmandocEntity.getInvcode()); - - //2024年8月6日 10:16:22 通过O出库单的表头,查询得出U8C档案,放在表体的原因是方便分组汇总 - //下一个步骤的分组汇总,是通过表体明细完成的 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = new GoodsRertunSonDetailsDto(); - goodsRertunSonDetailsDto.setHeader(header); - goodsRertunSonDetailsDto.setBdCorpEntity(bdCorpEntity); - goodsRertunSonDetailsDto.setDeliverGoodsCorp(bdCorpEntity); - goodsRertunSonDetailsDto.setBdCalbodyEntity(bdCalbodyEntity); - goodsRertunSonDetailsDto.setBdStordocEntity(bdStordocEntity); - goodsRertunSonDetailsDto.setBdCalbodyEntity1(bdCalbodyEntity); - goodsRertunSonDetailsDto.setBdStordocEntity1(bdStordocEntity); - goodsRertunSonDetailsDto.setBdSalestruEntity(bdSalestruEntity); - goodsRertunSonDetailsDto.setBdDeptdocEntity(bdDeptdocEntity); - goodsRertunSonDetailsDto.setBdCumandocEntity(bdCumandocEntity); - goodsRertunSonDetailsDto.setBdCubasdocEntity(bdCubasdocEntity); - goodsRertunSonDetailsDto.setPlatformArchives(bdDefdocEntity); - goodsRertunSonDetailsDto.setBdRdclEntity(bdRdclEntity); - goodsRertunSonDetailsDto.setShopArchives(bdDefdocEntity1); - goodsRertunSonDetailsDto.setBdInvmandocEntity(bdInvmandocEntity); - goodsRertunSonDetailsDto.setBdInvbasdocEntity(bdInvbasdocEntity); - goodsRertunSonDetailsDto.setBdTaxitemsEntity(bdTaxitemsEntity); - - BeanUtil.copyPropertiesV2(stockinB, goodsRertunSonDetailsDto); - sonDetailsDtoList.add(goodsRertunSonDetailsDto); - //成功收集进入到集合 - } - } catch (Exception e) { - logger.error("档案转换抛出异常", e); - - //失败 - String message = e.getMessage(); - if (message == null) { - message = "未知错误"; - } - ErrorHeaderDetailsDtoDtoV2 errorHeaderDetailsDtoDto = new ErrorHeaderDetailsDtoDtoV2(); - errorHeaderDetailsDtoDto.setNewPushDate(getNewDateStr()); - errorHeaderDetailsDtoDto.setNewTransmitInfo(message); - errorHeaderDetailsDtoDto.setNewstate("N"); - errorHeaderDetailsDtoDto.setHeader(header); - errorHeaderDetailsDtoDto.setDetails(details); - errorHeaderDetailsDtoDtoList.add(errorHeaderDetailsDtoDto); - } - } - } catch (Exception e) { - logger.error("OFS销售出库单关联查询U8C档案失败", e); - } - } else { - logger.info("queryBasicArchives方法headerDetailsDtoList.size为0"); - } - //错误日志同步到数据 - if (errorHeaderDetailsDtoDtoList.size() > 0) { - updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(errorHeaderDetailsDtoDtoList, sceneType); - } - return sonDetailsDtoList; - } - - /** - * 对象拷贝 bean copy - * 2024年8月9日 11:23:57 - */ - private List copyHeaderDto(List stockinHS) { - List tocofsReturngoodsEntityArrayList = new ArrayList<>(); - if (stockinHS != null && stockinHS.size() > 0) { - for (int i = 0; i < stockinHS.size(); i++) { - StockinOrderSearchResponse.StockinOrder.StockinH stockinH = stockinHS.get(i); - - TocofsReturngoodsEntity tocofsReturngoodsEntity = new TocofsReturngoodsEntity(); - BeanUtil.copyPropertiesV2(stockinH, tocofsReturngoodsEntity); - tocofsReturngoodsEntityArrayList.add(tocofsReturngoodsEntity); - } - } else { - logger.info("需要复制{}个bean对象(O表头)", stockinHS.size()); - } - return tocofsReturngoodsEntityArrayList; - } - - /** - * 对象拷贝 bean copy - * 2024年8月9日 11:24:01 - */ - private List copyDetailsDto(List stockinBS) { - List tocofsSaleoutDetailedEntityArrayList = new ArrayList<>(); - if (stockinBS != null && stockinBS.size() > 0) { - for (int i = 0; i < stockinBS.size(); i++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = stockinBS.get(i); - - //表头 - StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto = stockinB.getReturnGoodSearchHeaderDto(); - - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - BeanUtil.copyPropertiesV2(stockinB, tocofsReturngoodsDetailedEntity); - //补充额外的字段信息 - createPrimaryKeyAndBusinessDateAndBusinessType(tocofsReturngoodsDetailedEntity, returnGoodSearchHeaderDto); - tocofsSaleoutDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity); - } - } else { - logger.info("需要复制{}个bean对象(O表体)", tocofsSaleoutDetailedEntityArrayList.size()); - } - return tocofsSaleoutDetailedEntityArrayList; - } - - /** - * 分组汇总:公司+店铺+仓库+SKU+出库类型,数量合并相加 - * 修改为:公司+店铺+仓库+SKU+收发类别+部门,数量合并相加 - * - * @author liuyang - */ - private Map> groupSummary(List goodsRertunSonDetailsDtos, String dimension) { - if (goodsRertunSonDetailsDtos != null && goodsRertunSonDetailsDtos.size() > 0) { - for (int i = 0; i < goodsRertunSonDetailsDtos.size(); i++) { - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = goodsRertunSonDetailsDtos.get(i); - //2024年8月6日 10:35:25表头对象用于带出表头相关的分组汇总信息 - StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader(); - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = header.getHeaderDetailsDto();//OFS销售订单 - - //公司 - BdCorpEntity bdCorpEntity = goodsRertunSonDetailsDto.getBdCorpEntity(); - //店铺(主要是店铺编码) - String storeCode = header.getStoreCode(); - //仓库 - String facilityCode = header.getFacilityCode(); - //SKU - String skuCode = goodsRertunSonDetailsDto.getSkuCode(); - //出库类型 -// String refOrderType = header.getRefOrderType(); - //收发类别 - BdRdclEntity bdRdclEntity = goodsRertunSonDetailsDto.getBdRdclEntity(); - //部门 - BdDeptdocEntity bdDeptdocEntity = goodsRertunSonDetailsDto.getBdDeptdocEntity(); - - StringBuffer summaryDimensionStr = new StringBuffer(); - if (bdCorpEntity != null && bdCorpEntity.getPkCorp() != null) { - summaryDimensionStr.append(bdCorpEntity.getPkCorp()); - } else { - summaryDimensionStr.append(NOTHING); - } - summaryDimensionStr.append(ADD); - - if (storeCode != null && !"".equals(storeCode)) { - summaryDimensionStr.append(storeCode); - } else { - summaryDimensionStr.append(NOTHING); - } - summaryDimensionStr.append(ADD); - - if (facilityCode != null && !"".equals(facilityCode)) { - summaryDimensionStr.append(facilityCode); - } else { - summaryDimensionStr.append(NOTHING); - } - summaryDimensionStr.append(ADD); - - if (skuCode != null && !"".equals(skuCode)) { - summaryDimensionStr.append(skuCode); - } else { - summaryDimensionStr.append(NOTHING); - } - summaryDimensionStr.append(ADD); - -// if (refOrderType != null && !"".equals(refOrderType)) { -// summaryDimensionStr.append(refOrderType); +// tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN"); +// returnGoodHeaderDetailsDataDtoArrayList = queryTocofsReturngoodsDetailed(tocofsReturngoodsDetailedEntity); +// } else { +// Assert.state(false, "未知的场景类型!"); +// } +// logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); +// if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { +// returnGoodHeaderDetailsDataDtoArrayList.removeIf(new Predicate() { +// @Override +// public boolean test(StockinOrderSearchResponse.StockinOrder headerDetailsDto) { +// StockinOrderSearchResponse.StockinOrder.StockinH header = headerDetailsDto.getHeader(); +// if (header != null && header.getCompanyCode() != null) { +// //过滤掉不需要的公司 +// if (ProfilesActiveConstant.FILTER_COMPANY.contains(header.getCompanyCode().trim())) { +// return true; +// } +// //过滤掉入库日期为空的单据 +// if (header.getClosedAt() == null || "".equals(header.getClosedAt().trim())) { +// return true; +// } +// } +// return false; +// } +// }); +// getSetTran(returnGoodHeaderDetailsDataDtoArrayList, pushScenarioType); +// } else { +// logger.info("没有查询到任何数据!不需要同步"); +// } +// +// long endMillis = System.currentTimeMillis(); +// String threadNameStrEnd = StrUtil.format("OFS售后入库(TOB)同步U8C销售订单(库存同步) 开始时间:{} 结束时间:{} 耗时:{}", startTime, endTime, (endMillis - startMillis)); +// logger.info(threadNameStrEnd); +// } catch (Exception e) { +// logger.error("startImplementByTradeTime方法抛出异常", e); +// } +// } +// +// /** +// * 无源件库存同步getSetStock方法发现逻辑 +// * +// * @author liuyang +// */ +// private void getSetStock(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { +// LOCK1.lock(); +// try { +// //过滤成功的数据 +// List data = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList); +// //保存到mysql底表 +// batchInsert(data); +// //执行推送主逻辑 +// implementStock(data); +// } catch (Exception e) { +// logger.error("TOC退货-库存:getSetStock方法抛出异常", e); +// } finally { +// LOCK1.unlock(); +// } +// } +// +// /** +// * 确认收入:预备执行逻辑 +// * +// * @author liuyang +// */ +// private void getSetTran(List returnGoodHeaderDetailsDataDtoArrayList, String pushScenarioType) throws Exception { +// LOCK2.lock(); +// try { +// //过滤成功的数据 +// List stockinOrderList = filterDataTran(returnGoodHeaderDetailsDataDtoArrayList); +// //保存到mysql +// if (!ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType)) { +// batchInsert(stockinOrderList); +// } +// //执行推送主逻辑 +// implementTran(stockinOrderList, pushScenarioType); +// } catch (Exception e) { +// logger.error("TOC退货-确认收入:getSetTran方法抛出异常", e); +// } finally { +// LOCK2.unlock(); +// } +// } +// +// /** +// * 库存同步,过滤掉成功的数据 +// * +// * @author liuyang +// */ +// private List filterDataStock(List passiveStorageResponseDataDtoArrayList) throws Exception { +// List ofsPassiveorderDetailEntitiesList = new ArrayList<>(); +// //查询每行无源入库单,对应的推送状态 +// if (passiveStorageResponseDataDtoArrayList != null && passiveStorageResponseDataDtoArrayList.size() > 0) { +// List> lists = SplitListByCountUtil.splitListByCount(passiveStorageResponseDataDtoArrayList, 1000); +// for (int i = 0; i < lists.size(); i++) { +// List data = lists.get(i); +// String idStr = commaConcatenatedPrimaryKeyStock(data); +// List ofsPassiveorderDetailEntities = queryStockTocOutLog(idStr); +// ofsPassiveorderDetailEntitiesList.addAll(ofsPassiveorderDetailEntities); +// } +// } +// return filterDataRowsAsPushOrFailedStock(ofsPassiveorderDetailEntitiesList, passiveStorageResponseDataDtoArrayList); +// } +// +// /** +// * 确认收入,过滤掉成功的数据 +// * +// * @author liuyang +// */ +// private List filterDataTran(List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { +//// List tocofsReturngoodsDetailedEntityList = new ArrayList<>(); +//// if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { +//// List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100); +//// for (int i = 0; i < splitListByCount.size(); i++) { +//// List stockinOrderList = splitListByCount.get(i); +//// String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList); +//// List tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr); +//// tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities); +//// } +//// } +//// return filterDataRowsAsPushOrFailedTran(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList); +// return null; +// } +// +// /** +// * 逗号拼接字符串主键,作为批处理的一部分,方便下一步的批量查询操作 +// * +// * @author liuyang +// */ +// private String commaConcatenatedPrimaryKeyStock(List headerDetailsDtoList2) throws Exception { +// StringBuffer idStr = new StringBuffer(); +// if (headerDetailsDtoList2 != null && headerDetailsDtoList2.size() > 0) { +// for (int i = 0; i < headerDetailsDtoList2.size(); i++) { +// PassiveStorageResponse.Data data = headerDetailsDtoList2.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// for (int j = 0; j < details.size(); j++) { +// PassiveStorageResponse.Details details1 = details.get(j); +// Assert.notNull(details1.getId(), "O明细主键不能为空!"); +// Assert.state(!"".equals(details1.getId()), "O明细主键不能为空!"); +// +// idStr.append("'"); +// idStr.append(details1.getId()); +// idStr.append("'"); +// idStr.append(","); +// } +// } +// } +// if (idStr.length() > 0) { +// return idStr.substring(0, idStr.length() - 1); +// } +// return null; +// } +// +// /** +// * 批查询toc退货入库日志,查询的量由splitListByCount方法控制 +// * +// * @author liuyang +// */ +// private List queryStockTocOutLog(String idStr) throws Exception { +// List tocofsReturngoodsDetailedEntities = null; +// if (idStr != null && !"".equals(idStr.trim())) { +// OfsPassiveorderDetailEntity ofsPassiveorderDetailEntity = new OfsPassiveorderDetailEntity(); +// ofsPassiveorderDetailEntity.setIds(idStr); +// tocofsReturngoodsDetailedEntities = iOfsPassiveorderDetailService.query(ofsPassiveorderDetailEntity); +// } else { +// logger.error("idStr为空,无法查询数据!"); +// } +// return tocofsReturngoodsDetailedEntities; +// } +// +// /** +// * 保存抓取到的数据到mysql底表,如果底表里已经存在,则会忽略,并且发生更新 +// * +// * @param passiveStorageResponseDataDtoArrayList 需要保存到 Mysql 底表的数据行 +// * @author liuyang +// */ +// private void batchInsert(List passiveStorageResponseDataDtoArrayList) throws Exception { +// if (passiveStorageResponseDataDtoArrayList != null && passiveStorageResponseDataDtoArrayList.size() > 0) { +// List headerDetailsDtoList1 = new ArrayList<>(); +// List headerDetailsDtoList2 = new ArrayList<>(); +// +// for (PassiveStorageResponse.Data index : passiveStorageResponseDataDtoArrayList) { +// //主表、明细表 +// PassiveStorageResponse.Header header = index.getHeader(); +// List details = index.getDetails(); +// if (details != null && details.size() > 0) { +// for (PassiveStorageResponse.Details passiveStorageResponseDetails : details) { +// passiveStorageResponseDetails.setHeader(header); +// } +// } +// headerDetailsDtoList1.add(header); +// headerDetailsDtoList2.addAll(details); +// } +// +// //每100作为一个批次插入主表,根据主键(id)判断是否重复,如果重复的,则不进行插入 +// List> lists = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 100); +// for (int i = 0; i < lists.size(); i++) { +// List headers = lists.get(i); +// +// final Throwable[] childException = {null}; +// long startTime = System.currentTimeMillis(); +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// try { +// List ofsPassiveorderHeaderEntities = copyHeaderDto(headers); +// if (ofsPassiveorderHeaderEntities.size() > 0) { +// logger.info("插入底表{}个对象(表头)", ofsPassiveorderHeaderEntities.size()); +// iOfsPassiveorderHeaderDao.entityInsertOrUpdateBatch(ofsPassiveorderHeaderEntities); +// } else { +// logger.info("ofsPassiveorderHeaderEntities:没有对象被插入表头底表"); +// } +// } catch (Exception e) { +// logger.error("线程保存无源件主表抛出异常", e); +// childException[0] = e; +// } +// } +// }); +// thread.start(); +// try { +// thread.join(); +// } catch (Exception e) { +// logger.error("线程保存TOC退货主表抛出异常", e); +// childException[0] = e; +// } +// long endTime = System.currentTimeMillis(); +// logger.info("插入或更新无源入库单表-耗时:{}", (endTime - startTime)); +// +// //如果子线程抛出异常,则反馈到主线程方便排查 +// if (childException[0] != null) { +// Assert.state(false, childException[0].getMessage()); +// } +// } +// +// //插入明细表 +// List> lists1 = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 100); +// for (int i = 0; i < lists1.size(); i++) { +// List details = lists1.get(i); +// List ofsPassiveorderDetailEntities = copyDetailsDto(details); +// +// final Throwable[] childException = {null}; +// long startTime = System.currentTimeMillis(); +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// try { +// if (ofsPassiveorderDetailEntities.size() > 0) { +// logger.info("插入底表{}个对象(表体)", ofsPassiveorderDetailEntities.size()); +// iOfsPassiveorderDetailDao.entityInsertOrUpdateBatch(ofsPassiveorderDetailEntities); +// } else { +// logger.info("ofsPassiveorderDetailEntities:没有对象被插入表头底表"); +// } +// } catch (Exception e) { +// logger.error("线程保存TOC退货明细抛出异常", e); +// childException[0] = e; +// } +// } +// }); +// thread.start(); +// try { +// thread.join(); +// } catch (Exception e) { +// logger.error("线程保存无源件明细表抛出异常", e); +// childException[0] = e; +// } +// long endTime = System.currentTimeMillis(); +// logger.info("插入或更新TOC退货入库表体-耗时:{}", (endTime - startTime)); +// //如果子线程抛出异常,则反馈到主线程方便排查 +// if (childException[0] != null) { +// Assert.state(false, childException[0].getMessage()); +// } +// } +// } +// } +// +// /** +// * 查询OFS售后退货入库单 +// * +// * @param queryOfsSoSaleOutVo 查询参数 +// * @param headerDetailsDtoList 查询结果集 +// * @param pageNo 从第pageNo页开始查询 +// */ +//// private void queryOfsReturnGoods(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo) throws Exception { +//// +//// Long pageSize = 200L; +//// queryOfsSoSaleOutVo.setPageNo(pageNo); +//// queryOfsSoSaleOutVo.setPageSize(pageSize); +//// +//// InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); +//// interfaceParamDto.setApi("ofs.receipt.search"); +//// interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); +//// RertunGoodsRootBean rertunGoodsRootBean = (RertunGoodsRootBean) ofsUnifiedService.unified(interfaceParamDto); +//// if (rertunGoodsRootBean != null) { +//// if ("false".equals(rertunGoodsRootBean.getError()) && "0".equals(rertunGoodsRootBean.getCode()) && "Success".equals(rertunGoodsRootBean.getMsg())) { +//// List returnGoodHeaderDetailsDataDtoList = rertunGoodsRootBean.getData(); +//// if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { +//// headerDetailsDtoList.addAll(returnGoodHeaderDetailsDataDtoList); +//// +//// //OFS没有提供分页字段,等待开发 +//// } +//// } else { +//// logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); +//// } +//// } else { +//// logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); +//// } +//// } +// +//// public void queryOfsSaleOrder() throws Exception { +//// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +//// queryOfsSoSaleOutVo.setCreated_start("2024-07-05 16:38:00"); +//// queryOfsSoSaleOutVo.setCreated_end("2024-07-05 16:40:30"); +//// queryOfsSoSaleOutVo.setClientCode("LETS"); +////// queryOfsSoSaleOutVo.setInternalInstructionType("SALES"); +//// queryOfsSoSaleOutVo.setCompanyCode("SHLZ"); +////// queryOfsSoSaleOutVo.setStatus(900L); +//// queryOfsSoSaleOutVo.setPageNo(1L); +//// queryOfsSoSaleOutVo.setPageSize(50L); +//// queryOfsSoSaleOutVo.setCode("LETS-SH2024070500000003"); +//// +//// InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); +//// interfaceParamDto.setApi("ofs.shipment.search"); +//// interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); +//// SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto); +//// System.out.println(saleOutReturnMessageDto); +//// } +// +// /** +// * 库存同步,代码同步逻辑 +// * +// * @param passiveStorageResponseList O无源入库单对象 +// * @author liuyang +// */ +// private void implementStock(List passiveStorageResponseList) throws Exception { +// Assert.notNull(passiveStorageResponseList, "passiveStorageResponseList不能为空"); +// logger.info("TOC无源件退货入库:{} 行需要进行数据转换", passiveStorageResponseList.size()); +// +// if (passiveStorageResponseList != null && passiveStorageResponseList.size() > 0) { +// try { +// // 查询基本档案 +// String sceneType = "stock"; +// List passiveStorageSonDetailsDtos = queryBasicArchivesStock(passiveStorageResponseList, sceneType); +// // 分组汇总 +// String dimension = null; +//// dimension = "1001&dy-intoyou&B2CHA20240033&6973391733588&SALES&002"; +// Map> stringListMap = groupSummary(passiveStorageSonDetailsDtos, dimension); +// // 查询U8C业务流程 +// BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); +// // 查询销售收发类别 +//// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); +// //初始化所有存货管理档案对应的结存价+采购价 +//// List mapList = initAllBalancePricePurchasePrice(); +// //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) +// List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); +// Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); +// String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); +// //查询存货对应的税目 +// Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); +// //查询「平台运费」对应的税率 +//// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); +// //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 +// Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); +// +// if (bdBusitypeEntity != null && stringListMap != null) { +// Iterator>> iterator = stringListMap.entrySet().iterator(); +// while (iterator.hasNext()) { +// Map.Entry> next = iterator.next(); +// String keyGroup = next.getKey(); +// List value = next.getValue(); +// +// PassiveStorageResponse.Header header = value.get(0).getHeader(); +// BdCorpEntity bdCorpEntity = value.get(0).getBdCorpEntity();//表头销售公司 +// BdCorpEntity deliverGoodsCorp = value.get(0).getDeliverGoodsCorp();//发货公司 +// BdCalbodyEntity bdCalbodyEntity = value.get(0).getBdCalbodyEntity();//发货仓库组织 +// BdStordocEntity bdStordocEntity = value.get(0).getBdStordocEntity();//发货仓库 +// BdCalbodyEntity bdCalbodyEntity1 = value.get(0).getBdCalbodyEntity1();//收货库存组织 +// BdStordocEntity bdStordocEntity1 = value.get(0).getBdStordocEntity1();//收货仓库 +// BdSalestruEntity bdSalestruEntity = value.get(0).getBdSalestruEntity();//销售组织 +// BdDeptdocEntity bdDeptdocEntity = value.get(0).getBdDeptdocEntity();//业务部门 +// BdCumandocEntity bdCumandocEntity = value.get(0).getBdCumandocEntity();//客商管理档案 +// BdCubasdocEntity bdCubasdocEntity = value.get(0).getBdCubasdocEntity();//客商基本档案 +// BdDefdocEntity platformArchives = value.get(0).getPlatformArchives();//U8C平台档案 +// BdDefdocEntity shopArchives = value.get(0).getShopArchives();//U8C店铺档案 +// BdRdclEntity bdRdclEntity = value.get(0).getBdRdclEntity();//U8C收发类别 +// +// try { +//// checkArchives(oldValue.get(0)); +// //生成业务日期 +// String generateBusinessDate = createGenerateBusinessDate(header); +// +// SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto(); +// SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto(); +// saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期 +// saleorderRequestParentDto.setBretinvflag("Y");//退货标记 +// saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程 +// saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织 +// saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位 +// saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门 +// saleorderRequestParentDto.setCemployeeid(null);//业务员 +// saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人 +// saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位 +// saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 +// saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织 +// saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库 +// saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期 +// saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣 +// saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id +// //汇总单号=汇总维度 +// saleorderRequestParentDto.setVdef18(keyGroup); +// //平台 +// saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc()); +// saleorderRequestParentDto.setVdef2(platformArchives.getDocname()); +// saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统 +// +// //收发类别 +// saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); +// saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname()); +// +// //2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传! +// //店铺 +// saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc()); +// saleorderRequestParentDto.setVdef1(shopArchives.getDocname()); +// +// //单据红字标识 +// saleorderRequestParentDto.setPk_defdoc16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键")); +// saleorderRequestParentDto.setVdef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称")); +// +// saleorderRequestDto.setParentvo(saleorderRequestParentDto); +// +// List saleorderRequestChildrenDtoList = new ArrayList<>(); +// saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); +// +// //验证是否为指定的店铺,如果为true,则取结存价 +// Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); +// +// //把汇总好的出库单明细行合并成一行 +// PassiveStorageSonDetailsDto passiveStorageSonDetailsDto = groupMergeDetailedRows(value, isCheckShopChoose); +// //存货管理档案:取发货公司的存货管理档案 +// BdInvmandocEntity bdInvmandocEntity = value.get(0).getBdInvmandocEntity(); +// //存货基础档案 +// BdInvbasdocEntity bdInvbasdocEntity = value.get(0).getBdInvbasdocEntity(); +// //根据存货基础档案编码,查询当前存货的税率 +// BdTaxitemsEntity bdTaxitemsEntity1 = value.get(0).getBdTaxitemsEntity(); +// +// //判断是否为赠品 +// Boolean isblargessflag = false; +// if ("0".equals(passiveStorageSonDetailsDto.getGroupTotalPayAmount().stripTrailingZeros().toPlainString())) { +// isblargessflag = true; +// } +// +// SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto(); +// saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品 +// saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 +// saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 +// saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 +// saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种 +// saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id +// saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 +// saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期 +// saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期 +// saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率 +// saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣 +// saleorderRequestChildrenDto.setNnumber("-" + passiveStorageSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量 +// saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额 +//// saleorderRequestChildrenDto.setNoriginalcurmny("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额 +//// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价 +//// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价 +//// saleorderRequestChildrenDto.setNoriginalcursummny("-" + noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计 +// saleorderRequestChildrenDto.setNoriginalcursummny("-" + passiveStorageSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());//价税合计 新逻辑 +//// saleorderRequestChildrenDto.setNoriginalcurtaxmny("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额 +//// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 +//// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 +//// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 +//// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 +//// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); +// //如果优惠金额为0,则传0 +// if (!"0".equals(passiveStorageSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef4("-" + passiveStorageSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef4("0"); +// } +// if (!"0".equals(passiveStorageSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef5("-" + passiveStorageSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef5("0"); +// } +// if (!"0".equals(passiveStorageSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef6("-" + passiveStorageSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef6("0"); +// } +// if (!"0".equals(passiveStorageSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef7("-" + passiveStorageSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef7("0"); +// } +// saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); +// +// //平台优惠 +// if (passiveStorageSonDetailsDto.getVdef4() != null) { +// BigDecimal vdef4 = passiveStorageSonDetailsDto.getVdef4(); +// if (vdef4.compareTo(BigDecimal.ZERO) > 0) { +// //发货运费-存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01"); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); +// //存货对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); +// //补充:平台优惠-存货 +// BigDecimal absAccumulatedPostage = vdef4.abs(); +// BigDecimal negativeValue = absAccumulatedPostage.negate(); +// queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); +// } +// } +// //达人优惠 +// if (passiveStorageSonDetailsDto.getVdef6() != null) { +// BigDecimal vdef6 = passiveStorageSonDetailsDto.getVdef6(); +// if (vdef6.compareTo(BigDecimal.ZERO) > 0) { +// //发货运费-存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02"); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); +// //存货对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); +// //补充:达人优惠-存货 +// BigDecimal absAccumulatedPostage = vdef6.abs(); +// BigDecimal negativeValue = absAccumulatedPostage.negate(); +// queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); +// } +// } +// //支付优惠 +// if (passiveStorageSonDetailsDto.getVdef5() != null) { +// BigDecimal vdef5 = passiveStorageSonDetailsDto.getVdef5(); +// if (vdef5.compareTo(BigDecimal.ZERO) > 0) { +// //发货运费-存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04"); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); +// //存货对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); +// //补充:支付优惠-存货 +// BigDecimal absAccumulatedPostage = vdef5.abs(); +// BigDecimal negativeValue = absAccumulatedPostage.negate(); +// queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); +// } +// } +// //推送u8c +// List saleorderRequestDtoList = new ArrayList<>(); +// saleorderRequestDtoList.add(saleorderRequestDto); +// Map> stringStringMap = new HashMap<>(); +// stringStringMap.put("saleorder", saleorderRequestDtoList); +// SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); +// String vreceiptcode = null; +// String pk_corp = null; +// String csaleid = null; +// if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) { +// vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode(); +// pk_corp = soSaleResultRootDto.getParentvo().getPk_corp(); +// csaleid = soSaleResultRootDto.getParentvo().getCsaleid(); +// } +// logger.info("TOC红字销售订单编号:{} 主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); +// updateSuccessOrFail1(value, "Y", "success", vreceiptcode, csaleid); +// } catch (Exception e) { +// //记录失败 +// logger.error("无源件业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e); +// String message = e.getMessage(); +// if (message == null) { +// message = "未知错误"; +// } +// updateSuccessOrFail1(value, "N", message, null, null); +// } +// } +// } else { +// //2024年8月6日 11:28:54此处不记录失败,不认为是错误 +// logger.info("summaryDimensionMap变量或者bdBusitypeEntity变量为空,因此主要的推送逻辑不会被执行!"); +// } +// } catch (Exception e) { +// logger.error("外层转换逻辑抛出异常", e); +// } +// } +// } +// +// /** +// * 到账成功:代码同步逻辑 +// * +// * @param returnGoodHeaderDetailsDataDtoList1 查询得到的O售后入库单对象 +// * @author liuyang +// */ +// private void implementTran(List returnGoodHeaderDetailsDataDtoList1, String pushScenarioType) throws Exception { +// Assert.notNull(pushScenarioType, "pushScenarioType不能为空"); +// if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { +// logger.info("TOC退货业务:{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size()); +// +// try { +// // 查询基本档案 +// String sceneType = "tran"; +// List goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1, sceneType); +// // 分组汇总 +// String dimension = null; +// Map> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos, dimension); +// // 查询U8C业务流程 +// BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); +// //初始化所有存货管理档案对应的结存价+采购价 +//// List mapList = initAllBalancePricePurchasePrice(); +// //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) +// List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); +// Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); +// String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); +// //查询存货对应的税目 +// Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); +// //查询「平台运费」对应的税率 +//// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); +// //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 +// Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); +// +// if (bdBusitypeEntity != null && summaryDimensionMap != null) { +// Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); +// while (iterator.hasNext()) { +// Map.Entry> entry = iterator.next(); +// String keyGroup = entry.getKey(); +// List oldValue = entry.getValue(); +// +// StockinOrderSearchResponse.StockinOrder.StockinH header = oldValue.get(0).getHeader(); +// BdCorpEntity bdCorpEntity = oldValue.get(0).getBdCorpEntity();//表头销售公司 +// BdCorpEntity deliverGoodsCorp = oldValue.get(0).getDeliverGoodsCorp();//发货公司 +// BdCalbodyEntity bdCalbodyEntity = oldValue.get(0).getBdCalbodyEntity();//发货仓库组织 +// BdStordocEntity bdStordocEntity = oldValue.get(0).getBdStordocEntity();//发货仓库 +// BdCalbodyEntity bdCalbodyEntity1 = oldValue.get(0).getBdCalbodyEntity1();//收货库存组织 +// BdStordocEntity bdStordocEntity1 = oldValue.get(0).getBdStordocEntity1();//收货仓库 +// BdSalestruEntity bdSalestruEntity = oldValue.get(0).getBdSalestruEntity();//销售组织 +// BdDeptdocEntity bdDeptdocEntity = oldValue.get(0).getBdDeptdocEntity();//业务部门 +// BdCumandocEntity bdCumandocEntity = oldValue.get(0).getBdCumandocEntity();//客商管理档案 +// BdCubasdocEntity bdCubasdocEntity = oldValue.get(0).getBdCubasdocEntity();//客商基本档案 +// BdDefdocEntity platformArchives = oldValue.get(0).getPlatformArchives();//U8C平台档案 +// BdDefdocEntity shopArchives = oldValue.get(0).getShopArchives();//U8C店铺档案 +// BdRdclEntity bdRdclEntity = oldValue.get(0).getBdRdclEntity();//U8C收发类别 +// +// try { +//// checkArchives(oldValue.get(0)); +// //生成业务日期 +// String generateBusinessDate = createSuccessFulTradeDate(header); +// +// SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto(); +// SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto(); +// saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期 +// saleorderRequestParentDto.setBretinvflag("Y");//退货标记 +// saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程 +// saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织 +// saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位 +// saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门 +// saleorderRequestParentDto.setCemployeeid(null);//业务员 +// saleorderRequestParentDto.setCoperatorid(OverallConstant.getOverAllValue("u8cApiZdrPK"));//制单人 +// saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位 +// saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位 +// saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织 +// saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库 +// saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期 +// saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣 +// saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id +// //汇总单号=汇总维度 +// saleorderRequestParentDto.setVdef18(keyGroup); +// //平台 +// saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc()); +// saleorderRequestParentDto.setVdef2(platformArchives.getDocname()); +// saleorderRequestParentDto.setVdef17(ProfilesActiveConstant.sourceSystem1);//来源系统 +// +// //收发类别 +// saleorderRequestParentDto.setPk_defdoc3(bdRdclEntity.getPkRdcl()); +// saleorderRequestParentDto.setVdef3(bdRdclEntity.getRdname()); +// +// //2024年8月8日 17:17:58 店铺档案自定义项1,先不传,后续维护好之后再传! +// //店铺 +// saleorderRequestParentDto.setPk_defdoc1(shopArchives.getPkDefdoc()); +// saleorderRequestParentDto.setVdef1(shopArchives.getDocname()); +// +// //单据红字标识 +// saleorderRequestParentDto.setPk_defdoc16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y主键")); +// saleorderRequestParentDto.setVdef16(OverallConstant.getOverAllValue("u8c自定义项档案-单据红字标识-Y名称")); +// +// saleorderRequestDto.setParentvo(saleorderRequestParentDto); +// +// List saleorderRequestChildrenDtoList = new ArrayList<>(); +// saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList); +// +// //验证是否为指定的店铺,如果为true,则取结存价 +// Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); +// //把汇总好的出库单明细行合并成一行 +// GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose); +// +// //存货管理档案:取发货公司的存货管理档案 +// BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); +// //存货基础档案 +// BdInvbasdocEntity bdInvbasdocEntity = oldValue.get(0).getBdInvbasdocEntity(); +// //根据存货基础档案编码,查询当前存货的税率 +// BdTaxitemsEntity bdTaxitemsEntity1 = oldValue.get(0).getBdTaxitemsEntity(); +// //查询收支项目 +//// BdInvclEntity bdInvclEntity = queryU8CEntityUtil.queryBdInvbasdocByBdInvcl(bdInvbasdocEntity); +//// BdCostsubjEntity bdCostsubjEntity = queryU8CEntityUtil.queryBdCostsubj(bdInvclEntity); +// +//// String tax = new BigDecimal(bdTaxitemsEntity1.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); +//// +//// BigDecimal noriginalcurprice = null;//无税单价 +//// BigDecimal noriginalcurmny = null;//无税金额 +//// BigDecimal noriginalcurtaxprice = null;//含税单价 +//// BigDecimal noriginalcursummny = null;//价税合计 +//// BigDecimal noriginalcurtaxmny = null;//税额=价税合计-无税金额 +//// try { +//// noriginalcurtaxprice = goodsRertunSonDetailsDto.getGroupTotalPayAmount().divide(goodsRertunSonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); +//// noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); +//// noriginalcurmny = noriginalcurprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); +//// noriginalcursummny = noriginalcurtaxprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); +//// noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); +//// } catch (Exception e) { +//// logger.error("TOC退货-确认收入,金额计算错误", e); +//// Assert.state(false, "U8C红字销售订单,金额计算错误,原因:{}", e.getMessage()); +//// } +// +// //判断是否为赠品 +// Boolean isblargessflag = false; +// if ("0".equals(goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString())) { +// isblargessflag = true; +// } +// +// SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto(); +// saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品 +// saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 +// saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 +// saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 +// saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种 +// saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id +// saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 +// saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期 +// saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);// 要求收货日期 +// saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率 +// saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣 +// saleorderRequestChildrenDto.setNnumber("-" + goodsRertunSonDetailsDto.getGroupShipQty().stripTrailingZeros().toPlainString());//数量 +// saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额 +//// saleorderRequestChildrenDto.setNoriginalcurmny("-" + noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额 +//// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价 +//// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价 +//// saleorderRequestChildrenDto.setNoriginalcursummny("-" + noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计 +// saleorderRequestChildrenDto.setNoriginalcursummny("-" + goodsRertunSonDetailsDto.getGroupTotalPayAmount().setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());//价税合计 新逻辑 +//// saleorderRequestChildrenDto.setNoriginalcurtaxmny("-" + noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额 +//// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 +//// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 +//// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 +//// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 +//// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); +// //如果优惠金额为0,则传0 +// if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef4("0"); +// } +// if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef5("0"); +// } +// if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef6("0"); +// } +// if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { +// saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); +// } else { +// saleorderRequestChildrenDto.setVdef7("0"); +// } +// saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); +// +// //退货没有邮费金额,已经向万万确认 +// //平台优惠 +// if (goodsRertunSonDetailsDto.getVdef4() != null) { +// BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4(); +// if (vdef4.compareTo(BigDecimal.ZERO) > 0) { +// //发货运费-存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01"); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); +// //存货对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); +// //补充:平台优惠-存货 +// BigDecimal absAccumulatedPostage = vdef4.abs(); +// BigDecimal negativeValue = absAccumulatedPostage.negate(); +// queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); +// } +// } +// //达人优惠 +// if (goodsRertunSonDetailsDto.getVdef6() != null) { +// BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6(); +// if (vdef6.compareTo(BigDecimal.ZERO) > 0) { +// //发货运费-存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02"); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); +// //存货对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); +// //补充:达人优惠-存货 +// BigDecimal absAccumulatedPostage = vdef6.abs(); +// BigDecimal negativeValue = absAccumulatedPostage.negate(); +// queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); +// } +// } +// //支付优惠 +// if (goodsRertunSonDetailsDto.getVdef5() != null) { +// BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5(); +// if (vdef5.compareTo(BigDecimal.ZERO) > 0) { +// //发货运费-存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04"); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); +// //存货对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); +// //补充:支付优惠-存货 +// BigDecimal absAccumulatedPostage = vdef5.abs(); +// BigDecimal negativeValue = absAccumulatedPostage.negate(); +// queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); +// } +// } +// +// if (ProfilesActiveConstant.PUSH_SCENE_TYPE_1.equals(pushScenarioType) || ProfilesActiveConstant.PUSH_SCENE_TYPE_2.equals(pushScenarioType)) { +// //推送U8C +// List saleorderRequestDtoList = new ArrayList<>(); +// saleorderRequestDtoList.add(saleorderRequestDto); +// Map> stringStringMap = new HashMap<>(); +// stringStringMap.put("saleorder", saleorderRequestDtoList); +// SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); +// String vreceiptcode = null; +// String pk_corp = null; +// String csaleid = null; +// if (soSaleResultRootDto != null && soSaleResultRootDto.getParentvo() != null) { +// vreceiptcode = soSaleResultRootDto.getParentvo().getVreceiptcode(); +// pk_corp = soSaleResultRootDto.getParentvo().getPk_corp(); +// csaleid = soSaleResultRootDto.getParentvo().getCsaleid(); +// } +// logger.info("TOC销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); +// updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid); +// } else if (ProfilesActiveConstant.PUSH_SCENE_TYPE_0.equals(pushScenarioType)) { +// //不推送U8C,单据暂存 +// String vreceiptcode = "暂存"; +// String csaleid = "暂存"; +// String newstate = "S"; +// String newTransmitInfo = "暂存"; +// updateSuccessOrFail2(oldValue, newstate, newTransmitInfo, vreceiptcode, csaleid); +// } else { +// Assert.state(false, "未知的场景类型 pushScenarioType={}", pushScenarioType); +// } +// } catch (Exception e) { +// logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e); +// //记录失败 +// String message = e.getMessage(); +// if (message == null) { +// message = "未知错误"; +// } +// updateSuccessOrFail2(oldValue, "N", message, null, null); +// } +// } +// } else { +// //2024年8月6日 11:28:54此处不记录失败,不认为是错误 +// logger.info("summaryDimensionMap变量或者bdBusitypeEntity变量为空,因此主要的推送逻辑不会被执行!"); +// } +// } catch (Exception e) { +// logger.error("外层转换逻辑抛出异常", e); +// } +// } +// } +// +// /** +// * 2025 年 3 月 12 日 15:53:27 +// * 生成业务日期:取「关联时间」,只能取关联时间,否则会存在跨月问题 +// * +// * @author liuyang +// */ +// private String createGenerateBusinessDate(PassiveStorageResponse.Header header) { +// String code = null; +// if (header != null && header.getReceiptCode() != null) { +// code = header.getReceiptCode(); +// } +// if (header != null && header.getRelatedAt() != null) { +// String closedAt = header.getRelatedAt(); +// String businessFormat = null; +// try { +// Date dbill = DateUtil.parse(closedAt); +// businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); +// } catch (Exception e) { +// logger.error("业务日期生成失败relatedAt(O 关联时间)解析异常:{} O 无源入库单号:{}", e.getMessage(), code); +// Assert.state(false, "业务日期生成失败closedAt(O 关联时间)解析异常:{} O 无源入库单号:{}", e.getMessage(), code); +// } +// return businessFormat; +// } else { +// logger.error("业务日期生成失败relatedAt(O 关联时间)不能为空 O 无源入库单号:{}", code); +// Assert.state(false, "业务日期生成失败relatedAt(O 关联时间)不能为空 O 无源入库单号:{}", code); +// return null; +// } +// } +// +// /** +// * 2024年8月28日 17:17:33 +// * 生成业务日期,以交易成功时间作为业务日期 +// * +// * @author liuyang +// */ +// private String createSuccessFulTradeDate(StockinOrderSearchResponse.StockinOrder.StockinH stockinH) { +// String code = null; +// if (stockinH != null && stockinH.getCode() != null) { +// code = stockinH.getCode(); +// } +// if (stockinH != null && stockinH.getRefundedAt() != null) { +// String refundedAt = stockinH.getRefundedAt(); +// +// String businessFormat = null; +// try { +// //2025年1月22日 17:44:55 先暂时还是使用旧逻辑 +// Date dbill = DateUtil.parse(refundedAt); +//// Date dbill = DateUtil.parse(timeJudgment(stockinH)); +// businessFormat = DateUtil.format(dbill, "yyyy-MM-dd"); +// } catch (Exception e) { +// logger.error("业务日期生成失败refundedAt(O退款完成时间)解析异常:{} O售后入库单编码:{}", e.getMessage(), code); +// Assert.state(false, "业务日期生成失败refundedAt(O退款完成时间)解析异常:{} O售后入库单编码:{}", e.getMessage(), code); +// } +// return businessFormat; +// } else { +// logger.error("业务日期生成失败refundedAt(O退款完成时间)不能为空! O售后入库单编码:{}", code); +// Assert.state(false, "业务日期生成失败refundedAt(O退款完成时间)不能为空! O售后入库单编码:{}", code); +// return null; +// } +// } +// +// /** +// * 先退款后退货场景时间判断 +// */ +// public String timeJudgment(StockinOrderSearchResponse.StockinOrder.StockinH stockinH) throws Exception { +// Assert.notNull(stockinH, "stockinH不能为空!"); +// Assert.notNull(stockinH.getRefundedAt(), "退款完成时间不能为空 O售后入库单号:{}", stockinH.getCode()); +// Assert.notNull(stockinH.getClosedAt(), "入库完成时间(关单时间)不能为空 O售后入库单号:{}", stockinH.getCode()); +// //退款完成时间 +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// Date refundedAtDate = sdf.parse(stockinH.getRefundedAt()); +// +// //入库完成时间 +// SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// Date closedAtDate = sdf2.parse(stockinH.getClosedAt()); +// +// if (refundedAtDate.before(closedAtDate)) { +// logger.info("O售后入库单:{} 入库时间:{} 退款完成时间:{} 「先退款」后退货", stockinH.getCode(), stockinH.getClosedAt(), stockinH.getRefundedAt()); +// return stockinH.getClosedAt(); +// } else { +// logger.info("O售后入库单:{} 入库时间:{} 退款完成时间:{} 「先退货」后退款", stockinH.getCode(), stockinH.getClosedAt(), stockinH.getRefundedAt()); +// return stockinH.getRefundedAt(); +// } +// } +// +// /** +// * 档案转换(OFS->U8C) +// * +// * @param passiveStorageResponseDataList OFS无源入库单 +// * @param sceneType 推送场景 +// * @author liuyang +// */ +// private List queryBasicArchivesStock(List passiveStorageResponseDataList, String sceneType) { +// Assert.notNull(passiveStorageResponseDataList, "returnGoodHeaderDetailsDataDtoList1不能为空"); +// Assert.notNull(sceneType, "sceneType不能为空"); +// +// List sonDetailsDtoList = new ArrayList<>(); +// List errorHeaderDetailsDtoDtoList = new ArrayList<>(); +// +// if (passiveStorageResponseDataList != null && passiveStorageResponseDataList.size() > 0) { +// try { +// //查询OFS无源入库单对应的售后订单,并关联无源无源入库单对象 +// List rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(passiveStorageResponseDataList); +// findAfterSalesOrder(rerturnGoodsOrderSearchData, passiveStorageResponseDataList); +// //查询OFS售后订单对应的OFS销售订单 +// List headerDetailsDtos = queryBatchOfsOrder(passiveStorageResponseDataList); +// findOfsOrder(headerDetailsDtos, passiveStorageResponseDataList); +// +// //初始化档案缓存 +// CacheTocMapVoV2 cacheTocMapVoV2 = passiveComponentsArchivesCacheUtil.initCache(passiveStorageResponseDataList); +// +// //初始化公司档案对照关系 +// Map comparisonCompanyArchives = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll(); +// +// for (int i = 0; i < passiveStorageResponseDataList.size(); i++) { +// PassiveStorageResponse.Data data = passiveStorageResponseDataList.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// +// try { +// //OFS售后订单 +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData1 = header.getRerturnGoodsOrderSearchData(); +// Assert.notNull(rerturnGoodsOrderSearchData1, "无法关联到OFS售后订单 售后无源入库单:{}", header.getReceiptCode().trim()); +// RerturnGoodsOrderSearchHeader header2 = rerturnGoodsOrderSearchData1.getHeader(); +// List details2 = rerturnGoodsOrderSearchData1.getDetails(); +// +// //OFS销售订单 +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = header.getHeaderDetailsDto(); +// Assert.notNull(headerDetailsDto, "无法关联到OFS销售订单 售后无源入库单:{}", header.getReceiptCode().trim()); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto.getHeader(); +// List details1 = headerDetailsDto.getDetails(); +// +// //如果不存在,则默认收发类别 +// if (header1.getSubOrderType() == null || "".equals(header1.getSubOrderType())) { +// header1.setSubOrderType("SALES"); +// } +// BdRdclEntity bdRdclEntity = cacheTocMapVoV2.getStringBdRdclEntityMap().get(header1.getSubOrderType().trim()); +// Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header1.getSubOrderType().trim()); +// +// String companyCode = header.getCompanyCode(); +// Assert.notNull(companyCode, "O货主编码不能为空"); +// //查找是否替换公司 +// String targetCorp = comparisonCompanyArchives.get(companyCode); +// if (targetCorp != null) { +// companyCode = targetCorp; +// } +// BdCorpEntity bdCorpEntity = cacheTocMapVoV2.getStringBdCorpEntityMap().get(companyCode.trim()); +// Assert.notNull(bdCorpEntity, "根据O公司编码(货主编码)({})没有匹配到U8C公司档案", header.getCompanyCode()); +// +// //发货库存组织 +// BdCalbodyEntity bdCalbodyEntity = cacheTocMapVoV2.getStringBdCalbodyEntityMap().get(bdCorpEntity.getPkCorp()); +// Assert.notNull(bdCalbodyEntity, "根据公司主键没有查询到发货库存组织 公司主键:{}", bdCorpEntity.getPkCorp()); +// +// //发货公司,暂时把O表头公司作为发货公司,正常情况下需要把O库存地点对于的公司作为发货公司 +// +// //发货仓库 +// //2024年8月5日 15:06:38 仓库O与U两边仓库编码是一致的,和妮姐确认过了 +// String facilityCode = header.getFacilityCode(); +// Assert.notNull(facilityCode, "O仓库编码不能为空"); +// BdStordocEntity bdStordocEntity = cacheTocMapVoV2.getStringBdStordocEntityMap().get(facilityCode.trim() + bdCalbodyEntity.getPkCalbody()); +// Assert.notNull(bdStordocEntity, "没有匹配到发货仓库 O库存地点编码:{} 发货库存组织主键:{} ", facilityCode, bdCalbodyEntity.getPkCalbody()); +// +// //2024年8月5日 15:25:07 收货库存组织、收货仓库、默认和发货库存组织、发货仓库一致,已经和佳妮确认 +// //收货库存组织:速网来看收货库存组织对应表头工具 +// //收货仓库:通过收货库存组织+仓库编码,确定收货仓库 +// +// //销售组织2024年8月5日 15:33:40 和妮姐确认,销售组织和表头公司,作为一对一的关系, +// BdSalestruEntity bdSalestruEntity = cacheTocMapVoV2.getStringBdSalestruEntityMap().get(bdCorpEntity.getUnitname()); +// Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname()); +// +// //业务部门:暂定的部门名称:其他,2024年8月5日 15:39:42 已经和妮姐确认 +// BdDeptdocEntity bdDeptdocEntity = null; +// if (header1.getDepartmentType() == null || "".equals(header1.getDepartmentType().trim())) { +// //默认业务部门 +// logger.info("OFS销售订单号:{} 不存在部门字段!", header1.getCode()); +// bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp()); +// Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:其他 对应公司名称:{}", bdCorpEntity.getPkCorp()); +// } else { +// logger.info("OFS销售订单号:{} 存在部门字段:{}!", header1.getCode(), header1.getDepartmentType()); +// String deptCode = header1.getDepartmentType().trim(); +// bdDeptdocEntity = cacheTocMapVoV2.getStringBdDeptdocEntityMapByDeptCode().get(deptCode); +// } +// +// //客商基本档案 +// //2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1,O没有店铺信息查询接口,因此无法通过出库单的店铺编码,查询到O店铺档案对应的业务编码,接口上线之后需要补充这一部分逻辑 +//// String custName = "天猫intoyou旗舰店-自营"; +// String storeCode = header.getStoreCode(); +// Assert.notNull(storeCode, "O店铺编码不能为空,没有办法完成业务逻辑!"); +// Assert.state(!"".equals(storeCode.trim()), "O店铺编码不能为空,没有办法完成业务逻辑!"); +// BdCubasdocEntity bdCubasdocEntity = cacheTocMapVoV2.getStringBdCubasdocEntityMap().get(storeCode.trim()); +// Assert.notNull(bdCubasdocEntity, "无法匹配到客户档案 客商名称:{}", storeCode); +// +// //客商管理档案:2024年8月5日 15:41:54 TOC店铺名称查询U8C客商档案,已经和妮姐确认 +// //2024年8月5日 15:49:49 先根据O店铺编码,得到店铺档案信息,取到名称,通过U8C接口查询出来 +// //目前O店铺信息查询接口还没有,等待开发,所以我这里先写所一个名字 +// BdCumandocEntity bdCumandocEntity = cacheTocMapVoV2.getStringBdCumandocEntityMap().get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp()); +// Assert.notNull(bdCumandocEntity, "无法匹配到客商档案 店铺名称:{}", "天猫intoyou旗舰店-自营"); +// +// //查找平台 +// String sourcePlatformCode = header2.getSourcePlatformCode(); +// Assert.notNull(sourcePlatformCode, "O平台编码不能为空!"); +// BdDefdocEntity bdDefdocEntity = cacheTocMapVoV2.getStringBdDefdocEntityMap().get(sourcePlatformCode.trim()); +// Assert.notNull(bdDefdocEntity, "根据O平台编码({})无法匹配到U8C平台档案", header2.getSourcePlatformCode()); +// +// //查找店铺 +//// String storeCode2 = header.getStoreCode(); +//// Assert.notNull(storeCode2, "O店铺编码不能为空!"); +// BdDefdocEntity bdDefdocEntity1 = cacheTocMapVoV2.getStringBdDefdocEntityMap1().get(storeCode.trim()); +// Assert.notNull(bdDefdocEntity1, "根据O店铺编码({})无法匹配到U8C店铺档案", storeCode.trim()); +// +// //字段拷贝 +// for (int j = 0; j < details.size(); j++) { +// PassiveStorageResponse.Details details3 = details.get(j); +// +// //存货管理档案,是发货公司的存货档案 +// Assert.notNull(details3.getSkuCode(), "skucode不能为空"); +// BdInvmandocEntity bdInvmandocEntity = cacheTocMapVoV2.getStringBdInvmandocEntityMap().get(details3.getSkuCode().trim() + bdCorpEntity.getPkCorp()); +// Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 货品sku:{} 公司:{}", details3.getSkuCode().trim(), bdCorpEntity.getPkCorp()); +// //存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity = cacheTocMapVoV2.getStringBdInvbasdocEntityMap().get(details3.getSkuCode().trim()); +// Assert.notNull(bdInvbasdocEntity, "无法匹配到存货基本档案 存货编码:{}", details3.getSkuCode().trim()); +// //存货税率 +// BdTaxitemsEntity bdTaxitemsEntity = cacheTocMapVoV2.getStringBdTaxitemsEntityMap().get(bdInvmandocEntity.getInvcode()); +// Assert.notNull(bdTaxitemsEntity, "无法匹配到存货税率 存货编码:{}", bdInvmandocEntity.getInvcode()); +// +// //2024年8月6日 10:16:22 通过O出库单的表头,查询得出U8C档案,放在表体的原因是方便分组汇总 +// //下一个步骤的分组汇总,是通过表体明细完成的 +// PassiveStorageSonDetailsDto goodsRertunSonDetailsDto = new PassiveStorageSonDetailsDto(); +// goodsRertunSonDetailsDto.setHeader(header); +// goodsRertunSonDetailsDto.setBdCorpEntity(bdCorpEntity); +// goodsRertunSonDetailsDto.setDeliverGoodsCorp(bdCorpEntity); +// goodsRertunSonDetailsDto.setBdCalbodyEntity(bdCalbodyEntity); +// goodsRertunSonDetailsDto.setBdStordocEntity(bdStordocEntity); +// goodsRertunSonDetailsDto.setBdCalbodyEntity1(bdCalbodyEntity); +// goodsRertunSonDetailsDto.setBdStordocEntity1(bdStordocEntity); +// goodsRertunSonDetailsDto.setBdSalestruEntity(bdSalestruEntity); +// goodsRertunSonDetailsDto.setBdDeptdocEntity(bdDeptdocEntity); +// goodsRertunSonDetailsDto.setBdCumandocEntity(bdCumandocEntity); +// goodsRertunSonDetailsDto.setBdCubasdocEntity(bdCubasdocEntity); +// goodsRertunSonDetailsDto.setPlatformArchives(bdDefdocEntity); +// goodsRertunSonDetailsDto.setBdRdclEntity(bdRdclEntity); +// goodsRertunSonDetailsDto.setShopArchives(bdDefdocEntity1); +// goodsRertunSonDetailsDto.setBdInvmandocEntity(bdInvmandocEntity); +// goodsRertunSonDetailsDto.setBdInvbasdocEntity(bdInvbasdocEntity); +// goodsRertunSonDetailsDto.setBdTaxitemsEntity(bdTaxitemsEntity); +// +// BeanUtil.copyPropertiesV2(details3, goodsRertunSonDetailsDto); +// sonDetailsDtoList.add(goodsRertunSonDetailsDto); +// //成功收集进入到集合 +// } +// } catch (Exception e) { +// logger.error("档案转换抛出异常", e); +// +// //失败 +// String message = e.getMessage(); +// if (message == null) { +// message = "未知错误"; +// } +// ErrorHeaderDetailsDtoDtoV3 errorHeaderDetailsDtoDto = new ErrorHeaderDetailsDtoDtoV3(); +// errorHeaderDetailsDtoDto.setNewPushDate(getNewDateStr()); +// errorHeaderDetailsDtoDto.setNewTransmitInfo(message); +// errorHeaderDetailsDtoDto.setNewstate("N"); +// errorHeaderDetailsDtoDto.setHeader(header); +// errorHeaderDetailsDtoDto.setDetails(details); +// errorHeaderDetailsDtoDtoList.add(errorHeaderDetailsDtoDto); +// } +// } +// } catch (Exception e) { +// logger.error("OFS无源入库单关联查询U8C档案失败", e); +// } +// } else { +// logger.info("queryBasicArchives方法passiveStorageResponseDataList.size为0"); +// } +// //错误日志同步到数据 +// if (errorHeaderDetailsDtoDtoList.size() > 0) { +// updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(errorHeaderDetailsDtoDtoList, sceneType); +// } +// return sonDetailsDtoList; +// } +// +// /** +// * 对象拷贝 bean copy +// * 2024年8月9日 11:23:57 +// */ +// private List copyHeaderDto(List stockinHS) { +// List ofsPassiveorderHeaderEntityArrayList = new ArrayList<>(); +// if (stockinHS != null && stockinHS.size() > 0) { +// for (int i = 0; i < stockinHS.size(); i++) { +// PassiveStorageResponse.Header header = stockinHS.get(i); +// +// OfsPassiveorderHeaderEntity ofsPassiveorderHeaderEntity = new OfsPassiveorderHeaderEntity(); +// BeanUtil.copyPropertiesV2(header, ofsPassiveorderHeaderEntity); +// ofsPassiveorderHeaderEntityArrayList.add(ofsPassiveorderHeaderEntity); +// } +// } else { +// logger.info("需要复制{}个bean对象(O表头)", stockinHS.size()); +// } +// return ofsPassiveorderHeaderEntityArrayList; +// } +// +// /** +// * 对象拷贝 bean copy +// * +// * @author liuyang +// */ +// private List copyDetailsDto(List stockinBS) { +// List ofsPassiveorderDetailEntityArrayList = new ArrayList<>(); +// if (stockinBS != null && stockinBS.size() > 0) { +// for (int i = 0; i < stockinBS.size(); i++) { +// PassiveStorageResponse.Details details = stockinBS.get(i); +// //表头 +// PassiveStorageResponse.Header header = details.getHeader(); +// //拷贝对象 +// OfsPassiveorderDetailEntity tocofsReturngoodsDetailedEntity = new OfsPassiveorderDetailEntity(); +// BeanUtil.copyPropertiesV2(details, tocofsReturngoodsDetailedEntity); +// //补充额外的字段信息 +// createPrimaryKeyAndBusinessDateAndBusinessType(tocofsReturngoodsDetailedEntity, header); +// ofsPassiveorderDetailEntityArrayList.add(tocofsReturngoodsDetailedEntity); +// } +// } else { +// logger.info("需要复制{}个bean对象(O表体)", ofsPassiveorderDetailEntityArrayList.size()); +// } +// return ofsPassiveorderDetailEntityArrayList; +// } +// +// /** +// * 分组汇总:公司+店铺+仓库+SKU+出库类型,数量合并相加 +// * 修改为:公司+店铺+仓库+SKU+收发类别+部门,数量合并相加 +// * +// * @author liuyang +// */ +// private Map> groupSummary(List goodsRertunSonDetailsDtos, String dimension) { +// if (goodsRertunSonDetailsDtos != null && goodsRertunSonDetailsDtos.size() > 0) { +// for (int i = 0; i < goodsRertunSonDetailsDtos.size(); i++) { +// PassiveStorageSonDetailsDto passiveStorageSonDetailsDto = goodsRertunSonDetailsDtos.get(i); +// //2024年8月6日 10:35:25表头对象用于带出表头相关的分组汇总信息 +// PassiveStorageResponse.Header header = passiveStorageSonDetailsDto.getHeader(); +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = header.getHeaderDetailsDto();//OFS销售订单 +// +// //公司 +// BdCorpEntity bdCorpEntity = passiveStorageSonDetailsDto.getBdCorpEntity(); +// //店铺(主要是店铺编码) +// String storeCode = header.getStoreCode(); +// //仓库 +// String facilityCode = header.getFacilityCode(); +// //SKU +// String skuCode = passiveStorageSonDetailsDto.getSkuCode(); +// //出库类型 +//// String refOrderType = header.getRefOrderType(); +// //收发类别 +// BdRdclEntity bdRdclEntity = passiveStorageSonDetailsDto.getBdRdclEntity(); +// //部门 +// BdDeptdocEntity bdDeptdocEntity = passiveStorageSonDetailsDto.getBdDeptdocEntity(); +// +// StringBuffer summaryDimensionStr = new StringBuffer(); +// if (bdCorpEntity != null && bdCorpEntity.getPkCorp() != null) { +// summaryDimensionStr.append(bdCorpEntity.getPkCorp()); // } else { // summaryDimensionStr.append(NOTHING); // } - - if (bdRdclEntity != null && bdRdclEntity.getRdcode() != null) { - summaryDimensionStr.append(bdRdclEntity.getRdcode()); - } else { - summaryDimensionStr.append(NOTHING); - } - summaryDimensionStr.append(ADD); - - if (bdDeptdocEntity != null && bdDeptdocEntity.getDeptcode() != null) { - summaryDimensionStr.append(bdDeptdocEntity.getDeptcode()); - } else { - summaryDimensionStr.append(NOTHING); - } - - goodsRertunSonDetailsDto.setSummaryDimensionStr(summaryDimensionStr.toString()); - } - logger.info("TOC:{} 个出库单对象需要汇总", goodsRertunSonDetailsDtos.size()); - if (dimension == null) { - return goodsRertunSonDetailsDtos.stream().collect(Collectors.groupingBy(GoodsRertunSonDetailsDto::getSummaryDimensionStr)); - } else { - Map> collect = goodsRertunSonDetailsDtos.stream().collect(Collectors.groupingBy(GoodsRertunSonDetailsDto::getSummaryDimensionStr)); - keepOnlyNeededKeys(collect, dimension); - return collect; - } - } - logger.info("TOC:0个对象需要汇总"); - return null; - } - - /** - * 移除不需要的键 - * - * @author liuyang - */ - private static void keepOnlyNeededKeys(Map> map, String... neededKeys) { - Iterator>> iterator = map.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry> entry = iterator.next(); - // 如果不是需要的键,则移除 - if (!contains(neededKeys, entry.getKey())) { - iterator.remove(); - } - } - } - - private static boolean contains(String[] array, String targetValue) { - for (String value : array) { - if (value.equals(targetValue)) { - return true; - } - } - return false; - } - - /** - * 2024年8月6日 10:59:03 查询U8C业务流程 - * - * @author liuyang - */ - public BdBusitypeEntity u8cOperationFlow() throws Exception { - //查询业务流程 - //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 - String processName = "TOC销售退货"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); - Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); - return bdBusitypeEntity; - } - - /** - * 2024年8月6日 10:59:03 查询U8C业务流程 - * - * @author liuyang - */ - private BdBusitypeEntity u8cOperationFlowV2() throws Exception { - //查询业务流程 - //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 - String processName = "TOC售后完成"; - BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); - Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); - return bdBusitypeEntity; - } - - /** - * 检查参数是否为空 - * 2024年8月6日 11:40:19 保险的做法,最好还是验证一下 - * - * @author liuyang - */ - private void checkArchives(GoodsRertunSonDetailsDto sonDetailsDto) { - Assert.notNull(sonDetailsDto, "sonDetailsDto不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getHeader(), "header对象不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdCorpEntity(), "表头公司不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdCalbodyEntity(), "发货库存组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdStordocEntity(), "发货仓库不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdCalbodyEntity1(), "收货库存组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdStordocEntity1(), "收货库存不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdSalestruEntity(), "销售组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdDeptdocEntity(), "业务部门不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getBdCumandocEntity(), "客商档案不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); - } - - /** - * 查询存货管理档案 - * - * @param pkCorp 发货公司主键 - * @param goodsRertunSonDetailsDto 出库单存货明细行 - * @author liuyang - */ -// private BdInvmandocEntity queryInventoryMan(GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, String pkCorp) { -// Assert.notNull(goodsRertunSonDetailsDto, "sonDetailsDto不能为空"); -// Assert.notNull(goodsRertunSonDetailsDto.getSkuCode(), "O存货商家编码不能为空"); -// Assert.notNull(pkCorp, "发货公司主键不能为空"); +// summaryDimensionStr.append(ADD); // -// BdInvmandocEntity bdInvmandocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvmandocEntityMap.get(goodsRertunSonDetailsDto.getSkuCode() + pkCorp); -// Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 存货商家编码:{} 存货发货公司:{}", goodsRertunSonDetailsDto.getSkuCode(), pkCorp); -// return bdInvmandocEntity; -// } - - /** - * 合并明细行 - * 单价计算公式:sum(实付金额/实发数量) 最后除以条数 - * - * @param sonDetailsDtoList 汇总过后的售后入库单明细 - * @param isCheckShopChoose true取建议零售价、false取实付金额 - * @author liuyang - */ - private GoodsRertunSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList, Boolean isCheckShopChoose) throws Exception { - Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); - Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); -// Assert.notNull(mapList, "mapLists不能为空"); - - if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { - BigDecimal groupTotalPayAmount = new BigDecimal("0"); - BigDecimal groupShipQty = new BigDecimal("0"); - - for (int i = 0; i < sonDetailsDtoList.size(); i++) { - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i);//O售后入库单明细行 - StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader();//O售后入库单表头 - - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 - RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData.getHeader();//OFS售后订单表头对象 - List details = rerturnGoodsOrderSearchData.getDetails();//OFS售后订单表体对象 - -// BdInvmandocEntity bdInvmandocEntity1 = goodsRertunSonDetailsDto.getBdInvmandocEntity();//存货管理档案 - BdInvbasdocEntity bdInvbasdocEntity = goodsRertunSonDetailsDto.getBdInvbasdocEntity();//存货基本档案 - BdInvmandocEntity bdInvmandocEntity = goodsRertunSonDetailsDto.getBdInvmandocEntity();//存货管理档案 - - //根据OFS售后入库单明细行,查找匹配OFS售后订单明细行 - RerturnGoodsOrderSearchDetails ofsOrderDetail = findOfsOrderDetail(details, goodsRertunSonDetailsDto); - - String totalAmount = null; - StringBuffer calculationFormulaStr = new StringBuffer(); - if (isCheckShopChoose) { - //取《U8C存货基本档案-参考售价》 - totalAmount = getRefsaleprice(bdInvmandocEntity, bdInvbasdocEntity, calculationFormulaStr, goodsRertunSonDetailsDto, header); - } else { - //取《O实退》 - totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); - } - - //取对应的售后订单明细,主要是取这个价格 -// String totalAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, goodsRertunSonDetailsDto, mapList, calculationFormulaStr); -// if (totalAmount == null) { -// calculationFormulaStr.append("取O实退金额:"); -// //取O实退金额 -//// RerturnGoodsOrderSearchDetails afterSalesOrder = findAfterSalesOrderV2(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData); -//// totalAmount = afterSalesOrder.getTotalAmount(); -// //测试 -//// goodsRertunSonDetailsDto.setReceivedQty("1"); -// totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); +// if (storeCode != null && !"".equals(storeCode)) { +// summaryDimensionStr.append(storeCode); +// } else { +// summaryDimensionStr.append(NOTHING); // } - //测试 -// goodsRertunSonDetailsDto.setReceivedQty("1"); - - Assert.notNull(totalAmount, "实退金额不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); - Assert.notNull(goodsRertunSonDetailsDto.getReceivedQty(), "实收数量不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); - - BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalAmount); - BigDecimal shipQtyBigDecimal = new BigDecimal(goodsRertunSonDetailsDto.getReceivedQty()); - - groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal); - groupShipQty = groupShipQty.add(shipQtyBigDecimal); - - goodsRertunSonDetailsDto.setCalculateAccountsReceivable(totalAmount); - goodsRertunSonDetailsDto.setCalculationFormula(calculationFormulaStr.toString()); - - goodsRertunSonDetailsDto.setPlatformDiscounts(ofsOrderDetail.getPlatformDiscounts()); - goodsRertunSonDetailsDto.setMerchantDiscounts(ofsOrderDetail.getMerchantDiscounts()); - goodsRertunSonDetailsDto.setExpertDiscounts(ofsOrderDetail.getExpertDiscounts()); - goodsRertunSonDetailsDto.setPayDiscounts(ofsOrderDetail.getPayDiscounts()); - } - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(0); - goodsRertunSonDetailsDto.setGroupShipQty(groupShipQty); - goodsRertunSonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount); - - //累加优惠金额 -// accumulationDiscountAmount(sonDetailsDtoList); - accumulatedDiscountAmountDef(sonDetailsDtoList); - -// logger.info("TOB{}个明细行发生了合并!", sonDetailsDtoList.size()); - return goodsRertunSonDetailsDto; - } else { - logger.info("sonDetailsDtoList集合是空的!"); - } - return null; - } - - /** - * 2024年8月7日 10:25:29 - * 查询基础档案,根据公司、管理档案主键查询 - * - * @author liuyang - */ -// private BdInvbasdocEntity queryStockBasicArchives(String pkInvmandoc, String pkCorp) { -// Assert.notNull(pkInvmandoc, "存货管理档案不能为空"); -// Assert.notNull(pkCorp, "公司档案不能为空"); -// BdInvbasdocEntity bdInvbasdocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvbasdocEntityHashMap.get(pkInvmandoc + pkCorp); -// Assert.notNull(bdInvbasdocEntity, "根据公司主键:{} 和存货管理档案主键:{} 没有查询到存货基本档案", pkCorp, pkInvmandoc); -// return bdInvbasdocEntity; +// summaryDimensionStr.append(ADD); +// +// if (facilityCode != null && !"".equals(facilityCode)) { +// summaryDimensionStr.append(facilityCode); +// } else { +// summaryDimensionStr.append(NOTHING); +// } +// summaryDimensionStr.append(ADD); +// +// if (skuCode != null && !"".equals(skuCode)) { +// summaryDimensionStr.append(skuCode); +// } else { +// summaryDimensionStr.append(NOTHING); +// } +// summaryDimensionStr.append(ADD); +// +// if (bdRdclEntity != null && bdRdclEntity.getRdcode() != null) { +// summaryDimensionStr.append(bdRdclEntity.getRdcode()); +// } else { +// summaryDimensionStr.append(NOTHING); +// } +// summaryDimensionStr.append(ADD); +// +// if (bdDeptdocEntity != null && bdDeptdocEntity.getDeptcode() != null) { +// summaryDimensionStr.append(bdDeptdocEntity.getDeptcode()); +// } else { +// summaryDimensionStr.append(NOTHING); +// } +// +// passiveStorageSonDetailsDto.setSummaryDimensionStr(summaryDimensionStr.toString()); +// } +// logger.info("无源件:{} 个出库单对象需要汇总", goodsRertunSonDetailsDtos.size()); +// if (dimension == null) { +// return goodsRertunSonDetailsDtos.stream().collect(Collectors.groupingBy(PassiveStorageSonDetailsDto::getSummaryDimensionStr)); +// } else { +// Map> collect = goodsRertunSonDetailsDtos.stream().collect(Collectors.groupingBy(PassiveStorageSonDetailsDto::getSummaryDimensionStr)); +// keepOnlyNeededKeys(collect, dimension); +// return collect; +// } +// } +// logger.info("无源件:0个对象需要汇总"); +// return null; // } - - /** - * 2024年8月7日 14:58:34 - * 查询税目档案 - * - * @author liuyang - */ -// private BdTaxitemsEntity queryBdTaxitems(String invcode) { -// Assert.notNull(invcode, "存货编码不能为空"); -// BdTaxitemsEntity bdTaxitemsEntity = TocReturnBasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode); -// Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode); -// return bdTaxitemsEntity; +// +// /** +// * 移除不需要的键 +// * +// * @author liuyang +// */ +// private static void keepOnlyNeededKeys(Map> map, String... neededKeys) { +// Iterator>> iterator = map.entrySet().iterator(); +// while (iterator.hasNext()) { +// Map.Entry> entry = iterator.next(); +// // 如果不是需要的键,则移除 +// if (!contains(neededKeys, entry.getKey())) { +// iterator.remove(); +// } +// } // } - - /** - * 2024年8月8日 10:54:48 - * 推送U8C销售订单方法 - * - * @author liuyang - */ - public SoSaleResultRootDto sendU8CTOCOrder(String param) { - long startLong = System.currentTimeMillis(); - logger.info("TOC推送开始,推送参数:" + param + ",U8C_URL:" + OverallConstant.getOverAllValue("u8c_url")); - String apiCode = "8000370006"; - String result = HttpRequest.post(OverallConstant.getOverAllValue("u8c_url")).header("appId", OverallConstant.getOverAllValue("appId"))//头信息,多个头信息多次调用此方法即可 - .header("usercode", OverallConstant.getOverAllValue("u8cApiUsercodePK")).header("password", OverallConstant.getOverAllValue("u8cApiPasswordPK")).header("system", OverallConstant.getOverAllValue("u8cApiSystemPK")).header("trantype", OverallConstant.getOverAllValue("u8cApiTrantypePK")).header("apiCode", apiCode)//头信息,多个头信息多次调用此方法即可 - .header("publicKey", OverallConstant.getOverAllValue("publicKey"))//头信息,多个头信息多次调用此方法即可 - .header("secretKey", OverallConstant.getOverAllValue("secretKey"))//头信息,多个头信息多次调用此方法即可 - .body(param)//表单内容 - .timeout(600000)//超时,毫秒 - .execute().body(); - logger.info("TOC推送结束,返回参数:" + result); - long endLong = System.currentTimeMillis(); - logger.info("TOC接口请求耗时:" + (endLong - startLong)); - - JSONObject jsonObject = JSON.parseObject(result); - result = String.valueOf(jsonObject.get("attribute")); - - boolean isSuccess = false; - SoSaleResultRootDto soSaleResultRootDto = null; - if (result != null && !"".equals(result)) { - ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); - if ("success".equals(reusltStrDto.getStatus())) { - soSaleResultRootDto = resultDataHandle(reusltStrDto.getData()); - isSuccess = true; - } - } - if (!isSuccess) { - Assert.state(false, "TOC业务O出库单推送U8C销售订单失败 接口返回结果:{}", result); - } - return soSaleResultRootDto; - } - - /** - * 返回结果解析处理,在确认了success后调用 - * - * @author liuyang - */ - private SoSaleResultRootDto resultDataHandle(String resultData) { - try { - if (resultData != null && !"".equals(resultData)) { - if (resultData.contains("[")) { - resultData = resultData.substring(1, resultData.length() - 1); - } - return JSON.parseObject(resultData, SoSaleResultRootDto.class); - } - } catch (Exception e) { - e.printStackTrace(); - logger.error("解析返回参数失败的错误", e); - //如果解析失败,记录原因,但是不能影响结果的记录 - } - return null; - } - - /** - * 填充主表主键、业务日期、业务类型 - * 2024年8月15日 17:31:54 - * - * @param tocofsReturngoodsDetailedEntity dao明细行对象 - * @param returnGoodSearchHeaderDto OFS售后入库单表头对象 - */ - private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto) { - if (tocofsReturngoodsDetailedEntity != null && returnGoodSearchHeaderDto != null) { - //主表主键 - if (returnGoodSearchHeaderDto.getId() != null) { - tocofsReturngoodsDetailedEntity.setMaintableid(returnGoodSearchHeaderDto.getId()); - } - //业务日期-入库时间 - if (returnGoodSearchHeaderDto.getClosedAt() != null) { - tocofsReturngoodsDetailedEntity.setBusinessdate(returnGoodSearchHeaderDto.getClosedAt()); - } - //业务日期-退款完成时间 - if (returnGoodSearchHeaderDto.getRefundedAt() != null) { - tocofsReturngoodsDetailedEntity.setRefundedat(returnGoodSearchHeaderDto.getRefundedAt()); - } - //业务类型 - tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN"); - } - } - - /** - * 通过OFS销售出库单,联查OFS销售订单 - * - * @param headerDetailsDtoList OFS销售出库单 - */ - private List queryOfsOrder(List headerDetailsDtoList) throws Exception { - List allHeaderDetailsDtoArrayList = new ArrayList<>(); - try { - if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); - for (int i = 0; i < splitListByCount.size(); i++) { - List headerDetailsDtos = splitListByCount.get(i); - - StringBuffer stringBuffer = new StringBuffer(); - if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { - for (int j = 0; j < headerDetailsDtos.size(); j++) { - HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j); - HeaderDto header = headerDetailsDto.getHeader(); -// List details = headerDetailsDto.getDetails(); -// stringBuffer.append("'"); - stringBuffer.append(header.getRefOrderCode()); -// stringBuffer.append("'"); - stringBuffer.append(","); - } - } - String substring = stringBuffer.substring(0, stringBuffer.length()); - - List headerDetailsDtoArrayList = new ArrayList<>(); - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setCode(substring); - ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); - allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList); - } - } - } catch (Exception e) { - logger.error("queryOfsOrder方法抛出异常", e); - } - return allHeaderDetailsDtoArrayList; - } - - /** - * 批量查询售后订单 - * - * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单 - * @author liuyang - */ - private List queryBatchAfterSalesOrder(List returnGoodHeaderDetailsDataDtoList1) { - List rerturnGoodsOrderSearchDataList = new ArrayList<>(); - if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - try { - //完成去重 - Set refOrderCodeSet = new HashSet<>(); -// List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoList1, 50); +// +// private static boolean contains(String[] array, String targetValue) { +// for (String value : array) { +// if (value.equals(targetValue)) { +// return true; +// } +// } +// return false; +// } +// +// /** +// * 2024年8月6日 10:59:03 查询U8C业务流程 +// * +// * @author liuyang +// */ +// public BdBusitypeEntity u8cOperationFlow() throws Exception { +// //查询业务流程 +// //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 +// String processName = "TOC销售退货"; +// BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); +// Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); +// return bdBusitypeEntity; +// } +// +// /** +// * 2024年8月6日 10:59:03 查询U8C业务流程 +// * +// * @author liuyang +// */ +// private BdBusitypeEntity u8cOperationFlowV2() throws Exception { +// //查询业务流程 +// //2024年8月6日 11:33:07 具体的业务流程名称,还需要实施提供 +// String processName = "TOC售后完成"; +// BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName); +// Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName); +// return bdBusitypeEntity; +// } +// +// /** +// * 检查参数是否为空 +// * 2024年8月6日 11:40:19 保险的做法,最好还是验证一下 +// * +// * @author liuyang +// */ +// private void checkArchives(GoodsRertunSonDetailsDto sonDetailsDto) { +// Assert.notNull(sonDetailsDto, "sonDetailsDto不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getHeader(), "header对象不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdCorpEntity(), "表头公司不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdCalbodyEntity(), "发货库存组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdStordocEntity(), "发货仓库不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdCalbodyEntity1(), "收货库存组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdStordocEntity1(), "收货库存不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdSalestruEntity(), "销售组织不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdDeptdocEntity(), "业务部门不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// Assert.notNull(sonDetailsDto.getBdCumandocEntity(), "客商档案不能为空 对象json:{}", JSON.toJSONString(sonDetailsDto)); +// } +// +// /** +// * 查询存货管理档案 +// * +// * @param pkCorp 发货公司主键 +// * @param goodsRertunSonDetailsDto 出库单存货明细行 +// * @author liuyang +// */ +//// private BdInvmandocEntity queryInventoryMan(GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, String pkCorp) { +//// Assert.notNull(goodsRertunSonDetailsDto, "sonDetailsDto不能为空"); +//// Assert.notNull(goodsRertunSonDetailsDto.getSkuCode(), "O存货商家编码不能为空"); +//// Assert.notNull(pkCorp, "发货公司主键不能为空"); +//// +//// BdInvmandocEntity bdInvmandocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvmandocEntityMap.get(goodsRertunSonDetailsDto.getSkuCode() + pkCorp); +//// Assert.notNull(bdInvmandocEntity, "无法匹配到存货管理档案 存货商家编码:{} 存货发货公司:{}", goodsRertunSonDetailsDto.getSkuCode(), pkCorp); +//// return bdInvmandocEntity; +//// } +// +// /** +// * 合并明细行 +// * 单价计算公式:sum(实付金额/实发数量) 最后除以条数 +// * +// * @param sonDetailsDtoList 汇总过后的售后入库单明细 +// * @param isCheckShopChoose true取建议零售价、false取实付金额 +// * @author liuyang +// */ +// private PassiveStorageSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList, Boolean isCheckShopChoose) throws Exception { +// Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); +// Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); +// +// if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { +// BigDecimal groupTotalPayAmount = new BigDecimal("0"); +// BigDecimal groupShipQty = new BigDecimal("0"); +// +// for (int i = 0; i < sonDetailsDtoList.size(); i++) { +// PassiveStorageSonDetailsDto passiveStorageSonDetailsDto = sonDetailsDtoList.get(i); +// PassiveStorageResponse.Header header = passiveStorageSonDetailsDto.getHeader(); +// +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 +// RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData.getHeader();//OFS售后订单表头对象 +// List details = rerturnGoodsOrderSearchData.getDetails();//OFS售后订单表体对象 +// +//// BdInvmandocEntity bdInvmandocEntity1 = goodsRertunSonDetailsDto.getBdInvmandocEntity();//存货管理档案 +// BdInvbasdocEntity bdInvbasdocEntity = passiveStorageSonDetailsDto.getBdInvbasdocEntity();//存货基本档案 +// BdInvmandocEntity bdInvmandocEntity = passiveStorageSonDetailsDto.getBdInvmandocEntity();//存货管理档案 +// +// //根据OFS售后入库单明细行,查找匹配OFS售后订单明细行 +// RerturnGoodsOrderSearchDetails ofsOrderDetail = findOfsOrderDetail(details, passiveStorageSonDetailsDto); +// +// String totalAmount = null; +// StringBuffer calculationFormulaStr = new StringBuffer(); +// if (isCheckShopChoose) { +// //取《U8C存货基本档案-参考售价》 +// totalAmount = getRefsaleprice(bdInvmandocEntity, bdInvbasdocEntity, calculationFormulaStr, passiveStorageSonDetailsDto); +// } else { +// //取《O实退》 +// totalAmount = accumulatedDiscounts(passiveStorageSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); +// } +// +// Assert.notNull(totalAmount, "计算出来的实退金额不能为空"); +// Assert.notNull(passiveStorageSonDetailsDto.getQuantity(), "实收数量不能为空"); +// +// BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalAmount); +// BigDecimal quantityBigDecimal = new BigDecimal(passiveStorageSonDetailsDto.getQuantity()); +// +// groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal); +// groupShipQty = groupShipQty.add(quantityBigDecimal); +// +// passiveStorageSonDetailsDto.setCalculateAccountsReceivable(totalAmount); +// passiveStorageSonDetailsDto.setCalculationFormula(calculationFormulaStr.toString()); +// +// passiveStorageSonDetailsDto.setPlatformDiscounts(ofsOrderDetail.getPlatformDiscounts()); +// passiveStorageSonDetailsDto.setMerchantDiscounts(ofsOrderDetail.getMerchantDiscounts()); +// passiveStorageSonDetailsDto.setExpertDiscounts(ofsOrderDetail.getExpertDiscounts()); +// passiveStorageSonDetailsDto.setPayDiscounts(ofsOrderDetail.getPayDiscounts()); +// } +// +// PassiveStorageSonDetailsDto passiveStorageSonDetailsDto = sonDetailsDtoList.get(0); +// passiveStorageSonDetailsDto.setGroupShipQty(groupShipQty); +// passiveStorageSonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount); +// +// //汇总好之后,相同的sku累加优惠金额 +// accumulatedDiscountAmountDef(sonDetailsDtoList); +// +// return passiveStorageSonDetailsDto; +// } else { +// logger.info("sonDetailsDtoList集合是空的!"); +// } +// return null; +// } +// +// /** +// * 2024年8月7日 10:25:29 +// * 查询基础档案,根据公司、管理档案主键查询 +// * +// * @author liuyang +// */ +//// private BdInvbasdocEntity queryStockBasicArchives(String pkInvmandoc, String pkCorp) { +//// Assert.notNull(pkInvmandoc, "存货管理档案不能为空"); +//// Assert.notNull(pkCorp, "公司档案不能为空"); +//// BdInvbasdocEntity bdInvbasdocEntity = TocReturnBasicArchivesCacheUtil.stringBdInvbasdocEntityHashMap.get(pkInvmandoc + pkCorp); +//// Assert.notNull(bdInvbasdocEntity, "根据公司主键:{} 和存货管理档案主键:{} 没有查询到存货基本档案", pkCorp, pkInvmandoc); +//// return bdInvbasdocEntity; +//// } +// +// /** +// * 2024年8月7日 14:58:34 +// * 查询税目档案 +// * +// * @author liuyang +// */ +//// private BdTaxitemsEntity queryBdTaxitems(String invcode) { +//// Assert.notNull(invcode, "存货编码不能为空"); +//// BdTaxitemsEntity bdTaxitemsEntity = TocReturnBasicArchivesCacheUtil.stringBdTaxitemsEntityHashMap.get(invcode); +//// Assert.notNull(bdTaxitemsEntity, "根据存货编码({}),无法匹配到税率!", invcode); +//// return bdTaxitemsEntity; +//// } +// +// /** +// * 2024年8月8日 10:54:48 +// * 推送U8C销售订单方法 +// * +// * @author liuyang +// */ +// public SoSaleResultRootDto sendU8CTOCOrder(String param) { +// long startLong = System.currentTimeMillis(); +// logger.info("TOC推送开始,推送参数:" + param + ",U8C_URL:" + OverallConstant.getOverAllValue("u8c_url")); +// String apiCode = "8000370006"; +// String result = HttpRequest.post(OverallConstant.getOverAllValue("u8c_url")).header("appId", OverallConstant.getOverAllValue("appId"))//头信息,多个头信息多次调用此方法即可 +// .header("usercode", OverallConstant.getOverAllValue("u8cApiUsercodePK")).header("password", OverallConstant.getOverAllValue("u8cApiPasswordPK")).header("system", OverallConstant.getOverAllValue("u8cApiSystemPK")).header("trantype", OverallConstant.getOverAllValue("u8cApiTrantypePK")).header("apiCode", apiCode)//头信息,多个头信息多次调用此方法即可 +// .header("publicKey", OverallConstant.getOverAllValue("publicKey"))//头信息,多个头信息多次调用此方法即可 +// .header("secretKey", OverallConstant.getOverAllValue("secretKey"))//头信息,多个头信息多次调用此方法即可 +// .body(param)//表单内容 +// .timeout(600000)//超时,毫秒 +// .execute().body(); +// logger.info("TOC推送结束,返回参数:" + result); +// long endLong = System.currentTimeMillis(); +// logger.info("TOC接口请求耗时:" + (endLong - startLong)); +// +// JSONObject jsonObject = JSON.parseObject(result); +// result = String.valueOf(jsonObject.get("attribute")); +// +// boolean isSuccess = false; +// SoSaleResultRootDto soSaleResultRootDto = null; +// if (result != null && !"".equals(result)) { +// ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class); +// if ("success".equals(reusltStrDto.getStatus())) { +// soSaleResultRootDto = resultDataHandle(reusltStrDto.getData()); +// isSuccess = true; +// } +// } +// if (!isSuccess) { +// Assert.state(false, "TOC业务O出库单推送U8C销售订单失败 接口返回结果:{}", result); +// } +// return soSaleResultRootDto; +// } +// +// /** +// * 返回结果解析处理,在确认了success后调用 +// * +// * @author liuyang +// */ +// private SoSaleResultRootDto resultDataHandle(String resultData) { +// try { +// if (resultData != null && !"".equals(resultData)) { +// if (resultData.contains("[")) { +// resultData = resultData.substring(1, resultData.length() - 1); +// } +// return JSON.parseObject(resultData, SoSaleResultRootDto.class); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// logger.error("解析返回参数失败的错误", e); +// //如果解析失败,记录原因,但是不能影响结果的记录 +// } +// return null; +// } +// +// /** +// * 填充主表主键、业务日期、业务类型 +// * 2024年8月15日 17:31:54 +// * +// * @param ofsPassiveorderDetailEntity 无源件明细表 dao 对象 +// * @param header O 无源件明细原始对象 +// */ +// private void createPrimaryKeyAndBusinessDateAndBusinessType(OfsPassiveorderDetailEntity ofsPassiveorderDetailEntity, PassiveStorageResponse.Header header) { +// if (ofsPassiveorderDetailEntity != null && header != null) { +// //主表主键 +// if (header.getId() != null) { +// ofsPassiveorderDetailEntity.setHeaderid(header.getId()); +// } +// //业务日期 +// if (header.getRelatedAt() != null) { +// ofsPassiveorderDetailEntity.setBusinessdate(header.getRelatedAt()); +// } +// //业务类型 +// ofsPassiveorderDetailEntity.setBusinesstype("TOC_ORDER"); +// } +// } +// +// /** +// * 通过OFS销售出库单,联查OFS销售订单 +// * +// * @param headerDetailsDtoList OFS销售出库单 +// */ +// private List queryOfsOrder(List headerDetailsDtoList) throws Exception { +// List allHeaderDetailsDtoArrayList = new ArrayList<>(); +// try { +// if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { +// List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); // for (int i = 0; i < splitListByCount.size(); i++) { -// List stockinOrderList = splitListByCount.get(i); -// //50个原始一个批次进行分割 -// StringBuffer idStr = new StringBuffer(); -// for (int j = 0; j < stockinOrderList.size(); j++) { -// StockinOrderSearchResponse.StockinOrder stockinOrder = stockinOrderList.get(j); -// StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); -//// List details = stockinOrder.getDetails(); -// idStr.append(header.getRefOrderCode()); -// idStr.append(","); -// } -// String idsStr = idStr.substring(0, idStr.length() - 1); +// List headerDetailsDtos = splitListByCount.get(i); // +// StringBuffer stringBuffer = new StringBuffer(); +// if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { +// for (int j = 0; j < headerDetailsDtos.size(); j++) { +// HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j); +// HeaderDto header = headerDetailsDto.getHeader(); +//// List details = headerDetailsDto.getDetails(); +//// stringBuffer.append("'"); +// stringBuffer.append(header.getRefOrderCode()); +//// stringBuffer.append("'"); +// stringBuffer.append(","); +// } +// } +// String substring = stringBuffer.substring(0, stringBuffer.length()); +// +// List headerDetailsDtoArrayList = new ArrayList<>(); // QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); -// queryOfsSoSaleOutVo.setCode(idsStr); -// afterSalesOrderUtil.getBatchOfsRertunOrder(queryOfsSoSaleOutVo, rerturnGoodsOrderSearchDataList, 1L); +// queryOfsSoSaleOutVo.setCode(substring); +// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); +// allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList); // } - //已经和万万确认,售后入库单明细行不会有合单的情况 - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList1.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - String refOrderCode = header.getRefOrderCode(); - if (refOrderCode != null && !"".equals(refOrderCode.trim())) { - refOrderCodeSet.add(refOrderCode.trim()); - } - } - if (refOrderCodeSet.size() > 0) { - List stringList = refOrderCodeSet.stream().collect(Collectors.toList()); - List> lists = SplitListByCountUtil.splitListByCount(stringList, 100); - for (int i = 0; i < lists.size(); i++) { - List strings = lists.get(i); - String result = strings.stream().map(s -> s.trim()).collect(Collectors.joining(",")); - if (result != null && result.length() > 0) { - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setCode(result); - afterSalesOrderUtil.getBatchOfsRertunOrder(queryOfsSoSaleOutVo, rerturnGoodsOrderSearchDataList, 1L); - } - } - } - } catch (Exception e) { - logger.error("批量查询关联售后订单抛出异常", e); - } - } - return rerturnGoodsOrderSearchDataList; - } - - /** - * 匹配售后订单 - * - * @param rerturnGoodsOrderSearchDataList OFS售后订单集合 - * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单集合 - * @author liuyang - */ - private void findAfterSalesOrder(List rerturnGoodsOrderSearchDataList, List returnGoodHeaderDetailsDataDtoList1) throws Exception { - if (rerturnGoodsOrderSearchDataList != null && rerturnGoodsOrderSearchDataList.size() > 0 && returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - try { - //key为售后订单主键,如果id为空,则这里会报错,所以把id设置为"" - rerturnGoodsOrderSearchDataList.forEach(dto -> { - if (dto.getHeader() != null && dto.getHeader().getId() == null) { - dto.getHeader().setId(""); - } - }); - Map collect = rerturnGoodsOrderSearchDataList.stream().collect(Collectors.toMap(dto -> dto.getHeader().getId(), dto -> dto)); - - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList1.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - -// Assert.notNull(header.getId(), "OFS售后入库单主键不能为空!"); -// for (int j = 0; j < rerturnGoodsOrderSearchDataList.size(); j++) { -// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = rerturnGoodsOrderSearchDataList.get(j); -// RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData.getHeader(); -// List details1 = rerturnGoodsOrderSearchData.getDetails(); -// if (header.getRefOrderId().equals(header1.getId())) { +// } +// } catch (Exception e) { +// logger.error("queryOfsOrder方法抛出异常", e); +// } +// return allHeaderDetailsDtoArrayList; +// } +// +// /** +// * 批量查询售后订单 +// * +// * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单 +// * @author liuyang +// */ +// private List queryBatchAfterSalesOrder(List returnGoodHeaderDetailsDataDtoList1) { +// List rerturnGoodsOrderSearchDataList = new ArrayList<>(); +// if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { +// try { +// //完成去重,已经和万万确认,售后入库单明细行不会有合单的情况 +// Set returnOrderCodeSet = new HashSet<>(); +// for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { +// PassiveStorageResponse.Data data = returnGoodHeaderDetailsDataDtoList1.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// +// String returnOrderCode = header.getReturnOrderCode(); +// if (returnOrderCode != null && !"".equals(returnOrderCode.trim())) { +// returnOrderCodeSet.add(returnOrderCode.trim()); +// } +// } +// +// if (returnOrderCodeSet.size() > 0) { +// List stringList = returnOrderCodeSet.stream().collect(Collectors.toList()); +// List> lists = SplitListByCountUtil.splitListByCount(stringList, 100); +// for (int i = 0; i < lists.size(); i++) { +// List strings = lists.get(i); +// String result = strings.stream().map(s -> s.trim()).collect(Collectors.joining(",")); +// if (result != null && result.length() > 0) { +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setCode(result); +// afterSalesOrderUtil.getBatchOfsRertunOrder(queryOfsSoSaleOutVo, rerturnGoodsOrderSearchDataList, 1L); +// } +// } +// } +// } catch (Exception e) { +// logger.error("批量查询关联售后订单抛出异常", e); +// Assert.state(false, "批量查询售后订单跑出异常,异常原因:{}", e.getMessage()); +// } +// } +// return rerturnGoodsOrderSearchDataList; +// } +// +// /** +// * 匹配售后订单 +// * +// * @param rerturnGoodsOrderSearchDataList OFS售后订单集合 +// * @param passiveStorageResponseList 无源入库单对象 +// * @author liuyang +// */ +// private void findAfterSalesOrder(List rerturnGoodsOrderSearchDataList, List passiveStorageResponseList) throws Exception { +// if (rerturnGoodsOrderSearchDataList != null && rerturnGoodsOrderSearchDataList.size() > 0 && passiveStorageResponseList != null && passiveStorageResponseList.size() > 0) { +// try { +// //key为售后订单主键,如果id为空,则这里会报错,所以把id设置为"" +// //使用 stream 完成快速查找 +// rerturnGoodsOrderSearchDataList.forEach(dto -> { +// if (dto.getHeader() != null && dto.getHeader().getId() == null) { +// dto.getHeader().setId(""); +// } +// }); +// Map collect = rerturnGoodsOrderSearchDataList.stream().collect(Collectors.toMap(dto -> dto.getHeader().getCode(), dto -> dto)); +// +// //查询关联匹配 +// for (int i = 0; i < passiveStorageResponseList.size(); i++) { +// PassiveStorageResponse.Data data = passiveStorageResponseList.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// +// String returnOrderCode = header.getReturnOrderCode(); +// if (returnOrderCode != null && !"".equals(returnOrderCode)) { +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = collect.get(returnOrderCode); +// if (rerturnGoodsOrderSearchData != null) { // header.setRerturnGoodsOrderSearchData(rerturnGoodsOrderSearchData); // } // } - String refOrderId = header.getRefOrderId(); - if (refOrderId != null && !"".equals(refOrderId)) { - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = collect.get(refOrderId); - if (rerturnGoodsOrderSearchData != null) { - header.setRerturnGoodsOrderSearchData(rerturnGoodsOrderSearchData); - } - } - } - } catch (Exception e) { - logger.error("findAfterSalesOrder方法抛出异常", e); - } - } - } - - /** - * 通过售后入库单明细行,查找售后订单明细行 - * - * @param stockinB 售后订单明细行 - * @param ofsRertunOrder OFS售后订单 - * @author liuyang - */ - private RerturnGoodsOrderSearchDetails findAfterSalesOrderV2(StockinOrderSearchResponse.StockinOrder.StockinB stockinB, RerturnGoodsOrderSearchData ofsRertunOrder) { - Assert.notNull(stockinB, "stockinB不能为空!"); - Assert.notNull(ofsRertunOrder, "saleOrderMessageDto不能为空!"); - - Assert.notNull(ofsRertunOrder.getHeader(), "售后订表头不能为空!"); - Assert.notNull(ofsRertunOrder.getDetails(), "售后订单表头"); - RerturnGoodsOrderSearchHeader header = ofsRertunOrder.getHeader(); - List details1 = ofsRertunOrder.getDetails(); - if (details1 == null || details1.size() == 0) { - Assert.state(false, "售后订单明细行不能为空,size不能为0!"); - } - for (int i = 0; i < details1.size(); i++) { - RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details1.get(i); - if (rerturnGoodsOrderSearchDetails.getId().equals(stockinB.getRefOrderDetailId())) { - return rerturnGoodsOrderSearchDetails; - } - } - Assert.state(false, "通过售后入库单号({})无法匹配到售后订单", stockinB.getId()); - return null; - } - - /** - * 通过售后入库单对应的售后订单,查询OFS销售订单 - * - * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单集合 - * @author liuyang - */ - private List queryBatchOfsOrder(List returnGoodHeaderDetailsDataDtoList1) throws Exception { - List headerDetailsDtoArrayList = new ArrayList<>(); - - if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - try { - Set refOrderCodeSet = new HashSet<>(); - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList1.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - if (header.getRerturnGoodsOrderSearchData() != null) { - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后入库单对应的「售后订单」 - RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData.getHeader(); - List details1 = rerturnGoodsOrderSearchData.getDetails(); - //得到「售后订单」关联的销售订单号 - if (header1.getRefOrderCode() != null && !"".equals(header1.getRefOrderCode())) { - refOrderCodeSet.add(header1.getRefOrderCode().trim()); - } - } - } - - //每50个作为一批,拆分 -// List> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoList1, 50); -// for (int i = 0; i < splitListByCount.size(); i++) { -// List stockinOrderList = splitListByCount.get(i); +// } // -// StringBuffer codes = new StringBuffer(); -// for (int j = 0; j < stockinOrderList.size(); j++) { -// StockinOrderSearchResponse.StockinOrder stockinOrder = stockinOrderList.get(j); -// StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); -// List details = stockinOrder.getDetails(); -// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData1 = header.getRerturnGoodsOrderSearchData();//OFS售后订单 -// if (rerturnGoodsOrderSearchData1 != null) { -// RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData1.getHeader(); -// List details1 = rerturnGoodsOrderSearchData1.getDetails(); -// codes.append(header1.getRefOrderCode()); -// codes.append(","); +// //去死皮 +// for (PassiveStorageResponse.Data data : passiveStorageResponseList) { +// PassiveStorageResponse.Header header = data.getHeader(); +// String returnOrderCode = header.getReturnOrderCode(); +// +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData(); +// if (rerturnGoodsOrderSearchData == null) { +// Assert.state(false, "无源入库单{}无法匹配到售后订单号 售后订单号:{}", header.getReceiptCode(), header.getReturnOrderCode()); +// } +// } +// } catch (Exception e) { +// logger.error("findAfterSalesOrder方法抛出异常", e); +// } +// } +// } +// +// /** +// * 通过售后入库单明细行,查找售后订单明细行 +// * +// * @param stockinB 售后订单明细行 +// * @param ofsRertunOrder OFS售后订单 +// * @author liuyang +// */ +// private RerturnGoodsOrderSearchDetails findAfterSalesOrderV2(StockinOrderSearchResponse.StockinOrder.StockinB stockinB, RerturnGoodsOrderSearchData ofsRertunOrder) { +// Assert.notNull(stockinB, "stockinB不能为空!"); +// Assert.notNull(ofsRertunOrder, "saleOrderMessageDto不能为空!"); +// +// Assert.notNull(ofsRertunOrder.getHeader(), "售后订表头不能为空!"); +// Assert.notNull(ofsRertunOrder.getDetails(), "售后订单表头"); +// RerturnGoodsOrderSearchHeader header = ofsRertunOrder.getHeader(); +// List details1 = ofsRertunOrder.getDetails(); +// if (details1 == null || details1.size() == 0) { +// Assert.state(false, "售后订单明细行不能为空,size不能为0!"); +// } +// for (int i = 0; i < details1.size(); i++) { +// RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details1.get(i); +// if (rerturnGoodsOrderSearchDetails.getId().equals(stockinB.getRefOrderDetailId())) { +// return rerturnGoodsOrderSearchDetails; +// } +// } +// Assert.state(false, "通过售后入库单号({})无法匹配到售后订单", stockinB.getId()); +// return null; +// } +// +// /** +// * 通过售后入库单对应的售后订单,查询OFS销售订单 +// * +// * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单集合 +// * @author liuyang +// */ +// private List queryBatchOfsOrder(List returnGoodHeaderDetailsDataDtoList1) throws Exception { +// List headerDetailsDtoArrayList = new ArrayList<>(); +// +// if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { +// try { +// Set refOrderCodeSet = new HashSet<>(); +// for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { +// PassiveStorageResponse.Data data = returnGoodHeaderDetailsDataDtoList1.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// +// if (header.getRerturnGoodsOrderSearchData() != null) { +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后入库单对应的「售后订单」 +// RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData.getHeader(); +// List details1 = rerturnGoodsOrderSearchData.getDetails(); +// //得到「售后订单」关联的销售订单号 +// if (header1.getRefOrderCode() != null && !"".equals(header1.getRefOrderCode())) { +// refOrderCodeSet.add(header1.getRefOrderCode().trim()); // } // } -// String codesStr = codes.substring(0, codes.length() - 1); -// -// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); -// queryOfsSoSaleOutVo.setCode(codesStr); -// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); // } - - //Set集合转List集合 - if (refOrderCodeSet.size() > 0) { - List stringList = refOrderCodeSet.stream().collect(Collectors.toList()); - List> lists = SplitListByCountUtil.splitListByCount(stringList, 100); - for (int i = 0; i < lists.size(); i++) { - List strings = lists.get(i); - String result = strings.stream().map(s -> s.trim()).collect(Collectors.joining(",")); - if (result != null && result.length() > 0) { - QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); - queryOfsSoSaleOutVo.setCode(result); - ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); - } - } - } - } catch (Exception e) { - logger.error("queryBatchOfsOrder方法抛出异常", e); - } - } - return headerDetailsDtoArrayList; - } - - /** - * 匹配OFS销售订单 - * - * @param headerDetailsDtoList OFS销售订单 - * @param returnGoodHeaderDetailsDataDtoList1 ofs售后入库单 - * @author liuyang - */ - private void findOfsOrder(List headerDetailsDtoList, List returnGoodHeaderDetailsDataDtoList1) { - if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0 && returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { - try { - headerDetailsDtoList.forEach(dto -> { - if (dto.getHeader() != null && dto.getHeader().getId() == null) { - dto.getHeader().setId(""); - } - }); - Map collect = headerDetailsDtoList.stream().collect(Collectors.toMap(dto -> dto.getHeader().getId(), dto -> dto)); - - for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoList1.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 - RerturnGoodsOrderSearchHeader header2 = rerturnGoodsOrderSearchData.getHeader(); - List details2 = rerturnGoodsOrderSearchData.getDetails(); -// for (int j = 0; j < headerDetailsDtoList.size(); j++) { -// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(j); -// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto.getHeader(); -// List details1 = headerDetailsDto.getDetails(); -// if (header2.getRefOrderId().equals(header1.getId())) { +// +// //Set集合转List集合 +// if (refOrderCodeSet.size() > 0) { +// List stringList = refOrderCodeSet.stream().collect(Collectors.toList()); +// List> lists = SplitListByCountUtil.splitListByCount(stringList, 100); +// for (int i = 0; i < lists.size(); i++) { +// List strings = lists.get(i); +// String result = strings.stream().map(s -> s.trim()).collect(Collectors.joining(",")); +// if (result != null && result.length() > 0) { +// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); +// queryOfsSoSaleOutVo.setCode(result); +// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); +// } +// } +// } +// } catch (Exception e) { +// logger.error("queryBatchOfsOrder方法抛出异常", e); +// } +// } +// return headerDetailsDtoArrayList; +// } +// +// /** +// * 匹配OFS销售订单 +// * +// * @param headerDetailsDtoList OFS销售订单 +// * @param returnGoodHeaderDetailsDataDtoList1 O无源入库单 +// * @author liuyang +// */ +// private void findOfsOrder(List headerDetailsDtoList, List returnGoodHeaderDetailsDataDtoList1) { +// if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0 && returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { +// try { +// headerDetailsDtoList.forEach(dto -> { +// if (dto.getHeader() != null && dto.getHeader().getId() == null) { +// dto.getHeader().setId(""); +// } +// }); +// Map collect = headerDetailsDtoList.stream().collect(Collectors.toMap(dto -> dto.getHeader().getId(), dto -> dto)); +// +// for (int i = 0; i < returnGoodHeaderDetailsDataDtoList1.size(); i++) { +// PassiveStorageResponse.Data data = returnGoodHeaderDetailsDataDtoList1.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// +// //OFS售后订单 +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData(); +// RerturnGoodsOrderSearchHeader header2 = rerturnGoodsOrderSearchData.getHeader(); +// List details2 = rerturnGoodsOrderSearchData.getDetails(); +// if (header2.getRefOrderId() != null && !"".equals(header2.getRefOrderId().trim())) { +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = collect.get(header2.getRefOrderId().trim()); +// if (headerDetailsDto != null) { // header.setHeaderDetailsDto(headerDetailsDto); // } // } - if (header2.getRefOrderId() != null && !"".equals(header2.getRefOrderId().trim())) { - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = collect.get(header2.getRefOrderId().trim()); - if (headerDetailsDto != null) { - header.setHeaderDetailsDto(headerDetailsDto); - } - } - } - } catch (Exception e) { - logger.error("findOfsOrder方法抛出异常", e); - } - } - } - - /** - * 生成当前日期 - * - * @author liuyang - */ - private String getNewDateStr() { - LocalDateTime now = LocalDateTime.now(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - return now.format(formatter); - } - - /** - * 批量修改成功、或者失败,适合档案查询的部分 - * - * @param errorHeaderDetailsDtoDtoList 错误日志 - * @param sceneType 场景类型 - * @author liuyang - */ - private void updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(List errorHeaderDetailsDtoDtoList, String sceneType) { - Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!"); - - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) { - List tocofsSaleoutDetailedEntityList = new ArrayList<>(); - for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) { - ErrorHeaderDetailsDtoDtoV2 errorHeaderDetailsDtoDtoV2 = errorHeaderDetailsDtoDtoList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = errorHeaderDetailsDtoDtoV2.getHeader(); - List details = errorHeaderDetailsDtoDtoV2.getDetails(); - String newstate = errorHeaderDetailsDtoDtoV2.getNewstate(); - String newPushDate = errorHeaderDetailsDtoDtoV2.getNewPushDate(); - String newTransmitInfo = errorHeaderDetailsDtoDtoV2.getNewTransmitInfo(); - - //如果报错内容太长了,则仅保留500个长度 - if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) { - newTransmitInfo = newTransmitInfo.substring(0, 400); - } - - for (int j = 0; j < details.size(); j++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); - - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - - tocofsReturngoodsDetailedEntity.setId(stockinB.getId()); - if (sceneType.equals("stock")) { - tocofsReturngoodsDetailedEntity.setNewpushdate3(newPushDate); - tocofsReturngoodsDetailedEntity.setNewtransmitinfo3(newTransmitInfo); - tocofsReturngoodsDetailedEntity.setNewstate3(newstate); - tocofsReturngoodsDetailedEntity.setNewsystemnumber3(null); - tocofsReturngoodsDetailedEntity.setNewsystemprimary3(null); - } else if (sceneType.equals("tran")) { - tocofsReturngoodsDetailedEntity.setNewpushdate4(newPushDate); - tocofsReturngoodsDetailedEntity.setNewtransmitinfo4(newTransmitInfo); - tocofsReturngoodsDetailedEntity.setNewstate4(newstate); - tocofsReturngoodsDetailedEntity.setNewsystemnumber4(null); - tocofsReturngoodsDetailedEntity.setNewsystemprimary4(null); - } - tocofsSaleoutDetailedEntityList.add(tocofsReturngoodsDetailedEntity); - } - } - - //以50行为一个批次更新状态 - if (tocofsSaleoutDetailedEntityList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); - for (int i = 0; i < splitListByCount.size(); i++) { - List tocofsReturngoodsDetailedEntities = splitListByCount.get(i); - if (sceneType.equals("stock")) { - //库存 - iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTocRerturnStock(tocofsReturngoodsDetailedEntities); - } else if (sceneType.equals("tran")) { - //确认收入 - iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTocRerturnTran(tocofsReturngoodsDetailedEntities); - } - } - } - } - } catch (Exception e) { - logger.error("TOB业务,填充出库明细日志抛出异常", e); - } - } - }); - thread.start(); - try { - thread.join(); - } catch (Exception e) { - logger.error("updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry方法现场抛出异常", e); - } - } - - /** - * 处理TOC-库存同步的成功、失败错误逻辑 - * - * @author liuyang - */ - private void updateSuccessOrFail1(List sonDetailsDtoList, String newstate, String newTransmitInfo, String newsystemnumber, String newsystemprimary) { - if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) { - newTransmitInfo = newTransmitInfo.substring(0, 400); - } - - String finalNewTransmitInfo = newTransmitInfo; - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - String successY = "Y"; - if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { - List tocofsReturngoodsDetailedEntityArrayList = new ArrayList<>(); - for (int i = 0; i < sonDetailsDtoList.size(); i++) { - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); - - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - tocofsReturngoodsDetailedEntity.setId(goodsRertunSonDetailsDto.getId()); - tocofsReturngoodsDetailedEntity.setNewpushdate3(getNewDateStr()); - tocofsReturngoodsDetailedEntity.setNewtransmitinfo3(finalNewTransmitInfo); - tocofsReturngoodsDetailedEntity.setNewstate3(newstate); - tocofsReturngoodsDetailedEntity.setDef7(goodsRertunSonDetailsDto.getCalculateAccountsReceivable()); - tocofsReturngoodsDetailedEntity.setDef8(goodsRertunSonDetailsDto.getCalculationFormula()); - tocofsReturngoodsDetailedEntity.setDef9(goodsRertunSonDetailsDto.getPlatformDiscounts()); - tocofsReturngoodsDetailedEntity.setDef10(goodsRertunSonDetailsDto.getPayDiscounts()); - tocofsReturngoodsDetailedEntity.setDef11(goodsRertunSonDetailsDto.getExpertDiscounts()); - tocofsReturngoodsDetailedEntity.setDef12(goodsRertunSonDetailsDto.getMerchantDiscounts()); - if (successY.equals(newstate)) { - tocofsReturngoodsDetailedEntity.setNewsystemnumber3(newsystemnumber); - tocofsReturngoodsDetailedEntity.setNewsystemprimary3(newsystemprimary); - } - tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity); - } - - //以50行为一个批次,推送到Mysql - if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 50); - for (int i = 0; i < splitListByCount.size(); i++) { - List tocofsReturngoodsDetailedEntities = splitListByCount.get(i); - iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTocRerturnStock(tocofsReturngoodsDetailedEntities); - } - } - } - } catch (Exception e) { - logger.error("TOC库存同步日志,抛出异常", e); - } - } - }); - thread.start(); - try { - thread.join(); - } catch (Exception e) { - logger.error("updateSuccessOrFail1方法现场抛出异常", e); - } - } - - /** - * 处理TOC-库存同步的成功、失败错误逻辑 - * - * @author liuyang - */ - private void updateSuccessOrFail2(List sonDetailsDtoList, String newstate, String newTransmitInfo, String newsystemnumber, String newsystemprimary) { - if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) { - newTransmitInfo = newTransmitInfo.substring(0, 400); - } - - String finalNewTransmitInfo = newTransmitInfo; - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - try { - String successY = "Y"; - if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { - List tocofsReturngoodsDetailedEntityArrayList = new ArrayList<>(); - for (int i = 0; i < sonDetailsDtoList.size(); i++) { - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); - - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); - tocofsReturngoodsDetailedEntity.setId(goodsRertunSonDetailsDto.getId()); - tocofsReturngoodsDetailedEntity.setNewpushdate4(getNewDateStr()); - tocofsReturngoodsDetailedEntity.setNewtransmitinfo4(finalNewTransmitInfo); - tocofsReturngoodsDetailedEntity.setNewstate4(newstate); - tocofsReturngoodsDetailedEntity.setDef7(goodsRertunSonDetailsDto.getCalculateAccountsReceivable()); - tocofsReturngoodsDetailedEntity.setDef8(goodsRertunSonDetailsDto.getCalculationFormula()); - tocofsReturngoodsDetailedEntity.setDef9(goodsRertunSonDetailsDto.getPlatformDiscounts()); - tocofsReturngoodsDetailedEntity.setDef10(goodsRertunSonDetailsDto.getPayDiscounts()); - tocofsReturngoodsDetailedEntity.setDef11(goodsRertunSonDetailsDto.getExpertDiscounts()); - tocofsReturngoodsDetailedEntity.setDef12(goodsRertunSonDetailsDto.getMerchantDiscounts()); - if (successY.equals(newstate)) { - tocofsReturngoodsDetailedEntity.setNewsystemnumber4(newsystemnumber); - tocofsReturngoodsDetailedEntity.setNewsystemprimary4(newsystemprimary); - } - tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity); - } - - //以50行为一个批次,推送到Mysql - if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 200); - for (int i = 0; i < splitListByCount.size(); i++) { - List tocofsReturngoodsDetailedEntities = splitListByCount.get(i); - iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTocRerturnTran(tocofsReturngoodsDetailedEntities); - } - } - } - } catch (Exception e) { - logger.error("TOC确认收入同步日志,抛出异常", e); - } - } - }); - thread.start(); - try { - thread.join(); - } catch (Exception e) { - logger.error("updateSuccessOrFail1方法现场抛出异常", e); - } - } - - /** - * 筛选出未推送、或者失败的数据行,过滤库存同步业务 - * - * @param tocofsReturngoodsDetailedEntityList 日志行状态 - * @param returnGoodHeaderDetailsDataDtoArrayList 返回结果 - * @author liuyang - */ - private List filterDataRowsAsPushOrFailedStock(List tocofsReturngoodsDetailedEntityList, List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { - List targetHeaderDetailsDtoList = new ArrayList<>(); - - if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - List resultList = tocofsReturngoodsDetailedEntityList.stream().map(obj -> { - if (obj.getNewstate3() == null) { - obj.setNewstate3(""); - } - return obj; - }).collect(Collectors.toList()); - Map no2NameMap = resultList.stream().collect(Collectors.toMap(TocofsReturngoodsDetailedEntity::getId, TocofsReturngoodsDetailedEntity::getNewstate3)); - - //字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行 - String succeseeY = "Y"; - String succeseeH = "H"; - for (int i = 0; i < returnGoodHeaderDetailsDataDtoArrayList.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoArrayList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - - List targetDetails = new ArrayList<>(); - for (int j = 0; j < details.size(); j++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); - Boolean isSuccess = false; - String newstate = null; -// if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) { -// for (int k = 0; k < tocofsReturngoodsDetailedEntityList.size(); k++) { -// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = tocofsReturngoodsDetailedEntityList.get(k); -// if (tocofsReturngoodsDetailedEntity.getId().equals(stockinB.getId())) { -// newstate = tocofsReturngoodsDetailedEntity.getNewstate3(); -// if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) { -// isSuccess = true; +// } +// } catch (Exception e) { +// logger.error("findOfsOrder方法抛出异常", e); +// Assert.state(false, "findOfsOrder方法抛出异常 错误详情:{}", e.getMessage()); +// } +// } +// } +// +// /** +// * 生成当前日期 +// * +// * @author liuyang +// */ +// private String getNewDateStr() { +// LocalDateTime now = LocalDateTime.now(); +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// return now.format(formatter); +// } +// +// /** +// * 批量修改成功、或者失败,适合档案查询的部分 +// * +// * @param errorHeaderDetailsDtoDtoV3List 错误日志 +// * @param sceneType 场景类型 +// * @author liuyang +// */ +// private void updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(List errorHeaderDetailsDtoDtoV3List, String sceneType) { +// Assert.notNull(errorHeaderDetailsDtoDtoV3List, "errorHeaderDetailsDtoDtoV3List不能为空!"); +// Assert.notNull(sceneType, "sceneType不能为空!"); +// +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// try { +// if (errorHeaderDetailsDtoDtoV3List != null && errorHeaderDetailsDtoDtoV3List.size() > 0) { +// List tocofsSaleoutDetailedEntityList = new ArrayList<>(); +// for (int i = 0; i < errorHeaderDetailsDtoDtoV3List.size(); i++) { +// ErrorHeaderDetailsDtoDtoV3 errorHeaderDetailsDtoDtoV3 = errorHeaderDetailsDtoDtoV3List.get(i); +// PassiveStorageResponse.Header header = errorHeaderDetailsDtoDtoV3.getHeader(); +// List details = errorHeaderDetailsDtoDtoV3.getDetails(); +// +// String newstate = errorHeaderDetailsDtoDtoV3.getNewstate(); +// String newPushDate = errorHeaderDetailsDtoDtoV3.getNewPushDate(); +// String newTransmitInfo = errorHeaderDetailsDtoDtoV3.getNewTransmitInfo(); +// String newsystemnumber = errorHeaderDetailsDtoDtoV3.getNewsystemnumber(); +// String newsystemprimary = errorHeaderDetailsDtoDtoV3.getNewsystemprimary(); +// +// //如果报错内容太长了,则仅保留400个长度,维护数据库性能,缓解资源公平使用 +// if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) { +// newTransmitInfo = newTransmitInfo.substring(0, 400); +// } +// +// for (int j = 0; j < details.size(); j++) { +// PassiveStorageResponse.Details details1 = details.get(j); +// +// OfsPassiveorderDetailEntity ofsPassiveorderDetailEntity = new OfsPassiveorderDetailEntity(); +// ofsPassiveorderDetailEntity.setId(details1.getId()); +// if (sceneType.equals("stock")) { +// ofsPassiveorderDetailEntity.setNewpushdate(newPushDate); +// ofsPassiveorderDetailEntity.setNewtransmitinfo(newTransmitInfo); +// ofsPassiveorderDetailEntity.setNewstate(newstate); +// if (!"N".equals(newstate)) { +// ofsPassiveorderDetailEntity.setNewsystemnumber(newsystemnumber); +// ofsPassiveorderDetailEntity.setNewsystemprimary(newsystemprimary); +// } +// +// } else if (sceneType.equals("tran")) { +// ofsPassiveorderDetailEntity.setNewpushdate2(newPushDate); +// ofsPassiveorderDetailEntity.setNewtransmitinfo2(newTransmitInfo); +// ofsPassiveorderDetailEntity.setNewstate2(newstate); +// if (!"N".equals(newstate)) { +// ofsPassiveorderDetailEntity.setNewsystemnumber2(newsystemnumber); +// ofsPassiveorderDetailEntity.setNewsystemprimary2(newTransmitInfo); +// } +// } +// tocofsSaleoutDetailedEntityList.add(ofsPassiveorderDetailEntity); +// } +// } +// +// //以50行为一个批次更新状态,并且入库和确认收入调用不同的方法 +// if (tocofsSaleoutDetailedEntityList.size() > 0) { +// List> lists = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); +// for (int i = 0; i < lists.size(); i++) { +// List ofsPassiveorderDetailEntities = lists.get(i); +// if (sceneType.equals("stock")) { +// iOfsPassiveorderDetailDao.entityInsertOrUpdateBatchByStock(ofsPassiveorderDetailEntities); +// } else if (sceneType.equals("tran")) { +// iOfsPassiveorderDetailDao.entityInsertOrUpdateBatchByTran(ofsPassiveorderDetailEntities); // } // } // } // } - newstate = no2NameMap.get(stockinB.getId()); - if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { - isSuccess = true; - } - if (!isSuccess) { - stockinB.setNewstate3(newstate); - targetDetails.add(stockinB); - } - } - if (targetDetails.size() > 0) { - //如果明细行中,还存在未推送或者失败的数据,则需要更新明细行 - stockinOrder.setDetails(targetDetails); - targetHeaderDetailsDtoList.add(stockinOrder); - } - } - } - return targetHeaderDetailsDtoList; - } - - /** - * 筛选出未推送、或者失败的数据行,过滤库存同步业务 - * - * @param tocofsReturngoodsDetailedEntityList 日志行状态 - * @param returnGoodHeaderDetailsDataDtoArrayList 返回结果 - * @author liuyang - */ - private List filterDataRowsAsPushOrFailedTran(List tocofsReturngoodsDetailedEntityList, List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { - Assert.notNull(tocofsReturngoodsDetailedEntityList, "tocofsReturngoodsDetailedEntityList不能为空"); - Assert.notNull(returnGoodHeaderDetailsDataDtoArrayList, "returnGoodHeaderDetailsDataDtoArrayList不能为空"); - - List targetHeaderDetailsDtoList = new ArrayList<>(); - if (tocofsReturngoodsDetailedEntityList != null && returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { - List collect = tocofsReturngoodsDetailedEntityList.stream().map(obj -> { - if (obj.getNewstate4() == null) { - obj.setNewstate4(""); - } - return obj; - }).collect(Collectors.toList()); - Map no2NameMap2 = collect.stream().collect(Collectors.toMap(TocofsReturngoodsDetailedEntity::getId, TocofsReturngoodsDetailedEntity::getNewstate4)); - - //字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行 - String succeseeY = "Y"; - String succeseeH = "H"; - for (int i = 0; i < returnGoodHeaderDetailsDataDtoArrayList.size(); i++) { - StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoArrayList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); - List details = stockinOrder.getDetails(); - - List targetDetails = new ArrayList<>(); - for (int j = 0; j < details.size(); j++) { - StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); - Boolean isSuccess = false; - String newstate = null; -// for (int k = 0; k < tocofsReturngoodsDetailedEntityList.size(); k++) { -// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = tocofsReturngoodsDetailedEntityList.get(k); -// if (tocofsReturngoodsDetailedEntity.getId().equals(stockinB.getId())) { -// newstate = tocofsReturngoodsDetailedEntity.getNewstate4(); -// if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) { -// isSuccess = true; +// } catch (Exception e) { +// logger.error("无源件业务填充出库明细日志抛出异常", e); +// } +// } +// }); +// thread.start(); +// try { +// thread.join(); +// } catch (Exception e) { +// logger.error("updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry方法调用join 跑出异常", e); +// } +// } +// +// /** +// * 处理TOC-库存同步的成功、失败错误逻辑 +// * +// * @author liuyang +// */ +// private void updateSuccessOrFail1(List sonDetailsDtoList, String newstate, String newTransmitInfo, String newsystemnumber, String newsystemprimary) { +// if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) { +// newTransmitInfo = newTransmitInfo.substring(0, 400); +// } +// +// String finalNewTransmitInfo = newTransmitInfo; +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// try { +// String successY = "Y"; +// if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { +// +// List ofsPassiveorderDetailEntityArrayList = new ArrayList<>(); +// +// for (int i = 0; i < sonDetailsDtoList.size(); i++) { +// PassiveStorageSonDetailsDto passiveStorageSonDetailsDto = sonDetailsDtoList.get(i); +// +// OfsPassiveorderDetailEntity ofsPassiveorderDetailEntity = new OfsPassiveorderDetailEntity(); +// ofsPassiveorderDetailEntity.setId(passiveStorageSonDetailsDto.getId()); +// ofsPassiveorderDetailEntity.setNewpushdate(getNewDateStr()); +// ofsPassiveorderDetailEntity.setNewtransmitinfo(finalNewTransmitInfo); +// ofsPassiveorderDetailEntity.setNewstate(newstate); +// if (successY.equals(newstate)) { +// ofsPassiveorderDetailEntity.setNewsystemnumber(newsystemnumber); +// ofsPassiveorderDetailEntity.setNewsystemprimary(newsystemprimary); +// } +// +// ofsPassiveorderDetailEntity.setDef1(passiveStorageSonDetailsDto.getCalculateAccountsReceivable()); +// ofsPassiveorderDetailEntity.setDef2(passiveStorageSonDetailsDto.getCalculationFormula()); +// ofsPassiveorderDetailEntity.setDef3(passiveStorageSonDetailsDto.getPlatformDiscounts()); +// ofsPassiveorderDetailEntity.setDef4(passiveStorageSonDetailsDto.getPayDiscounts()); +// ofsPassiveorderDetailEntity.setDef5(passiveStorageSonDetailsDto.getExpertDiscounts()); +// ofsPassiveorderDetailEntity.setDef6(passiveStorageSonDetailsDto.getMerchantDiscounts()); +// +// ofsPassiveorderDetailEntityArrayList.add(ofsPassiveorderDetailEntity); +// } +// +// //以50行为一个批次,推送到Mysql +// if (ofsPassiveorderDetailEntityArrayList.size() > 0) { +// List> lists = SplitListByCountUtil.splitListByCount(ofsPassiveorderDetailEntityArrayList, 50); +// for (int i = 0; i < lists.size(); i++) { +// List ofsPassiveorderDetailEntities = lists.get(i); +// iOfsPassiveorderDetailDao.entityInsertOrUpdateBatchByStock(ofsPassiveorderDetailEntities); // } // } // } - newstate = no2NameMap2.get(stockinB.getId()); - if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { - isSuccess = true; - } - - if (!isSuccess) { - stockinB.setNewstate4(newstate); - targetDetails.add(stockinB); - } - } - if (targetDetails.size() > 0) { - //如果明细行中,还存在未推送或者失败的数据,则需要更新明细行 - stockinOrder.setDetails(targetDetails); - targetHeaderDetailsDtoList.add(stockinOrder); - } - } - } - return targetHeaderDetailsDtoList; - } - - /** - * 计算时间间隔 - * - * @author liuyang - */ - public String computingTime(String param) { - if (param != null && !"".equals(param)) { - String[] split = param.split("/"); - if (!(split.length == 2)) { - Assert.state(false, "传递的日期格式不完整 格式参考:2024-04-01/2024-04-30"); - } - - LocalDate startDate = LocalDate.parse(split[0]); - LocalDate endDate = LocalDate.parse(split[1]); - - List stringArrayList = new ArrayList<>(); - List dateRange = getDateRange(startDate, endDate); - if (dateRange != null && dateRange.size() > 0) { - for (int i = 0; i < dateRange.size(); i++) { - String dateStr = dateRange.get(i); - StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(dateStr); - stringBuffer.append(" 00:00:00"); - stringBuffer.append(","); - stringBuffer.append(dateStr); - stringBuffer.append(" 23:59:59"); - stringArrayList.add(stringBuffer.toString()); - } - } - String collectDateStr = stringArrayList.stream().collect(Collectors.joining("*")); - logger.info("类型:time_frame 生成的日期范围:" + collectDateStr); - return collectDateStr; - } - return null; - } - - /** - * 分割日期之后,再进行推送 - * - * @author liuyang - */ - public void splitDateAndPush(String param, String sceneType, String pushScenarioType) throws Exception { - try { - Assert.notNull(param, "param不能为空!"); - Assert.state(!"".equals(param), "param不能为空!"); - - Assert.notNull(sceneType, "sceneType不能为空!"); - Assert.state(!"".equals(sceneType), "sceneType不能为空!"); - - Assert.notNull(pushScenarioType, "pushScenarioType不能为空!"); - Assert.state(!"".equals(pushScenarioType), "pushScenarioType不能为空!"); - - if (param.contains("*")) { - String[] params = param.split("\\*"); - if (params.length > 0) { - for (int i = 0; i < params.length; i++) { - String indexStr = params[i]; - String[] split = indexStr.split(","); - logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]); - if (sceneType.equals(STOCK)) { - startImplementStockByTime(split[0], split[1], pushScenarioType); - } else if (sceneType.equals(TRAN)) { - startImplementByTradeTime(split[0], split[1], pushScenarioType); - } - } - } - } else { - String[] split = param.split(","); - logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]); - if (sceneType.equals(STOCK)) { - startImplementStockByTime(split[0], split[1], pushScenarioType); - } else if (sceneType.equals(TRAN)) { - startImplementByTradeTime(split[0], split[1], pushScenarioType); - } - } - } catch (Exception e) { - logger.error("记录splitDateAndPush方法抛出的异常", e); - } - } - - /** - * 计算全天时间段 - * - * @author liuyang - */ - public List calculateCalculateEntireDayPeriod(String dateStr) { - List startAndEnd = new ArrayList<>(); - - String calculateYesterdayStr = null; - if (dateStr != null) { - calculateYesterdayStr = dateStr; - } else { - calculateYesterdayStr = calculateYesterdayDate();//拉取'昨天'的日期 - } - logger.info("OFS销售出库单同步U8C销售订单,目标拉取时间:" + calculateYesterdayStr); - - StartAndEndVo startAndEndVo = new StartAndEndVo(); - startAndEndVo.setStart_time(calculateYesterdayStr + " 00:00:00"); - startAndEndVo.setEnd_time(calculateYesterdayStr + " 23:59:59"); - startAndEnd.add(startAndEndVo); - -// for (int i = 0; i <= 23; i++) { -// String iStr = null; -// if (i <= 9) { -// iStr = "0" + i; -// } else { -// iStr = String.valueOf(i); +// } catch (Exception e) { +// logger.error("无源件日志同步,抛出异常", e); +// } // } -// String startTime = calculateYesterdayStr + " " + iStr + ":00:00"; -// String endTime = calculateYesterdayStr + " " + iStr + ":59:59"; +// }); +// thread.start(); +// try { +// thread.join(); +// } catch (Exception e) { +// logger.error("updateSuccessOrFail1方法现场抛出异常", e); +// } +// } // -// StartAndEndVo startAndEndVo = new StartAndEndVo(); -// startAndEndVo.setStart_time(startTime); -// startAndEndVo.setEnd_time(endTime); -// startAndEnd.add(startAndEndVo); -// } - return startAndEnd; - } - - /** - * 计算昨天的单据日期,基于定时器在凌晨5分执行的情况下 - * - * @author liuyang - */ - public String calculateYesterdayDate() { - DateTime yesterdayDate = DateUtil.yesterday(); - return DateUtil.format(yesterdayDate, "yyyy-MM-dd"); - } - - /** - * 计算时间范围对应的字符串集合 - * - * @author liuyang - */ - private List getDateRange(LocalDate startDate, LocalDate endDate) { - List dateRange = new ArrayList<>(); - LocalDate currentDate = startDate; - while (!currentDate.isAfter(endDate)) { - dateRange.add(currentDate.format(DateTimeFormatter.ISO_DATE)); - currentDate = currentDate.plusDays(1); - } - return dateRange; - } - - /** - * 累加平台优惠 - * - * @param sonDetailsDtoList OFS售后入库单 - * @author liuyang - */ - private void accumulationDiscountAmount(List sonDetailsDtoList) throws Exception { - Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); - - if (sonDetailsDtoList.size() > 0) { - BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0"); - BigDecimal totalShareTargetMerchantDiscounts = new BigDecimal("0"); - BigDecimal totalShareTargetExpertDiscounts = new BigDecimal("0"); - BigDecimal totalShareTargetPayDiscounts = new BigDecimal("0"); - - for (int i = 0; i < sonDetailsDtoList.size(); i++) { - //OFS售后入库单表体 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); - //OFS售后入库单表头 - StockinOrderSearchResponse.StockinOrder.StockinH header1 = goodsRertunSonDetailsDto.getHeader(); - Assert.notNull(header1, "OFS售后入库单表头不能为空!"); - //OFS售后订单 - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header1.getRerturnGoodsOrderSearchData(); - Assert.notNull(rerturnGoodsOrderSearchData, "通过OFS售后入库单号无法关联批量到OFS售后订单! OFS售后入库单编码:{} OFS售后订单号:{}", header1.getCode(), header1.getRefOrderCode()); - RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader(); - List details = rerturnGoodsOrderSearchData.getDetails(); - - //四舍五入保留2位 - RerturnGoodsOrderSearchDetails ofsOrderDetail = findOfsOrderDetail(details, goodsRertunSonDetailsDto); - if (ofsOrderDetail.getShareTargetPlatformDiscounts() != null) { - totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(ofsOrderDetail.getShareTargetPlatformDiscounts()); - } - if (ofsOrderDetail.getShareTargetMerchantDiscounts() != null) { - totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(ofsOrderDetail.getShareTargetMerchantDiscounts()); - } - if (ofsOrderDetail.getShareTargetExpertDiscounts() != null) { - totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(ofsOrderDetail.getShareTargetExpertDiscounts()); - } - if (ofsOrderDetail.getShareTargetPayDiscounts() != null) { - totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(ofsOrderDetail.getShareTargetPayDiscounts()); - } - logger.info("对应的售后入库单明细行主键:{}", goodsRertunSonDetailsDto.getId()); - } - - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(0); - StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader(); - - goodsRertunSonDetailsDto.setVdef4(totalShareTargetPlatformDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - goodsRertunSonDetailsDto.setVdef5(totalShareTargetMerchantDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - goodsRertunSonDetailsDto.setVdef6(totalShareTargetExpertDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - goodsRertunSonDetailsDto.setVdef7(totalShareTargetPayDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - - logger.info("售后入库明细主键:{} 售后入库单号:{} 最终汇总好的平台优惠:{}、支付优惠:{}、达人优惠:{}、商家优惠:{}", goodsRertunSonDetailsDto.getId(), header.getCode(), goodsRertunSonDetailsDto.getVdef4(), goodsRertunSonDetailsDto.getVdef5(), goodsRertunSonDetailsDto.getVdef6(), goodsRertunSonDetailsDto.getVdef7()); - } else { - logger.info("accumulationDiscountAmount方法对应的sonDetailsDtoList.size为零!"); - } - } - - /** - * 根据OFS售后入库单明细行,查找匹配OFS售后订单明细行 - * - * @param details OFS售后订单明细行 - * @param goodsRertunSonDetailsDto OFS售后入库单明细对象 - * @author liuyang - */ - private RerturnGoodsOrderSearchDetails findOfsOrderDetail(List details, GoodsRertunSonDetailsDto goodsRertunSonDetailsDto) { - Assert.notNull(details, "details不能为空"); - Assert.notNull(goodsRertunSonDetailsDto, "goodsRertunSonDetailsDto不能为空"); - - for (int i = 0; i < details.size(); i++) { - RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i); - if (goodsRertunSonDetailsDto.getRefOrderDetailId() != null && rerturnGoodsOrderSearchDetails.getId() != null) { - if (goodsRertunSonDetailsDto.getRefOrderDetailId().equals(rerturnGoodsOrderSearchDetails.getId())) { - return rerturnGoodsOrderSearchDetails; - } - } - } - Assert.state(false, "根据OFS售后入库单明细行,无法查找OFS售后订单明细行 来源明细行主键:{} 来源单据主键:{}", goodsRertunSonDetailsDto.getRefOrderDetailId(), goodsRertunSonDetailsDto.getRefOrderId()); - return null; - } - - /** - * 初始化所有存货管理档案对应的结存价、采购价 - * - * @author liuyang - */ - private List initAllBalancePricePurchasePrice() throws Exception { - List mapList = new ArrayList<>(); - Map stringIaPeriodaccountEntityMap = balanceUnitPriceUtil.initBalancePrice(); - Map stringPoOrderBEntityMap = balanceUnitPriceUtil.initPurchasePrice(); - mapList.add(stringIaPeriodaccountEntityMap); - mapList.add(stringPoOrderBEntityMap); - return mapList; - } - - /** - * 获取结存金额或者采购金额 - * - * @param isCheckShopChoose true取OFS实付金额、false取结存金额或者采购价 - * @param bdInvmandocEntity 存货基本档案 - * @param header 对应的销售入库单表头 - * @param sonDetailsDto 对应的销售入库单明细行对象 - * @param mapList 索引为0结存价为1采购价 - * @author liuyang - */ - private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, StockinOrderSearchResponse.StockinOrder.StockinH header, GoodsRertunSonDetailsDto sonDetailsDto, List mapList, StringBuffer calculationFormulaStr) throws Exception { - Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); - Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空"); - Assert.notNull(header, "header不能为空"); - Assert.notNull(sonDetailsDto, "detailsDto不能为空"); - Assert.notNull(mapList, "mapList不能为空"); - Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空"); - - //此处只能为金额 - String totalPayAmount = null; - if (isCheckShopChoose) { - IaPeriodaccountEntity iaPeriodaccountEntity1 = null; - if (mapList != null && mapList.size() > 0) { - Map stringIaPeriodaccountEntityMap = (Map) mapList.get(0); - iaPeriodaccountEntity1 = stringIaPeriodaccountEntityMap.get(bdInvmandocEntity.getPkInvmandoc()); - } - if (iaPeriodaccountEntity1 != null) { - //取结存价 - logger.info("店铺:{} 取O结存价", header.getStoreCode()); - calculationFormulaStr.append("取结存价:"); - - //结存金额 - String nabmny = iaPeriodaccountEntity1.getNabmny(); - if (nabmny == null || "".equals(nabmny)) { - nabmny = "0"; - } - BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny); - - //结存数量 - String nabnum = iaPeriodaccountEntity1.getNabnum(); - if (nabnum == null || "".equals(nabnum)) { - nabnum = "0"; - } - BigDecimal nabnumBigDecimal = new BigDecimal(nabnum); - - if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString()) && !"0".equals(nabnumBigDecimal.stripTrailingZeros().toPlainString())) { - String format = StrUtil.format("{}/{}*{}", nabmnyBigDecimal.stripTrailingZeros().toPlainString(), nabnumBigDecimal.stripTrailingZeros().toPlainString(), sonDetailsDto.getReceivedQty()); - calculationFormulaStr.append(format); - BigDecimal bigDecimal = nabmnyBigDecimal.divide(nabnumBigDecimal, 20, BigDecimal.ROUND_HALF_UP); - BigDecimal totalPayAmountBigDecimal = bigDecimal.multiply(new BigDecimal(sonDetailsDto.getReceivedQty())).setScale(2, BigDecimal.ROUND_HALF_UP); - totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString(); - } else { - //如果结存金额为或者数量为0,则设置为0 - calculationFormulaStr.append("0"); - totalPayAmount = "0"; - } - } else { - //取采购价 - logger.info("店铺:{} 取O采购价", header.getStoreCode()); - calculationFormulaStr.append("取采购价:"); - PoOrderBEntity poOrderBEntity = null; - if (mapList != null && mapList.size() > 0) { - Map poOrderBEntityList = (Map) mapList.get(1); - if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) { - poOrderBEntity = poOrderBEntityList.get(bdInvmandocEntity.getPkInvmandoc()); - } - } - if (poOrderBEntity != null) { - String norgtaxprice = poOrderBEntity.getNorgtaxprice(); - Assert.notNull(norgtaxprice, "U8C采购订单明细行存在「原币含税单价」为空"); - if (norgtaxprice != null && !"0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) { - String format = StrUtil.format("{}*{}", norgtaxprice, sonDetailsDto.getReceivedQty()); - calculationFormulaStr.append(format); - BigDecimal totalPayAmountBigDecimal = new BigDecimal(norgtaxprice).multiply(new BigDecimal(sonDetailsDto.getReceivedQty())).setScale(2, BigDecimal.ROUND_HALF_UP); - totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString(); - } else { - //如果采购单价都为0,那么金额也为0 - totalPayAmount = "0"; - calculationFormulaStr.append("0"); - } - } else { - Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc()); - } - } - } - return totalPayAmount; - } - - /** - * 累加应收金额=实退金额+达人优惠+支付优惠+平台优惠 - * - * @param goodsRertunSonDetailsDto OFS售后入库单明细行 - * @param rerturnGoodsOrderSearchData OFS售后订单 - * @param calculationFormulaStr 计算公式 - * @author liuyang - */ - private String accumulatedDiscounts(GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData, StringBuffer calculationFormulaStr) throws Exception { - Assert.notNull(goodsRertunSonDetailsDto, "goodsRertunSonDetailsDto OFS售后入库单明细行不能为空!"); - Assert.notNull(rerturnGoodsOrderSearchData, "rerturnGoodsOrderSearchData OFS售后订单不能为空!"); - Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空!"); - - //O售后入库单表头 - StockinOrderSearchResponse.StockinOrder.StockinH header1 = goodsRertunSonDetailsDto.getHeader(); - - //O售后订单表头+明细行 - RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader(); - List details = rerturnGoodsOrderSearchData.getDetails(); - - //根据「入库单明细」匹配「售后订单明细行」 - RerturnGoodsOrderSearchDetails targetDetails = null; - for (int i = 0; i < details.size(); i++) { - RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i); - if (goodsRertunSonDetailsDto.getRefOrderDetailId() != null && rerturnGoodsOrderSearchDetails.getId() != null) { - if (rerturnGoodsOrderSearchDetails.getId().equals(goodsRertunSonDetailsDto.getRefOrderDetailId())) { - targetDetails = rerturnGoodsOrderSearchDetails; - } - } - } - Assert.notNull(targetDetails, "根据OFS售后入库单细行(refOrderDetailId)无法匹配售后订单明细行", goodsRertunSonDetailsDto.getRefOrderDetailId()); - - //售后订单明细行-退货金额 - String totalAmount = targetDetails.getTotalAmount();//实退金额 - Assert.notNull(totalAmount, "售后订单:{} 存货明细行:{} 退货金额不能为空!", header.getCode(), targetDetails.getSkuCode()); - Assert.state(!"".equals(totalAmount), "售后订单:{} 存货明细行:{} 退货金额不能为空!", header.getCode(), targetDetails.getSkuCode()); - //售后订单明细行-请求数量 - //实退数量存在可能为0的情况,如果用退货金额/实退数量可能会抛出异常 - String requestQty = targetDetails.getRequestQty();//请求数量 - Assert.notNull(requestQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); - Assert.state(!"".equals(requestQty), "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); - - //测试 -// goodsRertunSonDetailsDto.setReceivedQty("1"); - - String receivedQty = goodsRertunSonDetailsDto.getReceivedQty(); - Assert.notNull(receivedQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header1.getCode(), goodsRertunSonDetailsDto.getId()); - Assert.state(!"".equals(receivedQty), header1.getCode(), goodsRertunSonDetailsDto.getId()); - if ("0".equals(new BigDecimal(receivedQty).stripTrailingZeros().toPlainString())) { - Assert.state(false, "售后订单:{} 存货明细行:{} 实退数量不能为0!", header1.getCode(), goodsRertunSonDetailsDto.getId()); - } - //O含税单价=通过退货金额/请求数量 - BigDecimal unitPriceIncludingTax = new BigDecimal(totalAmount).divide(new BigDecimal(requestQty), 20, BigDecimal.ROUND_HALF_UP); - //实退金额=O含税单价*(O售后入库单)实退数量 - BigDecimal actualRefundAmount = unitPriceIncludingTax.multiply(new BigDecimal(receivedQty)).setScale(4, BigDecimal.ROUND_HALF_UP); - //出库对应的实退=含税单价(actualRefundAmount)*出库单实退数量 -// BigDecimal actualRefundAmountBigDecimal = new BigDecimal(receivedQty).multiply(actualRefundAmount).setScale(2, BigDecimal.ROUND_HALF_UP); - String format = StrUtil.format("{}/{}*{}", totalAmount, requestQty, receivedQty); - calculationFormulaStr.append(format); - -// //商家优惠:不处理!!!仅保存 -// String merchantDiscounts = targetDetails.getMerchantDiscounts(); -// //达人优惠 -// String expertDiscounts = targetDetails.getExpertDiscounts(); -// //支付优惠 -// String payDiscounts = targetDetails.getPayDiscounts(); -// //平台优惠 -// String platformDiscounts = targetDetails.getPlatformDiscounts(); -// -// BigDecimal totalBigDecimal = new BigDecimal("0");//相加总和 -// BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");//实退金额 -// BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人优惠 -// BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付优惠 -// BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台优惠 -// -// if (actualRefundAmount != null) { -// totalPayAmountBigDecimal = actualRefundAmount; -// } -// if (expertDiscounts != null && !"".equals(expertDiscounts)) { -// expertDiscountsBigDecimal = new BigDecimal(expertDiscounts); -// } -// if (payDiscounts != null && !"".equals(payDiscounts)) { -// payDiscountsBigDecimal = new BigDecimal(payDiscounts); -// } -// if (platformDiscounts != null && !"".equals(platformDiscounts)) { -// platformDiscountsBigDecimal = new BigDecimal(platformDiscounts); +// /** +// * 处理TOC-库存同步的成功、失败错误逻辑 +// * +// * @author liuyang +// */ +// private void updateSuccessOrFail2(List sonDetailsDtoList, String newstate, String newTransmitInfo, String newsystemnumber, String newsystemprimary) { +// if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) { +// newTransmitInfo = newTransmitInfo.substring(0, 400); // } // -// //总和累加 -// totalBigDecimal = totalBigDecimal.add(totalPayAmountBigDecimal); -// totalBigDecimal = totalBigDecimal.add(expertDiscountsBigDecimal); -// totalBigDecimal = totalBigDecimal.add(payDiscountsBigDecimal); -// totalBigDecimal = totalBigDecimal.add(platformDiscountsBigDecimal); -// return totalBigDecimal.stripTrailingZeros().toPlainString(); - return actualRefundAmount.stripTrailingZeros().toPlainString(); - } - - /** - * 累加优惠金额,放在自定义项里最后传给U8C - * - * @param sonDetailsDtoList OFS售后入库单明细行List集合(按纬度汇总好的) - * @author liuyang - */ - private void accumulatedDiscountAmountDef(List sonDetailsDtoList) throws Exception { - Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); - - if (sonDetailsDtoList.size() > 0) { - BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台 - BigDecimal merchantDiscountsBigDecimal = new BigDecimal("0");//商家 - BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人 - BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付 - for (int i = 0; i < sonDetailsDtoList.size(); i++) { - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader();//O售后入库单表头 - RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 - - Assert.notNull(rerturnGoodsOrderSearchData, "O售后订单不能为空 O售后入库单编码:{}", header.getCode()); - List details = rerturnGoodsOrderSearchData.getDetails();//OFS售后订单明细行 - if (details != null && details.size() > 0) { - for (int j = 0; j < details.size(); j++) { - RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(j); - if (goodsRertunSonDetailsDto.getRefOrderDetailId() != null && rerturnGoodsOrderSearchDetails.getId() != null) { - if (goodsRertunSonDetailsDto.getRefOrderDetailId().equals(rerturnGoodsOrderSearchDetails.getId())) { - //累加优惠 - String platformDiscounts = rerturnGoodsOrderSearchDetails.getPlatformDiscounts(); - String merchantDiscounts = rerturnGoodsOrderSearchDetails.getMerchantDiscounts(); - String expertDiscounts = rerturnGoodsOrderSearchDetails.getExpertDiscounts(); - String payDiscounts = rerturnGoodsOrderSearchDetails.getPayDiscounts(); - - if (platformDiscounts == null || "".equals(platformDiscounts.trim())) { - platformDiscounts = "0"; - } - if (merchantDiscounts == null || "".equals(merchantDiscounts.trim())) { - merchantDiscounts = "0"; - } - if (expertDiscounts == null || "".equals(expertDiscounts.trim())) { - expertDiscounts = "0"; - } - if (payDiscounts == null || "".equals(payDiscounts.trim())) { - payDiscounts = "0"; - } - - platformDiscountsBigDecimal = platformDiscountsBigDecimal.add(new BigDecimal(platformDiscounts)); - merchantDiscountsBigDecimal = merchantDiscountsBigDecimal.add(new BigDecimal(merchantDiscounts)); - expertDiscountsBigDecimal = expertDiscountsBigDecimal.add(new BigDecimal(expertDiscounts)); - payDiscountsBigDecimal = payDiscountsBigDecimal.add(new BigDecimal(payDiscounts)); - } - } - } - } - } - sonDetailsDtoList.get(0).setVdef4(platformDiscountsBigDecimal);//平台 - sonDetailsDtoList.get(0).setVdef5(payDiscountsBigDecimal);//支付 - sonDetailsDtoList.get(0).setVdef6(expertDiscountsBigDecimal);//达人 - sonDetailsDtoList.get(0).setVdef7(merchantDiscountsBigDecimal);//商家 - } - } - - /** - * 获取参考售价 - * - * @param bdInvmandocEntity 存货管理档案 - * @param bdInvbasdocEntity 存货基本档案 - * @param calculationFormulaStr 计算公式 - * @param goodsRertunSonDetailsDto O售后入库单明细行 - * @param header O售后入库单表头 - * @author liuyang - */ - private String getRefsaleprice(BdInvmandocEntity bdInvmandocEntity, BdInvbasdocEntity bdInvbasdocEntity, StringBuffer calculationFormulaStr, GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, StockinOrderSearchResponse.StockinOrder.StockinH header) throws Exception { - Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空!"); - Assert.notNull(bdInvbasdocEntity, "bdInvbasdocEntity不能为空!"); - Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空!"); - Assert.notNull(goodsRertunSonDetailsDto, "goodsRertunSonDetailsDto不能为空!"); - Assert.notNull(header, "header不能为空"); - - //U参考售价 - String refsaleprice = bdInvmandocEntity.getRefsaleprice(); - Assert.notNull(refsaleprice, "存货:{} 公司:{} 不存在参考售价,请维护!", bdInvbasdocEntity.getInvname(), bdInvmandocEntity.getPkCorp()); - - //O实收数量 - String receivedQty = goodsRertunSonDetailsDto.getReceivedQty(); - Assert.notNull(receivedQty, "O实收数量不能为空 O售后入库单编码:{} O明细行主键:{}", header.getCode(), goodsRertunSonDetailsDto.getId()); - Assert.state(!"".equals(receivedQty), "O实收数量不能为空 O售后入库单编码:{} O明细行主键:{}", header.getCode(), goodsRertunSonDetailsDto.getId()); - - BigDecimal amountOfMoney = new BigDecimal(refsaleprice).multiply(new BigDecimal(receivedQty)); - String format = StrUtil.format("取U参考售价:{}*{}", refsaleprice, receivedQty); - calculationFormulaStr.append(format); - return amountOfMoney.stripTrailingZeros().toPlainString(); - } - - /** - * 查询OFS底表的O售后入库单数据 - * - * @author liuyang - */ - public List queryTocofsReturngoodsDetailed(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity) throws Exception { - Assert.notNull(tocofsReturngoodsDetailedEntity, "tocofsReturngoodsDetailedEntity不能为空"); - - //底表O售后入库单表头对象 - List allTocofsReturngoodsEntityList = new ArrayList<>(); - //底表O售后入库单明细行 - List tocofsReturngoodsDetailedEntityList = iTocofsReturngoodsDetailedDao.query(tocofsReturngoodsDetailedEntity); - if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) { - Set mainTableIdSet = tocofsReturngoodsDetailedEntityList.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet()); - List mainTableIdList = Lists.newArrayList(mainTableIdSet); - - List> splitListByCount = SplitListByCountUtil.splitListByCount(mainTableIdList, 1000); -// List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityList, 1000); - for (int i = 0; i < splitListByCount.size(); i++) { - List strings = splitListByCount.get(i); -// Set mainTableIdSet = tocofsReturngoodsDetailedEntityList1.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet()); - String mainTableIds = strings.stream().map(id -> "'" + id + "'").collect(Collectors.joining(",")); - //查询对应的O售后入库单表头 - TocofsReturngoodsEntity tocofsReturngoodsEntity = new TocofsReturngoodsEntity(); - tocofsReturngoodsEntity.setIds(mainTableIds); - List tocofsReturngoodsEntityList = iTocofsReturngoodsDao.query(tocofsReturngoodsEntity); - allTocofsReturngoodsEntityList.addAll(tocofsReturngoodsEntityList); - } - } - - //通过「O售后入库单表头」匹配「O售后入库单明细」 - if (allTocofsReturngoodsEntityList.size() > 0) { - Map> stringListMap = convertToMap(tocofsReturngoodsDetailedEntityList); - for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) { - TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i); - //性能太差了,使用Map搜索 -// List tocofsReturngoodsDetailedEntityList1 = new ArrayList<>(); -// for (int j = 0; j < tocofsReturngoodsDetailedEntityList.size(); j++) { -// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList.get(j); -// if (tocofsReturngoodsDetailedEntity1.getMaintableid().equals(tocofsReturngoodsEntity.getId())) { -// tocofsReturngoodsDetailedEntityList1.add(tocofsReturngoodsDetailedEntity1); +// String finalNewTransmitInfo = newTransmitInfo; +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// try { +// String successY = "Y"; +// if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { +// List tocofsReturngoodsDetailedEntityArrayList = new ArrayList<>(); +// for (int i = 0; i < sonDetailsDtoList.size(); i++) { +// GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); +// +// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); +// tocofsReturngoodsDetailedEntity.setId(goodsRertunSonDetailsDto.getId()); +// tocofsReturngoodsDetailedEntity.setNewpushdate4(getNewDateStr()); +// tocofsReturngoodsDetailedEntity.setNewtransmitinfo4(finalNewTransmitInfo); +// tocofsReturngoodsDetailedEntity.setNewstate4(newstate); +// tocofsReturngoodsDetailedEntity.setDef7(goodsRertunSonDetailsDto.getCalculateAccountsReceivable()); +// tocofsReturngoodsDetailedEntity.setDef8(goodsRertunSonDetailsDto.getCalculationFormula()); +// tocofsReturngoodsDetailedEntity.setDef9(goodsRertunSonDetailsDto.getPlatformDiscounts()); +// tocofsReturngoodsDetailedEntity.setDef10(goodsRertunSonDetailsDto.getPayDiscounts()); +// tocofsReturngoodsDetailedEntity.setDef11(goodsRertunSonDetailsDto.getExpertDiscounts()); +// tocofsReturngoodsDetailedEntity.setDef12(goodsRertunSonDetailsDto.getMerchantDiscounts()); +// if (successY.equals(newstate)) { +// tocofsReturngoodsDetailedEntity.setNewsystemnumber4(newsystemnumber); +// tocofsReturngoodsDetailedEntity.setNewsystemprimary4(newsystemprimary); +// } +// tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity); +// } +// +// //以50行为一个批次,推送到Mysql +// if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) { +// List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 200); +// for (int i = 0; i < splitListByCount.size(); i++) { +// List tocofsReturngoodsDetailedEntities = splitListByCount.get(i); +// iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTocRerturnTran(tocofsReturngoodsDetailedEntities); +// } +// } +// } +// } catch (Exception e) { +// logger.error("TOC确认收入同步日志,抛出异常", e); +// } +// } +// }); +// thread.start(); +// try { +// thread.join(); +// } catch (Exception e) { +// logger.error("updateSuccessOrFail1方法现场抛出异常", e); +// } +// } +// +// /** +// * 过滤库存同步业务,筛选出未推送、或者失败的数据行,使用批处理并且直接在内存中计算这样比较高效 +// * +// * @param tocofsReturngoodsDetailedEntityList 无源入库单推送状态信息 +// * @param returnGoodHeaderDetailsDataDtoArrayList O 无源入库单对象封装 +// * @author liuyang +// */ +// private List filterDataRowsAsPushOrFailedStock(List tocofsReturngoodsDetailedEntityList, List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { +// List targetHeaderDetailsDtoList = new ArrayList<>(); +// +// if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { +// //如果推送状态为 null,则赋予"",便于 stream 计算 +// List resultList = tocofsReturngoodsDetailedEntityList.stream().map(obj -> { +// if (obj.getNewstate() == null) { +// obj.setNewstate(""); +// } +// return obj; +// }).collect(Collectors.toList()); +// //汇总每个 id 对应的推送状态 +// Map no2NameMap = resultList.stream().collect(Collectors.toMap(OfsPassiveorderDetailEntity::getId, OfsPassiveorderDetailEntity::getNewstate)); +// +// //字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行 +// String succeseeY = "Y"; +// String succeseeH = "H"; +// for (int i = 0; i < returnGoodHeaderDetailsDataDtoArrayList.size(); i++) { +// PassiveStorageResponse.Data data = returnGoodHeaderDetailsDataDtoArrayList.get(i); +// PassiveStorageResponse.Header header = data.getHeader(); +// List details = data.getDetails(); +// +// List targetDetails = new ArrayList<>(); +// for (int j = 0; j < details.size(); j++) { +// PassiveStorageResponse.Details details1 = details.get(j); +// Boolean isSuccess = false; +// +// String newstate = no2NameMap.get(details1.getId()); +// if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { +// isSuccess = true; +// } +// if (!isSuccess) { +// targetDetails.add(details1); // } // } -// tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntityList1); - List tocofsReturngoodsDetailedEntities = stringListMap.get(tocofsReturngoodsEntity.getId()); - tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntities); - } - } - - //转换为OFS售后入库单对象 - List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); - if (allTocofsReturngoodsEntityList.size() > 0) { - for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) { - - StockinOrderSearchResponse.StockinOrder stockinOrder = new StockinOrderSearchResponse.StockinOrder(); - returnGoodHeaderDetailsDataDtoArrayList.add(stockinOrder); - - //处理表头 - TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i); - StockinOrderSearchResponse.StockinOrder.StockinH stockinH = new StockinOrderSearchResponse.StockinOrder.StockinH(); - stockinH.setId(tocofsReturngoodsEntity.getId()); - BeanUtil.copyPropertiesV2(tocofsReturngoodsEntity, stockinH); - stockinOrder.setHeader(stockinH); - - //处理明细行 - List tocofsReturngoodsDetailedEntityList1 = tocofsReturngoodsEntity.getTocofsReturngoodsDetailedEntityList(); - List stockinB = new ArrayList<>(); - stockinOrder.setDetails(stockinB); - for (int j = 0; j < tocofsReturngoodsDetailedEntityList1.size(); j++) { - TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList1.get(j); - - StockinOrderSearchResponse.StockinOrder.StockinB stockinB1 = new StockinOrderSearchResponse.StockinOrder.StockinB(); - BeanUtil.copyPropertiesV2(tocofsReturngoodsDetailedEntity1, stockinB1); - stockinB1.setId(tocofsReturngoodsDetailedEntity1.getId()); - stockinB.add(stockinB1); - } - } - } - return returnGoodHeaderDetailsDataDtoArrayList; - } - - /** - * 存在相同Maintableid汇总在一起 - * - * @author liuyang - */ - public static Map> convertToMap(List tocofsReturngoodsDetailedEntityList) { - Map> map = new HashMap<>(); - for (TocofsReturngoodsDetailedEntity entity : tocofsReturngoodsDetailedEntityList) { - String maintableid = entity.getMaintableid(); - map.computeIfAbsent(maintableid, k -> new ArrayList<>()).add(entity); - } - return map; - } +// if (targetDetails.size() > 0) { +// //如果明细行中,还存在未推送或者失败的数据,则需要更新明细行 +// //相当于覆盖对应的对象 +// data.setDetails(targetDetails); +// targetHeaderDetailsDtoList.add(data); +// } +// } +// } +// return targetHeaderDetailsDtoList; +// } +// +// /** +// * 筛选出未推送、或者失败的数据行,过滤库存同步业务 +// * +// * @param tocofsReturngoodsDetailedEntityList 日志行状态 +// * @param returnGoodHeaderDetailsDataDtoArrayList 返回结果 +// * @author liuyang +// */ +// private List filterDataRowsAsPushOrFailedTran(List tocofsReturngoodsDetailedEntityList, List returnGoodHeaderDetailsDataDtoArrayList) throws Exception { +// Assert.notNull(tocofsReturngoodsDetailedEntityList, "tocofsReturngoodsDetailedEntityList不能为空"); +// Assert.notNull(returnGoodHeaderDetailsDataDtoArrayList, "returnGoodHeaderDetailsDataDtoArrayList不能为空"); +// +// List targetHeaderDetailsDtoList = new ArrayList<>(); +// if (tocofsReturngoodsDetailedEntityList != null && returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { +// List collect = tocofsReturngoodsDetailedEntityList.stream().map(obj -> { +// if (obj.getNewstate4() == null) { +// obj.setNewstate4(""); +// } +// return obj; +// }).collect(Collectors.toList()); +// Map no2NameMap2 = collect.stream().collect(Collectors.toMap(TocofsReturngoodsDetailedEntity::getId, TocofsReturngoodsDetailedEntity::getNewstate4)); +// +// //字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行 +// String succeseeY = "Y"; +// String succeseeH = "H"; +// for (int i = 0; i < returnGoodHeaderDetailsDataDtoArrayList.size(); i++) { +// StockinOrderSearchResponse.StockinOrder stockinOrder = returnGoodHeaderDetailsDataDtoArrayList.get(i); +// StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); +// List details = stockinOrder.getDetails(); +// +// List targetDetails = new ArrayList<>(); +// for (int j = 0; j < details.size(); j++) { +// StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(j); +// Boolean isSuccess = false; +// String newstate = null; +//// for (int k = 0; k < tocofsReturngoodsDetailedEntityList.size(); k++) { +//// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = tocofsReturngoodsDetailedEntityList.get(k); +//// if (tocofsReturngoodsDetailedEntity.getId().equals(stockinB.getId())) { +//// newstate = tocofsReturngoodsDetailedEntity.getNewstate4(); +//// if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) { +//// isSuccess = true; +//// } +//// } +//// } +// newstate = no2NameMap2.get(stockinB.getId()); +// if (newstate != null && !"".equals(newstate) && (succeseeY.equals(newstate) || succeseeH.equals(newstate))) { +// isSuccess = true; +// } +// +// if (!isSuccess) { +// stockinB.setNewstate4(newstate); +// targetDetails.add(stockinB); +// } +// } +// if (targetDetails.size() > 0) { +// //如果明细行中,还存在未推送或者失败的数据,则需要更新明细行 +// stockinOrder.setDetails(targetDetails); +// targetHeaderDetailsDtoList.add(stockinOrder); +// } +// } +// } +// return targetHeaderDetailsDtoList; +// } +// +// /** +// * 计算时间间隔 +// * +// * @author liuyang +// */ +// public String computingTime(String param) { +// if (param != null && !"".equals(param)) { +// String[] split = param.split("/"); +// if (!(split.length == 2)) { +// Assert.state(false, "传递的日期格式不完整 格式参考:2024-04-01/2024-04-30"); +// } +// +// LocalDate startDate = LocalDate.parse(split[0]); +// LocalDate endDate = LocalDate.parse(split[1]); +// +// List stringArrayList = new ArrayList<>(); +// List dateRange = getDateRange(startDate, endDate); +// if (dateRange != null && dateRange.size() > 0) { +// for (int i = 0; i < dateRange.size(); i++) { +// String dateStr = dateRange.get(i); +// StringBuffer stringBuffer = new StringBuffer(); +// stringBuffer.append(dateStr); +// stringBuffer.append(" 00:00:00"); +// stringBuffer.append(","); +// stringBuffer.append(dateStr); +// stringBuffer.append(" 23:59:59"); +// stringArrayList.add(stringBuffer.toString()); +// } +// } +// String collectDateStr = stringArrayList.stream().collect(Collectors.joining("*")); +// logger.info("类型:time_frame 生成的日期范围:" + collectDateStr); +// return collectDateStr; +// } +// return null; +// } +// +// /** +// * 分割日期之后,再进行推送 +// * +// * @author liuyang +// */ +//// public void splitDateAndPush(String param, String sceneType, String pushScenarioType) throws Exception { +//// try { +//// Assert.notNull(param, "param不能为空!"); +//// Assert.state(!"".equals(param), "param不能为空!"); +//// +//// Assert.notNull(sceneType, "sceneType不能为空!"); +//// Assert.state(!"".equals(sceneType), "sceneType不能为空!"); +//// +//// Assert.notNull(pushScenarioType, "pushScenarioType不能为空!"); +//// Assert.state(!"".equals(pushScenarioType), "pushScenarioType不能为空!"); +//// +//// if (param.contains("*")) { +//// String[] params = param.split("\\*"); +//// if (params.length > 0) { +//// for (int i = 0; i < params.length; i++) { +//// String indexStr = params[i]; +//// String[] split = indexStr.split(","); +//// logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]); +//// if (sceneType.equals(STOCK)) { +//// startImplementStockByTime(split[0], split[1], pushScenarioType); +//// } else if (sceneType.equals(TRAN)) { +//// startImplementByTradeTime(split[0], split[1], pushScenarioType); +//// } +//// } +//// } +//// } else { +//// String[] split = param.split(","); +//// logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]); +//// if (sceneType.equals(STOCK)) { +//// startImplementStockByTime(split[0], split[1], pushScenarioType); +//// } else if (sceneType.equals(TRAN)) { +//// startImplementByTradeTime(split[0], split[1], pushScenarioType); +//// } +//// } +//// } catch (Exception e) { +//// logger.error("记录splitDateAndPush方法抛出的异常", e); +//// } +//// } +// +// /** +// * 计算全天时间段 +// * +// * @author liuyang +// */ +// public List calculateCalculateEntireDayPeriod(String dateStr) { +// List startAndEnd = new ArrayList<>(); +// +// String calculateYesterdayStr = null; +// if (dateStr != null) { +// calculateYesterdayStr = dateStr; +// } else { +// calculateYesterdayStr = calculateYesterdayDate();//拉取'昨天'的日期 +// } +// logger.info("OFS销售出库单同步U8C销售订单,目标拉取时间:" + calculateYesterdayStr); +// +// StartAndEndVo startAndEndVo = new StartAndEndVo(); +// startAndEndVo.setStart_time(calculateYesterdayStr + " 00:00:00"); +// startAndEndVo.setEnd_time(calculateYesterdayStr + " 23:59:59"); +// startAndEnd.add(startAndEndVo); +// +//// for (int i = 0; i <= 23; i++) { +//// String iStr = null; +//// if (i <= 9) { +//// iStr = "0" + i; +//// } else { +//// iStr = String.valueOf(i); +//// } +//// String startTime = calculateYesterdayStr + " " + iStr + ":00:00"; +//// String endTime = calculateYesterdayStr + " " + iStr + ":59:59"; +//// +//// StartAndEndVo startAndEndVo = new StartAndEndVo(); +//// startAndEndVo.setStart_time(startTime); +//// startAndEndVo.setEnd_time(endTime); +//// startAndEnd.add(startAndEndVo); +//// } +// return startAndEnd; +// } +// +// /** +// * 计算昨天的单据日期,基于定时器在凌晨5分执行的情况下 +// * +// * @author liuyang +// */ +// public String calculateYesterdayDate() { +// DateTime yesterdayDate = DateUtil.yesterday(); +// return DateUtil.format(yesterdayDate, "yyyy-MM-dd"); +// } +// +// /** +// * 计算时间范围对应的字符串集合 +// * +// * @author liuyang +// */ +// private List getDateRange(LocalDate startDate, LocalDate endDate) { +// List dateRange = new ArrayList<>(); +// LocalDate currentDate = startDate; +// while (!currentDate.isAfter(endDate)) { +// dateRange.add(currentDate.format(DateTimeFormatter.ISO_DATE)); +// currentDate = currentDate.plusDays(1); +// } +// return dateRange; +// } +// +// /** +// * 累加平台优惠 +// * +// * @param sonDetailsDtoList OFS售后入库单 +// * @author liuyang +// */ +// private void accumulationDiscountAmount(List sonDetailsDtoList) throws Exception { +// Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); +// +// if (sonDetailsDtoList.size() > 0) { +// BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0"); +// BigDecimal totalShareTargetMerchantDiscounts = new BigDecimal("0"); +// BigDecimal totalShareTargetExpertDiscounts = new BigDecimal("0"); +// BigDecimal totalShareTargetPayDiscounts = new BigDecimal("0"); +// +// for (int i = 0; i < sonDetailsDtoList.size(); i++) { +// //OFS售后入库单表体 +// GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(i); +// //OFS售后入库单表头 +// StockinOrderSearchResponse.StockinOrder.StockinH header1 = goodsRertunSonDetailsDto.getHeader(); +// Assert.notNull(header1, "OFS售后入库单表头不能为空!"); +// //OFS售后订单 +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header1.getRerturnGoodsOrderSearchData(); +// Assert.notNull(rerturnGoodsOrderSearchData, "通过OFS售后入库单号无法关联批量到OFS售后订单! OFS售后入库单编码:{} OFS售后订单号:{}", header1.getCode(), header1.getRefOrderCode()); +// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader(); +// List details = rerturnGoodsOrderSearchData.getDetails(); +// +// //四舍五入保留2位 +// RerturnGoodsOrderSearchDetails ofsOrderDetail = findOfsOrderDetail(details, goodsRertunSonDetailsDto); +// if (ofsOrderDetail.getShareTargetPlatformDiscounts() != null) { +// totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(ofsOrderDetail.getShareTargetPlatformDiscounts()); +// } +// if (ofsOrderDetail.getShareTargetMerchantDiscounts() != null) { +// totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(ofsOrderDetail.getShareTargetMerchantDiscounts()); +// } +// if (ofsOrderDetail.getShareTargetExpertDiscounts() != null) { +// totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(ofsOrderDetail.getShareTargetExpertDiscounts()); +// } +// if (ofsOrderDetail.getShareTargetPayDiscounts() != null) { +// totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(ofsOrderDetail.getShareTargetPayDiscounts()); +// } +// logger.info("对应的售后入库单明细行主键:{}", goodsRertunSonDetailsDto.getId()); +// } +// +// GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = sonDetailsDtoList.get(0); +// StockinOrderSearchResponse.StockinOrder.StockinH header = goodsRertunSonDetailsDto.getHeader(); +// +// goodsRertunSonDetailsDto.setVdef4(totalShareTargetPlatformDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// goodsRertunSonDetailsDto.setVdef5(totalShareTargetMerchantDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// goodsRertunSonDetailsDto.setVdef6(totalShareTargetExpertDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// goodsRertunSonDetailsDto.setVdef7(totalShareTargetPayDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// +// logger.info("售后入库明细主键:{} 售后入库单号:{} 最终汇总好的平台优惠:{}、支付优惠:{}、达人优惠:{}、商家优惠:{}", goodsRertunSonDetailsDto.getId(), header.getCode(), goodsRertunSonDetailsDto.getVdef4(), goodsRertunSonDetailsDto.getVdef5(), goodsRertunSonDetailsDto.getVdef6(), goodsRertunSonDetailsDto.getVdef7()); +// } else { +// logger.info("accumulationDiscountAmount方法对应的sonDetailsDtoList.size为零!"); +// } +// } +// +// /** +// * 根据OFS售后入库单明细行,查找匹配OFS售后订单明细行 +// * +// * @param details OFS售后订单明细行 +// * @param goodsRertunSonDetailsDto OFS售后入库单明细对象 +// * @author liuyang +// */ +// private RerturnGoodsOrderSearchDetails findOfsOrderDetail(List details, PassiveStorageSonDetailsDto goodsRertunSonDetailsDto) { +// Assert.notNull(details, "details不能为空"); +// Assert.notNull(goodsRertunSonDetailsDto, "goodsRertunSonDetailsDto不能为空"); +// +// for (int i = 0; i < details.size(); i++) { +// RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i); +// if (goodsRertunSonDetailsDto.getSkuCode() != null && rerturnGoodsOrderSearchDetails.getSkuCode() != null) { +// if (goodsRertunSonDetailsDto.getSkuCode().equals(rerturnGoodsOrderSearchDetails.getSkuCode())) { +// return rerturnGoodsOrderSearchDetails; +// } +// } +// } +//// Assert.state(false, "根据OFS售后入库单明细行,无法查找OFS售后订单明细行 来源明细行主键:{} 来源单据主键:{}", goodsRertunSonDetailsDto.getRefOrderDetailId(), goodsRertunSonDetailsDto.getRefOrderId()); +// Assert.state(false, "无源入库单明细行存货 sku:{} 名称:{} 无法匹配售后订单明细行 sku", goodsRertunSonDetailsDto.getSkuCode(), goodsRertunSonDetailsDto.getSkuName()); +// return null; +// } +// +// /** +// * 初始化所有存货管理档案对应的结存价、采购价 +// * +// * @author liuyang +// */ +// private List initAllBalancePricePurchasePrice() throws Exception { +// List mapList = new ArrayList<>(); +// Map stringIaPeriodaccountEntityMap = balanceUnitPriceUtil.initBalancePrice(); +// Map stringPoOrderBEntityMap = balanceUnitPriceUtil.initPurchasePrice(); +// mapList.add(stringIaPeriodaccountEntityMap); +// mapList.add(stringPoOrderBEntityMap); +// return mapList; +// } +// +// /** +// * 获取结存金额或者采购金额 +// * +// * @param isCheckShopChoose true取OFS实付金额、false取结存金额或者采购价 +// * @param bdInvmandocEntity 存货基本档案 +// * @param header 对应的销售入库单表头 +// * @param sonDetailsDto 对应的销售入库单明细行对象 +// * @param mapList 索引为0结存价为1采购价 +// * @author liuyang +// */ +// private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, StockinOrderSearchResponse.StockinOrder.StockinH header, GoodsRertunSonDetailsDto sonDetailsDto, List mapList, StringBuffer calculationFormulaStr) throws Exception { +// Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); +// Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空"); +// Assert.notNull(header, "header不能为空"); +// Assert.notNull(sonDetailsDto, "detailsDto不能为空"); +// Assert.notNull(mapList, "mapList不能为空"); +// Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空"); +// +// //此处只能为金额 +// String totalPayAmount = null; +// if (isCheckShopChoose) { +// IaPeriodaccountEntity iaPeriodaccountEntity1 = null; +// if (mapList != null && mapList.size() > 0) { +// Map stringIaPeriodaccountEntityMap = (Map) mapList.get(0); +// iaPeriodaccountEntity1 = stringIaPeriodaccountEntityMap.get(bdInvmandocEntity.getPkInvmandoc()); +// } +// if (iaPeriodaccountEntity1 != null) { +// //取结存价 +// logger.info("店铺:{} 取O结存价", header.getStoreCode()); +// calculationFormulaStr.append("取结存价:"); +// +// //结存金额 +// String nabmny = iaPeriodaccountEntity1.getNabmny(); +// if (nabmny == null || "".equals(nabmny)) { +// nabmny = "0"; +// } +// BigDecimal nabmnyBigDecimal = new BigDecimal(nabmny); +// +// //结存数量 +// String nabnum = iaPeriodaccountEntity1.getNabnum(); +// if (nabnum == null || "".equals(nabnum)) { +// nabnum = "0"; +// } +// BigDecimal nabnumBigDecimal = new BigDecimal(nabnum); +// +// if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString()) && !"0".equals(nabnumBigDecimal.stripTrailingZeros().toPlainString())) { +// String format = StrUtil.format("{}/{}*{}", nabmnyBigDecimal.stripTrailingZeros().toPlainString(), nabnumBigDecimal.stripTrailingZeros().toPlainString(), sonDetailsDto.getReceivedQty()); +// calculationFormulaStr.append(format); +// BigDecimal bigDecimal = nabmnyBigDecimal.divide(nabnumBigDecimal, 20, BigDecimal.ROUND_HALF_UP); +// BigDecimal totalPayAmountBigDecimal = bigDecimal.multiply(new BigDecimal(sonDetailsDto.getReceivedQty())).setScale(2, BigDecimal.ROUND_HALF_UP); +// totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString(); +// } else { +// //如果结存金额为或者数量为0,则设置为0 +// calculationFormulaStr.append("0"); +// totalPayAmount = "0"; +// } +// } else { +// //取采购价 +// logger.info("店铺:{} 取O采购价", header.getStoreCode()); +// calculationFormulaStr.append("取采购价:"); +// PoOrderBEntity poOrderBEntity = null; +// if (mapList != null && mapList.size() > 0) { +// Map poOrderBEntityList = (Map) mapList.get(1); +// if (poOrderBEntityList != null && poOrderBEntityList.size() > 0) { +// poOrderBEntity = poOrderBEntityList.get(bdInvmandocEntity.getPkInvmandoc()); +// } +// } +// if (poOrderBEntity != null) { +// String norgtaxprice = poOrderBEntity.getNorgtaxprice(); +// Assert.notNull(norgtaxprice, "U8C采购订单明细行存在「原币含税单价」为空"); +// if (norgtaxprice != null && !"0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) { +// String format = StrUtil.format("{}*{}", norgtaxprice, sonDetailsDto.getReceivedQty()); +// calculationFormulaStr.append(format); +// BigDecimal totalPayAmountBigDecimal = new BigDecimal(norgtaxprice).multiply(new BigDecimal(sonDetailsDto.getReceivedQty())).setScale(2, BigDecimal.ROUND_HALF_UP); +// totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString(); +// } else { +// //如果采购单价都为0,那么金额也为0 +// totalPayAmount = "0"; +// calculationFormulaStr.append("0"); +// } +// } else { +// Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc()); +// } +// } +// } +// return totalPayAmount; +// } +// +// /** +// * 累加应收金额=实退金额+达人优惠+支付优惠+平台优惠 +// * +// * @param passiveStorageSonDetailsDto O无源入库单 +// * @param rerturnGoodsOrderSearchData OFS售后订单 +// * @param calculationFormulaStr 计算公式 +// * @author liuyang +// */ +// private String accumulatedDiscounts(PassiveStorageSonDetailsDto passiveStorageSonDetailsDto, RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData, StringBuffer calculationFormulaStr) throws Exception { +// Assert.notNull(passiveStorageSonDetailsDto, "goodsRertunSonDetailsDto OFS售后入库单明细行不能为空!"); +// Assert.notNull(rerturnGoodsOrderSearchData, "rerturnGoodsOrderSearchData OFS售后订单不能为空!"); +// Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空!"); +// +// //O 无源入库单表头 +// PassiveStorageResponse.Header header1 = passiveStorageSonDetailsDto.getHeader(); +// +// //O售后订单表头、明细行 +// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader(); +// List details = rerturnGoodsOrderSearchData.getDetails(); +// +// //根据「入库单明细」匹配「售后订单明细行」 +// RerturnGoodsOrderSearchDetails targetDetails = null; +// for (int i = 0; i < details.size(); i++) { +// RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i); +// if (passiveStorageSonDetailsDto.getSkuCode() != null && rerturnGoodsOrderSearchDetails.getSkuCode() != null) { +// if (passiveStorageSonDetailsDto.getSkuCode().equals(rerturnGoodsOrderSearchDetails.getSkuCode())) { +// targetDetails = rerturnGoodsOrderSearchDetails; +// } +// } +// } +// Assert.notNull(targetDetails, "根据OFS无源入库单单细行(sku匹配)无法匹配售后订单明细行", passiveStorageSonDetailsDto.getSkuCode()); +// +// //售后订单明细行-退货金额 +// String totalAmount = targetDetails.getTotalAmount();//实退金额 +// Assert.notNull(totalAmount, "售后订单:{} 存货明细行:{} 退货金额不能为空!", header.getCode(), targetDetails.getSkuCode()); +// Assert.state(!"".equals(totalAmount), "售后订单:{} 存货明细行:{} 退货金额不能为空!", header.getCode(), targetDetails.getSkuCode()); +// //售后订单明细行-请求数量 +// //实退数量存在可能为0的情况,如果用退货金额/实退数量可能会抛出异常 +// String requestQty = targetDetails.getRequestQty();//请求数量 +// Assert.notNull(requestQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); +// Assert.state(!"".equals(requestQty), "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); +// +// String quantity = passiveStorageSonDetailsDto.getQuantity(); +// Assert.notNull(quantity, "无源入库单:{} sku:{} 实退数量不能为空", passiveStorageSonDetailsDto.getQuantity(), passiveStorageSonDetailsDto.getSkuName()); +// Assert.state(!"".equals(quantity), "无源入库单:{} sku:{} 实退数量不能为空", passiveStorageSonDetailsDto.getQuantity(), passiveStorageSonDetailsDto.getSkuName()); +// if ("0".equals(new BigDecimal(quantity).stripTrailingZeros().toPlainString())) { +// Assert.state(false, "无源入库单:{} sku:{} 实退数量不能为0!", passiveStorageSonDetailsDto.getQuantity(), passiveStorageSonDetailsDto.getSkuName()); +// } +// +// //O含税单价=通过退货金额/请求数量 +// BigDecimal unitPriceIncludingTax = new BigDecimal(totalAmount).divide(new BigDecimal(requestQty), 20, BigDecimal.ROUND_HALF_UP); +// //实退金额=O含税单价*(O售后入库单)实退数量 +// BigDecimal actualRefundAmount = unitPriceIncludingTax.multiply(new BigDecimal(quantity)).setScale(4, BigDecimal.ROUND_HALF_UP); +// String format = StrUtil.format("{}/{}*{}", totalAmount, requestQty, quantity); +// calculationFormulaStr.append(format); +// return actualRefundAmount.stripTrailingZeros().toPlainString(); +// } +// +// /** +// * 汇总好之后,相同的 sku,累加优惠金额,放在自定义项里最后传给U8C +// * +// * @param sonDetailsDtoList OFS售后入库单明细行List集合(按纬度汇总好的) +// * @author liuyang +// */ +// private void accumulatedDiscountAmountDef(List sonDetailsDtoList) throws Exception { +// Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); +// +// if (sonDetailsDtoList.size() > 0) { +// BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台 +// BigDecimal merchantDiscountsBigDecimal = new BigDecimal("0");//商家 +// BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人 +// BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付 +// +// for (int i = 0; i < sonDetailsDtoList.size(); i++) { +// PassiveStorageSonDetailsDto passiveStorageSonDetailsDto = sonDetailsDtoList.get(i); +// PassiveStorageResponse.Header header = passiveStorageSonDetailsDto.getHeader();//O无源入库单表头 +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = header.getRerturnGoodsOrderSearchData();//OFS售后订单 +// Assert.notNull(rerturnGoodsOrderSearchData, "O售后订单不能为空!"); +// List details = rerturnGoodsOrderSearchData.getDetails();//OFS售后订单明细行 +// +// if (details != null && details.size() > 0) { +// for (int j = 0; j < details.size(); j++) { +// RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(j); +// if (passiveStorageSonDetailsDto.getSkuCode() != null && rerturnGoodsOrderSearchDetails.getSkuCode() != null) { +// if (passiveStorageSonDetailsDto.getSkuCode().equals(rerturnGoodsOrderSearchDetails.getSkuCode())) { +// //累加优惠 +// String platformDiscounts = rerturnGoodsOrderSearchDetails.getPlatformDiscounts(); +// String merchantDiscounts = rerturnGoodsOrderSearchDetails.getMerchantDiscounts(); +// String expertDiscounts = rerturnGoodsOrderSearchDetails.getExpertDiscounts(); +// String payDiscounts = rerturnGoodsOrderSearchDetails.getPayDiscounts(); +// +// if (platformDiscounts == null || "".equals(platformDiscounts.trim())) { +// platformDiscounts = "0"; +// } +// if (merchantDiscounts == null || "".equals(merchantDiscounts.trim())) { +// merchantDiscounts = "0"; +// } +// if (expertDiscounts == null || "".equals(expertDiscounts.trim())) { +// expertDiscounts = "0"; +// } +// if (payDiscounts == null || "".equals(payDiscounts.trim())) { +// payDiscounts = "0"; +// } +// +// platformDiscountsBigDecimal = platformDiscountsBigDecimal.add(new BigDecimal(platformDiscounts)); +// merchantDiscountsBigDecimal = merchantDiscountsBigDecimal.add(new BigDecimal(merchantDiscounts)); +// expertDiscountsBigDecimal = expertDiscountsBigDecimal.add(new BigDecimal(expertDiscounts)); +// payDiscountsBigDecimal = payDiscountsBigDecimal.add(new BigDecimal(payDiscounts)); +// } +// } +// } +// } +// } +// sonDetailsDtoList.get(0).setVdef4(platformDiscountsBigDecimal);//平台 +// sonDetailsDtoList.get(0).setVdef5(payDiscountsBigDecimal);//支付 +// sonDetailsDtoList.get(0).setVdef6(expertDiscountsBigDecimal);//达人 +// sonDetailsDtoList.get(0).setVdef7(merchantDiscountsBigDecimal);//商家 +// } +// } +// +// /** +// * 获取参考售价 +// * +// * @param bdInvmandocEntity 存货管理档案 +// * @param bdInvbasdocEntity 存货基本档案 +// * @param calculationFormulaStr 计算公式 +// * @param passiveStorageSonDetailsDto O 无源入库单 +// * @param header O售后入库单表头 +// * @author liuyang +// */ +// private String getRefsaleprice(BdInvmandocEntity bdInvmandocEntity, BdInvbasdocEntity bdInvbasdocEntity, StringBuffer calculationFormulaStr, PassiveStorageSonDetailsDto passiveStorageSonDetailsDto) throws Exception { +// Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空!"); +// Assert.notNull(bdInvbasdocEntity, "bdInvbasdocEntity不能为空!"); +// Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空!"); +// Assert.notNull(passiveStorageSonDetailsDto, "passiveStorageSonDetailsDto不能为空!"); +//// Assert.notNull(header, "header不能为空"); +// +// //U参考售价 +// String refsaleprice = bdInvmandocEntity.getRefsaleprice(); +// Assert.notNull(refsaleprice, "存货:{} 公司:{} 不存在参考售价,请维护!", bdInvbasdocEntity.getInvname(), bdInvmandocEntity.getPkCorp()); +// +// //O无源入库单实收数量 +// String receivedQty = passiveStorageSonDetailsDto.getQuantity(); +// Assert.notNull(receivedQty, "O实收数量不能为空 O 无源入库单编码:{}", passiveStorageSonDetailsDto.getReceiptCode()); +// Assert.state(!"".equals(receivedQty), "O实收数量不能为空 O 无源入库单编码:{}", passiveStorageSonDetailsDto.getReceiptCode()); +// +// BigDecimal amountOfMoney = new BigDecimal(refsaleprice).multiply(new BigDecimal(receivedQty)); +// String format = StrUtil.format("取U参考售价:{}*{}", refsaleprice, receivedQty); +// calculationFormulaStr.append(format); +// return amountOfMoney.stripTrailingZeros().toPlainString(); +// } +// +// /** +// * 查询OFS底表的O售后入库单数据 +// * +// * @author liuyang +// */ +// public List queryTocofsReturngoodsDetailed(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity) throws Exception { +// Assert.notNull(tocofsReturngoodsDetailedEntity, "tocofsReturngoodsDetailedEntity不能为空"); +// +// //底表O售后入库单表头对象 +// List allTocofsReturngoodsEntityList = new ArrayList<>(); +// //底表O售后入库单明细行 +// List tocofsReturngoodsDetailedEntityList = iTocofsReturngoodsDetailedDao.query(tocofsReturngoodsDetailedEntity); +// if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0) { +// Set mainTableIdSet = tocofsReturngoodsDetailedEntityList.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet()); +// List mainTableIdList = Lists.newArrayList(mainTableIdSet); +// +// List> splitListByCount = SplitListByCountUtil.splitListByCount(mainTableIdList, 1000); +//// List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityList, 1000); +// for (int i = 0; i < splitListByCount.size(); i++) { +// List strings = splitListByCount.get(i); +//// Set mainTableIdSet = tocofsReturngoodsDetailedEntityList1.stream().map(TocofsReturngoodsDetailedEntity::getMaintableid).collect(Collectors.toSet()); +// String mainTableIds = strings.stream().map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// //查询对应的O售后入库单表头 +// TocofsReturngoodsEntity tocofsReturngoodsEntity = new TocofsReturngoodsEntity(); +// tocofsReturngoodsEntity.setIds(mainTableIds); +// List tocofsReturngoodsEntityList = iTocofsReturngoodsDao.query(tocofsReturngoodsEntity); +// allTocofsReturngoodsEntityList.addAll(tocofsReturngoodsEntityList); +// } +// } +// +// //通过「O售后入库单表头」匹配「O售后入库单明细」 +// if (allTocofsReturngoodsEntityList.size() > 0) { +// Map> stringListMap = convertToMap(tocofsReturngoodsDetailedEntityList); +// for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) { +// TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i); +// //性能太差了,使用Map搜索 +//// List tocofsReturngoodsDetailedEntityList1 = new ArrayList<>(); +//// for (int j = 0; j < tocofsReturngoodsDetailedEntityList.size(); j++) { +//// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList.get(j); +//// if (tocofsReturngoodsDetailedEntity1.getMaintableid().equals(tocofsReturngoodsEntity.getId())) { +//// tocofsReturngoodsDetailedEntityList1.add(tocofsReturngoodsDetailedEntity1); +//// } +//// } +//// tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntityList1); +// List tocofsReturngoodsDetailedEntities = stringListMap.get(tocofsReturngoodsEntity.getId()); +// tocofsReturngoodsEntity.setTocofsReturngoodsDetailedEntityList(tocofsReturngoodsDetailedEntities); +// } +// } +// +// //转换为OFS售后入库单对象 +// List returnGoodHeaderDetailsDataDtoArrayList = new ArrayList<>(); +// if (allTocofsReturngoodsEntityList.size() > 0) { +// for (int i = 0; i < allTocofsReturngoodsEntityList.size(); i++) { +// +// StockinOrderSearchResponse.StockinOrder stockinOrder = new StockinOrderSearchResponse.StockinOrder(); +// returnGoodHeaderDetailsDataDtoArrayList.add(stockinOrder); +// +// //处理表头 +// TocofsReturngoodsEntity tocofsReturngoodsEntity = allTocofsReturngoodsEntityList.get(i); +// StockinOrderSearchResponse.StockinOrder.StockinH stockinH = new StockinOrderSearchResponse.StockinOrder.StockinH(); +// stockinH.setId(tocofsReturngoodsEntity.getId()); +// BeanUtil.copyPropertiesV2(tocofsReturngoodsEntity, stockinH); +// stockinOrder.setHeader(stockinH); +// +// //处理明细行 +// List tocofsReturngoodsDetailedEntityList1 = tocofsReturngoodsEntity.getTocofsReturngoodsDetailedEntityList(); +// List stockinB = new ArrayList<>(); +// stockinOrder.setDetails(stockinB); +// for (int j = 0; j < tocofsReturngoodsDetailedEntityList1.size(); j++) { +// TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity1 = tocofsReturngoodsDetailedEntityList1.get(j); +// +// StockinOrderSearchResponse.StockinOrder.StockinB stockinB1 = new StockinOrderSearchResponse.StockinOrder.StockinB(); +// BeanUtil.copyPropertiesV2(tocofsReturngoodsDetailedEntity1, stockinB1); +// stockinB1.setId(tocofsReturngoodsDetailedEntity1.getId()); +// stockinB.add(stockinB1); +// } +// } +// } +// return returnGoodHeaderDetailsDataDtoArrayList; +// } +// +// /** +// * 存在相同Maintableid汇总在一起 +// * +// * @author liuyang +// */ +// public static Map> convertToMap(List tocofsReturngoodsDetailedEntityList) { +// Map> map = new HashMap<>(); +// for (TocofsReturngoodsDetailedEntity entity : tocofsReturngoodsDetailedEntityList) { +// String maintableid = entity.getMaintableid(); +// map.computeIfAbsent(maintableid, k -> new ArrayList<>()).add(entity); +// } +// return map; +// } } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDtoV3.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDtoV3.java new file mode 100644 index 00000000..8a15a59e --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDtoV3.java @@ -0,0 +1,43 @@ +package com.hzya.frame.plugin.lets.u8cdto; + +import com.hzya.frame.ttxofs.dto.passivestorage.PassiveStorageResponse; +import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; +import lombok.Data; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.u8cdto + * @Project:kangarooDataCenterV3 + * @name:ErrorHeaderDetailsDtoDto + * @Date:2024/9/5 15:48 + * @Filename:ErrorHeaderDetailsDtoDto + */ +@Data +public class ErrorHeaderDetailsDtoDtoV3 extends PassiveStorageResponse.Data { + //(销售)推送时间 + private String newPushDate; + //(销售)报错详情 + private String newTransmitInfo; + //(销售)出库同步是否成功 + private String newstate; + //推送时间 + private String def5; + //报错详情 + private String def6; + //(销售)交易成功(TOB发票)是否成功 + private String newstate4; + //下游单号 + private String newSystemNumber4; + //下游主键 + private String newSystemPrimary4; + //(销售)推送时间 + private String newPushDate2; + //(销售)报错详情 + private String newTransmitInfo2; + //(销售)出库同步是否成功 + private String newstate2; + //下游单据 + private String newsystemnumber; + //下游主键 + private String newsystemprimary; +} diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/PassiveStorageSonDetailsDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/PassiveStorageSonDetailsDto.java new file mode 100644 index 00000000..518063c0 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/PassiveStorageSonDetailsDto.java @@ -0,0 +1,145 @@ +package com.hzya.frame.plugin.lets.u8cdto; + +import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.ttxofs.dto.passivestorage.PassiveStorageResponse; +import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.ttxofs.dto.u8cson + * @Project:kangarooDataCenterV3 + * @name:SonDetailsDto + * @Date:2024/8/5 16:07 + * @Filename:SonDetailsDto + */ +@Data +public class PassiveStorageSonDetailsDto extends PassiveStorageResponse.Details { + /** + * 表头对象 + */ + private PassiveStorageResponse.Header header; + + /** + * 表头公司(销售公司) + */ + private BdCorpEntity bdCorpEntity; + + /** + * 发货库存组织 + */ + private BdCalbodyEntity bdCalbodyEntity; + + /** + * 发货仓库 + */ + private BdStordocEntity bdStordocEntity; + + /** + * 收货库存组织 + */ + private BdCalbodyEntity bdCalbodyEntity1; + + /** + * 收货仓库 + */ + private BdStordocEntity bdStordocEntity1; + + /** + * 销售组织 + */ + private BdSalestruEntity bdSalestruEntity; + + /** + * 业务部门 + */ + private BdDeptdocEntity bdDeptdocEntity; + + /** + * 客商管理档案 + */ + private BdCumandocEntity bdCumandocEntity; + + /** + * 客商基本档案 + */ + private BdCubasdocEntity bdCubasdocEntity; + + /** + * 生成汇总维度字符串 + */ + private String summaryDimensionStr; + + /** + * 汇总总金额 + */ + private BigDecimal groupTotalPayAmount; + + /** + * 汇总实发数量 + */ + private BigDecimal groupShipQty; + + /** + * 发货公司 + */ + private BdCorpEntity deliverGoodsCorp; + + /** + * U8C平台档案 + */ + private BdDefdocEntity platformArchives; + + /** + * U8C店铺档案 + */ + private BdDefdocEntity shopArchives; + + /** + * OFS收发类别 + */ + private BdRdclEntity bdRdclEntity; + + /** + * 存货管理档案 + */ + private BdInvmandocEntity bdInvmandocEntity; + + /** + * 存货基本档案 + */ + private BdInvbasdocEntity bdInvbasdocEntity; + + /** + * 存货税率 + */ + private BdTaxitemsEntity bdTaxitemsEntity; + + //累加平台优惠 + private BigDecimal vdef4; + + //累加支付优惠 + private BigDecimal vdef5; + + //累加达人优惠 + private BigDecimal vdef6; + + //累加商家优惠 + private BigDecimal vdef7; + + //把销售订单明细行对应的优惠金额保存到销售出库单明细行一份,便于存储到中台的底表 + //计算应收 + private String calculateAccountsReceivable; + //计算公式 + private String calculationFormula; + //平台优惠 + private String platformDiscounts; + //商家优惠 + private String merchantDiscounts; + //达人优惠 + private String expertDiscounts; + //支付优惠 + private String payDiscounts; +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java index adf438d2..b239ed8b 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java @@ -15,6 +15,7 @@ import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto; import com.hzya.frame.ttxofs.dto.ofswareconfirma.OfsWareConfirmaResponse; +import com.hzya.frame.ttxofs.dto.passivestorage.PassiveStorageResponse; import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; import com.hzya.frame.ttxofs.service.OfsUnifiedService; import org.slf4j.Logger; @@ -323,4 +324,43 @@ public class OfsStandardUtil { logger.error("rertunGoodsRootBean为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); } } + + + /** + * OFS无源入库单查询 + * + * @param queryOfsSoSaleOutVo 接口入参 + * @param headerDetailsDtoList 收集对象 + * @param pageNo 从第几页开始查询 + * @param api api接口名称 + * @author liuyang + */ + public void queryOfsPassiveComponents(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List headerDetailsDtoList, Long pageNo, String api) throws Exception { + Assert.notNull(queryOfsSoSaleOutVo, "queryOfsSoSaleOutVo不能为空!"); + Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空"); + Assert.notNull(pageNo, "pageNo不能为空"); + Assert.notNull(api, "api不能为空"); + + Long pageSize = 200L; + queryOfsSoSaleOutVo.setPageNo(pageNo); + queryOfsSoSaleOutVo.setPageSize(pageSize); + + InterfaceParamDto interfaceParamDto = new InterfaceParamDto(); + interfaceParamDto.setApi(api); + interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo)); + PassiveStorageResponse passiveStorageResponse = (PassiveStorageResponse) ofsUnifiedService.unified(interfaceParamDto); + if (passiveStorageResponse != null) { + if ("false".equals(passiveStorageResponse.getError()) && "0".equals(passiveStorageResponse.getCode()) && "Success".equals(passiveStorageResponse.getMsg())) { + List data = passiveStorageResponse.getData(); + if (data != null && data.size() > 0) { + headerDetailsDtoList.addAll(data); + queryOfsPassiveComponents(queryOfsSoSaleOutVo, headerDetailsDtoList, ++pageNo, api); + } + } else { + logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); + } + } else { + logger.error("passiveStorageResponse为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto)); + } + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PassiveComponentsArchivesCacheUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PassiveComponentsArchivesCacheUtil.java new file mode 100644 index 00000000..3117e53f --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PassiveComponentsArchivesCacheUtil.java @@ -0,0 +1,651 @@ +package com.hzya.frame.plugin.lets.util; + +import cn.hutool.core.lang.Assert; +import com.hzya.frame.plugin.lets.constant.OverallConstant; +import com.hzya.frame.plugin.lets.dao.*; +import com.hzya.frame.plugin.lets.entity.*; +import com.hzya.frame.plugin.lets.resultvo.CacheTocMapVoV2; +import com.hzya.frame.split.SplitListByCountUtil; +import com.hzya.frame.ttxofs.dto.passivestorage.PassiveStorageResponse; +import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * 档案类缓存,TOC销售订单转换 + * + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:BasicArchivesCacheUtil + * @Date:2024/7/31 11:27 + * @Filename:BasicArchivesCacheUtil + */ +@Component +public class PassiveComponentsArchivesCacheUtil { + + @Autowired + private IBdCorpDao iBdCorpDao; + + @Autowired + private IBdStordocDao iBdStordocDao; + + @Autowired + private IBdCalbodyDao iBdCalbodyDao; + + @Autowired + private IBdSalestruDao iBdSalestruDao; + + @Autowired + private IBdDeptdocDao iBdDeptdocDao; + + @Autowired + private IBdCumandocDao iBdCumandocDao; + + @Autowired + private IBdInvmandocDao iBdInvmandocDao; + + @Autowired + private IBdInvbasdocDao iBdInvbasdocDao; + + @Autowired + private IBdTaxitemsDao iBdTaxitemsDao; + + @Autowired + private IBdCubasdocDao iBdCubasdocDao; + + @Autowired + private IBdDefdocDao iBdDefdocDao; + + @Autowired + private IBdRdclDao iBdRdclDao; + +// public static Map stringBdCorpEntityMap = new HashMap<>(); + + /** + * 初始化公司档案-表头公司 + * 2024年7月31日 11:16:23 + */ + private Map initShop() throws Exception { + Map stringBdCorpEntityMap = new HashMap<>(); + BdCorpEntity bdCorpEntity = new BdCorpEntity(); + bdCorpEntity.setDr(0); + bdCorpEntity.setDataSourceCode("lets_u8c"); + List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); + if (bdCorpEntityList != null && bdCorpEntityList.size() > 0) { + for (int i = 0; i < bdCorpEntityList.size(); i++) { + BdCorpEntity bdCorpEntity1 = bdCorpEntityList.get(i); + stringBdCorpEntityMap.put(bdCorpEntity1.getUnitcode(), bdCorpEntity1); + } + } + return stringBdCorpEntityMap; + } + + // public static Map stringBdStordocEntityMap = new HashMap<>(); + + /** + * 初始化发货仓库 + * 2024年7月31日 11:16:27 + * 202403011513:仓库根据仓库编码+库存组织编码去查询,之前是仓库编码+公司主键,和李佳妮确认好了 + */ + private Map initBdStordoc() throws Exception { + Map stringBdStordocEntityMap = new HashMap<>(); + BdStordocEntity bdStordocEntity = new BdStordocEntity(); + bdStordocEntity.setDr(0L); + bdStordocEntity.setDataSourceCode("lets_u8c"); + List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); + if (bdStordocEntityList != null && bdStordocEntityList.size() > 0) { + for (int i = 0; i < bdStordocEntityList.size(); i++) { + BdStordocEntity bdStordocEntity1 = bdStordocEntityList.get(i); + stringBdStordocEntityMap.put(bdStordocEntity1.getStorcode() + bdStordocEntity1.getPkCalbody(), bdStordocEntity1); + } + } + return stringBdStordocEntityMap; + } + + /** + * 2024年7月31日 11:09:12 查询发货库存组织 + */ +// public static Map stringBdCalbodyEntityMap = new HashMap<>(); + private Map initBdCalbody() throws Exception { + Map stringBdCalbodyEntityMap = new HashMap<>(); + BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); + bdCalbodyEntity.setDr(0); + bdCalbodyEntity.setDataSourceCode("lets_u8c"); + List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); + if (bdCalbodyEntities != null && bdCalbodyEntities.size() > 0) { + for (int i = 0; i < bdCalbodyEntities.size(); i++) { + BdCalbodyEntity bdCalbodyEntity1 = bdCalbodyEntities.get(i); + stringBdCalbodyEntityMap.put(bdCalbodyEntity1.getPkCorp(), bdCalbodyEntity1); + } + } + return stringBdCalbodyEntityMap; + } + + /** + * 初始化销售组织 + */ +// public static Map stringBdSalestruEntityMap = new HashMap<>(); + private Map initBdSalestru() throws Exception { + Map stringBdSalestruEntityMap = new HashMap<>(); + BdSalestruEntity bdSalestruEntity = new BdSalestruEntity(); + bdSalestruEntity.setDr(0); + bdSalestruEntity.setDataSourceCode("lets_u8c"); + List bdSalestruEntityList = iBdSalestruDao.query(bdSalestruEntity); + if (bdSalestruEntityList != null && bdSalestruEntityList.size() > 0) { + for (int i = 0; i < bdSalestruEntityList.size(); i++) { + BdSalestruEntity bdSalestruEntity1 = bdSalestruEntityList.get(i); + stringBdSalestruEntityMap.put(bdSalestruEntity1.getVsalestruname(), bdSalestruEntity1); + } + } + return stringBdSalestruEntityMap; + } + + /** + * 初始化业务部门 + * + * @author liuyang + */ +// public static Map stringBdDeptdocEntityMap = new HashMap<>(); + private List> initDept() { + List> bddeptdocEntityList = new ArrayList<>(); + + Map stringBdDeptdocEntityMap1 = new HashMap<>(); + Map stringBdDeptdocEntityMap2 = new HashMap<>(); + bddeptdocEntityList.add(stringBdDeptdocEntityMap1); + bddeptdocEntityList.add(stringBdDeptdocEntityMap2); + + String deptName = "业务部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList != null && bdDeptdocEntityList.size() > 0) { + for (int i = 0; i < bdDeptdocEntityList.size(); i++) { + BdDeptdocEntity bdDeptdocEntity1 = bdDeptdocEntityList.get(i); + stringBdDeptdocEntityMap1.put(bdDeptdocEntity1.getPkCorp(), bdDeptdocEntity1); + } + } + + BdDeptdocEntity bdDeptdocEntity2 = new BdDeptdocEntity(); + bdDeptdocEntity2.setDataSourceCode("lets_u8c"); + bdDeptdocEntity2.setDr(0); + List bdDeptdocEntityList2 = iBdDeptdocDao.query(bdDeptdocEntity2); + if (bdDeptdocEntityList2 != null && bdDeptdocEntityList2.size() > 0) { + for (int i = 0; i < bdDeptdocEntityList2.size(); i++) { + BdDeptdocEntity bdDeptdocEntity1 = bdDeptdocEntityList2.get(i); + stringBdDeptdocEntityMap2.put(bdDeptdocEntity1.getDeptcode(), bdDeptdocEntity1); + } + } + return bddeptdocEntityList; + } + + /** + * 初始化客商基本档案 + * + * @author liuyang + */ +// public static Map stringBdCubasdocEntityHashMap = new HashMap<>(); +// private Map initBdCubasdoc() { +// Map stringBdCubasdocEntityHashMap = new HashMap<>(); +// +// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); +// bdCubasdocEntity.setDataSourceCode("lets_u8c"); +// bdCubasdocEntity.setDr(0L); +// List bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); +// if (bdCumandocEntityList != null && bdCumandocEntityList.size() > 0) { +// for (int i = 0; i < bdCumandocEntityList.size(); i++) { +// BdCubasdocEntity bdCubasdocEntity1 = bdCumandocEntityList.get(i); +// stringBdCubasdocEntityHashMap.put(bdCubasdocEntity1.getCustname(), bdCubasdocEntity1); +// } +// } +// return stringBdCubasdocEntityHashMap; +// } + + //O店铺编码=U8C客商档案def1 + private Map initBdCubasdocV2(List headerDtoList) { + Map stringBdCubasdocEntityMap = new HashMap<>(); + List allBdCumandocEntityList = new ArrayList<>(); + if (headerDtoList != null && headerDtoList.size() > 0) { + Set stringSet = headerDtoList.stream().map(PassiveStorageResponse.Header::getStoreCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); + for (int i = 0; i < lists.size(); i++) { + List strings = lists.get(i); + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (codesStr != null && codesStr.length() > 0) { + BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); + bdCubasdocEntity.setDataSourceCode("lets_u8c"); + bdCubasdocEntity.setDr(0L); + bdCubasdocEntity.setDef1s(codesStr); + List bdCumandocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); + allBdCumandocEntityList.addAll(bdCumandocEntityList); + } + } + } + if (allBdCumandocEntityList.size() > 0) { + for (int i = 0; i < allBdCumandocEntityList.size(); i++) { + BdCubasdocEntity bdCubasdocEntity = allBdCumandocEntityList.get(i); + if (bdCubasdocEntity.getDef1() != null) { + stringBdCubasdocEntityMap.put(bdCubasdocEntity.getDef1(), bdCubasdocEntity); + } + } + } + return stringBdCubasdocEntityMap; + } + + /** + * 初始化客商管理档案 + * + * @author liuyang + */ +// public static Map stringBdCumandocEntityMap = new HashMap<>(); +// private Map initBdCumandoc() { +// Map stringBdCumandocEntityMap = new HashMap<>(); +// +// BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); +// bdCumandocEntity1.setDataSourceCode("lets_u8c"); +// bdCumandocEntity1.setDr(0L); +//// bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER);//客商:2客户 +// List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); +// if (bdCumandocEntityList != null && bdCumandocEntityList.size() > 0) { +// for (int i = 0; i < bdCumandocEntityList.size(); i++) { +// BdCumandocEntity bdCumandocEntity = bdCumandocEntityList.get(i); +// stringBdCumandocEntityMap.put(bdCumandocEntity.getPkCubasdoc() + bdCumandocEntity.getPkCorp(), bdCumandocEntity); +// } +// } +// return stringBdCumandocEntityMap; +// } + + /** + * 查询客商管理档案 + * + * @author liuyang + */ + private Map initBdCumandocV2(List headerDtoList) throws Exception { + Map stringBdCumandocEntityMap = new HashMap<>(); + List allBdCumandocEntityList = new ArrayList<>(); + + if (headerDtoList != null && headerDtoList.size() > 0) { + Set stringSet = headerDtoList.stream().map(PassiveStorageResponse.Header::getStoreCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); + + for (int i = 0; i < lists.size(); i++) { + List strings = lists.get(i); + + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + BdCumandocEntity bdCumandocEntity = new BdCumandocEntity(); + bdCumandocEntity.setDataSourceCode("lets_u8c"); + bdCumandocEntity.setDr(0L); + bdCumandocEntity.setDef1s(codesStr); + List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity); + allBdCumandocEntityList.addAll(bdCumandocEntityList); + } + } + + if (allBdCumandocEntityList.size() > 0) { + for (int i = 0; i < allBdCumandocEntityList.size(); i++) { + BdCumandocEntity bdCumandocEntity = allBdCumandocEntityList.get(i); + stringBdCumandocEntityMap.put(bdCumandocEntity.getPkCubasdoc() + bdCumandocEntity.getPkCorp(), bdCumandocEntity); + } + } + return stringBdCumandocEntityMap; + } + + /** + * 初始化存货管理档案 + */ +// public static Map stringBdInvmandocEntityMap = new HashMap<>(); +// private Map initInventoryFile() throws Exception { +// Map stringBdInvmandocEntityMap = new HashMap<>(); +// +// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); +//// bdInvmandocEntity.setInvcode(copyRowDetailsListVo.getSpec_no()); +//// bdInvmandocEntity.setPkCorp(shippingCompanyBdCorpEntity.getPkCorp()); +// List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); +// if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { +// for (int i = 0; i < bdInvmandocEntity2.size(); i++) { +// BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(i); +// //2024年8月6日 14:27:45 通过存货编码+公司缓存 +// stringBdInvmandocEntityMap.put(bdInvmandocEntity1.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); +// } +// } +// return stringBdInvmandocEntityMap; +// } + public Map initInventoryFileV2(List detailsDtos) throws Exception { + List allBdInvmandocEntity = new ArrayList<>(); + Map stringBdInvmandocEntityMap = new HashMap<>(); + + if (detailsDtos != null && detailsDtos.size() > 0) { + Set stringSet = detailsDtos.stream().map(PassiveStorageResponse.Details::getSkuCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); + for (int i = 0; i < lists.size(); i++) { + List strings = lists.get(i); + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (codesStr != null && codesStr.length() > 0) { + BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); + bdInvmandocEntity.setInvcodes(codesStr); + List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); + allBdInvmandocEntity.addAll(bdInvmandocEntity2); + } + } + +// List> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinBList = lists.get(i); +// String idsStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); +// bdInvmandocEntity.setInvcodes(idsStr); +// List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); +// allBdInvmandocEntity.addAll(bdInvmandocEntity2); +// } + } + if (allBdInvmandocEntity.size() > 0) { + for (int i = 0; i < allBdInvmandocEntity.size(); i++) { + BdInvmandocEntity bdInvmandocEntity = allBdInvmandocEntity.get(i); + stringBdInvmandocEntityMap.put(bdInvmandocEntity.getInvcode() + bdInvmandocEntity.getPkCorp(), bdInvmandocEntity); + } + } + return stringBdInvmandocEntityMap; + } + + /** + * 初始化存货基本档案 + * 2024年8月7日 10:57:55 + */ +// public static Map stringBdInvbasdocEntityHashMap = new HashMap<>(); +// private Map initBasicInventoryFile() throws Exception { +// Map stringBdInvbasdocEntityHashMap = new HashMap<>(); +// +// BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); +//// bdInvbasdocEntity.setPk_invmandoc(bdInvmandocEntity1.getPkInvmandoc()); +//// bdInvbasdocEntity.setPk_corp(shippingCompanyBdCorpEntity.getPkCorp()); +// List bdInvbasdocEntity2 = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV2(bdInvbasdocEntity); +// if (bdInvbasdocEntity2 != null && bdInvbasdocEntity2.size() > 0) { +// for (int i = 0; i < bdInvbasdocEntity2.size(); i++) { +// BdInvbasdocEntity bdInvbasdocEntity1 = bdInvbasdocEntity2.get(i); +// stringBdInvbasdocEntityHashMap.put(bdInvbasdocEntity1.getPk_invmandoc() + bdInvbasdocEntity1.getPk_corp_man(), bdInvbasdocEntity1); +// } +// } +// return stringBdInvbasdocEntityHashMap; +// } + + /** + * 根据O存货商家编码初始化存货基本档案 + * + * @author liuyang + */ + private Map initBasicInventoryFileV2(List detailsDtoList) throws Exception { + List allBdInvbasdocEntityList = new ArrayList<>(); + if (detailsDtoList != null && detailsDtoList.size() > 0) { + Set stringSet = detailsDtoList.stream().map(PassiveStorageResponse.Details::getSkuCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); + for (int i = 0; i < lists.size(); i++) { + List strings = lists.get(i); + String codesStr = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (codesStr != null && codesStr.length() > 0) { + BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); + bdInvbasdocEntity.setInvcodes(codesStr); + List bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity); + allBdInvbasdocEntityList.addAll(bdInvbasdocEntities); + } + } +// List> lists = SplitListByCountUtil.splitListByCount(detailsDtoList, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinBList = lists.get(i); +// String idsStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); +// bdInvbasdocEntity.setInvcodes(idsStr); +// List bdInvbasdocEntities = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV3(bdInvbasdocEntity); +// allBdInvbasdocEntityList.addAll(bdInvbasdocEntities); +// } + } + Map stringBdInvbasdocEntityMap = new HashMap<>(); + for (int i = 0; i < allBdInvbasdocEntityList.size(); i++) { + BdInvbasdocEntity bdInvbasdocEntity = allBdInvbasdocEntityList.get(i); + stringBdInvbasdocEntityMap.put(bdInvbasdocEntity.getInvcode(), bdInvbasdocEntity); + } + return stringBdInvbasdocEntityMap; + } + + /** + * 2024年8月7日 10:59:30 + * 初始化存货税率 + * + * @author liuyang + */ +// public static Map stringBdTaxitemsEntityHashMap = new HashMap<>(); +// private Map initBdTaxitemsEntity() throws Exception { +// Map stringBdTaxitemsEntityHashMap = new HashMap<>(); +// +// BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); +// List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); +// if (bdTaxitemsEntityList != null && bdTaxitemsEntityList.size() > 0) { +// for (int i = 0; i < bdTaxitemsEntityList.size(); i++) { +// BdTaxitemsEntity bdTaxitemsEntity1 = bdTaxitemsEntityList.get(i); +// stringBdTaxitemsEntityHashMap.put(bdTaxitemsEntity1.getInvcode(), bdTaxitemsEntity1); +// } +// } +// return stringBdTaxitemsEntityHashMap; +// } + private Map initBdTaxitemsEntityV2(List detailsDtos) throws Exception { + List allBdTaxitemsEntityList = new ArrayList<>(); + Map stringBdTaxitemsEntityMap = new HashMap<>(); + if (detailsDtos != null && detailsDtos.size() > 0) { + Set stringSet = detailsDtos.stream().map(PassiveStorageResponse.Details::getSkuCode).collect(Collectors.toSet()); + List stringList = stringSet.stream().collect(Collectors.toList()); + List> lists = SplitListByCountUtil.splitListByCount(stringList, 900); + for (int i = 0; i < lists.size(); i++) { + List strings = lists.get(i); + String result = strings.stream().map(s -> "'" + s.trim() + "'").collect(Collectors.joining(",")); + if (result != null && result.length() > 0) { + BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); + bdTaxitemsEntity.setInvcodes(result); + List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); + allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList); + } + } +// List> lists = SplitListByCountUtil.splitListByCount(detailsDtos, 500); +// for (int i = 0; i < lists.size(); i++) { +// List stockinBList = lists.get(i); +// String codesStr = stockinBList.stream().map(StockinOrderSearchResponse.StockinOrder.StockinB::getSkuCode).map(id -> "'" + id + "'").collect(Collectors.joining(",")); +// +// BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); +// bdTaxitemsEntity.setInvcodes(codesStr); +// List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); +// allBdTaxitemsEntityList.addAll(bdTaxitemsEntityList); +// } + } + if (allBdTaxitemsEntityList.size() > 0) { + for (int i = 0; i < allBdTaxitemsEntityList.size(); i++) { + BdTaxitemsEntity bdTaxitemsEntity = allBdTaxitemsEntityList.get(i); + stringBdTaxitemsEntityMap.put(bdTaxitemsEntity.getInvcode(), bdTaxitemsEntity); + } + } + return stringBdTaxitemsEntityMap; + } + + /** + * 缓存来源平台逻辑 + * + * @author liuyang + */ +// public static Map stringBdDefdocEntityHashMap = new HashMap<>(); + private Map initSourcePlatform() { + Map stringBdDefdocEntityHashMap = new HashMap<>(); + + String platformZdyId2 = OverallConstant.getOverAllValue("u8c自定义项档案-平台主键"); + BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); +// bdDefdocEntity.setPkDefdoclist("0001A210000000000JUD"); + bdDefdocEntity.setPkDefdoclist(platformZdyId2); +// bdDefdocEntity.setDr(0); + bdDefdocEntity.setDataSourceCode("lets_u8c"); + List bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity); + if (bdDefdocEntityList != null && bdDefdocEntityList.size() > 0) { + for (int i = 0; i < bdDefdocEntityList.size(); i++) { + BdDefdocEntity bdDefdocEntity1 = bdDefdocEntityList.get(i); + stringBdDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1); + } + } + return stringBdDefdocEntityHashMap; + } + + /** + * 2024年8月14日 15:17:48 缓存U8C店铺自定义档案逻辑 + */ +// public static Map shopDefdocEntityHashMap = new HashMap<>(); + private Map initShopDiy() { + Map shopDefdocEntityHashMap = new HashMap<>(); + + String platformZdyId2 = OverallConstant.getOverAllValue("u8c自定义项档案-店铺主键"); + BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); +// bdDefdocEntity.setPkDefdoclist("0001A210000000000XZX"); + bdDefdocEntity.setPkDefdoclist(platformZdyId2); +// bdDefdocEntity.setDr(0); + bdDefdocEntity.setDataSourceCode("lets_u8c"); + List bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity); + if (bdDefdocEntityList != null && bdDefdocEntityList.size() > 0) { + for (int i = 0; i < bdDefdocEntityList.size(); i++) { + BdDefdocEntity bdDefdocEntity1 = bdDefdocEntityList.get(i); + shopDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1); + } + } + return shopDefdocEntityHashMap; + } + +// public static Map stringBdRdclEntityHashMap = new HashMap<>(); + + /** + * 初始化收发类别 + */ + private Map initBdRdcl() { + Map stringBdRdclEntityHashMap = new HashMap<>(); + + BdRdclEntity bdRdclEntity = new BdRdclEntity(); + bdRdclEntity.setDr(0); + bdRdclEntity.setDataSourceCode("lets_u8c"); + List bdRdclEntityList = iBdRdclDao.query(bdRdclEntity); + if (bdRdclEntityList != null && bdRdclEntityList.size() > 0) { + for (int i = 0; i < bdRdclEntityList.size(); i++) { + BdRdclEntity bdRdclEntity1 = bdRdclEntityList.get(i); + stringBdRdclEntityHashMap.put(bdRdclEntity1.getRdcode(), bdRdclEntity1); + } + } + return stringBdRdclEntityHashMap; + } + + /** + * 清理缓存 + * + * @author liuyang + */ +// public void clearCache() throws Exception { +// stringBdCorpEntityMap.clear(); +// stringBdStordocEntityMap.clear(); +// stringBdCalbodyEntityMap.clear(); +// stringBdSalestruEntityMap.clear(); +// stringBdDeptdocEntityMap.clear(); +// stringBdCumandocEntityMap.clear(); +// stringBdInvmandocEntityMap.clear(); +// stringBdInvbasdocEntityHashMap.clear(); +// stringBdTaxitemsEntityHashMap.clear(); +// stringBdCubasdocEntityHashMap.clear(); +// stringBdDefdocEntityHashMap.clear(); +// shopDefdocEntityHashMap.clear(); +// stringBdRdclEntityHashMap.clear(); +// } + + /** + * 初始化缓存 + * + * @param returnGoodHeaderDetailsDataDtoList OFS售后入库单 + * @author liuyang + */ + public CacheTocMapVoV2 initCache(List returnGoodHeaderDetailsDataDtoList) throws Exception { + Assert.notNull(returnGoodHeaderDetailsDataDtoList, "returnGoodHeaderDetailsDataDtoList不能为空!"); + + List headers = initOFsHeadDto(returnGoodHeaderDetailsDataDtoList); + List details = initOfsDetailsDto(returnGoodHeaderDetailsDataDtoList); + + Map stringBdCorpEntityMap = initShop(); + Map stringBdStordocEntityMap = initBdStordoc(); + Map stringBdCalbodyEntityMap = initBdCalbody(); + Map stringBdSalestruEntityMap = initBdSalestru(); + List> maps = initDept(); + Map stringBdCubasdocEntityMap = initBdCubasdocV2(headers); + Map stringBdCumandocEntityMap = initBdCumandocV2(headers); + Map stringBdInvmandocEntityMap = initInventoryFileV2(details); + Map stringBdInvbasdocEntityMap = initBasicInventoryFileV2(details); + Map stringBdTaxitemsEntityMap = initBdTaxitemsEntityV2(details); + Map stringBdDefdocEntityMap = initSourcePlatform(); + Map stringBdDefdocEntityMap1 = initShopDiy(); + Map stringBdRdclEntityMap = initBdRdcl(); + + CacheTocMapVoV2 cacheTocMapVoV2 = new CacheTocMapVoV2(); + cacheTocMapVoV2.setStringBdCorpEntityMap(stringBdCorpEntityMap); + cacheTocMapVoV2.setStringBdStordocEntityMap(stringBdStordocEntityMap); + cacheTocMapVoV2.setStringBdCalbodyEntityMap(stringBdCalbodyEntityMap); + cacheTocMapVoV2.setStringBdSalestruEntityMap(stringBdSalestruEntityMap); + cacheTocMapVoV2.setStringBdDeptdocEntityMap(maps.get(0)); + cacheTocMapVoV2.setStringBdDeptdocEntityMapByDeptCode(maps.get(1)); + cacheTocMapVoV2.setStringBdCubasdocEntityMap(stringBdCubasdocEntityMap); + cacheTocMapVoV2.setStringBdCumandocEntityMap(stringBdCumandocEntityMap); + cacheTocMapVoV2.setStringBdInvmandocEntityMap(stringBdInvmandocEntityMap); + cacheTocMapVoV2.setStringBdInvbasdocEntityMap(stringBdInvbasdocEntityMap); + cacheTocMapVoV2.setStringBdTaxitemsEntityMap(stringBdTaxitemsEntityMap); + cacheTocMapVoV2.setStringBdDefdocEntityMap(stringBdDefdocEntityMap); + cacheTocMapVoV2.setStringBdDefdocEntityMap1(stringBdDefdocEntityMap1); + cacheTocMapVoV2.setStringBdRdclEntityMap(stringBdRdclEntityMap); + return cacheTocMapVoV2; + } + + /** + * 整理出明细集合 + * + * @author liuyang + */ + private List initOfsDetailsDto(List passiveStorageResponseDataDtoList) { + List stockinBList = new ArrayList<>(); + + if (passiveStorageResponseDataDtoList != null && passiveStorageResponseDataDtoList.size() > 0) { + for (int i = 0; i < passiveStorageResponseDataDtoList.size(); i++) { + PassiveStorageResponse.Data data = passiveStorageResponseDataDtoList.get(i); + PassiveStorageResponse.Header header = data.getHeader(); + List details = data.getDetails(); + + stockinBList.addAll(details); + } + } + return stockinBList; + } + + /** + * 整理出表头集合 + * + * @author liuyang + */ + private List initOFsHeadDto(List passiveStorageResponseDataDtoList) throws Exception { + List stockinHList = new ArrayList<>(); + + if (passiveStorageResponseDataDtoList != null && passiveStorageResponseDataDtoList.size() > 0) { + for (int i = 0; i < passiveStorageResponseDataDtoList.size(); i++) { + PassiveStorageResponse.Data data = passiveStorageResponseDataDtoList.get(i); + PassiveStorageResponse.Header header = data.getHeader(); + List details = data.getDetails(); + + stockinHList.add(header); + } + } + return stockinHList; + } +} \ No newline at end of file diff --git a/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-dao.xml b/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-dao.xml index b2ca2ccd..11daadd0 100644 --- a/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-dao.xml +++ b/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-dao.xml @@ -67,4 +67,7 @@ + + + \ No newline at end of file diff --git a/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-service.xml b/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-service.xml index a0035994..eaf45e17 100644 --- a/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-service.xml +++ b/buildpackage/src/main/resources/cfgHome/plugin/lets/spring/spring-lets-service.xml @@ -6,4 +6,7 @@ + + + \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToCTest.java new file mode 100644 index 00000000..cbb2eca9 --- /dev/null +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/PassiveWarehouseReceiptToCTest.java @@ -0,0 +1,35 @@ +package com.hzya.frame.plugin.lets.plugin.sales; + +import com.hzya.frame.WebappApplication; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.Assert.*; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.plugin.sales + * @Project:kangarooDataCenterV3 + * @name:PassiveWarehouseReceiptToCTest + * @Date:2025/3/11 18:34 + * @Filename:PassiveWarehouseReceiptToCTest + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WebappApplication.class) +public class PassiveWarehouseReceiptToCTest { + + @Autowired + private PassiveWarehouseReceiptToC passiveWarehouseReceiptToC; + + @Test + public void startImplementStockByTime() { + try { + passiveWarehouseReceiptToC.startImplementStockByTime("2025-03-11 00:00:00", "2025-03-11 23:59:59"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/ttxofs/basics/ApiDtoCacheMap.java b/service/src/main/java/com/hzya/frame/ttxofs/basics/ApiDtoCacheMap.java index f9b1a040..68f0b68f 100644 --- a/service/src/main/java/com/hzya/frame/ttxofs/basics/ApiDtoCacheMap.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/basics/ApiDtoCacheMap.java @@ -13,6 +13,7 @@ import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderBean; import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto; import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto; import com.hzya.frame.ttxofs.dto.ofswareconfirma.OfsWareConfirmaResponse; +import com.hzya.frame.ttxofs.dto.passivestorage.PassiveStorageResponse; import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchJsonRootBean; import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse; @@ -54,7 +55,8 @@ public class ApiDtoCacheMap { apiDtoCacheMap.put("ofs.adjustOrder.search", new OFSAdjustOrderSearchResponse());//调整单 apiDtoCacheMap.put("ofs.receipt.confirm.search", new OFSReceiptConfirmSearchResponse());//入库确认单 - // apiDtoCacheMap.put("ofs.receipt.confirm.search", new OfsWareConfirmaResponse());//入库确认单 + + apiDtoCacheMap.put("ofs.passive.order.search", new PassiveStorageResponse());//无源入库单 } } \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/passivestorage/PassiveStorageResponse.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/passivestorage/PassiveStorageResponse.java new file mode 100644 index 00000000..dc162c93 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/passivestorage/PassiveStorageResponse.java @@ -0,0 +1,73 @@ +package com.hzya.frame.ttxofs.dto.passivestorage; + +import com.hzya.frame.ttxofs.basics.ReturnMessageBasics; +import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchData; + +import java.util.List; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.ttxofs.dto.passivestorage + * @Project:kangarooDataCenterV3 + * @name:PassiveStorageResponse + * @Date:2025/3/11 18:51 + * @Filename:PassiveStorageResponse + */ +@lombok.Data +public class PassiveStorageResponse extends ReturnMessageBasics { + + private List data; + + @lombok.Data + public static class Data { + private Header header; + private List
details; + } + + @lombok.Data + public static class Header { + private String id; + private String clientCode; + private String companyCode; + private String facilityCode; + private String storeCode; + private String receiptCode; + private String warehouseCode; + private String returnWaybillCode; + private String sourceReturnCode; + private String sourceOrderCode; + private String returnOrderCode; + private String actualRefundAmount; + private String returnTime; + private String relatedAt; + private String status; + private String created; + private String createdBy; + private String lastUpdated; + private String lastUpdatedBy; + //让表头能够关联明细表 +// List detailsList; + //对应的售后订单 + private RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData; + //对应的销售订单 + private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; + } + + @lombok.Data + public static class Details { + private String id; + private String headerId; + private String receiptCode; + private String clientCode; + private String companyCode; + private String skuCode; + private String skuName; + private String quantity; + private String inventorySts; + private String created; + private String createdBy; + private String lastUpdated; + private String lastUpdatedBy; + private PassiveStorageResponse.Header header; + } +}