优化TOC、TOB的日志存储
This commit is contained in:
parent
149b43bdd0
commit
3860651162
|
@ -1,6 +1,7 @@
|
|||
package com.hzya.frame.plugin.lets.entity;
|
||||
|
||||
import com.hzya.frame.web.entity.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* (BdRdcl)实体类
|
||||
|
@ -8,8 +9,8 @@ import com.hzya.frame.web.entity.BaseEntity;
|
|||
* @author makejava
|
||||
* @since 2023-12-04 13:49:11
|
||||
*/
|
||||
@Data
|
||||
public class BdRdclEntity extends BaseEntity {
|
||||
|
||||
private Integer dr;
|
||||
private Integer iflag;
|
||||
private String pkCorp;
|
||||
|
@ -20,87 +21,4 @@ public class BdRdclEntity extends BaseEntity {
|
|||
private String rdname;
|
||||
private String sealflag;
|
||||
private String ts;
|
||||
|
||||
|
||||
public Integer getDr() {
|
||||
return dr;
|
||||
}
|
||||
|
||||
public void setDr(Integer dr) {
|
||||
this.dr = dr;
|
||||
}
|
||||
|
||||
public Integer getIflag() {
|
||||
return iflag;
|
||||
}
|
||||
|
||||
public void setIflag(Integer iflag) {
|
||||
this.iflag = iflag;
|
||||
}
|
||||
|
||||
public String getPkCorp() {
|
||||
return pkCorp;
|
||||
}
|
||||
|
||||
public void setPkCorp(String pkCorp) {
|
||||
this.pkCorp = pkCorp;
|
||||
}
|
||||
|
||||
public String getPkFrdcl() {
|
||||
return pkFrdcl;
|
||||
}
|
||||
|
||||
public void setPkFrdcl(String pkFrdcl) {
|
||||
this.pkFrdcl = pkFrdcl;
|
||||
}
|
||||
|
||||
public String getPkRdcl() {
|
||||
return pkRdcl;
|
||||
}
|
||||
|
||||
public void setPkRdcl(String pkRdcl) {
|
||||
this.pkRdcl = pkRdcl;
|
||||
}
|
||||
|
||||
public String getRdcode() {
|
||||
return rdcode;
|
||||
}
|
||||
|
||||
public void setRdcode(String rdcode) {
|
||||
this.rdcode = rdcode;
|
||||
}
|
||||
|
||||
public Integer getRdflag() {
|
||||
return rdflag;
|
||||
}
|
||||
|
||||
public void setRdflag(Integer rdflag) {
|
||||
this.rdflag = rdflag;
|
||||
}
|
||||
|
||||
public String getRdname() {
|
||||
return rdname;
|
||||
}
|
||||
|
||||
public void setRdname(String rdname) {
|
||||
this.rdname = rdname;
|
||||
}
|
||||
|
||||
public String getSealflag() {
|
||||
return sealflag;
|
||||
}
|
||||
|
||||
public void setSealflag(String sealflag) {
|
||||
this.sealflag = sealflag;
|
||||
}
|
||||
|
||||
public String getTs() {
|
||||
return ts;
|
||||
}
|
||||
|
||||
public void setTs(String ts) {
|
||||
this.ts = ts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -46,5 +46,33 @@ public interface ITocofsSaleoutDetailedDao extends IBaseDao<TocofsSaleoutDetaile
|
|||
* @author liuyang
|
||||
*/
|
||||
void entityInsertOrUpdateBatchStock4(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新出库状态的日志(适用TOB交易成功)
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
void entityInsertOrUpdateBatchStock5(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新出库状态的日志(适用TOB库存推送)
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
void entityInsertOrUpdateBatchStock6(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新出库状态的日志(适用TOB确认收入推送)
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
void entityInsertOrUpdateBatchStock7(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新出库状态的日志(适用TOB确认收入推送)
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
void entityInsertOrUpdateBatchStock8(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,4 +38,24 @@ public class TocofsSaleoutDetailedDaoImpl extends MybatisGenericDao<TocofsSaleou
|
|||
public void entityInsertOrUpdateBatchStock4(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock4", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInsertOrUpdateBatchStock5(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock5", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInsertOrUpdateBatchStock6(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock6", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInsertOrUpdateBatchStock7(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock7", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInsertOrUpdateBatchStock8(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock8", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
}
|
|
@ -979,6 +979,98 @@
|
|||
</insert>
|
||||
|
||||
|
||||
|
||||
<!-- TOB更新推送状态(适合确认收入蓝字)-->
|
||||
<insert id="entityInsertOrUpdateBatchStock5" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState4,newSystemNumber,newSystemPrimary)
|
||||
values
|
||||
<foreach collection="list" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id},
|
||||
#{entity.newPushDate},
|
||||
#{entity.newTransmitInfo},
|
||||
#{entity.newState4},
|
||||
#{entity.newSystemNumber},
|
||||
#{entity.newSystemPrimary}
|
||||
)
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
id = values(id),
|
||||
newPushDate = values(newPushDate),
|
||||
newTransmitInfo = values(newTransmitInfo),
|
||||
newState4 = values(newState4),
|
||||
newSystemNumber = values(newSystemNumber),
|
||||
newSystemPrimary = values(newSystemPrimary)
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- TOB更新推送状态(适合确认收入蓝字)-->
|
||||
<insert id="entityInsertOrUpdateBatchStock6" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary)
|
||||
values
|
||||
<foreach collection="list" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id},
|
||||
#{entity.newpushdate},
|
||||
#{entity.newtransmitinfo},
|
||||
#{entity.newstate},
|
||||
#{entity.newsystemnumber},
|
||||
#{entity.newsystemprimary}
|
||||
)
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
id = values(id),
|
||||
newPushDate = values(newPushDate),
|
||||
newTransmitInfo = values(newTransmitInfo),
|
||||
newState = values(newState),
|
||||
newSystemNumber = values(newSystemNumber),
|
||||
newSystemPrimary = values(newSystemPrimary)
|
||||
</insert>
|
||||
|
||||
<!-- TOB更新推送状态(适合确认收入蓝字)-->
|
||||
<insert id="entityInsertOrUpdateBatchStock7" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tocofs_saleout_detailed(id,def5,def6,newstate4)
|
||||
values
|
||||
<foreach collection="list" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id},
|
||||
#{entity.def5},
|
||||
#{entity.def6},
|
||||
#{entity.newstate4}
|
||||
)
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
id = values(id),
|
||||
def5 = values(def5),
|
||||
def6 = values(def6),
|
||||
newstate4 = values(newstate4)
|
||||
</insert>
|
||||
|
||||
<!-- TOB更新推送状态(适合确认收入蓝字)-->
|
||||
<insert id="entityInsertOrUpdateBatchStock8" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tocofs_saleout_detailed(id,def5,def6,newState4,newSystemNumber4,newSystemPrimary4)
|
||||
values
|
||||
<foreach collection="list" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id},
|
||||
#{entity.def5},
|
||||
#{entity.def6},
|
||||
#{entity.newstate4},
|
||||
#{entity.newsystemnumber4},
|
||||
#{entity.newsystemprimary4}
|
||||
)
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
id = values(id),
|
||||
def5 = values(def5),
|
||||
def6 = values(def6),
|
||||
newState4 = values(newState4),
|
||||
newSystemNumber4 = values(newSystemNumber4),
|
||||
newSystemPrimary4 = values(newSystemPrimary4)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改方法-->
|
||||
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity" >
|
||||
update tocofs_saleout_detailed set
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
|
|||
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity;
|
||||
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo;
|
||||
import com.hzya.frame.plugin.lets.queryvo.ExtIntegrationTaskLivingDetailsQueryVo;
|
||||
import com.hzya.frame.plugin.lets.queryvo.StartAndEndVo;
|
||||
import com.hzya.frame.plugin.lets.u8cdto.*;
|
||||
import com.hzya.frame.plugin.lets.util.*;
|
||||
import com.hzya.frame.split.SplitListByCountUtil;
|
||||
|
@ -32,7 +33,11 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* OFS销售出库单(TOB)生成U8C销售订单
|
||||
|
@ -57,6 +62,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
@Autowired
|
||||
private ISoSaleorderBDao iSoSaleorderBDao;
|
||||
|
||||
@Autowired
|
||||
private OffsetTimeTime offsetTimeTime;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
|
@ -87,8 +95,46 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
return "3";
|
||||
}
|
||||
|
||||
private static final String STOCK = "stock";
|
||||
|
||||
private static final String TRAN = "tran";
|
||||
|
||||
private static final String PROD_FILED = "prod";
|
||||
|
||||
@Override
|
||||
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"));//sceneType:stock、tran
|
||||
if (ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type"))) {
|
||||
//按单号
|
||||
if (param != null && !"".equals(param)) {
|
||||
startImplementByCode(param);
|
||||
}
|
||||
} else if (ProfilesActiveConstant.TYPE_TIME_FRAME.equals(requestJson.get("type"))) {
|
||||
//前台页面功能日期推送,或者接口调用也行
|
||||
Assert.notNull(sceneType, "sceneType参数不能为空");
|
||||
Assert.notNull(!"".equals(sceneType), "sceneType参数不能为空");
|
||||
String craeteDateStr = computingTime(param);
|
||||
if (craeteDateStr != null && !"".equals(craeteDateStr)) {
|
||||
splitDateAndPush(craeteDateStr, sceneType);
|
||||
}
|
||||
} else {
|
||||
if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(PROD_FILED)) {
|
||||
//实时执行,每1分钟调度一次
|
||||
StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
|
||||
startImplementByStockTime(startAndEndVo.getStart_time(), startAndEndVo.getEnd_time());
|
||||
startImplementByTranTime(startAndEndVo.getStart_time(), startAndEndVo.getEnd_time());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("executeBusiness方法异常", e);
|
||||
}
|
||||
long endMillis = System.currentTimeMillis();
|
||||
logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -321,7 +367,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
//保存到mysql
|
||||
batchInsert(headerDetailsDtoList);
|
||||
//过滤成功的数据
|
||||
List<HeaderDetailsDto> headerDetailsDtos = filterData(headerDetailsDtoList);
|
||||
List<HeaderDetailsDto> headerDetailsDtos = filterDataStock(headerDetailsDtoList);
|
||||
//执行推送主逻辑
|
||||
implementStock(headerDetailsDtos);
|
||||
}
|
||||
|
@ -333,23 +379,197 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
//保存到mysql
|
||||
batchInsert(headerDetailsDtoList);
|
||||
//过滤成功的数据
|
||||
List<HeaderDetailsDto> headerDetailsDtos = filterData(headerDetailsDtoList);
|
||||
List<HeaderDetailsDto> headerDetailsDtos = filterDataTran(headerDetailsDtoList);
|
||||
//执行主推送逻辑
|
||||
implementSuccessfulTrade(headerDetailsDtos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤掉成功的数据
|
||||
* 库存同步,过滤掉成功的数据
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<HeaderDetailsDto> filterData(List<HeaderDetailsDto> headerDetailsDtoList) {
|
||||
List<HeaderDetailsDto> headerDetailsDtoList1 = new ArrayList<>();
|
||||
private List<HeaderDetailsDto> filterDataStock(List<HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
// List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList1 = new ArrayList<>();
|
||||
List<TocofsSaleoutDetailedEntity> allTocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
//TODO 出库单明细主键,需要O返回,目前没有,已经提需求
|
||||
headerDetailsDtoList1.addAll(headerDetailsDtoList);
|
||||
List<List<HeaderDetailsDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<HeaderDetailsDto> headerDetailsDtoList2 = splitListByCount.get(i);
|
||||
String idStr = commaConcatenatedPrimaryKeyStock(headerDetailsDtoList2);
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = queryStockTocOutLog(idStr);
|
||||
allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList);
|
||||
}
|
||||
return headerDetailsDtoList1;
|
||||
}
|
||||
if (allTocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逗号拼接字符串主键,作为批处理的一部分,方便下一步的批量查询操作
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private String commaConcatenatedPrimaryKeyStock(List<HeaderDetailsDto> headerDetailsDtoList2) throws Exception {
|
||||
StringBuffer idStr = new StringBuffer();
|
||||
if (headerDetailsDtoList2 != null && headerDetailsDtoList2.size() > 0) {
|
||||
for (int i = 0; i < headerDetailsDtoList2.size(); i++) {
|
||||
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList2.get(i);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
Assert.notNull(detailsDto.getId(), "O明细主键不能为空!");
|
||||
Assert.state(!"".equals(detailsDto.getId()), "O明细主键不能为空!");
|
||||
|
||||
idStr.append(detailsDto.getId());
|
||||
idStr.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idStr.length() > 0) {
|
||||
return idStr.substring(0, idStr.length());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批查询toc出库日志,查询的量由splitListByCount方法控制
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<TocofsSaleoutDetailedEntity> queryStockTocOutLog(String idStr) throws Exception {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = null;
|
||||
if (idStr != null && !"".equals(idStr.trim())) {
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
tocofsSaleoutDetailedEntity.setIds(idStr);
|
||||
tocofsSaleoutDetailedEntityList = iTocofsSaleoutDetailedDao.query(tocofsSaleoutDetailedEntity);
|
||||
} else {
|
||||
logger.error("idStr为空,无法查询数据!");
|
||||
}
|
||||
return tocofsSaleoutDetailedEntityList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选出未推送、或者失败的数据行
|
||||
*
|
||||
* @param allTocofsSaleoutDetailedEntityList 日志行状态
|
||||
* @param headerDetailsDtoList 返回结果
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> filterDataRowsAsPushOrFailedStock(List<TocofsSaleoutDetailedEntity> allTocofsSaleoutDetailedEntityList, List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> targetHeaderDetailsDtoList = new ArrayList<>();
|
||||
if (allTocofsSaleoutDetailedEntityList != null && allTocofsSaleoutDetailedEntityList.size() > 0 && headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
//字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行
|
||||
String succeseeY = "Y";
|
||||
String succeseeH = "H";
|
||||
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
|
||||
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
List<DetailsDto> targetDetails = new ArrayList<>();
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
Boolean isSuccess = false;
|
||||
String newstate = null;
|
||||
for (int k = 0; k < allTocofsSaleoutDetailedEntityList.size(); k++) {
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = allTocofsSaleoutDetailedEntityList.get(k);
|
||||
if (tocofsSaleoutDetailedEntity.getId().equals(detailsDto.getId())) {
|
||||
newstate = tocofsSaleoutDetailedEntity.getNewstate();
|
||||
if (succeseeY.equals(newstate) || succeseeH.equals(newstate)) {
|
||||
isSuccess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isSuccess) {
|
||||
detailsDto.setNewState(newstate);
|
||||
targetDetails.add(detailsDto);
|
||||
}
|
||||
}
|
||||
if (targetDetails.size() > 0) {
|
||||
//如果明细行中,还存在未推送或者失败的数据,则需要更新明细行
|
||||
headerDetailsDto.setDetails(targetDetails);
|
||||
targetHeaderDetailsDtoList.add(headerDetailsDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
return targetHeaderDetailsDtoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认收入,过滤掉成功的数据
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<HeaderDetailsDto> filterDataTran(List<HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
List<TocofsSaleoutDetailedEntity> allTocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
List<List<HeaderDetailsDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<HeaderDetailsDto> headerDetailsDtoList2 = splitListByCount.get(i);
|
||||
String idStr = commaConcatenatedPrimaryKeyStock(headerDetailsDtoList2);
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = queryStockTocOutLog(idStr);
|
||||
allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList);
|
||||
}
|
||||
}
|
||||
if (allTocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
return filterDataRowsAsPushOrFailedTran(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选出未推送、或者失败的数据行
|
||||
*
|
||||
* @param allTocofsSaleoutDetailedEntityList 日志行状态
|
||||
* @param headerDetailsDtoList 返回结果
|
||||
* @author liuyang
|
||||
*/
|
||||
private List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> filterDataRowsAsPushOrFailedTran(List<TocofsSaleoutDetailedEntity> allTocofsSaleoutDetailedEntityList, List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> targetHeaderDetailsDtoList = new ArrayList<>();
|
||||
if (allTocofsSaleoutDetailedEntityList != null && allTocofsSaleoutDetailedEntityList.size() > 0 && headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
//字段Y(成功)或者为H(待处理)可以视为成功,完成了小段业务闭环的数据行
|
||||
String succeseeY = "Y";
|
||||
String succeseeH = "H";
|
||||
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
|
||||
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
List<DetailsDto> targetDetails = new ArrayList<>();
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
|
||||
Boolean isSuccess = false;
|
||||
String newstate4 = null;
|
||||
for (int k = 0; k < allTocofsSaleoutDetailedEntityList.size(); k++) {
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = allTocofsSaleoutDetailedEntityList.get(k);
|
||||
if (tocofsSaleoutDetailedEntity.getId().equals(detailsDto.getId())) {
|
||||
newstate4 = tocofsSaleoutDetailedEntity.getNewstate4();
|
||||
//验证交易成功(红)是否成功、(销售)交易成功(蓝)是否成功 两者如果都成功,则过滤掉,如果其中一个不能成功,则还是需要进行补推!
|
||||
//验证红或蓝单据是否推送成功的代码,在implementTran中实现
|
||||
if ((succeseeY.equals(newstate4) || succeseeH.equals(newstate4))) {
|
||||
isSuccess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isSuccess) {
|
||||
//拷贝推送状态参数,方便推送是进行判断
|
||||
detailsDto.setNewState4(newstate4);
|
||||
targetDetails.add(detailsDto);
|
||||
}
|
||||
}
|
||||
if (targetDetails.size() > 0) {
|
||||
//如果明细行中,还存在未推送或者失败的数据,则需要更新明细行
|
||||
headerDetailsDto.setDetails(targetDetails);
|
||||
targetHeaderDetailsDtoList.add(headerDetailsDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
return targetHeaderDetailsDtoList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -433,7 +653,6 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
logger.info("TOB销售业务库存同步:{}行需要进行数据转换", headerDetailsDtos.size());
|
||||
}
|
||||
if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) {
|
||||
try {
|
||||
try {
|
||||
// 查询基本档案
|
||||
List<OrderOutTobHeaderDto> orderOutTobHeaderDtos = queryBasicArchives(headerDetailsDtos);
|
||||
|
@ -447,6 +666,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
HeaderDto header = orderOutTobHeaderDto.getHeader();
|
||||
List<DetailsDto> details = orderOutTobHeaderDto.getDetails();
|
||||
|
||||
try {
|
||||
//销售公司、发货公司
|
||||
BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity();
|
||||
//发货库存组织
|
||||
|
@ -529,9 +749,6 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
tax = "0";
|
||||
}
|
||||
|
||||
//TODO 测试
|
||||
detailsDto.setShipQty("1");
|
||||
|
||||
BigDecimal noriginalcurprice = null;//无税单价
|
||||
BigDecimal noriginalcurmny = null;//无税金额
|
||||
BigDecimal noriginalcurtaxprice = null;//含税单价
|
||||
|
@ -589,7 +806,9 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
saleorderRequestDtoList.add(saleorderRequestDto);
|
||||
|
||||
Boolean aBoolean = checkTobOrder(header.getId(), header.getCode());
|
||||
if (!aBoolean) {
|
||||
if (aBoolean) {
|
||||
logger.error("经过SQL查询判断,在U8C销售订单已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId());
|
||||
} else {
|
||||
logger.error("经过SQL查询判断,在U8C销售订单不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId());
|
||||
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
|
||||
stringStringMap.put("saleorder", saleorderRequestDtoList);
|
||||
|
@ -607,18 +826,23 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
csaleid = parentvo.getCsaleid();
|
||||
}
|
||||
logger.info("TOB销售订单编号:{} 主键:{} 公司:{}", vreceiptcode, csaleid, pk_corp);
|
||||
} else {
|
||||
logger.error("经过SQL查询判断,在U8C销售订单已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId());
|
||||
//记录成功
|
||||
updateSuccessOrFail2(details, "Y", "success", vreceiptcode, csaleid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("推送TOB销售订单失败", e);
|
||||
//记录失败
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = "未知错误";
|
||||
}
|
||||
updateSuccessOrFail2(details, "N", message, null, null);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e);
|
||||
//记录失败
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB外层转换逻辑抛出异常", e);
|
||||
// 记录失败
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -677,7 +901,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
}
|
||||
|
||||
/**
|
||||
* 档案转换
|
||||
* 库存类-档案转换
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
|
@ -686,6 +910,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
logger.info("库存同步:需要把OFS档案转换为U8C档案的O数据条数:{}", headerDetailsDtoList.size());
|
||||
}
|
||||
List<OrderOutTobHeaderDto> orderOutTobHeaderDtoArrayList = new ArrayList<>();
|
||||
List<ErrorHeaderDetailsDtoDto> errorHeaderDetailsDtoDtoList = new ArrayList<>();
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
try {
|
||||
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
|
||||
|
@ -693,6 +918,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
try {
|
||||
//根据OFS销售出库单,查询得到OFS销售订单
|
||||
SaleOrderMessageDto saleOrderMessageDto = null;
|
||||
try {
|
||||
|
@ -858,15 +1084,34 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
|
||||
BeanUtil.copyPropertiesV2(header, orderOutTobHeaderDto);
|
||||
orderOutTobHeaderDtoArrayList.add(orderOutTobHeaderDto);
|
||||
//档案转换成功
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB档案转换失败", e);
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = "未知错误";
|
||||
}
|
||||
//失败,只记录失败
|
||||
ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = new ErrorHeaderDetailsDtoDto();
|
||||
errorHeaderDetailsDtoDto.setNewPushDate(getNewDateStr());
|
||||
errorHeaderDetailsDtoDto.setNewTransmitInfo(message);
|
||||
errorHeaderDetailsDtoDto.setNewstate("N");
|
||||
errorHeaderDetailsDtoDto.setHeader(header);
|
||||
errorHeaderDetailsDtoDto.setDetails(details);
|
||||
errorHeaderDetailsDtoDtoList.add(errorHeaderDetailsDtoDto);
|
||||
}
|
||||
}
|
||||
//成功
|
||||
} catch (Exception e) {
|
||||
logger.error("OFS销售出库单关联查询U8C档案失败", e);
|
||||
//失败
|
||||
}
|
||||
} else {
|
||||
logger.info("queryBasicArchives方法对应的headerDetailsDtoList.size为0");
|
||||
}
|
||||
|
||||
//批量把错误写入到日志信息表
|
||||
if (errorHeaderDetailsDtoDtoList.size() > 0) {
|
||||
updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryStock(errorHeaderDetailsDtoDtoList);
|
||||
}
|
||||
return orderOutTobHeaderDtoArrayList;
|
||||
}
|
||||
|
||||
|
@ -901,6 +1146,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
// tocofsSaleoutDetailedEntity.setBusinessType("TOB_ORDER");
|
||||
// BeanUtils.copyProperties(detailsDto, tocofsSaleoutDetailedEntity);
|
||||
BeanUtil.copyPropertiesV2(detailsDto, tocofsSaleoutDetailedEntity);
|
||||
//补充一些业务字段
|
||||
createPrimaryKeyAndBusinessDateAndBusinessType(tocofsSaleoutDetailedEntity, detailsDto);
|
||||
tocofsSaleoutDetailedEntityArrayList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
|
@ -1112,8 +1358,11 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
* @author liuyang
|
||||
*/
|
||||
private List<OrderOutTobHeaderDto> queryBasicArchivesSaleinvoice(List<HeaderDetailsDto> headerDetailsDtoList) {
|
||||
if (headerDetailsDtoList != null) {
|
||||
logger.info("库存同步:需要把OFS档案转换为U8C档案的O数据条数:{}", headerDetailsDtoList.size());
|
||||
}
|
||||
List<OrderOutTobHeaderDto> orderOutTobHeaderDtoArrayList = new ArrayList<>();
|
||||
|
||||
List<ErrorHeaderDetailsDtoDto> errorHeaderDetailsDtoDtoList = new ArrayList<>();
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
try {
|
||||
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
|
||||
|
@ -1121,6 +1370,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
try {
|
||||
//根据OFS销售出库单,查询得到OFS销售订单
|
||||
SaleOrderMessageDto saleOrderMessageDto = null;
|
||||
try {
|
||||
|
@ -1351,15 +1601,33 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
|
||||
BeanUtil.copyPropertiesV2(header, orderOutTobHeaderDto);
|
||||
orderOutTobHeaderDtoArrayList.add(orderOutTobHeaderDto);
|
||||
//成功,进入下一个环节
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB档案转换失败", e);
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = "未知错误";
|
||||
}
|
||||
//失败,只记录失败
|
||||
ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = new ErrorHeaderDetailsDtoDto();
|
||||
errorHeaderDetailsDtoDto.setDef5(getNewDateStr());//推送时间
|
||||
errorHeaderDetailsDtoDto.setDef6(message);//报错详情
|
||||
errorHeaderDetailsDtoDto.setNewstate4("N");//交易成功-红
|
||||
errorHeaderDetailsDtoDto.setHeader(header);
|
||||
errorHeaderDetailsDtoDto.setDetails(details);
|
||||
errorHeaderDetailsDtoDtoList.add(errorHeaderDetailsDtoDto);
|
||||
}
|
||||
}
|
||||
//成功,记录到日志表
|
||||
} catch (Exception e) {
|
||||
logger.error("OFS销售出库单关联查询U8C档案失败", e);
|
||||
//失败,记录到日子表
|
||||
}
|
||||
} else {
|
||||
logger.info("queryBasicArchives方法对应的headerDetailsDtoList.size为0");
|
||||
}
|
||||
//批量把错误写入到日志信息表
|
||||
if (errorHeaderDetailsDtoDtoList.size() > 0) {
|
||||
updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryTran(errorHeaderDetailsDtoDtoList);
|
||||
}
|
||||
return orderOutTobHeaderDtoArrayList;
|
||||
}
|
||||
|
||||
|
@ -1383,11 +1651,11 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
logger.info("TOB销售业务交易成功同步,档案转换成功对应的数量:{}行需要进行数据转换", orderOutTobHeaderDtos.size());
|
||||
logger.info("TOB销售发票业务流程编码:{}", bdBusitypeEntity.getBusicode());
|
||||
for (int i = 0; i < orderOutTobHeaderDtos.size(); i++) {
|
||||
try {
|
||||
OrderOutTobHeaderDto orderOutTobHeaderDto = orderOutTobHeaderDtos.get(i);
|
||||
HeaderDto header = orderOutTobHeaderDto.getHeader();
|
||||
List<DetailsDto> details = orderOutTobHeaderDto.getDetails();
|
||||
|
||||
try {
|
||||
//销售公司、发货公司
|
||||
BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity();
|
||||
//发货库存组织
|
||||
|
@ -1477,8 +1745,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
if (noriginalcurtaxprice == null) {
|
||||
isblargessflag = true;
|
||||
}
|
||||
//TODO 测试
|
||||
// detailsDto.setShipQty("1");
|
||||
|
||||
SalesInvoiceBodyDto salesInvoiceBodyDto = new SalesInvoiceBodyDto();
|
||||
salesInvoiceBodyDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());
|
||||
salesInvoiceBodyDto.setCupreceipttype("4C");//来源单据类型
|
||||
|
@ -1518,21 +1785,34 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
|
||||
//推送到U8C之前,再次验证,在U8C是否已经存在
|
||||
Boolean aBoolean = checkTobSalesInvoice(header.getId(), header.getCode());
|
||||
if (!aBoolean) {
|
||||
if (aBoolean) {
|
||||
logger.error("经过SQL查询判断,在U8C销售发票中已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId());
|
||||
} else {
|
||||
logger.error("经过SQL查询判断,在U8C销售发票中不存在OFS入库单号为:{} OFS入库主键为:{}的单据,将调用U8C接口执行推送!", header.getCode(), header.getId());
|
||||
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) {
|
||||
SaleinvoiceHeadDto parentvo = saleinvoiceDto.getParentvo();
|
||||
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();
|
||||
}
|
||||
} else {
|
||||
logger.error("经过SQL查询判断,在U8C销售发票中已经存在OFS入库单号为:{} OFS入库主键为:{}的单据,为了避免造成单据重复,不推送到U8C!", header.getCode(), header.getId());
|
||||
logger.info("TOB销售发票生成成功 编码:{} 主键:{} 发票公司:{}", vreceiptcode, csaleid, pk_corp);
|
||||
//记录成功
|
||||
updateSuccessOrFail3(details, "Y", "success", vreceiptcode, csaleid);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB的销售发票传输失败,抛出异常", e);
|
||||
//失败
|
||||
//记录失败
|
||||
String message = e.getMessage();
|
||||
if (message == null) {
|
||||
message = "未知错误";
|
||||
}
|
||||
updateSuccessOrFail3(details, "N", message, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1714,4 +1994,400 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间间隔
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分割日期之后,再进行推送
|
||||
*
|
||||
* @param param 日期参数
|
||||
* @param sceneType 场景类型 TOB库存、TOB确认收入
|
||||
* @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)) {
|
||||
startImplementByStockTime(split[0], split[1]);
|
||||
} else if (sceneType.equals(TRAN)) {
|
||||
startImplementByTranTime(split[0], split[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] split = param.split(",");
|
||||
logger.info("splitDateAndPush方法正在执行主要的逻辑 开始时间:{} 结束时间:{}", split[0], split[1]);
|
||||
if (sceneType.equals(STOCK)) {
|
||||
startImplementByStockTime(split[0], split[1]);
|
||||
} else if (sceneType.equals(TRAN)) {
|
||||
startImplementByTranTime(split[0], split[1]);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("记录splitDateAndPush方法抛出的异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理调用U8C接口,抛出的异常,或者调用成功的记录
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
// private void updateSuccessOrFail1(List<DetailsDto> orderOutTobHeaderDtoList, 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 (orderOutTobHeaderDtoList != null && orderOutTobHeaderDtoList.size() > 0) {
|
||||
// List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
// for (int i = 0; i < orderOutTobHeaderDtoList.size(); i++) {
|
||||
// DetailsDto detailsDto = orderOutTobHeaderDtoList.get(i);
|
||||
//
|
||||
// TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
// tocofsSaleoutDetailedEntity.setId(detailsDto.getId());
|
||||
// tocofsSaleoutDetailedEntity.setNewpushdate(getNewDateStr());
|
||||
// tocofsSaleoutDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo);
|
||||
// tocofsSaleoutDetailedEntity.setNewstate4(newstate);
|
||||
// if (successY.equals(newstate)) {
|
||||
// //只有成功才填充下游系统主键和编码
|
||||
// tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber);
|
||||
// tocofsSaleoutDetailedEntity.setNewsystemprimary(newsystemprimary);
|
||||
// }
|
||||
// tocofsSaleoutDetailedEntityList.add(tocofsSaleoutDetailedEntity);
|
||||
// }
|
||||
//
|
||||
// //以50行为一个批次,推送到Mysql
|
||||
// if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
// List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
||||
// for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
// List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
||||
// iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock5(tocofsSaleoutDetailedEntityList1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("处理调用U8C接口,抛出的异常,或者调用成功的记录对应的方法抛出异常", e);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// thread.start();
|
||||
// try {
|
||||
// thread.join();
|
||||
// } catch (Exception e) {
|
||||
// logger.error("updateSuccessOrFail1方法现场抛出异常", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理调用U8C接口,抛出的异常,或者调用成功的记录
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void updateSuccessOrFail2(List<DetailsDto> orderOutTobHeaderDtoList, 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 (orderOutTobHeaderDtoList != null && orderOutTobHeaderDtoList.size() > 0) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
for (int i = 0; i < orderOutTobHeaderDtoList.size(); i++) {
|
||||
DetailsDto detailsDto = orderOutTobHeaderDtoList.get(i);
|
||||
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
tocofsSaleoutDetailedEntity.setId(detailsDto.getId());
|
||||
tocofsSaleoutDetailedEntity.setNewpushdate(getNewDateStr());
|
||||
tocofsSaleoutDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo);
|
||||
tocofsSaleoutDetailedEntity.setNewstate(newstate);
|
||||
if (successY.equals(newstate)) {
|
||||
//只有成功才填充下游系统主键和编码
|
||||
tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber);
|
||||
tocofsSaleoutDetailedEntity.setNewsystemprimary(newsystemprimary);
|
||||
}
|
||||
tocofsSaleoutDetailedEntityList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
|
||||
//以50行为一个批次,推送到Mysql
|
||||
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
||||
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock6(tocofsSaleoutDetailedEntityList1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("处理调用U8C接口,抛出的异常,或者调用成功的记录对应的方法抛出异常", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (Exception e) {
|
||||
logger.error("updateSuccessOrFail1方法现场抛出异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理调用U8C接口,抛出的异常,或者调用成功的记录
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void updateSuccessOrFail3(List<DetailsDto> orderOutTobHeaderDtoList, 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 (orderOutTobHeaderDtoList != null && orderOutTobHeaderDtoList.size() > 0) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
for (int i = 0; i < orderOutTobHeaderDtoList.size(); i++) {
|
||||
DetailsDto detailsDto = orderOutTobHeaderDtoList.get(i);
|
||||
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
tocofsSaleoutDetailedEntity.setId(detailsDto.getId());
|
||||
tocofsSaleoutDetailedEntity.setDef5(getNewDateStr());
|
||||
tocofsSaleoutDetailedEntity.setDef6(finalNewTransmitInfo);
|
||||
tocofsSaleoutDetailedEntity.setNewstate4(newstate);
|
||||
if (successY.equals(newstate)) {
|
||||
//只有成功才填充下游系统主键和编码
|
||||
tocofsSaleoutDetailedEntity.setNewsystemnumber4(newsystemnumber);
|
||||
tocofsSaleoutDetailedEntity.setNewsystemprimary4(newsystemprimary);
|
||||
}
|
||||
tocofsSaleoutDetailedEntityList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
|
||||
//以50行为一个批次,推送到Mysql
|
||||
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
||||
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock8(tocofsSaleoutDetailedEntityList1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("处理调用U8C接口,抛出的异常,或者调用成功的记录对应的方法抛出异常", 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改成功、或者失败,适合档案查询的部分
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryStock(List<ErrorHeaderDetailsDtoDto> errorHeaderDetailsDtoDtoList) {
|
||||
Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!");
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) {
|
||||
ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = errorHeaderDetailsDtoDtoList.get(i);
|
||||
HeaderDto header = errorHeaderDetailsDtoDto.getHeader();
|
||||
List<DetailsDto> details = errorHeaderDetailsDtoDto.getDetails();
|
||||
String newstate = errorHeaderDetailsDtoDto.getNewstate();
|
||||
String newPushDate = errorHeaderDetailsDtoDto.getNewPushDate();
|
||||
String newTransmitInfo = errorHeaderDetailsDtoDto.getNewTransmitInfo();
|
||||
|
||||
//如果报错内容太长了,则仅保留500个长度
|
||||
if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) {
|
||||
newTransmitInfo = newTransmitInfo.substring(0, 400);
|
||||
}
|
||||
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
tocofsSaleoutDetailedEntity.setId(detailsDto.getId());
|
||||
tocofsSaleoutDetailedEntity.setNewpushdate(newPushDate);
|
||||
tocofsSaleoutDetailedEntity.setNewtransmitinfo(newTransmitInfo);
|
||||
tocofsSaleoutDetailedEntity.setNewstate(newstate);
|
||||
tocofsSaleoutDetailedEntityList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
//以50行为一个批次更新状态
|
||||
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
||||
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1(tocofsSaleoutDetailedEntityList1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB填充出库明细日志抛出异常", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (Exception e) {
|
||||
logger.error("updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry方法现场抛出异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改成功、或者失败,适合档案查询的部分
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryTran(List<ErrorHeaderDetailsDtoDto> errorHeaderDetailsDtoDtoList) {
|
||||
Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!");
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) {
|
||||
ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = errorHeaderDetailsDtoDtoList.get(i);
|
||||
HeaderDto header = errorHeaderDetailsDtoDto.getHeader();
|
||||
List<DetailsDto> details = errorHeaderDetailsDtoDto.getDetails();
|
||||
|
||||
String newstate = errorHeaderDetailsDtoDto.getNewstate4();
|
||||
String newPushDate = errorHeaderDetailsDtoDto.getDef5();
|
||||
String newTransmitInfo = errorHeaderDetailsDtoDto.getDef6();
|
||||
|
||||
//如果报错内容太长了,则仅保留500个长度
|
||||
if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) {
|
||||
newTransmitInfo = newTransmitInfo.substring(0, 400);
|
||||
}
|
||||
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
tocofsSaleoutDetailedEntity.setId(detailsDto.getId());
|
||||
tocofsSaleoutDetailedEntity.setDef5(newPushDate);
|
||||
tocofsSaleoutDetailedEntity.setDef6(newTransmitInfo);
|
||||
tocofsSaleoutDetailedEntity.setNewstate4(newstate);
|
||||
tocofsSaleoutDetailedEntityList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
//以50行为一个批次更新状态
|
||||
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
||||
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock7(tocofsSaleoutDetailedEntityList1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("TOB填充出库明细日志抛出异常", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (Exception e) {
|
||||
logger.error("updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry方法现场抛出异常", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,6 +28,8 @@ import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto;
|
|||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto;
|
||||
import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse;
|
||||
import com.hzya.frame.ttxofs.service.OfsUnifiedService;
|
||||
import com.hzya.frame.u8c.ax.entity.Ass;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
|
@ -57,6 +59,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
private static final ReentrantLock LOCK = new ReentrantLock(true);
|
||||
|
||||
private static final String PROD_FILED = "prod";
|
||||
//
|
||||
// @Autowired
|
||||
// private SoSaleOutPluginInitializerToC soSaleOutPluginInitializerToC;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
@ -964,12 +969,19 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
try {
|
||||
//初始化档案缓存
|
||||
CacheTocMapVo cacheTocMapVo = basicArchivesCacheUtil.initCache();
|
||||
//查询对应的OFS销售订单
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtos = queryOfsOrder(headerDetailsDtoList);
|
||||
findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList);
|
||||
|
||||
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
|
||||
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto> details = headerDetailsDto.getDetails();
|
||||
try {
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = header.getHeaderDetailsDto();
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
|
||||
|
||||
//表头公司:通过名称匹配U8C公司
|
||||
// String corpName = "上海丽知品牌管理有限公司";
|
||||
String companyCode = header.getCompanyCode();
|
||||
|
@ -1025,6 +1037,8 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
BdDefdocEntity bdDefdocEntity1 = cacheTocMapVo.getStringBdDefdocShopEntityMap().get(header.getStoreCode());
|
||||
Assert.notNull(bdDefdocEntity1, "根据O店铺编码({})无法匹配到U8C店铺自定义档案", header.getStoreCode());
|
||||
|
||||
// TODO 查询该单据的收发类别-取销售订单对应的单据类型名称
|
||||
|
||||
//字段拷贝
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
|
@ -1058,6 +1072,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
sonDetailsDto.setBdInvmandocEntity(bdInvmandocEntity);
|
||||
sonDetailsDto.setBdInvbasdocEntity(bdInvbasdocEntity);
|
||||
sonDetailsDto.setBdTaxitemsEntity(bdTaxitemsEntity);
|
||||
sonDetailsDto.setHeaderDetailsDto(headerDetailsDto1);
|
||||
|
||||
BeanUtil.copyPropertiesV2(detailsDto, sonDetailsDto);
|
||||
sonDetailsDtoList.add(sonDetailsDto);
|
||||
|
@ -1759,6 +1774,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
* @author liuyang
|
||||
*/
|
||||
private void updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(List<ErrorHeaderDetailsDtoDto> errorHeaderDetailsDtoDtoList) {
|
||||
Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!");
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
|
@ -2150,4 +2166,75 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
logger.error("记录splitDateAndPush方法抛出的异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过OFS销售出库单,联查OFS销售订单
|
||||
*
|
||||
* @param headerDetailsDtoList OFS销售出库单
|
||||
*/
|
||||
private List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> queryOfsOrder(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList) throws Exception {
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> allHeaderDetailsDtoArrayList = new ArrayList<>();
|
||||
try {
|
||||
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
|
||||
List<List<HeaderDetailsDto>> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<HeaderDetailsDto> headerDetailsDtos = splitListByCount.get(i);
|
||||
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) {
|
||||
for (int j = 0; j < headerDetailsDtos.size(); j++) {
|
||||
HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
// List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
// stringBuffer.append("'");
|
||||
stringBuffer.append(header.getRefOrderCode());
|
||||
// stringBuffer.append("'");
|
||||
stringBuffer.append(",");
|
||||
}
|
||||
}
|
||||
String substring = stringBuffer.substring(0, stringBuffer.length());
|
||||
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoArrayList = new ArrayList<>();
|
||||
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
queryOfsSoSaleOutVo.setCode(substring);
|
||||
ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L);
|
||||
allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("queryOfsOrder方法抛出异常", e);
|
||||
}
|
||||
return allHeaderDetailsDtoArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 代码匹配销售订单
|
||||
*
|
||||
* @param ofsSaleOrder ofs销售订单集合
|
||||
* @param ofsSaleOutOrder ofs销售出库单集合
|
||||
* @author liuyang
|
||||
*/
|
||||
private void findMatchingOfsOrder(List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> ofsSaleOrder, List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> ofsSaleOutOrder) throws Exception {
|
||||
if (ofsSaleOrder != null && ofsSaleOutOrder != null && ofsSaleOrder.size() > 0 && ofsSaleOutOrder.size() > 0) {
|
||||
try {
|
||||
for (int i = 0; i < ofsSaleOutOrder.size(); i++) {
|
||||
HeaderDetailsDto headerDetailsDto = ofsSaleOutOrder.get(i);
|
||||
HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
String targetRefOrderCode = header.getRefOrderCode();
|
||||
for (int j = 0; j < ofsSaleOrder.size(); j++) {
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(j);
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
|
||||
if (header1.getCode().equals(targetRefOrderCode)) {
|
||||
header.setHeaderDetailsDto(headerDetailsDto1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("findMatchingOfsOrder方法抛出异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,7 +39,10 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* OFS售后入库单(TOB)生成U8C红字销售订单
|
||||
|
@ -90,6 +93,38 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
|
|||
|
||||
@Override
|
||||
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"));//sceneType:stock、tran
|
||||
if (ProfilesActiveConstant.TYPE_VBILLCODE.equals(requestJson.get("type"))) {
|
||||
//按单号
|
||||
if (param != null && !"".equals(param)) {
|
||||
startImplementByCode(param);
|
||||
}
|
||||
} else if (ProfilesActiveConstant.TYPE_TIME_FRAME.equals(requestJson.get("type"))) {
|
||||
//前台页面功能日期推送,或者接口调用也行
|
||||
Assert.notNull(sceneType, "sceneType参数不能为空");
|
||||
Assert.notNull(!"".equals(sceneType), "sceneType参数不能为空");
|
||||
String craeteDateStr = computingTime(param);
|
||||
if (craeteDateStr != null && !"".equals(craeteDateStr)) {
|
||||
splitDateAndPush(craeteDateStr, sceneType);
|
||||
}
|
||||
} else {
|
||||
if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals(PROD_FILED)) {
|
||||
//实时执行,每1分钟调度一次
|
||||
StartAndEndVo startAndEndVo = offsetTimeTime.offsetTime();
|
||||
startImplementByStockTime(startAndEndVo.getStart_time(), startAndEndVo.getEnd_time());
|
||||
startImplementByTradeTime(startAndEndVo.getStart_time(), startAndEndVo.getEnd_time());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("executeBusiness方法异常", e);
|
||||
}
|
||||
long endMillis = System.currentTimeMillis();
|
||||
logger.info("executeBusiness方法调用结束:" + getPluginName() + "-插件 执行耗时:{}", (endMillis - startMillis));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -162,6 +197,12 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
|
|||
@Autowired
|
||||
private ISoSaleinvoiceDao iSoSaleinvoiceDao;
|
||||
|
||||
private static final String STOCK = "stock";
|
||||
|
||||
private static final String TRAN = "tran";
|
||||
|
||||
private static final String PROD_FILED = "prod";
|
||||
|
||||
private static final String VNOTETYPE = "RETURN";
|
||||
|
||||
/**
|
||||
|
@ -1710,4 +1751,98 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间间隔
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分割日期之后,再进行推送
|
||||
*
|
||||
* @param param 日期参数
|
||||
* @param sceneType 场景类型 TOB库存、TOB确认收入
|
||||
* @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)) {
|
||||
startImplementByStockTime(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)) {
|
||||
startImplementByStockTime(split[0], split[1]);
|
||||
} else if (sceneType.equals(TRAN)) {
|
||||
startImplementByTradeTime(split[0], split[1]);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("记录splitDateAndPush方法抛出的异常", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,4 +19,14 @@ public class ErrorHeaderDetailsDtoDto extends HeaderDetailsDto {
|
|||
private String newTransmitInfo;
|
||||
//(销售)出库同步是否成功
|
||||
private String newstate;
|
||||
//推送时间
|
||||
private String def5;
|
||||
//报错详情
|
||||
private String def6;
|
||||
//(销售)交易成功(TOB发票)是否成功
|
||||
private String newstate4;
|
||||
//下游单号
|
||||
private String newSystemNumber4;
|
||||
//下游主键
|
||||
private String newSystemPrimary4;
|
||||
}
|
||||
|
|
|
@ -73,4 +73,7 @@ public class SonDetailsDto extends DetailsDto {
|
|||
|
||||
//存货税率
|
||||
private BdTaxitemsEntity bdTaxitemsEntity;
|
||||
|
||||
//对应的OFS销售订单
|
||||
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
|
||||
}
|
|
@ -12,6 +12,7 @@ import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrder;
|
|||
import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderBean;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto;
|
||||
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto;
|
||||
import com.hzya.frame.ttxofs.dto.stock.StockinOrderSearchResponse;
|
||||
import com.hzya.frame.ttxofs.service.OfsUnifiedService;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -195,4 +196,46 @@ public class OfsStandardUtil {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询OFS销售订单
|
||||
*
|
||||
* @param queryOfsSoSaleOutVo 查询条件
|
||||
* @param headerDetailsDtoList 需要填充原始的数组集合
|
||||
* @param pageNo 从第几页开始查询
|
||||
* @author liuyang
|
||||
*/
|
||||
public void getOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoList, Long pageNo) throws Exception {
|
||||
Assert.notNull(queryOfsSoSaleOutVo, "queryOfsSoSaleOutVo不能为空!");
|
||||
Assert.notNull(headerDetailsDtoList, "saleOrderMessageDtoList不能为空!");
|
||||
Assert.notNull(pageNo, "pageNo不能为空!");
|
||||
|
||||
Long pageSize = 200L;
|
||||
// Long pageNo = 1L;
|
||||
queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
|
||||
// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
// queryOfsSoSaleOutVo.setPageNo(pageNo);
|
||||
// queryOfsSoSaleOutVo.setPageSize(pageSize);
|
||||
// queryOfsSoSaleOutVo.setCode(code);
|
||||
|
||||
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
|
||||
interfaceParamDto.setApi("ofs.salesOrder.search");
|
||||
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
|
||||
SaleOrderMessageDto saleOrderMessageDto = (SaleOrderMessageDto) ofsUnifiedService.unified(interfaceParamDto);
|
||||
if (saleOrderMessageDto != null) {
|
||||
if ("false".equals(saleOrderMessageDto.getError()) && "0".equals(saleOrderMessageDto.getCode()) && "Success".equals(saleOrderMessageDto.getMsg())) {
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> data = saleOrderMessageDto.getData();
|
||||
if (data != null && data.size() > 0) {
|
||||
headerDetailsDtoList.addAll(data);
|
||||
getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, ++pageNo);
|
||||
}
|
||||
} else {
|
||||
logger.error("查询失败,失败原因:{}", JSON.toJSON(saleOrderMessageDto));
|
||||
}
|
||||
} else {
|
||||
logger.error("getOfsSaleOrder为空!interfaceParamDto对象的结果集json:{}", JSON.toJSON(interfaceParamDto));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -74,7 +74,11 @@ class SoSaleOutPluginInitializerToCTest {
|
|||
// System.out.println(aaa.length());
|
||||
|
||||
|
||||
String computingTime = soSaleOutPluginInitializerToC.computingTime("2024-01-01/2024-01-01");
|
||||
soSaleOutPluginInitializerToC.splitDateAndPush(computingTime, "tran");
|
||||
// String computingTime = soSaleOutPluginInitializerToC.computingTime("2024-01-01/2024-01-01");
|
||||
// soSaleOutPluginInitializerToC.splitDateAndPush(computingTime, "tran");
|
||||
|
||||
|
||||
String s = "LETS-SH2024081900000001";
|
||||
soSaleOutPluginInitializerToC.startImplementStockByCode(s);
|
||||
}
|
||||
}
|
|
@ -49,4 +49,22 @@ public class OfsStandardUtilTest {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试销售订单
|
||||
*/
|
||||
@Test
|
||||
public void getOfsOrder() {
|
||||
try {
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
|
||||
|
||||
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
queryOfsSoSaleOutVo.setCode("LETS-SO2024082300021950,LETS-SO2024082300021944");
|
||||
ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L);
|
||||
|
||||
System.out.println(headerDetailsDtoList.size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,4 +49,8 @@ public class DetailsDto {
|
|||
* 额外参数:(销售)交易成功(蓝)是否成功
|
||||
*/
|
||||
private String newState3;
|
||||
/**
|
||||
* (销售)交易成功(TOB发票)是否成功
|
||||
*/
|
||||
private String newState4;
|
||||
}
|
|
@ -73,4 +73,7 @@ public class HeaderDto {
|
|||
|
||||
//出库类型
|
||||
private String shipmentType;
|
||||
|
||||
//OFS销售订单
|
||||
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
|
||||
}
|
Loading…
Reference in New Issue