refactor(buildpackage): 更新TocofsReturngoods实体类和数据访问层

- 重构TocofsReturngoods和TocofsReturngoodsDetailed实体类,以符合最新项目需求。
- 更新数据访问层方法,以支持批量插入或更新操作。
- 重命名字段并添加新字段以增加功能和数据一致性。
- 删除过时的列表插入方法,以避免未来的错误和混淆。
This commit is contained in:
liuy 2024-09-14 11:15:52 +08:00
parent faa88f0683
commit 16650807f4
12 changed files with 3202 additions and 1777 deletions

View File

@ -9,14 +9,14 @@ import java.util.List;
* OFS售后入库单(tocofs_returngoods: table)表数据库访问层 * OFS售后入库单(tocofs_returngoods: table)表数据库访问层
* *
* @author makejava * @author makejava
* @since 2024-08-09 11:08:40 * @since 2024-09-13 11:58:10
*/ */
public interface ITocofsReturngoodsDao extends IBaseDao<TocofsReturngoodsEntity, String> { public interface ITocofsReturngoodsDao extends IBaseDao<TocofsReturngoodsEntity, String> {
/** /**
* 批量插入 * 批量保存或者更新数据行底表
* *
* @author liuyang * @author liuyang
*/ */
void entityInsertBatchV2(List<TocofsReturngoodsEntity> tocofsReturngoodsEntityList) throws Exception; void entityInsertOrUpdateBatch(List<TocofsReturngoodsEntity> tocofsReturngoodsEntityList) throws Exception;
} }

View File

@ -2,7 +2,6 @@ package com.hzya.frame.plugin.lets.ofs.dao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity;
import com.hzya.frame.basedao.dao.IBaseDao; import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsEntity;
import java.util.List; import java.util.List;
@ -10,13 +9,41 @@ import java.util.List;
* root(tocofs_returngoods_detailed: table)表数据库访问层 * root(tocofs_returngoods_detailed: table)表数据库访问层
* *
* @author makejava * @author makejava
* @since 2024-08-09 13:45:47 * @since 2024-09-13 11:58:26
*/ */
public interface ITocofsReturngoodsDetailedDao extends IBaseDao<TocofsReturngoodsDetailedEntity, String> { public interface ITocofsReturngoodsDetailedDao extends IBaseDao<TocofsReturngoodsDetailedEntity, String> {
/** /**
* 批量插入 * 批量插入或更新到底表
* *
* @author liuyang * @author liuyang
*/ */
void entityInsertBatchV2(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsEntityList) throws Exception; void entityInsertOrUpdateBatch(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception;
/**
* 批量新增或者修改TOC退货-库存
*
* @author liuyang
*/
void entityInsertOrUpdateBatchByTocRerturnStock(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception;
/**
* 批量新增或者修改TOC退货-确认收入
*
* @author liuyang
*/
void entityInsertOrUpdateBatchByTocRerturnTran(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception;
/**
* 批量新增或者修改TOB退货-库存
*
* @author liuyang
*/
void entityInsertOrUpdateBatchByTobRerturnStock(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception;
/**
* 批量新增或者修改TOB退货-确认收入
*
* @author liuyang
*/
void entityInsertOrUpdateBatchByTobRerturnTran(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception;
} }

View File

@ -11,12 +11,11 @@ import java.util.List;
* OFS售后入库单(TocofsReturngoods)表数据库访问层 * OFS售后入库单(TocofsReturngoods)表数据库访问层
* *
* @author makejava * @author makejava
* @since 2024-08-09 11:08:40 * @since 2024-09-13 11:58:10
*/ */
public class TocofsReturngoodsDaoImpl extends MybatisGenericDao<TocofsReturngoodsEntity, String> implements ITocofsReturngoodsDao { public class TocofsReturngoodsDaoImpl extends MybatisGenericDao<TocofsReturngoodsEntity, String> implements ITocofsReturngoodsDao {
@Override @Override
public void entityInsertBatchV2(List<TocofsReturngoodsEntity> tocofsReturngoodsEntityList) throws Exception { public void entityInsertOrUpdateBatch(List<TocofsReturngoodsEntity> tocofsReturngoodsEntityList) throws Exception {
this.insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDaoImpl.entityInsertBatchV2", tocofsReturngoodsEntityList); insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDaoImpl.entityInsertOrUpdateBatch", tocofsReturngoodsEntityList);
} }
} }

View File

@ -2,7 +2,6 @@ package com.hzya.frame.plugin.lets.ofs.dao.impl;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsReturngoodsDetailedDao; import com.hzya.frame.plugin.lets.ofs.dao.ITocofsReturngoodsDetailedDao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsEntity;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.hzya.frame.basedao.dao.MybatisGenericDao; import com.hzya.frame.basedao.dao.MybatisGenericDao;
@ -12,11 +11,33 @@ import java.util.List;
* root(TocofsReturngoodsDetailed)表数据库访问层 * root(TocofsReturngoodsDetailed)表数据库访问层
* *
* @author makejava * @author makejava
* @since 2024-08-09 13:45:47 * @since 2024-09-13 11:58:26
*/ */
public class TocofsReturngoodsDetailedDaoImpl extends MybatisGenericDao<TocofsReturngoodsDetailedEntity, String> implements ITocofsReturngoodsDetailedDao { public class TocofsReturngoodsDetailedDaoImpl extends MybatisGenericDao<TocofsReturngoodsDetailedEntity, String> implements ITocofsReturngoodsDetailedDao {
@Override @Override
public void entityInsertBatchV2(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception { public void entityInsertOrUpdateBatch(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception {
this.insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDetailedDaoImpl.entityInsertBatchV2", tocofsReturngoodsDetailedEntityList); insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDetailedDaoImpl.entityInsertOrUpdateBatch", tocofsReturngoodsDetailedEntityList);
}
@Override
public void entityInsertOrUpdateBatchByTocRerturnStock(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception {
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDetailedDaoImpl.entityInsertOrUpdateBatchByTocRerturnStock", tocofsReturngoodsDetailedEntityList);
}
@Override
public void entityInsertOrUpdateBatchByTocRerturnTran(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception {
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDetailedDaoImpl.entityInsertOrUpdateBatchByTocRerturnTran", tocofsReturngoodsDetailedEntityList);
}
@Override
public void entityInsertOrUpdateBatchByTobRerturnStock(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception {
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDetailedDaoImpl.entityInsertOrUpdateBatchByTobRerturnStock", tocofsReturngoodsDetailedEntityList);
}
@Override
public void entityInsertOrUpdateBatchByTobRerturnTran(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList) throws Exception {
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsReturngoodsDetailedDaoImpl.entityInsertOrUpdateBatchByTobRerturnTran", tocofsReturngoodsDetailedEntityList);
} }
} }

View File

@ -1,6 +1,5 @@
package com.hzya.frame.plugin.lets.ofs.entity; package com.hzya.frame.plugin.lets.ofs.entity;
import com.hzya.frame.ttxofs.dto.returngoodsearch.ReturnGoodSearchHeaderDto;
import com.hzya.frame.web.entity.BaseEntity; import com.hzya.frame.web.entity.BaseEntity;
import lombok.Data; import lombok.Data;
@ -8,98 +7,100 @@ import lombok.Data;
* root(TocofsReturngoodsDetailed)实体类 * root(TocofsReturngoodsDetailed)实体类
* *
* @author makejava * @author makejava
* @since 2024-08-09 13:45:47 * @since 2024-09-13 11:58:26
*/ */
@Data @Data
public class TocofsReturngoodsDetailedEntity extends BaseEntity { public class TocofsReturngoodsDetailedEntity extends BaseEntity {
/** /**
* 81159 * 81159
*/ */
private String receiptId; private String receiptid;
/** /**
* LETS-RE2024071600000001 * LETS-RE2024071600000001
*/ */
private String receiptCode; private String receiptcode;
/** /**
* 128 * 128
*/ */
private String refOrderId; private String reforderid;
/** /**
* 299 * 299
*/ */
private String refOrderDetailId; private String reforderdetailid;
/** /**
* LETS-SO2024070500000001 * LETS-SO2024070500000001
*/ */
private String sourceOrderCode; private String sourceordercode;
private String sourcelinenum;
/** /**
* LETS * LETS
*/ */
private String clientCode; private String clientcode;
/** /**
* SHLZ * SHLZ
*/ */
private String companyCode; private String companycode;
/** /**
* intoyou-tmxs * intoyou-tmxs
*/ */
private String facilityCode; private String facilitycode;
/** /**
* 6973391730617 * 6973391730617
*/ */
private String skuCode; private String skucode;
/** /**
* INTOYOU心慕与你水感裸雾唇釉W01 * INTOYOU心慕与你水感裸雾唇釉W01
*/ */
private String skuName; private String skuname;
/** /**
* 2 * 2
*/ */
private String requestQty; private String requestqty;
/** /**
* 2 * 2
*/ */
private String receivedQty; private String receivedqty;
/** /**
* 0 * 0
*/ */
private String openQty; private String openqty;
/** /**
* EA * EA
*/ */
private String quantityUM; private String quantityum;
/** /**
* 0 * 0
*/ */
private String totalWeight; private String totalweight;
/** /**
* 0 * 0
*/ */
private String totalVolume; private String totalvolume;
/** /**
* 0 * 0
*/ */
private String totalVolumeWeight; private String totalvolumeweight;
/** /**
* 118 * 118
*/ */
private String totalAmount; private String totalamount;
/** /**
* G * G
*/ */
private String weightUM; private String weightum;
/** /**
* CM3 * CM3
*/ */
private String volumeUM; private String volumeum;
/** /**
* AVAILABLE * AVAILABLE
*/ */
private String inventorySts; private String inventorysts;
/** /**
* 30796 * 30796
*/ */
private String inTransInvId; private String intransinvid;
/** /**
* 0 * 0
*/ */
@ -111,52 +112,278 @@ public class TocofsReturngoodsDetailedEntity extends BaseEntity {
/** /**
* admin * admin
*/ */
private String createdBy; private String createdby;
/** /**
* 2024-07-16 16:44:01 * 2024-07-16 16:44:01
*/ */
private String lastUpdated; private String lastupdated;
/** /**
* api * api
*/ */
private String lastUpdatedBy; private String lastupdatedby;
/** /**
* 59 * 59
*/ */
private String discountPrice; private String discountprice;
/**
* 主表主键
*/
private String maintableid;
/** /**
* 报错内容 * 报错内容
*/ */
private String newTransmitinfo; private String newtransmitinfo;
/** /**
* 推送时间 * 推送时间
*/ */
private String newPushdate; private String newpushdate;
/** /**
* 是否成功 * 是否成功
*/ */
private String newState; private String newstate;
/** /**
* 下游系统编码 * 下游系统编码
*/ */
private String newSystemNumber; private String newsystemnumber;
/** /**
* 下游系统主键 * 下游系统主键
*/ */
private String newSystemPrimary; private String newsystemprimary;
/** /**
* 主表主键 * 报错内容
*/ */
private String primaryKey; private String newtransmitinfo2;
/** /**
* 业务日期 * 推送时间
*/ */
private String businessDate; private String newpushdate2;
/** /**
* 主表主键 * 是否成功
*/ */
// private String returngoodsId; private String newstate2;
/**
private String businessType; * 下游系统编码
*/
private String newsystemnumber2;
/**
* 下游系统主键
*/
private String newsystemprimary2;
/**
* 报错内容
*/
private String newtransmitinfo3;
/**
* 推送时间
*/
private String newpushdate3;
/**
* 是否成功
*/
private String newstate3;
/**
* 下游系统编码
*/
private String newsystemnumber3;
/**
* 下游系统主键
*/
private String newsystemprimary3;
/**
* 报错内容
*/
private String newtransmitinfo4;
/**
* 推送时间
*/
private String newpushdate4;
/**
* 是否成功
*/
private String newstate4;
/**
* 下游系统编码
*/
private String newsystemnumber4;
/**
* 下游系统主键
*/
private String newsystemprimary4;
/**
* 业务日期-入库时间
*/
private String businessdate;
/**
* 业务日期-退款完成时间
*/
private String refundedat;
/**
* 业务类型(TOC退货orTOB退货)
*/
private String businesstype;
/**
* 自定义项
*/
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;
/**
* 自定义项
*/
private String def11;
/**
* 自定义项
*/
private String def12;
/**
* 自定义项
*/
private String def13;
/**
* 自定义项
*/
private String def14;
/**
* 自定义项
*/
private String def15;
/**
* 自定义项
*/
private String def16;
/**
* 自定义项
*/
private String def17;
/**
* 自定义项
*/
private String def18;
/**
* 自定义项
*/
private String def19;
/**
* 自定义项
*/
private String def20;
/**
* 自定义项
*/
private String def21;
/**
* 自定义项
*/
private String def22;
/**
* 自定义项
*/
private String def23;
/**
* 自定义项
*/
private String def24;
/**
* 自定义项
*/
private String def25;
/**
* 自定义项
*/
private String def26;
/**
* 自定义项
*/
private String def27;
/**
* 自定义项
*/
private String def28;
/**
* 自定义项
*/
private String def29;
/**
* 自定义项
*/
private String def30;
/**
* 自定义项
*/
private String def31;
/**
* 自定义项
*/
private String def32;
/**
* 自定义项
*/
private String def33;
/**
* 自定义项
*/
private String def34;
/**
* 自定义项
*/
private String def35;
/**
* 自定义项
*/
private String def36;
/**
* 自定义项
*/
private String def37;
/**
* 自定义项
*/
private String def38;
/**
* 自定义项
*/
private String def39;
/**
* 自定义项
*/
private String def40;
/**
* 补充的查询条件
*/
private String ids;
} }

View File

@ -1,30 +1,32 @@
package com.hzya.frame.plugin.lets.ofs.entity; package com.hzya.frame.plugin.lets.ofs.entity;
import com.hzya.frame.web.entity.BaseEntity; import com.hzya.frame.web.entity.BaseEntity;
import lombok.Data;
/** /**
* OFS售后入库单(TocofsReturngoods)实体类 * OFS售后入库单(TocofsReturngoods)实体类
* *
* @author makejava * @author makejava
* @since 2024-08-09 11:08:40 * @since 2024-09-13 11:58:10
*/ */
@Data
public class TocofsReturngoodsEntity extends BaseEntity { public class TocofsReturngoodsEntity extends BaseEntity {
/** /**
* LETS * LETS
*/ */
private String clientCode; private String clientcode;
/** /**
* SHLZ * SHLZ
*/ */
private String companyCode; private String companycode;
/** /**
* tm-intoyou * tm-intoyou
*/ */
private String storeCode; private String storecode;
/** /**
* intoyou-tmxs * intoyou-tmxs
*/ */
private String facilityCode; private String facilitycode;
/** /**
* LETS-RE2024071600000001 * LETS-RE2024071600000001
*/ */
@ -32,23 +34,23 @@ public class TocofsReturngoodsEntity extends BaseEntity {
/** /**
* RETURN * RETURN
*/ */
private String internalInstructionType; private String internalinstructiontype;
/** /**
* B2C * B2C
*/ */
private String bizChannel; private String bizchannel;
/** /**
* 128 * 128
*/ */
private String refOrderId; private String reforderid;
/** /**
* LETS-RO2024071600000001 * LETS-RO2024071600000001
*/ */
private String refOrderCode; private String refordercode;
/** /**
* RETURN * RETURN
*/ */
private String refOrderType; private String refordertype;
/** /**
* 1 * 1
*/ */
@ -56,7 +58,7 @@ public class TocofsReturngoodsEntity extends BaseEntity {
/** /**
* api * api
*/ */
private String closedBy; private String closedby;
/** /**
* 900 * 900
*/ */
@ -64,540 +66,69 @@ public class TocofsReturngoodsEntity extends BaseEntity {
/** /**
* 0 * 0
*/ */
private String allowOverReceive; private String allowoverreceive;
/** /**
* 张三 * 张三
*/ */
private String shipFromAttentionTo; private String shipfromattentionto;
/** /**
* 测试售后流程 * 测试售后流程
*/ */
private String shipFromAddress; private String shipfromaddress;
/** /**
* 中国 * 中国
*/ */
private String shipFromCountry; private String shipfromcountry;
/** /**
* 上海市 * 上海市
*/ */
private String shipFromState; private String shipfromstate;
/** /**
* 上海市 * 上海市
*/ */
private String shipFromCity; private String shipfromcity;
/** /**
* 金山区 * 金山区
*/ */
private String shipFromDistrict; private String shipfromdistrict;
/** /**
* 17878787878 * 17878787878
*/ */
private String shipFromMobile; private String shipfrompostalcode;
/** private String shipfrommobile;
* 2 private String shipfromemail;
*/ private String totallines;
private String totalLines; private String totalqty;
/** private String totalamount;
* 4 private String totalweight;
*/ private String totalvolume;
private String totalQty; private String totalvolumeweight;
/** private String totalfulfillamount;
* 236 private String totalfulfillweight;
*/ private String totalfulfillvolume;
private String totalAmount; private String totalfulfillvolumeweight;
/** private String totalfulfillqty;
* 0 private String totalcases;
*/ private String totalcontainers;
private String totalWeight; private String closeatqty;
/** private String quantityum;
* 0 private String weightum;
*/ private String volumeum;
private String totalVolume; private String checkinfrom;
/** private String checkinto;
* 0 private String closedat;
*/ private String sourceplatformcode;
private String totalVolumeWeight; private String sourceordercode;
/**
* 236
*/
private String totalFulfillAmount;
/**
* 0
*/
private String totalFulfillWeight;
/**
* 0
*/
private String totalFulfillVolume;
/**
* 0
*/
private String totalFulfillVolumeWeight;
/**
* 4
*/
private String totalFulfillQty;
/**
* 0
*/
private String totalCases;
/**
* 0
*/
private String totalContainers;
/**
* 0
*/
private String closeAtQty;
/**
* EA
*/
private String quantityUM;
/**
* G
*/
private String weightUM;
/**
* CM3
*/
private String volumeUM;
/**
* 2024-07-16 16:44:00
*/
private String checkInFrom;
/**
* 2024-07-16 16:44:01
*/
private String checkInTo;
/**
* 2024-07-16 16:44:01
*/
private String closedAt;
/**
* OFS
*/
private String sourcePlatformCode;
/**
* LETS-SO2024070500000001
*/
private String sourceOrderCode;
/** /**
* 2024-07-16 15:35:36 * 2024-07-16 15:35:36
*/ */
private String created; private String created;
/** private String createdby;
* admin private String lastupdated;
*/ private String lastupdatedby;
private String createdBy; private String returnwaybillcode;
/** private String returncarrier;
* 2024-07-16 16:44:01 private String refundedat;
*/ private String refundstatus;
private String lastUpdated;
/**
* api
*/
private String lastUpdatedBy;
/**
* YT7478903028607
*/
private String returnWaybillCode;
/**
* YTO
*/
private String returnCarrier;
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 getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
public String getFacilityCode() {
return facilityCode;
}
public void setFacilityCode(String facilityCode) {
this.facilityCode = facilityCode;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getInternalInstructionType() {
return internalInstructionType;
}
public void setInternalInstructionType(String internalInstructionType) {
this.internalInstructionType = internalInstructionType;
}
public String getBizChannel() {
return bizChannel;
}
public void setBizChannel(String bizChannel) {
this.bizChannel = bizChannel;
}
public String getRefOrderId() {
return refOrderId;
}
public void setRefOrderId(String refOrderId) {
this.refOrderId = refOrderId;
}
public String getRefOrderCode() {
return refOrderCode;
}
public void setRefOrderCode(String refOrderCode) {
this.refOrderCode = refOrderCode;
}
public String getRefOrderType() {
return refOrderType;
}
public void setRefOrderType(String refOrderType) {
this.refOrderType = refOrderType;
}
public String getClosed() {
return closed;
}
public void setClosed(String closed) {
this.closed = closed;
}
public String getClosedBy() {
return closedBy;
}
public void setClosedBy(String closedBy) {
this.closedBy = closedBy;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAllowOverReceive() {
return allowOverReceive;
}
public void setAllowOverReceive(String allowOverReceive) {
this.allowOverReceive = allowOverReceive;
}
public String getShipFromAttentionTo() {
return shipFromAttentionTo;
}
public void setShipFromAttentionTo(String shipFromAttentionTo) {
this.shipFromAttentionTo = shipFromAttentionTo;
}
public String getShipFromAddress() {
return shipFromAddress;
}
public void setShipFromAddress(String shipFromAddress) {
this.shipFromAddress = shipFromAddress;
}
public String getShipFromCountry() {
return shipFromCountry;
}
public void setShipFromCountry(String shipFromCountry) {
this.shipFromCountry = shipFromCountry;
}
public String getShipFromState() {
return shipFromState;
}
public void setShipFromState(String shipFromState) {
this.shipFromState = shipFromState;
}
public String getShipFromCity() {
return shipFromCity;
}
public void setShipFromCity(String shipFromCity) {
this.shipFromCity = shipFromCity;
}
public String getShipFromDistrict() {
return shipFromDistrict;
}
public void setShipFromDistrict(String shipFromDistrict) {
this.shipFromDistrict = shipFromDistrict;
}
public String getShipFromMobile() {
return shipFromMobile;
}
public void setShipFromMobile(String shipFromMobile) {
this.shipFromMobile = shipFromMobile;
}
public String getTotalLines() {
return totalLines;
}
public void setTotalLines(String totalLines) {
this.totalLines = totalLines;
}
public String getTotalQty() {
return totalQty;
}
public void setTotalQty(String totalQty) {
this.totalQty = totalQty;
}
public String getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(String totalAmount) {
this.totalAmount = totalAmount;
}
public String getTotalWeight() {
return totalWeight;
}
public void setTotalWeight(String totalWeight) {
this.totalWeight = totalWeight;
}
public String getTotalVolume() {
return totalVolume;
}
public void setTotalVolume(String totalVolume) {
this.totalVolume = totalVolume;
}
public String getTotalVolumeWeight() {
return totalVolumeWeight;
}
public void setTotalVolumeWeight(String totalVolumeWeight) {
this.totalVolumeWeight = totalVolumeWeight;
}
public String getTotalFulfillAmount() {
return totalFulfillAmount;
}
public void setTotalFulfillAmount(String totalFulfillAmount) {
this.totalFulfillAmount = totalFulfillAmount;
}
public String getTotalFulfillWeight() {
return totalFulfillWeight;
}
public void setTotalFulfillWeight(String totalFulfillWeight) {
this.totalFulfillWeight = totalFulfillWeight;
}
public String getTotalFulfillVolume() {
return totalFulfillVolume;
}
public void setTotalFulfillVolume(String totalFulfillVolume) {
this.totalFulfillVolume = totalFulfillVolume;
}
public String getTotalFulfillVolumeWeight() {
return totalFulfillVolumeWeight;
}
public void setTotalFulfillVolumeWeight(String totalFulfillVolumeWeight) {
this.totalFulfillVolumeWeight = totalFulfillVolumeWeight;
}
public String getTotalFulfillQty() {
return totalFulfillQty;
}
public void setTotalFulfillQty(String totalFulfillQty) {
this.totalFulfillQty = totalFulfillQty;
}
public String getTotalCases() {
return totalCases;
}
public void setTotalCases(String totalCases) {
this.totalCases = totalCases;
}
public String getTotalContainers() {
return totalContainers;
}
public void setTotalContainers(String totalContainers) {
this.totalContainers = totalContainers;
}
public String getCloseAtQty() {
return closeAtQty;
}
public void setCloseAtQty(String closeAtQty) {
this.closeAtQty = closeAtQty;
}
public String getQuantityUM() {
return quantityUM;
}
public void setQuantityUM(String quantityUM) {
this.quantityUM = quantityUM;
}
public String getWeightUM() {
return weightUM;
}
public void setWeightUM(String weightUM) {
this.weightUM = weightUM;
}
public String getVolumeUM() {
return volumeUM;
}
public void setVolumeUM(String volumeUM) {
this.volumeUM = volumeUM;
}
public String getCheckInFrom() {
return checkInFrom;
}
public void setCheckInFrom(String checkInFrom) {
this.checkInFrom = checkInFrom;
}
public String getCheckInTo() {
return checkInTo;
}
public void setCheckInTo(String checkInTo) {
this.checkInTo = checkInTo;
}
public String getClosedAt() {
return closedAt;
}
public void setClosedAt(String closedAt) {
this.closedAt = closedAt;
}
public String getSourcePlatformCode() {
return sourcePlatformCode;
}
public void setSourcePlatformCode(String sourcePlatformCode) {
this.sourcePlatformCode = sourcePlatformCode;
}
public String getSourceOrderCode() {
return sourceOrderCode;
}
public void setSourceOrderCode(String sourceOrderCode) {
this.sourceOrderCode = sourceOrderCode;
}
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 getReturnWaybillCode() {
return returnWaybillCode;
}
public void setReturnWaybillCode(String returnWaybillCode) {
this.returnWaybillCode = returnWaybillCode;
}
public String getReturnCarrier() {
return returnCarrier;
}
public void setReturnCarrier(String returnCarrier) {
this.returnCarrier = returnCarrier;
}
} }

View File

@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -220,6 +221,8 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
@Override @Override
public void run() { public void run() {
try { try {
Assert.notNull(startTime, "startTime不能为空");
Assert.notNull(endTime, "endTime不能为空");
//生成一个时间范围 //生成一个时间范围
// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime(); // StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
//2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性 //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性
@ -273,7 +276,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
public void run() { public void run() {
try { try {
Assert.notNull(startTime, "startTime不能为空"); Assert.notNull(startTime, "startTime不能为空");
Assert.notNull(endTime, "end不能为空"); Assert.notNull(endTime, "endTime不能为空");
//生成一个时间范围 //生成一个时间范围
// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime(); // StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
@ -328,6 +331,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
@Override @Override
public void run() { public void run() {
try { try {
Assert.notNull(code, "code不能为空");
//生成一个时间范围 //生成一个时间范围
// StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime(); // StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
//2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性 //2024年8月19日 15:47:51 查询出U8C里标记的店铺TOB属性
@ -375,7 +379,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
//保存到mysql //保存到mysql
batchInsert(returnGoodHeaderDetailsDataDtoArrayList); batchInsert(returnGoodHeaderDetailsDataDtoArrayList);
//过滤成功的数据 //过滤成功的数据
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterData(returnGoodHeaderDetailsDataDtoArrayList); List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList);
//执行推送主逻辑 //执行推送主逻辑
implementStock(stockinOrderList); implementStock(stockinOrderList);
} }
@ -389,23 +393,147 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
//保存到mysql //保存到mysql
batchInsert(returnGoodHeaderDetailsDataDtoArrayList); batchInsert(returnGoodHeaderDetailsDataDtoArrayList);
//过滤成功的数据 //过滤成功的数据
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterData(returnGoodHeaderDetailsDataDtoArrayList); List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterDataTran(returnGoodHeaderDetailsDataDtoArrayList);
//执行推送主逻辑 //执行推送主逻辑
implementSuccessfulTrade(stockinOrderList); implementSuccessfulTrade(stockinOrderList);
} }
/** /**
* 过滤掉成功的数据 * 库存过滤掉成功的数据
* *
* @author liuyang * @author liuyang
*/ */
private List<StockinOrderSearchResponse.StockinOrder> filterData(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) { private List<StockinOrderSearchResponse.StockinOrder> filterDataStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
List<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList1 = new ArrayList<>(); // List<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList1 = new ArrayList<>();
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList = new ArrayList<>();
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
//TODO 出库单明细主键需要O返回目前没有已经提需求 List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100);
headerDetailsDtoList1.addAll(returnGoodHeaderDetailsDataDtoArrayList); for (int i = 0; i < splitListByCount.size(); i++) {
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = splitListByCount.get(i);
String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList);
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr);
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
} }
return headerDetailsDtoList1; }
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
}
/**
* 筛选出未推送或者失败的数据行过滤库存同步业务
*
* @param tocofsReturngoodsDetailedEntityList 日志行状态
* @param returnGoodHeaderDetailsDataDtoArrayList 返回结果
* @author liuyang
*/
private List<StockinOrderSearchResponse.StockinOrder> filterDataRowsAsPushOrFailedStock(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList, List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
List<StockinOrderSearchResponse.StockinOrder> targetHeaderDetailsDtoList = new ArrayList<>();
if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0 && returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
//字段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<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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.getNewstate2();
if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) {
isSuccess = true;
}
}
}
if (!isSuccess) {
stockinB.setNewstate(newstate);
targetDetails.add(stockinB);
}
}
if (targetDetails.size() > 0) {
//如果明细行中还存在未推送或者失败的数据则需要更新明细行
stockinOrder.setDetails(targetDetails);
targetHeaderDetailsDtoList.add(stockinOrder);
}
}
}
return targetHeaderDetailsDtoList;
}
/**
* 批查询toc退货入库日志查询的量由splitListByCount方法控制
*
* @author liuyang
*/
private List<TocofsReturngoodsDetailedEntity> queryStockTocOutLog(String idStr) throws Exception {
List<TocofsReturngoodsDetailedEntity> 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;
}
/**
* 逗号拼接字符串主键作为批处理的一部分方便下一步的批量查询操作
*
* @author liuyang
*/
private String commaConcatenatedPrimaryKeyStock(List<StockinOrderSearchResponse.StockinOrder> 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<StockinOrderSearchResponse.StockinOrder.StockinB> 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(stockinB.getId());
idStr.append(",");
}
}
}
if (idStr.length() > 0) {
return idStr.substring(0, idStr.length());
}
return null;
}
/**
* 确认收入过滤掉成功的数据
*
* @author liuyang
*/
private List<StockinOrderSearchResponse.StockinOrder> filterDataTran(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
// List<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList1 = new ArrayList<>();
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList = new ArrayList<>();
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100);
for (int i = 0; i < splitListByCount.size(); i++) {
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = splitListByCount.get(i);
String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList);
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr);
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
}
}
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
} }
/** /**
@ -417,16 +545,13 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
List<StockinOrderSearchResponse.StockinOrder.StockinH> headerDetailsDtoList1 = new ArrayList<>(); List<StockinOrderSearchResponse.StockinOrder.StockinH> headerDetailsDtoList1 = new ArrayList<>();
List<StockinOrderSearchResponse.StockinOrder.StockinB> headerDetailsDtoList2 = new ArrayList<>(); List<StockinOrderSearchResponse.StockinOrder.StockinB> headerDetailsDtoList2 = new ArrayList<>();
for (StockinOrderSearchResponse.StockinOrder index : returnGoodHeaderDetailsDataDtoArrayList) { for (StockinOrderSearchResponse.StockinOrder index : returnGoodHeaderDetailsDataDtoArrayList) {
StockinOrderSearchResponse.StockinOrder.StockinH header = index.getHeader();// 主表 StockinOrderSearchResponse.StockinOrder.StockinH header = index.getHeader();// 主表
List<StockinOrderSearchResponse.StockinOrder.StockinB> details = index.getDetails();//明细表 List<StockinOrderSearchResponse.StockinOrder.StockinB> details = index.getDetails();//明细表
for (int i = 0; i < details.size(); i++) { for (int i = 0; i < details.size(); i++) {
StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(i); StockinOrderSearchResponse.StockinOrder.StockinB stockinB = details.get(i);
stockinB.setReturnGoodSearchHeaderDto(header); stockinB.setReturnGoodSearchHeaderDto(header);
} }
headerDetailsDtoList1.add(header); headerDetailsDtoList1.add(header);
headerDetailsDtoList2.addAll(details); headerDetailsDtoList2.addAll(details);
} }
@ -438,7 +563,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
List<TocofsReturngoodsEntity> tocofsReturngoodsEntities = copyHeaderDto(stockinHS); List<TocofsReturngoodsEntity> tocofsReturngoodsEntities = copyHeaderDto(stockinHS);
if (tocofsReturngoodsEntities.size() > 0) { if (tocofsReturngoodsEntities.size() > 0) {
logger.info("TocofsReturngoodsEntity插入底表{}个对象(表头)", tocofsReturngoodsEntities.size()); logger.info("TocofsReturngoodsEntity插入底表{}个对象(表头)", tocofsReturngoodsEntities.size());
iTocofsReturngoodsDao.entityInsertBatchV2(tocofsReturngoodsEntities); iTocofsReturngoodsDao.entityInsertOrUpdateBatch(tocofsReturngoodsEntities);
} else { } else {
logger.info("TocofsReturngoodsEntity没有对象被插入表头底表"); logger.info("TocofsReturngoodsEntity没有对象被插入表头底表");
} }
@ -451,11 +576,13 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS); List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS);
if (tocofsReturngoodsDetailedEntities.size() > 0) { if (tocofsReturngoodsDetailedEntities.size() > 0) {
logger.info("TocofsReturngoodsDetailedEntity插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size()); logger.info("TocofsReturngoodsDetailedEntity插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size());
iTocofsReturngoodsDetailedDao.entityInsertBatchV2(tocofsReturngoodsDetailedEntities); iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatch(tocofsReturngoodsDetailedEntities);
} else { } else {
logger.info("TocofsReturngoodsDetailedEntity没有对象被插入表头底表"); logger.info("TocofsReturngoodsDetailedEntity没有对象被插入表头底表");
} }
} }
} else {
logger.info("returnGoodHeaderDetailsDataDtoArrayList为空或者原始为零!");
} }
} }
@ -467,7 +594,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
*/ */
private void implementStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList) throws Exception { private void implementStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList) throws Exception {
if (returnGoodHeaderDetailsDataDtoList != null) { if (returnGoodHeaderDetailsDataDtoList != null) {
logger.info("TOB退货业务出库成功{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList.size()); logger.info("TOB售后入库{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList.size());
} }
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
try { try {
@ -478,12 +605,11 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// 查询销售收发类别 // 查询销售收发类别
// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("201"); // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("201");
try {
for (int i = 0; i < orderToBHeaderDtos.size(); i++) { for (int i = 0; i < orderToBHeaderDtos.size(); i++) {
OrderToBHeaderDto orderOutTobHeaderDto = orderToBHeaderDtos.get(i); OrderToBHeaderDto orderOutTobHeaderDto = orderToBHeaderDtos.get(i);
StockinOrderSearchResponse.StockinOrder.StockinH header = orderOutTobHeaderDto.getHeader(); StockinOrderSearchResponse.StockinOrder.StockinH header = orderOutTobHeaderDto.getHeader();
List<StockinOrderSearchResponse.StockinOrder.StockinB> details = orderOutTobHeaderDto.getDetails(); List<StockinOrderSearchResponse.StockinOrder.StockinB> details = orderOutTobHeaderDto.getDetails();
try {
//销售公司发货公司 //销售公司发货公司
BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity(); BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity();
//发货库存组织 //发货库存组织
@ -636,22 +762,34 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>(); Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList); stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
String vreceiptcode = null;
String csaleid = null;
String pk_corp = null;
if (soSaleResultRootDto != null) { if (soSaleResultRootDto != null) {
SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo(); SoSaleResultHeadDto parentvo = soSaleResultRootDto.getParentvo();
List<SoSaleResultBodyDto> childrenvo = soSaleResultRootDto.getChildrenvo(); List<SoSaleResultBodyDto> childrenvo = soSaleResultRootDto.getChildrenvo();
logger.info("TOB红字销售订单编号{} 主键:{} 销售公司:{}", parentvo.getVreceiptcode(), parentvo.getCsaleid(), parentvo.getPk_corp()); vreceiptcode = parentvo.getVreceiptcode();
csaleid = parentvo.getCsaleid();
pk_corp = parentvo.getPk_corp();
} }
logger.info("TOB红字销售订单编号{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功
updateSuccessOrFail1(details, "Y", "success", vreceiptcode, csaleid);
} else { } else {
logger.error("经过SQL查询判断在U8C(红字)销售订单存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId()); logger.error("经过SQL查询判断在U8C(红字)销售订单存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId());
} }
}
} catch (Exception e) { } catch (Exception e) {
logger.error("TOB业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e); logger.error("TOB售后收入推送U8C失败", e);
//记录失败 //记录失败
String message = e.getMessage();
if (message == null) {
message = "未知错误";
}
updateSuccessOrFail1(details, "N", message, null, null);
}
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("TOB外层转换逻辑抛出异常", e); logger.error("TOB外层转换逻辑抛出异常", e);
// 记录失败
} }
} }
} }
@ -1368,9 +1506,20 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
*/ */
private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto) { private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto) {
if (tocofsReturngoodsDetailedEntity != null && returnGoodSearchHeaderDto != null) { if (tocofsReturngoodsDetailedEntity != null && returnGoodSearchHeaderDto != null) {
tocofsReturngoodsDetailedEntity.setPrimaryKey(returnGoodSearchHeaderDto.getId());//主表主键 //主表主键
tocofsReturngoodsDetailedEntity.setBusinessDate(returnGoodSearchHeaderDto.getCheckInFrom());//业务日期 if (tocofsReturngoodsDetailedEntity.getId() != null) {
tocofsReturngoodsDetailedEntity.setBusinessType("TOB_RETURN");//业务类型 tocofsReturngoodsDetailedEntity.setMaintableid(tocofsReturngoodsDetailedEntity.getId());
}
//业务日期-入库时间
if (returnGoodSearchHeaderDto.getCheckInFrom() != null) {
tocofsReturngoodsDetailedEntity.setBusinessdate(returnGoodSearchHeaderDto.getCheckInFrom());
}
//业务日期-退款完成时间
if (returnGoodSearchHeaderDto.getRefundedAt() != null) {
tocofsReturngoodsDetailedEntity.setRefundedat(returnGoodSearchHeaderDto.getRefundedAt());
}
//业务类型
tocofsReturngoodsDetailedEntity.setBusinesstype("TOB_RETURN");
} }
} }
@ -1382,7 +1531,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
*/ */
private void implementSuccessfulTrade(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList) throws Exception { private void implementSuccessfulTrade(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList) throws Exception {
if (returnGoodHeaderDetailsDataDtoList != null) { if (returnGoodHeaderDetailsDataDtoList != null) {
logger.info("TOB退货业务交易成功{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList.size()); logger.info("TOB售后入库退货到账完成{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList.size());
} }
if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
try { try {
@ -1400,6 +1549,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
StockinOrderSearchResponse.StockinOrder.StockinH header = orderOutTobHeaderDto.getHeader(); StockinOrderSearchResponse.StockinOrder.StockinH header = orderOutTobHeaderDto.getHeader();
List<StockinOrderSearchResponse.StockinOrder.StockinB> details = orderOutTobHeaderDto.getDetails(); List<StockinOrderSearchResponse.StockinOrder.StockinB> details = orderOutTobHeaderDto.getDetails();
try {
//销售公司发货公司 //销售公司发货公司
BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity(); BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity();
//发货库存组织 //发货库存组织
@ -1528,18 +1678,34 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
if (!aBoolean) { if (!aBoolean) {
logger.error("经过SQL查询判断在U8C红字销售发票中不存在OFS入库单号为{} OFS入库主键为{}的单据将调用U8C接口执行推送", header.getCode(), header.getId()); logger.error("经过SQL查询判断在U8C红字销售发票中不存在OFS入库单号为{} OFS入库主键为{}的单据将调用U8C接口执行推送", header.getCode(), header.getId());
SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap)); SaleinvoiceDto saleinvoiceDto = sendU8CTOCSoSaleinvoiceB(JSON.toJSONString(stringListMap));
String vreceiptcode = null;
String csaleid = null;
String pk_corp = null;
if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) { if (saleinvoiceDto != null && saleinvoiceDto.getParentvo() != null && saleinvoiceDto.getChildrenvo() != null) {
SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo(); SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo();
List<SaleinvoiceBodyDto> childrenvo = saleinvoiceDto.getChildrenvo(); List<SaleinvoiceBodyDto> childrenvo = saleinvoiceDto.getChildrenvo();
logger.info("TOB销售发票(红字)生成成功 编码:{} 主键:{} 发票公司:{}", parentvo.getVreceiptcode(), parentvo.getCsaleid(), parentvo.getPk_corp()); vreceiptcode = parentvo.getVreceiptcode();
csaleid = parentvo.getCsaleid();
pk_corp = parentvo.getPk_corp();
} }
logger.info("TOB销售发票(红字)生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功
updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid);
} else { } else {
logger.error("经过SQL查询判断在U8C红字销售发票中已经存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId()); logger.error("经过SQL查询判断在U8C红字销售发票中已经存在OFS入库单号为{} OFS入库主键为{}的单据为了避免造成单据重复不推送到U8C", header.getCode(), header.getId());
} }
} catch (Exception e) {
logger.error("TOB售后到账完成推送U8C抛出异常", e);
// 记录失败
String message = e.getMessage();
if (message == null) {
message = "未知错误";
}
updateSuccessOrFail2(details, "N", message, null, null);
}
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("TOB外层转换逻辑抛出异常", e); logger.error("TOB外层转换逻辑抛出异常", e);
// 记录失败
} }
} }
} }
@ -1869,4 +2035,125 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
logger.error("记录splitDateAndPush方法抛出的异常", e); logger.error("记录splitDateAndPush方法抛出的异常", e);
} }
} }
/**
* 处理TOC-库存同步的成功失败错误逻辑
*
* @author liuyang
*/
private void updateSuccessOrFail1(List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityArrayList = new ArrayList<>();
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
StockinOrderSearchResponse.StockinOrder.StockinB stockinB = sonDetailsDtoList.get(i);
TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity();
tocofsReturngoodsDetailedEntity.setId(stockinB.getId());
tocofsReturngoodsDetailedEntity.setNewpushdate(getNewDateStr());
tocofsReturngoodsDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo);
tocofsReturngoodsDetailedEntity.setNewstate(newstate);
if (successY.equals(newstate)) {
tocofsReturngoodsDetailedEntity.setNewsystemnumber(newsystemnumber);
tocofsReturngoodsDetailedEntity.setNewsystemprimary(newsystemprimary);
}
tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity);
}
//以50行为一个批次推送到Mysql
if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) {
List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 50);
for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = splitListByCount.get(i);
iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTobRerturnStock(tocofsReturngoodsDetailedEntities);
}
}
}
} catch (Exception e) {
logger.error("TOC库存同步日志抛出异常", e);
}
}
});
thread.start();
try {
thread.join();
} catch (Exception e) {
logger.error("updateSuccessOrFail1方法现场抛出异常", e);
}
}
/**
* 生成当前日期
*
* @author liuyang
*/
private String getNewDateStr() {
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return now.format(formatter);
}
/**
* 处理TOC-库存同步的成功失败错误逻辑
*
* @author liuyang
*/
private void updateSuccessOrFail2(List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityArrayList = new ArrayList<>();
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
StockinOrderSearchResponse.StockinOrder.StockinB stockinB = sonDetailsDtoList.get(i);
TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity();
tocofsReturngoodsDetailedEntity.setId(stockinB.getId());
tocofsReturngoodsDetailedEntity.setNewpushdate2(getNewDateStr());
tocofsReturngoodsDetailedEntity.setNewtransmitinfo2(finalNewTransmitInfo);
tocofsReturngoodsDetailedEntity.setNewstate2(newstate);
if (successY.equals(newstate)) {
tocofsReturngoodsDetailedEntity.setNewsystemnumber2(newsystemnumber);
tocofsReturngoodsDetailedEntity.setNewsystemprimary2(newsystemprimary);
}
tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity);
}
//以50行为一个批次推送到Mysql
if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) {
List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 50);
for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = splitListByCount.get(i);
iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatchByTobRerturnTran(tocofsReturngoodsDetailedEntities);
}
}
}
} catch (Exception e) {
logger.error("TOC库存同步日志抛出异常", e);
}
}
});
thread.start();
try {
thread.join();
} catch (Exception e) {
logger.error("updateSuccessOrFail2方法现场抛出异常", e);
}
}
} }

View File

@ -1,5 +1,6 @@
package com.hzya.frame.plugin.lets.plugin.sales; package com.hzya.frame.plugin.lets.plugin.sales;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -17,6 +18,7 @@ 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.entity.TocofsReturngoodsEntity;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity; import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo;
import com.hzya.frame.plugin.lets.queryvo.StartAndEndVo;
import com.hzya.frame.plugin.lets.resultvo.CacheTocMapVoV2; import com.hzya.frame.plugin.lets.resultvo.CacheTocMapVoV2;
import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo; import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo;
import com.hzya.frame.plugin.lets.u8cdto.*; import com.hzya.frame.plugin.lets.u8cdto.*;
@ -37,6 +39,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -53,6 +58,12 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
private static final ReentrantLock LOCK = new ReentrantLock(true); private static final ReentrantLock LOCK = new ReentrantLock(true);
private static final String STOCK = "stock";
private static final String TRAN = "tran";
private static final String PROD_FILED = "prod";
@Override @Override
public void initialize() { public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()"); logger.info(getPluginLabel() + "執行初始化方法initialize()");
@ -85,6 +96,37 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
@Override @Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
long startMillis = System.currentTimeMillis();
logger.info("executeBusiness方法调用开始" + getPluginName() + "-插件");
try {
String param = String.valueOf(requestJson.get("param"));
String sceneType = String.valueOf(requestJson.get("sceneType"));//sceneTypestocktran
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);
}
} else {
if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(PROD_FILED)) {
//默认被定时器执行每天晚上凌晨0点5分
//暂定先同步TOC销售库存再推送TOC销售确认收入
List<StartAndEndVo> startAndEndVos = calculateCalculateEntireDayPeriod(null);
startImplementStockByTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time());
startImplementByTradeTime(startAndEndVos.get(0).getStart_time(), startAndEndVos.get(0).getEnd_time());
}
}
} catch (Exception e) {
logger.error("executeBusiness方法异常", e);
}
long endMillis = System.currentTimeMillis();
logger.info("executeBusiness方法调用结束" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis));
return null; return null;
} }
@ -120,7 +162,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
private RdclUtil rdclUtil; private RdclUtil rdclUtil;
/** /**
* 根据指定时间范围拉群 * 库存同步根据时间范围拉取
* *
* @author liuyang * @author liuyang
*/ */
@ -185,21 +227,25 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
} }
/** /**
* 按指定时间拉取 * 根据编码场景类型拉取
* *
* @param code 编码 * @param code 编码
* @param sceneType 场景类型 * @param sceneType 场景类型
* @author liuyang * @author liuyang
*/ */
public void startImplementByCode(String code, String sceneType) { public void startImplementByCode(String code, String sceneType) {
String threadNameStr = StrUtil.format("OFS销售出库(TOC)同步U8C销售订单 同步单据号:{}", code); long startMillis = System.currentTimeMillis();
logger.info(threadNameStr); String threadNameStrStart = StrUtil.format("开始-OFS销售出库(TOC)同步U8C销售订单 同步单据号:{} 业务场景:{}", code, sceneType);
logger.info(threadNameStrStart);
Thread thread = new Thread(new Runnable() { Thread thread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
LOCK.lock(); LOCK.lock();
try { try {
Assert.notNull(code, "code不能为空");
Assert.notNull(sceneType, "sceneType不能为空");
String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); String tocShop = shopTobOrToCUtil.getCommaShop("TOC");
List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList = new ArrayList<>(); List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList = new ArrayList<>();
@ -215,7 +261,11 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L, "ofs.receipt.search"); ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoList, 1L, "ofs.receipt.search");
logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size()); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoList.size());
if (returnGoodHeaderDetailsDataDtoList.size() > 0) { if (returnGoodHeaderDetailsDataDtoList.size() > 0) {
if (sceneType.equals("stock")) {
getSetStock(returnGoodHeaderDetailsDataDtoList); getSetStock(returnGoodHeaderDetailsDataDtoList);
} else if (sceneType.equals("tran")) {
getSetTran(returnGoodHeaderDetailsDataDtoList);
}
} else { } else {
logger.info("没有查询到任何数据!不需要同步"); logger.info("没有查询到任何数据!不需要同步");
} }
@ -230,17 +280,20 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
LOCK.unlock(); LOCK.unlock();
} }
} }
}, threadNameStr); }, threadNameStrStart);
thread.start(); thread.start();
try { try {
thread.join(); thread.join();
} catch (Exception e) { } catch (Exception e) {
logger.error("thread.join()异常", e); logger.error("thread.join()异常", e);
} }
long endMillis = System.currentTimeMillis();
String threadNameStrEnd = StrUtil.format("结束-OFS销售出库(TOC)同步U8C销售订单 同步单据号:{} 业务场景:{} 耗时:{}", code, sceneType, (endMillis - startMillis));
logger.info(threadNameStrEnd);
} }
/** /**
* 库存同步按指定时间拉取 * 交易采购按指定时间拉取
* *
* @author liuyang * @author liuyang
*/ */
@ -295,7 +348,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
} }
/** /**
* 预备执行逻辑 * 库存同步预备执行逻辑
* *
* @author liuyang * @author liuyang
*/ */
@ -309,7 +362,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
} }
/** /**
* 预备执行逻辑 * 确认收入预备执行逻辑
* *
* @author liuyang * @author liuyang
*/ */
@ -317,23 +370,98 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
//保存到mysql //保存到mysql
batchInsert(returnGoodHeaderDetailsDataDtoArrayList); batchInsert(returnGoodHeaderDetailsDataDtoArrayList);
//过滤成功的数据 //过滤成功的数据
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterDataStock(returnGoodHeaderDetailsDataDtoArrayList); List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = filterDataTran(returnGoodHeaderDetailsDataDtoArrayList);
//执行推送主逻辑 //执行推送主逻辑
implementTran(stockinOrderList); implementTran(stockinOrderList);
} }
/** /**
* 过滤掉成功的数据 * 库存同步过滤掉成功的数据
* *
* @author liuyang * @author liuyang
*/ */
private List<StockinOrderSearchResponse.StockinOrder> filterDataStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) { private List<StockinOrderSearchResponse.StockinOrder> filterDataStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
List<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList1 = new ArrayList<>(); // List<StockinOrderSearchResponse.StockinOrder> headerDetailsDtoList1 = new ArrayList<>();
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList = new ArrayList<>();
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
//TODO 出库单明细主键需要O返回目前没有已经提需求 List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100);
headerDetailsDtoList1.addAll(returnGoodHeaderDetailsDataDtoArrayList); for (int i = 0; i < splitListByCount.size(); i++) {
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = splitListByCount.get(i);
String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList);
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr);
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
} }
return headerDetailsDtoList1; }
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedStock(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
}
/**
* 确认收入过滤掉成功的数据
*
* @author liuyang
*/
private List<StockinOrderSearchResponse.StockinOrder> filterDataTran(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList = new ArrayList<>();
if (returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
List<List<StockinOrderSearchResponse.StockinOrder>> splitListByCount = SplitListByCountUtil.splitListByCount(returnGoodHeaderDetailsDataDtoArrayList, 100);
for (int i = 0; i < splitListByCount.size(); i++) {
List<StockinOrderSearchResponse.StockinOrder> stockinOrderList = splitListByCount.get(i);
String idStr = commaConcatenatedPrimaryKeyStock(stockinOrderList);
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = queryStockTocOutLog(idStr);
tocofsReturngoodsDetailedEntityList.addAll(tocofsReturngoodsDetailedEntities);
}
}
if (tocofsReturngoodsDetailedEntityList.size() > 0) {
return filterDataRowsAsPushOrFailedTran(tocofsReturngoodsDetailedEntityList, returnGoodHeaderDetailsDataDtoArrayList);
}
return null;
}
/**
* 逗号拼接字符串主键作为批处理的一部分方便下一步的批量查询操作
*
* @author liuyang
*/
private String commaConcatenatedPrimaryKeyStock(List<StockinOrderSearchResponse.StockinOrder> 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<StockinOrderSearchResponse.StockinOrder.StockinB> 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(stockinB.getId());
idStr.append(",");
}
}
}
if (idStr.length() > 0) {
return idStr.substring(0, idStr.length());
}
return null;
}
/**
* 批查询toc退货入库日志查询的量由splitListByCount方法控制
*
* @author liuyang
*/
private List<TocofsReturngoodsDetailedEntity> queryStockTocOutLog(String idStr) throws Exception {
List<TocofsReturngoodsDetailedEntity> 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;
} }
/** /**
@ -366,7 +494,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
List<TocofsReturngoodsEntity> tocofsReturngoodsEntities = copyHeaderDto(stockinHS); List<TocofsReturngoodsEntity> tocofsReturngoodsEntities = copyHeaderDto(stockinHS);
if (tocofsReturngoodsEntities.size() > 0) { if (tocofsReturngoodsEntities.size() > 0) {
logger.info("插入底表{}个对象(表头)", tocofsReturngoodsEntities.size()); logger.info("插入底表{}个对象(表头)", tocofsReturngoodsEntities.size());
iTocofsReturngoodsDao.entityInsertBatchV2(tocofsReturngoodsEntities); iTocofsReturngoodsDao.entityInsertOrUpdateBatch(tocofsReturngoodsEntities);
} else { } else {
logger.info("tocofsReturngoodsEntities没有对象被插入表头底表"); logger.info("tocofsReturngoodsEntities没有对象被插入表头底表");
} }
@ -379,7 +507,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS); List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntities = copyDetailsDto(stockinBS);
if (tocofsReturngoodsDetailedEntities.size() > 0) { if (tocofsReturngoodsDetailedEntities.size() > 0) {
logger.info("插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size()); logger.info("插入底表{}个对象(表体)", tocofsReturngoodsDetailedEntities.size());
iTocofsReturngoodsDetailedDao.entityInsertBatchV2(tocofsReturngoodsDetailedEntities); iTocofsReturngoodsDetailedDao.entityInsertOrUpdateBatch(tocofsReturngoodsDetailedEntities);
} else { } else {
logger.info("tocofsReturngoodsDetailedEntities没有对象被插入表头底表"); logger.info("tocofsReturngoodsDetailedEntities没有对象被插入表头底表");
} }
@ -410,7 +538,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
// if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) { // if (returnGoodHeaderDetailsDataDtoList != null && returnGoodHeaderDetailsDataDtoList.size() > 0) {
// headerDetailsDtoList.addAll(returnGoodHeaderDetailsDataDtoList); // headerDetailsDtoList.addAll(returnGoodHeaderDetailsDataDtoList);
// //
// //TODO OFS没有提供分页字段等待开发 // //OFS没有提供分页字段等待开发
// } // }
// } else { // } else {
// logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto)); // logger.error("查询失败,失败原因:{}", JSON.toJSON(interfaceParamDto));
@ -446,11 +574,14 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* @author liuyang * @author liuyang
*/ */
private void implementStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList1) throws Exception { private void implementStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList1) throws Exception {
if (returnGoodHeaderDetailsDataDtoList1 != null) {
logger.info("TOC退货业务{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size()); logger.info("TOC退货业务{}行需要进行数据转换", returnGoodHeaderDetailsDataDtoList1.size());
}
if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) {
try { try {
// 查询基本档案 // 查询基本档案
List<GoodsRertunSonDetailsDto> goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1); String sceneType = "stock";
List<GoodsRertunSonDetailsDto> goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1, sceneType);
// 分组汇总 // 分组汇总
Map<String, List<GoodsRertunSonDetailsDto>> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos); Map<String, List<GoodsRertunSonDetailsDto>> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos);
// 查询U8C业务流程 // 查询U8C业务流程
@ -585,11 +716,25 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>(); Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList); stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
logger.info("TOC销售订单编号{} 销售公司:{}", soSaleResultRootDto.getParentvo().getVreceiptcode(), soSaleResultRootDto.getParentvo().getPk_corp()); 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);
} catch (Exception e) { } catch (Exception e) {
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e); logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e);
//记录失败 //记录失败
String message = e.getMessage();
if (message == null) {
message = "未知错误";
}
updateSuccessOrFail1(oldValue, "N", message, null, null);
} }
} }
} else { } else {
@ -614,7 +759,8 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) {
try { try {
// 查询基本档案 // 查询基本档案
List<GoodsRertunSonDetailsDto> goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1); String sceneType = "tran";
List<GoodsRertunSonDetailsDto> goodsRertunSonDetailsDtos = queryBasicArchivesStock(returnGoodHeaderDetailsDataDtoList1, sceneType);
// 分组汇总 // 分组汇总
Map<String, List<GoodsRertunSonDetailsDto>> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos); Map<String, List<GoodsRertunSonDetailsDto>> summaryDimensionMap = groupSummary(goodsRertunSonDetailsDtos);
// 查询U8C业务流程 // 查询U8C业务流程
@ -707,7 +853,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
noriginalcursummny = noriginalcurtaxprice.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); noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) { } catch (Exception e) {
logger.error("TOC金额计算错误", e); logger.error("TOC退货-确认收入,金额计算错误", e);
Assert.state(false, "U8C红字销售订单金额计算错误原因{}", e.getMessage()); Assert.state(false, "U8C红字销售订单金额计算错误原因{}", e.getMessage());
} }
@ -747,11 +893,26 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>(); Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList); stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap)); SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
logger.info("TOC销售订单编号{} 销售公司:{}", soSaleResultRootDto.getParentvo().getVreceiptcode(), soSaleResultRootDto.getParentvo().getPk_corp());
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);
} catch (Exception e) { } catch (Exception e) {
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e); logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e);
//记录失败 //记录失败
String message = e.getMessage();
if (message == null) {
message = "未知错误";
}
updateSuccessOrFail2(oldValue, "N", message, null, null);
} }
} }
} else { } else {
@ -797,8 +958,12 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单对象 * @param returnGoodHeaderDetailsDataDtoList1 OFS售后入库单对象
* @author liuyang * @author liuyang
*/ */
private List<GoodsRertunSonDetailsDto> queryBasicArchivesStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList1) { private List<GoodsRertunSonDetailsDto> queryBasicArchivesStock(List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoList1, String sceneType) {
Assert.notNull(returnGoodHeaderDetailsDataDtoList1, "returnGoodHeaderDetailsDataDtoList1不能为空");
Assert.notNull(sceneType, "sceneType不能为空");
List<GoodsRertunSonDetailsDto> sonDetailsDtoList = new ArrayList<>(); List<GoodsRertunSonDetailsDto> sonDetailsDtoList = new ArrayList<>();
List<ErrorHeaderDetailsDtoDtoV2> errorHeaderDetailsDtoDtoList = new ArrayList<>();
if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) { if (returnGoodHeaderDetailsDataDtoList1 != null && returnGoodHeaderDetailsDataDtoList1.size() > 0) {
try { try {
@ -816,6 +981,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader(); StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader();
List<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails(); List<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
try {
//OFS售后订单 //OFS售后订单
RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData1 = header.getRerturnGoodsOrderSearchData(); RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData1 = header.getRerturnGoodsOrderSearchData();
Assert.notNull(rerturnGoodsOrderSearchData1, "无法关联到OFS售后订单 售后入库单号:{}", header.getCode()); Assert.notNull(rerturnGoodsOrderSearchData1, "无法关联到OFS售后订单 售后入库单号:{}", header.getCode());
@ -927,16 +1093,35 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
BeanUtil.copyPropertiesV2(stockinB, goodsRertunSonDetailsDto); BeanUtil.copyPropertiesV2(stockinB, goodsRertunSonDetailsDto);
sonDetailsDtoList.add(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) { } catch (Exception e) {
logger.error("OFS销售出库单关联查询U8C档案失败", e); logger.error("OFS销售出库单关联查询U8C档案失败", e);
//失败
} }
} else { } else {
logger.info("queryBasicArchives方法headerDetailsDtoList.size为0"); logger.info("queryBasicArchives方法headerDetailsDtoList.size为0");
} }
//错误日志同步到数据
if (errorHeaderDetailsDtoDtoList.size() > 0) {
updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(errorHeaderDetailsDtoDtoList, sceneType);
}
return sonDetailsDtoList; return sonDetailsDtoList;
} }
@ -975,6 +1160,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity(); TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity();
BeanUtil.copyPropertiesV2(stockinB, tocofsReturngoodsDetailedEntity); BeanUtil.copyPropertiesV2(stockinB, tocofsReturngoodsDetailedEntity);
//补充额外的字段信息
createPrimaryKeyAndBusinessDateAndBusinessType(tocofsReturngoodsDetailedEntity, returnGoodSearchHeaderDto); createPrimaryKeyAndBusinessDateAndBusinessType(tocofsReturngoodsDetailedEntity, returnGoodSearchHeaderDto);
tocofsSaleoutDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity); tocofsSaleoutDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity);
} }
@ -1264,9 +1450,20 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
*/ */
private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto) { private void createPrimaryKeyAndBusinessDateAndBusinessType(TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity, StockinOrderSearchResponse.StockinOrder.StockinH returnGoodSearchHeaderDto) {
if (tocofsReturngoodsDetailedEntity != null && returnGoodSearchHeaderDto != null) { if (tocofsReturngoodsDetailedEntity != null && returnGoodSearchHeaderDto != null) {
tocofsReturngoodsDetailedEntity.setPrimaryKey(tocofsReturngoodsDetailedEntity.getId());//主表主键 //主表主键
tocofsReturngoodsDetailedEntity.setBusinessDate(returnGoodSearchHeaderDto.getCheckInFrom());//业务日期 if (tocofsReturngoodsDetailedEntity.getId() != null) {
tocofsReturngoodsDetailedEntity.setBusinessType("TOC_RETURN");//业务类型 tocofsReturngoodsDetailedEntity.setMaintableid(tocofsReturngoodsDetailedEntity.getId());
}
//业务日期-入库时间
if (returnGoodSearchHeaderDto.getCheckInFrom() != null) {
tocofsReturngoodsDetailedEntity.setBusinessdate(returnGoodSearchHeaderDto.getCheckInFrom());
}
//业务日期-退款完成时间
if (returnGoodSearchHeaderDto.getRefundedAt() != null) {
tocofsReturngoodsDetailedEntity.setRefundedat(returnGoodSearchHeaderDto.getRefundedAt());
}
//业务类型
tocofsReturngoodsDetailedEntity.setBusinesstype("TOC_RETURN");
} }
} }
@ -1474,4 +1671,440 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
} }
} }
} }
/**
* 生成当前日期
*
* @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<ErrorHeaderDetailsDtoDtoV2> 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<TocofsReturngoodsDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) {
ErrorHeaderDetailsDtoDtoV2 errorHeaderDetailsDtoDtoV2 = errorHeaderDetailsDtoDtoList.get(i);
StockinOrderSearchResponse.StockinOrder.StockinH header = errorHeaderDetailsDtoDtoV2.getHeader();
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsReturngoodsDetailedEntity> 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<GoodsRertunSonDetailsDto> 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<TocofsReturngoodsDetailedEntity> 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);
if (successY.equals(newstate)) {
tocofsReturngoodsDetailedEntity.setNewsystemnumber3(newsystemnumber);
tocofsReturngoodsDetailedEntity.setNewsystemprimary3(newsystemprimary);
}
tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity);
}
//以50行为一个批次推送到Mysql
if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) {
List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 50);
for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsReturngoodsDetailedEntity> 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<GoodsRertunSonDetailsDto> 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<TocofsReturngoodsDetailedEntity> 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);
if (successY.equals(newstate)) {
tocofsReturngoodsDetailedEntity.setNewsystemnumber4(newsystemnumber);
tocofsReturngoodsDetailedEntity.setNewsystemprimary4(newsystemprimary);
}
tocofsReturngoodsDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity);
}
//以50行为一个批次推送到Mysql
if (tocofsReturngoodsDetailedEntityArrayList.size() > 0) {
List<List<TocofsReturngoodsDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsReturngoodsDetailedEntityArrayList, 50);
for (int i = 0; i < splitListByCount.size(); i++) {
List<TocofsReturngoodsDetailedEntity> 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<StockinOrderSearchResponse.StockinOrder> filterDataRowsAsPushOrFailedStock(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList, List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
List<StockinOrderSearchResponse.StockinOrder> targetHeaderDetailsDtoList = new ArrayList<>();
if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0 && returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
//字段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<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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.getNewstate3();
if (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<StockinOrderSearchResponse.StockinOrder> filterDataRowsAsPushOrFailedTran(List<TocofsReturngoodsDetailedEntity> tocofsReturngoodsDetailedEntityList, List<StockinOrderSearchResponse.StockinOrder> returnGoodHeaderDetailsDataDtoArrayList) throws Exception {
Assert.notNull(tocofsReturngoodsDetailedEntityList, "tocofsReturngoodsDetailedEntityList不能为空");
Assert.notNull(returnGoodHeaderDetailsDataDtoArrayList, "returnGoodHeaderDetailsDataDtoArrayList不能为空");
List<StockinOrderSearchResponse.StockinOrder> targetHeaderDetailsDtoList = new ArrayList<>();
if (tocofsReturngoodsDetailedEntityList != null && tocofsReturngoodsDetailedEntityList.size() > 0 && returnGoodHeaderDetailsDataDtoArrayList != null && returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {
//字段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<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
List<StockinOrderSearchResponse.StockinOrder.StockinB> 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;
}
}
}
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<String> stringArrayList = new ArrayList<>();
List<String> 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) throws Exception {
try {
Assert.notNull(param, "param不能为空!");
Assert.state(!"".equals(param), "param不能为空");
Assert.notNull(sceneType, "sceneType不能为空");
Assert.state(!"".equals(sceneType), "sceneType不能为空");
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]);
} else if (sceneType.equals(TRAN)) {
startImplementByTradeTime(split[0], split[1]);
}
}
}
} else {
String[] split = param.split(",");
logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]);
if (sceneType.equals(STOCK)) {
startImplementStockByTime(split[0], split[1]);
} else if (sceneType.equals(TRAN)) {
startImplementByTradeTime(split[0], split[1]);
}
}
} catch (Exception e) {
logger.error("记录splitDateAndPush方法抛出的异常", e);
}
}
/**
* 计算全天时间段
*
* @author liuyang
*/
public List<StartAndEndVo> calculateCalculateEntireDayPeriod(String dateStr) {
List<StartAndEndVo> startAndEnd = new ArrayList<>();
String calculateYesterdayStr = null;
if (dateStr != null) {
calculateYesterdayStr = dateStr;
} else {
calculateYesterdayStr = calculateYesterdayDate();//拉取'昨天'的日期
}
logger.info("OFS销售出库单同步U8C销售订单目标拉取时间" + calculateYesterdayStr);
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<String> getDateRange(LocalDate startDate, LocalDate endDate) {
List<String> dateRange = new ArrayList<>();
LocalDate currentDate = startDate;
while (!currentDate.isAfter(endDate)) {
dateRange.add(currentDate.format(DateTimeFormatter.ISO_DATE));
currentDate = currentDate.plusDays(1);
}
return dateRange;
}
} }

View File

@ -0,0 +1,33 @@
package com.hzya.frame.plugin.lets.u8cdto;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto;
import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse;
import lombok.Data;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.u8cdto
* @ProjectkangarooDataCenterV3
* @nameErrorHeaderDetailsDtoDto
* @Date2024/9/5 15:48
* @FilenameErrorHeaderDetailsDtoDto
*/
@Data
public class ErrorHeaderDetailsDtoDtoV2 extends StockinOrderSearchResponse.StockinOrder {
//(销售)推送时间
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;
}

View File

@ -102,6 +102,9 @@ public class StockinOrderSearchResponse extends ReturnMessageBasics {
private String lastUpdated; private String lastUpdated;
private String lastUpdatedBy; private String lastUpdatedBy;
private String discountPrice; private String discountPrice;
private String newstate;
private String newstate3;
private String newstate4;
//表头对象 //表头对象
private StockinH returnGoodSearchHeaderDto; private StockinH returnGoodSearchHeaderDto;
} }