diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java index 5744683b..85e8b1a3 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdRdclEntity.java @@ -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; - } - -} - +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java index fdc848e2..2c3b40d6 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java @@ -46,5 +46,33 @@ public interface ITocofsSaleoutDetailedDao extends IBaseDao tocofsSaleoutDetailedEntities) throws Exception; + + /** + * 更新出库状态的日志(适用TOB交易成功) + * + * @author liuyang + */ + void entityInsertOrUpdateBatchStock5(List tocofsSaleoutDetailedEntities) throws Exception; + + /** + * 更新出库状态的日志(适用TOB库存推送) + * + * @author liuyang + */ + void entityInsertOrUpdateBatchStock6(List tocofsSaleoutDetailedEntities) throws Exception; + + /** + * 更新出库状态的日志(适用TOB确认收入推送) + * + * @author liuyang + */ + void entityInsertOrUpdateBatchStock7(List tocofsSaleoutDetailedEntities) throws Exception; + + /** + * 更新出库状态的日志(适用TOB确认收入推送) + * + * @author liuyang + */ + void entityInsertOrUpdateBatchStock8(List tocofsSaleoutDetailedEntities) throws Exception; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java index 2986fb9d..267d9abf 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java @@ -38,4 +38,24 @@ public class TocofsSaleoutDetailedDaoImpl extends MybatisGenericDao tocofsSaleoutDetailedEntities) throws Exception { insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock4", tocofsSaleoutDetailedEntities); } + + @Override + public void entityInsertOrUpdateBatchStock5(List tocofsSaleoutDetailedEntities) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock5", tocofsSaleoutDetailedEntities); + } + + @Override + public void entityInsertOrUpdateBatchStock6(List tocofsSaleoutDetailedEntities) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock6", tocofsSaleoutDetailedEntities); + } + + @Override + public void entityInsertOrUpdateBatchStock7(List tocofsSaleoutDetailedEntities) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock7", tocofsSaleoutDetailedEntities); + } + + @Override + public void entityInsertOrUpdateBatchStock8(List tocofsSaleoutDetailedEntities) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock8", tocofsSaleoutDetailedEntities); + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml index d6cfdec9..0a89b11e 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml @@ -979,6 +979,98 @@ + + + + insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState4,newSystemNumber,newSystemPrimary) + values + + ( + #{entity.id}, + #{entity.newPushDate}, + #{entity.newTransmitInfo}, + #{entity.newState4}, + #{entity.newSystemNumber}, + #{entity.newSystemPrimary} + ) + + on duplicate key update + id = values(id), + newPushDate = values(newPushDate), + newTransmitInfo = values(newTransmitInfo), + newState4 = values(newState4), + newSystemNumber = values(newSystemNumber), + newSystemPrimary = values(newSystemPrimary) + + + + + + + + insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary) + values + + ( + #{entity.id}, + #{entity.newpushdate}, + #{entity.newtransmitinfo}, + #{entity.newstate}, + #{entity.newsystemnumber}, + #{entity.newsystemprimary} + ) + + on duplicate key update + id = values(id), + newPushDate = values(newPushDate), + newTransmitInfo = values(newTransmitInfo), + newState = values(newState), + newSystemNumber = values(newSystemNumber), + newSystemPrimary = values(newSystemPrimary) + + + + + insert into tocofs_saleout_detailed(id,def5,def6,newstate4) + values + + ( + #{entity.id}, + #{entity.def5}, + #{entity.def6}, + #{entity.newstate4} + ) + + on duplicate key update + id = values(id), + def5 = values(def5), + def6 = values(def6), + newstate4 = values(newstate4) + + + + + insert into tocofs_saleout_detailed(id,def5,def6,newState4,newSystemNumber4,newSystemPrimary4) + values + + ( + #{entity.id}, + #{entity.def5}, + #{entity.def6}, + #{entity.newstate4}, + #{entity.newsystemnumber4}, + #{entity.newsystemprimary4} + ) + + on duplicate key update + id = values(id), + def5 = values(def5), + def6 = values(def6), + newState4 = values(newState4), + newSystemNumber4 = values(newSystemNumber4), + newSystemPrimary4 = values(newSystemPrimary4) + + update tocofs_saleout_detailed set diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java index fb270ee1..99540b8a 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java @@ -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 headerDetailsDtos = filterData(headerDetailsDtoList); + List headerDetailsDtos = filterDataStock(headerDetailsDtoList); //执行推送主逻辑 implementStock(headerDetailsDtos); } @@ -333,23 +379,197 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { //保存到mysql batchInsert(headerDetailsDtoList); //过滤成功的数据 - List headerDetailsDtos = filterData(headerDetailsDtoList); + List headerDetailsDtos = filterDataTran(headerDetailsDtoList); //执行主推送逻辑 implementSuccessfulTrade(headerDetailsDtos); } /** - * 过滤掉成功的数据 + * 库存同步,过滤掉成功的数据 * * @author liuyang */ - private List filterData(List headerDetailsDtoList) { - List headerDetailsDtoList1 = new ArrayList<>(); + private List filterDataStock(List headerDetailsDtoList) throws Exception { + // List headerDetailsDtoList1 = new ArrayList<>(); + List allTocofsSaleoutDetailedEntityList = new ArrayList<>(); if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { - //TODO 出库单明细主键,需要O返回,目前没有,已经提需求 - headerDetailsDtoList1.addAll(headerDetailsDtoList); + List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); + for (int i = 0; i < splitListByCount.size(); i++) { + List headerDetailsDtoList2 = splitListByCount.get(i); + String idStr = commaConcatenatedPrimaryKeyStock(headerDetailsDtoList2); + List tocofsSaleoutDetailedEntityList = queryStockTocOutLog(idStr); + allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList); + } } - return headerDetailsDtoList1; + if (allTocofsSaleoutDetailedEntityList.size() > 0) { + return filterDataRowsAsPushOrFailedStock(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList); + } + return null; + } + + /** + * 逗号拼接字符串主键,作为批处理的一部分,方便下一步的批量查询操作 + * + * @author liuyang + */ + private String commaConcatenatedPrimaryKeyStock(List headerDetailsDtoList2) throws Exception { + StringBuffer idStr = new StringBuffer(); + if (headerDetailsDtoList2 != null && headerDetailsDtoList2.size() > 0) { + for (int i = 0; i < headerDetailsDtoList2.size(); i++) { + HeaderDetailsDto headerDetailsDto = headerDetailsDtoList2.get(i); + HeaderDto header = headerDetailsDto.getHeader(); + List 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 queryStockTocOutLog(String idStr) throws Exception { + List 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 filterDataRowsAsPushOrFailedStock(List allTocofsSaleoutDetailedEntityList, List headerDetailsDtoList) throws Exception { + List 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 details = headerDetailsDto.getDetails(); + + List 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 filterDataTran(List headerDetailsDtoList) throws Exception { + List allTocofsSaleoutDetailedEntityList = new ArrayList<>(); + if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { + List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); + for (int i = 0; i < splitListByCount.size(); i++) { + List headerDetailsDtoList2 = splitListByCount.get(i); + String idStr = commaConcatenatedPrimaryKeyStock(headerDetailsDtoList2); + List tocofsSaleoutDetailedEntityList = queryStockTocOutLog(idStr); + allTocofsSaleoutDetailedEntityList.addAll(tocofsSaleoutDetailedEntityList); + } + } + if (allTocofsSaleoutDetailedEntityList.size() > 0) { + return filterDataRowsAsPushOrFailedTran(allTocofsSaleoutDetailedEntityList, headerDetailsDtoList); + } + return null; + } + + /** + * 筛选出未推送、或者失败的数据行 + * + * @param allTocofsSaleoutDetailedEntityList 日志行状态 + * @param headerDetailsDtoList 返回结果 + * @author liuyang + */ + private List filterDataRowsAsPushOrFailedTran(List allTocofsSaleoutDetailedEntityList, List headerDetailsDtoList) throws Exception { + List 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 details = headerDetailsDto.getDetails(); + + List 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; } /** @@ -434,19 +654,19 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { } if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { try { - try { - // 查询基本档案 - List orderOutTobHeaderDtos = queryBasicArchives(headerDetailsDtos); - // 查询U8C业务流程 - BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); - // 查询销售收发类别 - BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("201"); + // 查询基本档案 + List orderOutTobHeaderDtos = queryBasicArchives(headerDetailsDtos); + // 查询U8C业务流程 + BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow(); + // 查询销售收发类别 + BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("201"); - for (int i = 0; i < orderOutTobHeaderDtos.size(); i++) { - OrderOutTobHeaderDto orderOutTobHeaderDto = orderOutTobHeaderDtos.get(i); - HeaderDto header = orderOutTobHeaderDto.getHeader(); - List details = orderOutTobHeaderDto.getDetails(); + for (int i = 0; i < orderOutTobHeaderDtos.size(); i++) { + OrderOutTobHeaderDto orderOutTobHeaderDto = orderOutTobHeaderDtos.get(i); + HeaderDto header = orderOutTobHeaderDto.getHeader(); + List 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> stringStringMap = new HashMap<>(); stringStringMap.put("saleorder", saleorderRequestDtoList); @@ -607,17 +826,22 @@ 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); - // 记录失败 + logger.error("TOB业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", 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 orderOutTobHeaderDtoArrayList = new ArrayList<>(); + List errorHeaderDetailsDtoDtoList = new ArrayList<>(); if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { try { for (int i = 0; i < headerDetailsDtoList.size(); i++) { @@ -693,180 +918,200 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { HeaderDto header = headerDetailsDto.getHeader(); List details = headerDetailsDto.getDetails(); - //根据OFS销售出库单,查询得到OFS销售订单 - SaleOrderMessageDto saleOrderMessageDto = null; try { - saleOrderMessageDto = afterSalesOrderUtil.getOfsOrder(header.getRefOrderCode()); - } catch (Exception e) { - logger.error("查询销售订单错误,失败原因:{}", e.getMessage()); - Assert.state(false, "查询销售订单错误,失败原因:{}", e.getMessage()); - } + //根据OFS销售出库单,查询得到OFS销售订单 + SaleOrderMessageDto saleOrderMessageDto = null; + try { + saleOrderMessageDto = afterSalesOrderUtil.getOfsOrder(header.getRefOrderCode()); + } catch (Exception e) { + logger.error("查询销售订单错误,失败原因:{}", e.getMessage()); + Assert.state(false, "查询销售订单错误,失败原因:{}", e.getMessage()); + } - if (saleOrderMessageDto == null) { - Assert.state(false, "没有匹配到售后订单,系统业务无法完成"); - } - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); - String memberId = header1.getMemberId(); - Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); - Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + if (saleOrderMessageDto == null) { + Assert.state(false, "没有匹配到售后订单,系统业务无法完成"); + } + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); + String memberId = header1.getMemberId(); + Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); - // 销售公司、发货公司 + // 销售公司、发货公司 // header.setCompanyCode("SHLZ"); - String companyCode = header.getCompanyCode(); - Assert.notNull(companyCode, "O表头公司不能为空"); - BdCorpEntity bdCorpEntity = new BdCorpEntity(); - bdCorpEntity.setDr(0); - bdCorpEntity.setDataSourceCode("lets_u8c"); - bdCorpEntity.setUnitcode(companyCode); - List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); - if (bdCorpEntityList.size() == 0) { - Assert.state(false, "根据O货主编码{},无法匹配到U8C销售公司", companyCode); - } else if (bdCorpEntityList.size() >= 2) { - Assert.state(false, "根据O货主编码{},匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size()); - } + String companyCode = header.getCompanyCode(); + Assert.notNull(companyCode, "O表头公司不能为空"); + BdCorpEntity bdCorpEntity = new BdCorpEntity(); + bdCorpEntity.setDr(0); + bdCorpEntity.setDataSourceCode("lets_u8c"); + bdCorpEntity.setUnitcode(companyCode); + List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); + if (bdCorpEntityList.size() == 0) { + Assert.state(false, "根据O货主编码{},无法匹配到U8C销售公司", companyCode); + } else if (bdCorpEntityList.size() >= 2) { + Assert.state(false, "根据O货主编码{},匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size()); + } - // 发货库存组织 - BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); - bdCalbodyEntity.setDr(0); - bdCalbodyEntity.setDataSourceCode("lets_u8c"); - bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); - if (bdCalbodyEntities.size() == 0) { - Assert.state(false, "根据U8C发货公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); - } else if (bdCalbodyEntities.size() >= 2) { - Assert.state(false, "根据U8C发货公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); - } + // 发货库存组织 + BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); + bdCalbodyEntity.setDr(0); + bdCalbodyEntity.setDataSourceCode("lets_u8c"); + bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); + if (bdCalbodyEntities.size() == 0) { + Assert.state(false, "根据U8C发货公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); + } else if (bdCalbodyEntities.size() >= 2) { + Assert.state(false, "根据U8C发货公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); + } - // 仓库 - String facilityCode = header.getFacilityCode(); - Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); - BdStordocEntity bdStordocEntity = new BdStordocEntity(); - bdStordocEntity.setDr(0L); - bdStordocEntity.setDataSourceCode("lets_u8c"); - bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); - bdStordocEntity.setStorcode(facilityCode); - List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); - if (bdStordocEntityList.size() == 0) { - Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,无法匹配到U8C仓库 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); - } else if (bdStordocEntityList.size() >= 2) { - Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,匹配到U8C仓库多个 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); - } + // 仓库 + String facilityCode = header.getFacilityCode(); + Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); + BdStordocEntity bdStordocEntity = new BdStordocEntity(); + bdStordocEntity.setDr(0L); + bdStordocEntity.setDataSourceCode("lets_u8c"); + bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); + bdStordocEntity.setStorcode(facilityCode); + List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); + if (bdStordocEntityList.size() == 0) { + Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,无法匹配到U8C仓库 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); + } else if (bdStordocEntityList.size() >= 2) { + Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,匹配到U8C仓库多个 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); + } - //销售组织 - //2024年8月13日 10:35:05 已经和佳妮在微信确认,U8C销售公司编码与U8C销售组织编码保持一致,因此通过销售公司编码匹配 - BdSalestruEntity bdSalestruEntity = new BdSalestruEntity(); - bdSalestruEntity.setDr(0); - bdSalestruEntity.setDataSourceCode("lets_u8c"); - bdSalestruEntity.setVsalestrucode(bdCorpEntityList.get(0).getUnitcode()); - List bdSalestruEntityList = iBdSalestruDao.query(bdSalestruEntity); - if (bdSalestruEntityList.size() == 0) { - Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); - } else if (bdSalestruEntityList.size() >= 2) { - Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); - } + //销售组织 + //2024年8月13日 10:35:05 已经和佳妮在微信确认,U8C销售公司编码与U8C销售组织编码保持一致,因此通过销售公司编码匹配 + BdSalestruEntity bdSalestruEntity = new BdSalestruEntity(); + bdSalestruEntity.setDr(0); + bdSalestruEntity.setDataSourceCode("lets_u8c"); + bdSalestruEntity.setVsalestrucode(bdCorpEntityList.get(0).getUnitcode()); + List bdSalestruEntityList = iBdSalestruDao.query(bdSalestruEntity); + if (bdSalestruEntityList.size() == 0) { + Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); + } else if (bdSalestruEntityList.size() >= 2) { + Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); + } - //业务部门 - //2024年8月14日 10:38:37 已经和佳妮确认 - String deptName = "其他部门"; - BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); - bdDeptdocEntity.setDataSourceCode("lets_u8c"); - bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname(deptName); - bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); - if (bdDeptdocEntityList.size() == 0) { - Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); - } else if (bdDeptdocEntityList.size() >= 2) { - Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); - } + //业务部门 + //2024年8月14日 10:38:37 已经和佳妮确认 + String deptName = "其他部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + } - //客商基本档案 - //查询OFS对应的销售订单,得到会员id + //客商基本档案 + //查询OFS对应的销售订单,得到会员id // QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); // queryOfsSoSaleOutVo.setCode(); // SaleOrderMessageDto ofsOrder = getOfsOrder(queryOfsSoSaleOutVo, 1L); // String custName = "天猫intoyou旗舰店-自营"; - BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); - bdCubasdocEntity.setDataSourceCode("lets_u8c"); - bdCubasdocEntity.setDr(0L); - bdCubasdocEntity.setDef1(memberId); - List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); - if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { - Assert.state(false, "根据OFS会员id{},无法查询到U8C客商基本档案", memberId); - } else if (bdCubasdocEntityList.size() >= 2) { - Assert.state(false, "根据OFS会员id{},查询到U8C多个客商基本档案", memberId); + BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); + bdCubasdocEntity.setDataSourceCode("lets_u8c"); + bdCubasdocEntity.setDr(0L); + bdCubasdocEntity.setDef1(memberId); + List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); + if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { + Assert.state(false, "根据OFS会员id{},无法查询到U8C客商基本档案", memberId); + } else if (bdCubasdocEntityList.size() >= 2) { + Assert.state(false, "根据OFS会员id{},查询到U8C多个客商基本档案", memberId); + } + + //客商管理档案 + BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); + bdCumandocEntity1.setDataSourceCode("lets_u8c"); + bdCumandocEntity1.setDr(0L); + bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER); + bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); + List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); + if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { + Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); + } + + //查找平台 + String platformZdyId = "0001A210000000000JUD"; + String sourcePlatformCode = header.getSourcePlatformCode(); + BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); + bdDefdocEntity.setPkDefdoclist(platformZdyId); + bdDefdocEntity.setDr(0); + bdDefdocEntity.setDataSourceCode("lets_u8c"); + bdDefdocEntity.setDoccode(sourcePlatformCode); + List bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity); + if (bdDefdocEntityList.size() == 0) { + Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); + } else if (bdDefdocEntityList.size() >= 2) { + Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); + } + + //查询U8C店铺档案 + String platformZdyId2 = "0001A210000000000XZX"; + String ofsStoreCode = header.getStoreCode(); + BdDefdocEntity bdDefdocEntity2 = new BdDefdocEntity(); + bdDefdocEntity2.setPkDefdoclist(platformZdyId2); + bdDefdocEntity2.setDr(0); + bdDefdocEntity2.setDataSourceCode("lets_u8c"); + bdDefdocEntity2.setDoccode(ofsStoreCode); + List bdDefdocEntityList2 = iBdDefdocDao.query(bdDefdocEntity2); + if (bdDefdocEntityList2.size() == 0) { + Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); + } else if (bdDefdocEntityList2.size() >= 2) { + Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); + } + + OrderOutTobHeaderDto orderOutTobHeaderDto = new OrderOutTobHeaderDto(); + orderOutTobHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); + orderOutTobHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); + orderOutTobHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); + orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0)); + orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0)); + orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); + orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); + orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0)); + orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0)); + orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0)); + orderOutTobHeaderDto.setSaleOrderMessageDto(saleOrderMessageDto); + + orderOutTobHeaderDto.setHeader(header); + orderOutTobHeaderDto.setDetails(details); + + 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); } - - //客商管理档案 - BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); - bdCumandocEntity1.setDataSourceCode("lets_u8c"); - bdCumandocEntity1.setDr(0L); - bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER); - bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); - List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); - if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { - Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); - } - - //查找平台 - String platformZdyId = "0001A210000000000JUD"; - String sourcePlatformCode = header.getSourcePlatformCode(); - BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); - bdDefdocEntity.setPkDefdoclist(platformZdyId); - bdDefdocEntity.setDr(0); - bdDefdocEntity.setDataSourceCode("lets_u8c"); - bdDefdocEntity.setDoccode(sourcePlatformCode); - List bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity); - if (bdDefdocEntityList.size() == 0) { - Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); - } else if (bdDefdocEntityList.size() >= 2) { - Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); - } - - //查询U8C店铺档案 - String platformZdyId2 = "0001A210000000000XZX"; - String ofsStoreCode = header.getStoreCode(); - BdDefdocEntity bdDefdocEntity2 = new BdDefdocEntity(); - bdDefdocEntity2.setPkDefdoclist(platformZdyId2); - bdDefdocEntity2.setDr(0); - bdDefdocEntity2.setDataSourceCode("lets_u8c"); - bdDefdocEntity2.setDoccode(ofsStoreCode); - List bdDefdocEntityList2 = iBdDefdocDao.query(bdDefdocEntity2); - if (bdDefdocEntityList2.size() == 0) { - Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); - } else if (bdDefdocEntityList2.size() >= 2) { - Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); - } - - OrderOutTobHeaderDto orderOutTobHeaderDto = new OrderOutTobHeaderDto(); - orderOutTobHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); - orderOutTobHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); - orderOutTobHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); - orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0)); - orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0)); - orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); - orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); - orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0)); - orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0)); - orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0)); - orderOutTobHeaderDto.setSaleOrderMessageDto(saleOrderMessageDto); - - orderOutTobHeaderDto.setHeader(header); - orderOutTobHeaderDto.setDetails(details); - - BeanUtil.copyPropertiesV2(header, orderOutTobHeaderDto); - orderOutTobHeaderDtoArrayList.add(orderOutTobHeaderDto); } - //成功 } 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 queryBasicArchivesSaleinvoice(List headerDetailsDtoList) { + if (headerDetailsDtoList != null) { + logger.info("库存同步:需要把OFS档案转换为U8C档案的O数据条数:{}", headerDetailsDtoList.size()); + } List orderOutTobHeaderDtoArrayList = new ArrayList<>(); - + List errorHeaderDetailsDtoDtoList = new ArrayList<>(); if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { try { for (int i = 0; i < headerDetailsDtoList.size(); i++) { @@ -1121,245 +1370,264 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { HeaderDto header = headerDetailsDto.getHeader(); List details = headerDetailsDto.getDetails(); - //根据OFS销售出库单,查询得到OFS销售订单 - SaleOrderMessageDto saleOrderMessageDto = null; try { - saleOrderMessageDto = afterSalesOrderUtil.getOfsOrder(header.getRefOrderCode()); - } catch (Exception e) { - logger.error("查询销售订单错误,失败原因:{}", e.getMessage()); - Assert.state(false, "查询销售订单错误,失败原因:{}", e.getMessage()); - } - if (saleOrderMessageDto == null) { - Assert.state(false, "根据单号:{},没有匹配到销售订单,系统业务无法完成", header.getRefOrderCode()); - } + //根据OFS销售出库单,查询得到OFS销售订单 + SaleOrderMessageDto saleOrderMessageDto = null; + try { + saleOrderMessageDto = afterSalesOrderUtil.getOfsOrder(header.getRefOrderCode()); + } catch (Exception e) { + logger.error("查询销售订单错误,失败原因:{}", e.getMessage()); + Assert.state(false, "查询销售订单错误,失败原因:{}", e.getMessage()); + } + if (saleOrderMessageDto == null) { + Assert.state(false, "根据单号:{},没有匹配到销售订单,系统业务无法完成", header.getRefOrderCode()); + } - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); - String memberId = header1.getMemberId(); - Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); - Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = saleOrderMessageDto.getData().get(0).getHeader(); + String memberId = header1.getMemberId(); + Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); + Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); - //2024年8月28日 11:01:07 查询对应的U8C销售订单 - SoSaleEntity soSaleEntity = new SoSaleEntity(); - soSaleEntity.setDr(0L); - soSaleEntity.setDataSourceCode("lets_u8c"); - soSaleEntity.setVdef19(header.getCode()); - soSaleEntity.setVdef20(header.getId()); - soSaleEntity.setBretinvflag("N");//仅查询销售订单 - List soSaleEntityList = iSoSaleDao.query(soSaleEntity); - if (soSaleEntityList == null || soSaleEntityList.size() == 0) { - Assert.state(false, "根据O出库单主键:{} 单号:{} 无法匹配到U8C销售订单(传到U8C可能失败了!bretinvflag=N)", header.getId(), header.getCode()); - } - //TODO 测试 + //2024年8月28日 11:01:07 查询对应的U8C销售订单 + SoSaleEntity soSaleEntity = new SoSaleEntity(); + soSaleEntity.setDr(0L); + soSaleEntity.setDataSourceCode("lets_u8c"); + soSaleEntity.setVdef19(header.getCode()); + soSaleEntity.setVdef20(header.getId()); + soSaleEntity.setBretinvflag("N");//仅查询销售订单 + List soSaleEntityList = iSoSaleDao.query(soSaleEntity); + if (soSaleEntityList == null || soSaleEntityList.size() == 0) { + Assert.state(false, "根据O出库单主键:{} 单号:{} 无法匹配到U8C销售订单(传到U8C可能失败了!bretinvflag=N)", header.getId(), header.getCode()); + } + //TODO 测试 // else if (soSaleEntityList.size() >= 2) { // Assert.state(false, "根据O出库单主键:{} 单号:{} 匹配到{}个U8C销售订单", header.getId(), header.getCode(), soSaleEntityList.size()); // } - //查询销售订单明细行表体 - SoSaleorderBEntity soSaleorderBEntity = new SoSaleorderBEntity(); - soSaleorderBEntity.setDr(0L); - soSaleorderBEntity.setCsaleid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - soSaleorderBEntity.setDataSourceCode("lets_u8c"); - List soSaleorderBEntityList = iSoSaleorderBDao.query(soSaleorderBEntity); - if (soSaleorderBEntityList == null || soSaleorderBEntityList.size() == 0) { - Assert.state(false, "根据O销售订单主键:{},无法匹配到U8C销售订单明细行(传到U8C可能失败了!)", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - } else if (soSaleorderBEntityList.size() >= 2) { - Assert.state(false, "根据O销售订单主键:{},无法匹配到U8C销售订单明细行(传到U8C可能失败了!)", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - } + //查询销售订单明细行表体 + SoSaleorderBEntity soSaleorderBEntity = new SoSaleorderBEntity(); + soSaleorderBEntity.setDr(0L); + soSaleorderBEntity.setCsaleid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + soSaleorderBEntity.setDataSourceCode("lets_u8c"); + List soSaleorderBEntityList = iSoSaleorderBDao.query(soSaleorderBEntity); + if (soSaleorderBEntityList == null || soSaleorderBEntityList.size() == 0) { + Assert.state(false, "根据O销售订单主键:{},无法匹配到U8C销售订单明细行(传到U8C可能失败了!)", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } else if (soSaleorderBEntityList.size() >= 2) { + Assert.state(false, "根据O销售订单主键:{},无法匹配到U8C销售订单明细行(传到U8C可能失败了!)", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } - //查询U8C销售订单对应的销售出库单表头 - IcGeneralHEntity icGeneralHEntity = new IcGeneralHEntity(); - icGeneralHEntity.setCsourcebillhid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - icGeneralHEntity.setDr(0); - icGeneralHEntity.setDataSourceCode("lets_u8c"); - List icGeneralHEntityList = iIcGeneralHDao.query(icGeneralHEntity); - if (icGeneralHEntityList == null || icGeneralHEntityList.size() == 0) { - Assert.state(false, "根据U8C销售订单表头id:{},无法查询到销售出库单", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - } else if (icGeneralHEntityList.size() >= 2) { - Assert.state(false, "根据U8C销售订单表头id:{},查询到{}个销售出库单", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid(), icGeneralHEntityList.size()); - } + //查询U8C销售订单对应的销售出库单表头 + IcGeneralHEntity icGeneralHEntity = new IcGeneralHEntity(); + icGeneralHEntity.setCsourcebillhid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + icGeneralHEntity.setDr(0); + icGeneralHEntity.setDataSourceCode("lets_u8c"); + List icGeneralHEntityList = iIcGeneralHDao.query(icGeneralHEntity); + if (icGeneralHEntityList == null || icGeneralHEntityList.size() == 0) { + Assert.state(false, "根据U8C销售订单表头id:{},无法查询到销售出库单", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } else if (icGeneralHEntityList.size() >= 2) { + Assert.state(false, "根据U8C销售订单表头id:{},查询到{}个销售出库单", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid(), icGeneralHEntityList.size()); + } - //查询U8C销售订单对应的销售出库单表体 - IcGeneralBEntity icGeneralBEntity = new IcGeneralBEntity(); - icGeneralBEntity.setCsourcebillhid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - icGeneralBEntity.setDr(0); - icGeneralBEntity.setDataSourceCode("lets_u8c"); - List icGeneralBEntityList = iIcGeneralBDao.query(icGeneralBEntity); - if (icGeneralBEntityList == null || icGeneralBEntityList.size() == 0) { - Assert.state(false, "根据U8C销售订单表头id:{},无法查询到销售出库单明细行", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - } + //查询U8C销售订单对应的销售出库单表体 + IcGeneralBEntity icGeneralBEntity = new IcGeneralBEntity(); + icGeneralBEntity.setCsourcebillhid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + icGeneralBEntity.setDr(0); + icGeneralBEntity.setDataSourceCode("lets_u8c"); + List icGeneralBEntityList = iIcGeneralBDao.query(icGeneralBEntity); + if (icGeneralBEntityList == null || icGeneralBEntityList.size() == 0) { + Assert.state(false, "根据U8C销售订单表头id:{},无法查询到销售出库单明细行", soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + } - //查询U8C销售订单执行情况明细表 - SoSaleorderBEntity soSaleorderBEntity1 = new SoSaleorderBEntity(); - soSaleorderBEntity1.setCsaleid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); - List extIntegrationTaskLivingDetailsQueryVos = iSoSaleorderBDao.queryErrorDetailsId(soSaleorderBEntity1); - if (extIntegrationTaskLivingDetailsQueryVos == null || extIntegrationTaskLivingDetailsQueryVos.size() == 0) { - Assert.state(false, "根据销售订单主键:{},无法匹配到销售订单执行情况明细"); - } + //查询U8C销售订单执行情况明细表 + SoSaleorderBEntity soSaleorderBEntity1 = new SoSaleorderBEntity(); + soSaleorderBEntity1.setCsaleid(soSaleEntityList.get(soSaleEntityList.size() - 1).getCsaleid()); + List extIntegrationTaskLivingDetailsQueryVos = iSoSaleorderBDao.queryErrorDetailsId(soSaleorderBEntity1); + if (extIntegrationTaskLivingDetailsQueryVos == null || extIntegrationTaskLivingDetailsQueryVos.size() == 0) { + Assert.state(false, "根据销售订单主键:{},无法匹配到销售订单执行情况明细"); + } - // 销售公司、发货公司 + // 销售公司、发货公司 // header.setCompanyCode("SHLZ"); - String companyCode = header.getCompanyCode(); - Assert.notNull(companyCode, "O表头公司不能为空"); - BdCorpEntity bdCorpEntity = new BdCorpEntity(); - bdCorpEntity.setDr(0); - bdCorpEntity.setDataSourceCode("lets_u8c"); - bdCorpEntity.setUnitcode(companyCode); - List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); - if (bdCorpEntityList.size() == 0) { - Assert.state(false, "根据O货主编码{},无法匹配到U8C销售公司", companyCode); - } else if (bdCorpEntityList.size() >= 2) { - Assert.state(false, "根据O货主编码{},匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size()); - } + String companyCode = header.getCompanyCode(); + Assert.notNull(companyCode, "O表头公司不能为空"); + BdCorpEntity bdCorpEntity = new BdCorpEntity(); + bdCorpEntity.setDr(0); + bdCorpEntity.setDataSourceCode("lets_u8c"); + bdCorpEntity.setUnitcode(companyCode); + List bdCorpEntityList = iBdCorpDao.query(bdCorpEntity); + if (bdCorpEntityList.size() == 0) { + Assert.state(false, "根据O货主编码{},无法匹配到U8C销售公司", companyCode); + } else if (bdCorpEntityList.size() >= 2) { + Assert.state(false, "根据O货主编码{},匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size()); + } - // 发货库存组织 - BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); - bdCalbodyEntity.setDr(0); - bdCalbodyEntity.setDataSourceCode("lets_u8c"); - bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); - if (bdCalbodyEntities.size() == 0) { - Assert.state(false, "根据U8C发货公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); - } else if (bdCalbodyEntities.size() >= 2) { - Assert.state(false, "根据U8C发货公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); - } + // 发货库存组织 + BdCalbodyEntity bdCalbodyEntity = new BdCalbodyEntity(); + bdCalbodyEntity.setDr(0); + bdCalbodyEntity.setDataSourceCode("lets_u8c"); + bdCalbodyEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdCalbodyEntities = iBdCalbodyDao.query(bdCalbodyEntity); + if (bdCalbodyEntities.size() == 0) { + Assert.state(false, "根据U8C发货公司{},无法匹配到U8C发货库存组织", bdCorpEntityList.get(0).getPkCorp()); + } else if (bdCalbodyEntities.size() >= 2) { + Assert.state(false, "根据U8C发货公司{},匹配到U8C发货库存组织{}个", bdCorpEntityList.get(0).getPkCorp(), bdCalbodyEntities.size()); + } - // 仓库 - String facilityCode = header.getFacilityCode(); - Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); - BdStordocEntity bdStordocEntity = new BdStordocEntity(); - bdStordocEntity.setDr(0L); - bdStordocEntity.setDataSourceCode("lets_u8c"); - bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); - bdStordocEntity.setStorcode(facilityCode); - List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); - if (bdStordocEntityList.size() == 0) { - Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,无法匹配到U8C仓库 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); - } else if (bdStordocEntityList.size() >= 2) { - Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,匹配到U8C仓库多个 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); - } + // 仓库 + String facilityCode = header.getFacilityCode(); + Assert.notNull(facilityCode, "O售后入库单仓库facilityCode字段不能为空"); + BdStordocEntity bdStordocEntity = new BdStordocEntity(); + bdStordocEntity.setDr(0L); + bdStordocEntity.setDataSourceCode("lets_u8c"); + bdStordocEntity.setPkCalbody(bdCalbodyEntities.get(0).getPkCalbody()); + bdStordocEntity.setStorcode(facilityCode); + List bdStordocEntityList = iBdStordocDao.query(bdStordocEntity); + if (bdStordocEntityList.size() == 0) { + Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,无法匹配到U8C仓库 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); + } else if (bdStordocEntityList.size() >= 2) { + Assert.state(false, "根据O仓库编码+U8C发货库存组织主键,匹配到U8C仓库多个 仓库编码:{} 组织机构主键:{} 公司名称:{}", facilityCode, bdCalbodyEntities.get(0).getPkCalbody(), bdCorpEntityList.get(0).getUnitname()); + } - //销售组织 - //2024年8月13日 10:35:05 已经和佳妮在微信确认,U8C销售公司编码与U8C销售组织编码保持一致,因此通过销售公司编码匹配 - BdSalestruEntity bdSalestruEntity = new BdSalestruEntity(); - bdSalestruEntity.setDr(0); - bdSalestruEntity.setDataSourceCode("lets_u8c"); - bdSalestruEntity.setVsalestrucode(bdCorpEntityList.get(0).getUnitcode()); - List bdSalestruEntityList = iBdSalestruDao.query(bdSalestruEntity); - if (bdSalestruEntityList.size() == 0) { - Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); - } else if (bdSalestruEntityList.size() >= 2) { - Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); - } + //销售组织 + //2024年8月13日 10:35:05 已经和佳妮在微信确认,U8C销售公司编码与U8C销售组织编码保持一致,因此通过销售公司编码匹配 + BdSalestruEntity bdSalestruEntity = new BdSalestruEntity(); + bdSalestruEntity.setDr(0); + bdSalestruEntity.setDataSourceCode("lets_u8c"); + bdSalestruEntity.setVsalestrucode(bdCorpEntityList.get(0).getUnitcode()); + List bdSalestruEntityList = iBdSalestruDao.query(bdSalestruEntity); + if (bdSalestruEntityList.size() == 0) { + Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); + } else if (bdSalestruEntityList.size() >= 2) { + Assert.state(false, "根据U8C销售公司编码:{},无法匹配到U8C销售组织", bdCorpEntityList.get(0).getUnitcode()); + } - //业务部门 - //2024年8月14日 10:38:37 已经和佳妮确认 - String deptName = "其他部门"; - BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); - bdDeptdocEntity.setDataSourceCode("lets_u8c"); - bdDeptdocEntity.setDr(0); - bdDeptdocEntity.setDeptname(deptName); - bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); - if (bdDeptdocEntityList.size() == 0) { - Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); - } else if (bdDeptdocEntityList.size() >= 2) { - Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); - } + //业务部门 + //2024年8月14日 10:38:37 已经和佳妮确认 + String deptName = "其他部门"; + BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity(); + bdDeptdocEntity.setDataSourceCode("lets_u8c"); + bdDeptdocEntity.setDr(0); + bdDeptdocEntity.setDeptname(deptName); + bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + List bdDeptdocEntityList = iBdDeptdocDao.query(bdDeptdocEntity); + if (bdDeptdocEntityList.size() == 0) { + Assert.state(false, "根据部门名称:{} 公司id:{},无法匹配到U8C销售组织", deptName, bdCorpEntityList.get(0).getPkCorp()); + } else if (bdDeptdocEntityList.size() >= 2) { + Assert.state(false, "根据部门名称:{} 公司id:{},匹配到U8C销售组织{}个", deptName, bdCorpEntityList.get(0).getPkCorp()); + } - //客商基本档案 - //查询OFS对应的销售订单,得到会员id + //客商基本档案 + //查询OFS对应的销售订单,得到会员id // QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); // queryOfsSoSaleOutVo.setCode(); // SaleOrderMessageDto ofsOrder = getOfsOrder(queryOfsSoSaleOutVo, 1L); // String custName = "天猫intoyou旗舰店-自营"; - BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); - bdCubasdocEntity.setDataSourceCode("lets_u8c"); - bdCubasdocEntity.setDr(0L); - bdCubasdocEntity.setDef1(memberId); - List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); - if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { - Assert.state(false, "根据OFS会员id{},无法查询到U8C客商基本档案", memberId); - } else if (bdCubasdocEntityList.size() >= 2) { - Assert.state(false, "根据OFS会员id{},查询到U8C多个客商基本档案", memberId); + BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity(); + bdCubasdocEntity.setDataSourceCode("lets_u8c"); + bdCubasdocEntity.setDr(0L); + bdCubasdocEntity.setDef1(memberId); + List bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity); + if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) { + Assert.state(false, "根据OFS会员id{},无法查询到U8C客商基本档案", memberId); + } else if (bdCubasdocEntityList.size() >= 2) { + Assert.state(false, "根据OFS会员id{},查询到U8C多个客商基本档案", memberId); + } + + //客商管理档案 + BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); + bdCumandocEntity1.setDataSourceCode("lets_u8c"); + bdCumandocEntity1.setDr(0L); + bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); + bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER); + bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); + List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); + if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { + Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); + } else if (bdCumandocEntityList.size() >= 2) { + Assert.state(false, "根据客商基本档案主键{},匹配到{}哥客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc(), bdCumandocEntityList.size()); + } + + //查找平台 + String platformZdyId = "0001A210000000000JUD"; + String sourcePlatformCode = header.getSourcePlatformCode(); + BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); + bdDefdocEntity.setPkDefdoclist(platformZdyId); + bdDefdocEntity.setDr(0); + bdDefdocEntity.setDataSourceCode("lets_u8c"); + bdDefdocEntity.setDoccode(sourcePlatformCode); + List bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity); + if (bdDefdocEntityList.size() == 0) { + Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); + } else if (bdDefdocEntityList.size() >= 2) { + Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); + } + + //查询U8C店铺档案 + String platformZdyId2 = "0001A210000000000XZX"; + String ofsStoreCode = header.getStoreCode(); + BdDefdocEntity bdDefdocEntity2 = new BdDefdocEntity(); + bdDefdocEntity2.setPkDefdoclist(platformZdyId2); + bdDefdocEntity2.setDr(0); + bdDefdocEntity2.setDataSourceCode("lets_u8c"); + bdDefdocEntity2.setDoccode(ofsStoreCode); + List bdDefdocEntityList2 = iBdDefdocDao.query(bdDefdocEntity2); + if (bdDefdocEntityList2.size() == 0) { + Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); + } else if (bdDefdocEntityList2.size() >= 2) { + Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); + } + + OrderOutTobHeaderDto orderOutTobHeaderDto = new OrderOutTobHeaderDto(); + orderOutTobHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); + orderOutTobHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); + orderOutTobHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); + orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0)); + orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0)); + orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); + orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); + orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0)); + orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0)); + orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0)); + orderOutTobHeaderDto.setSaleOrderMessageDto(saleOrderMessageDto); + orderOutTobHeaderDto.setSoSaleEntity(soSaleEntityList.get(soSaleEntityList.size() - 1)); + orderOutTobHeaderDto.setIcGeneralHEntity(icGeneralHEntityList.get(0)); + orderOutTobHeaderDto.setIcGeneralBEntityList(icGeneralBEntityList); + orderOutTobHeaderDto.setSoSaleorderBEntityList(soSaleorderBEntityList); + orderOutTobHeaderDto.setExtIntegrationTaskLivingDetailsQueryVos(extIntegrationTaskLivingDetailsQueryVos); + + orderOutTobHeaderDto.setHeader(header); + orderOutTobHeaderDto.setDetails(details); + + 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); } - - //客商管理档案 - BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity(); - bdCumandocEntity1.setDataSourceCode("lets_u8c"); - bdCumandocEntity1.setDr(0L); - bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp()); - bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER); - bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc()); - List bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1); - if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) { - Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc()); - } else if (bdCumandocEntityList.size() >= 2) { - Assert.state(false, "根据客商基本档案主键{},匹配到{}哥客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc(), bdCumandocEntityList.size()); - } - - //查找平台 - String platformZdyId = "0001A210000000000JUD"; - String sourcePlatformCode = header.getSourcePlatformCode(); - BdDefdocEntity bdDefdocEntity = new BdDefdocEntity(); - bdDefdocEntity.setPkDefdoclist(platformZdyId); - bdDefdocEntity.setDr(0); - bdDefdocEntity.setDataSourceCode("lets_u8c"); - bdDefdocEntity.setDoccode(sourcePlatformCode); - List bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity); - if (bdDefdocEntityList.size() == 0) { - Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); - } else if (bdDefdocEntityList.size() >= 2) { - Assert.state(false, "根据O平台编码{},无法匹配到U8C平台自定义档案 自定义档案主键:{}", sourcePlatformCode, platformZdyId); - } - - //查询U8C店铺档案 - String platformZdyId2 = "0001A210000000000XZX"; - String ofsStoreCode = header.getStoreCode(); - BdDefdocEntity bdDefdocEntity2 = new BdDefdocEntity(); - bdDefdocEntity2.setPkDefdoclist(platformZdyId2); - bdDefdocEntity2.setDr(0); - bdDefdocEntity2.setDataSourceCode("lets_u8c"); - bdDefdocEntity2.setDoccode(ofsStoreCode); - List bdDefdocEntityList2 = iBdDefdocDao.query(bdDefdocEntity2); - if (bdDefdocEntityList2.size() == 0) { - Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); - } else if (bdDefdocEntityList2.size() >= 2) { - Assert.state(false, "根据O店铺编码{},无法匹配到U8C店铺自定义档案 自定义档案主键:{}", ofsStoreCode, platformZdyId); - } - - OrderOutTobHeaderDto orderOutTobHeaderDto = new OrderOutTobHeaderDto(); - orderOutTobHeaderDto.setBdCorpEntity(bdCorpEntityList.get(0)); - orderOutTobHeaderDto.setBdCalbodyEntity(bdCalbodyEntities.get(0)); - orderOutTobHeaderDto.setBdStordocEntity(bdStordocEntityList.get(0)); - orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0)); - orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0)); - orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0)); - orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0)); - orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0)); - orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0)); - orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0)); - orderOutTobHeaderDto.setSaleOrderMessageDto(saleOrderMessageDto); - orderOutTobHeaderDto.setSoSaleEntity(soSaleEntityList.get(soSaleEntityList.size() - 1)); - orderOutTobHeaderDto.setIcGeneralHEntity(icGeneralHEntityList.get(0)); - orderOutTobHeaderDto.setIcGeneralBEntityList(icGeneralBEntityList); - orderOutTobHeaderDto.setSoSaleorderBEntityList(soSaleorderBEntityList); - orderOutTobHeaderDto.setExtIntegrationTaskLivingDetailsQueryVos(extIntegrationTaskLivingDetailsQueryVos); - - orderOutTobHeaderDto.setHeader(header); - orderOutTobHeaderDto.setDetails(details); - - BeanUtil.copyPropertiesV2(header, orderOutTobHeaderDto); - orderOutTobHeaderDtoArrayList.add(orderOutTobHeaderDto); } - //成功,记录到日志表 } 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 details = orderOutTobHeaderDto.getDetails(); + OrderOutTobHeaderDto orderOutTobHeaderDto = orderOutTobHeaderDtos.get(i); + HeaderDto header = orderOutTobHeaderDto.getHeader(); + List 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 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 stringArrayList = new ArrayList<>(); + List dateRange = getDateRange(startDate, endDate); + if (dateRange != null && dateRange.size() > 0) { + for (int i = 0; i < dateRange.size(); i++) { + String dateStr = dateRange.get(i); + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(dateStr); + stringBuffer.append(" 00:00:00"); + stringBuffer.append(","); + stringBuffer.append(dateStr); + stringBuffer.append(" 23:59:59"); + stringArrayList.add(stringBuffer.toString()); + } + } + String collectDateStr = stringArrayList.stream().collect(Collectors.joining("*")); + logger.info("类型:time_frame 生成的日期范围:" + collectDateStr); + return collectDateStr; + } + return null; + } + + /** + * 计算日期范围 + * + * @author liuyang + */ + private List getDateRange(LocalDate startDate, LocalDate endDate) { + List dateRange = new ArrayList<>(); + LocalDate currentDate = startDate; + while (!currentDate.isAfter(endDate)) { + dateRange.add(currentDate.format(DateTimeFormatter.ISO_DATE)); + currentDate = currentDate.plusDays(1); + } + return dateRange; + } + + /** + * 分割日期之后,再进行推送 + * + * @param 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 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 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); +// for (int i = 0; i < splitListByCount.size(); i++) { +// List 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 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 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + for (int i = 0; i < splitListByCount.size(); i++) { + List 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 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 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + for (int i = 0; i < splitListByCount.size(); i++) { + List 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 errorHeaderDetailsDtoDtoList) { + Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!"); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) { + List tocofsSaleoutDetailedEntityList = new ArrayList<>(); + for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) { + ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = errorHeaderDetailsDtoDtoList.get(i); + HeaderDto header = errorHeaderDetailsDtoDto.getHeader(); + List 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + for (int i = 0; i < splitListByCount.size(); i++) { + List 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 errorHeaderDetailsDtoDtoList) { + Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!"); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) { + List tocofsSaleoutDetailedEntityList = new ArrayList<>(); + for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) { + ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = errorHeaderDetailsDtoDtoList.get(i); + HeaderDto header = errorHeaderDetailsDtoDto.getHeader(); + List 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + for (int i = 0; i < splitListByCount.size(); i++) { + List 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); + } + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java index af49c5f8..1ac7820f 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java @@ -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 headerDetailsDtos = queryOfsOrder(headerDetailsDtoList); + findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList); for (int i = 0; i < headerDetailsDtoList.size(); i++) { HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i); HeaderDto header = headerDetailsDto.getHeader(); List 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 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 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 queryOfsOrder(List headerDetailsDtoList) throws Exception { + List allHeaderDetailsDtoArrayList = new ArrayList<>(); + try { + if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { + List> splitListByCount = SplitListByCountUtil.splitListByCount(headerDetailsDtoList, 100); + for (int i = 0; i < splitListByCount.size(); i++) { + List headerDetailsDtos = splitListByCount.get(i); + + StringBuffer stringBuffer = new StringBuffer(); + if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { + for (int j = 0; j < headerDetailsDtos.size(); j++) { + HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j); + HeaderDto header = headerDetailsDto.getHeader(); +// List details = headerDetailsDto.getDetails(); +// stringBuffer.append("'"); + stringBuffer.append(header.getRefOrderCode()); +// stringBuffer.append("'"); + stringBuffer.append(","); + } + } + String substring = stringBuffer.substring(0, stringBuffer.length()); + + List headerDetailsDtoArrayList = new ArrayList<>(); + QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo(); + queryOfsSoSaleOutVo.setCode(substring); + ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L); + allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList); + } + } + } catch (Exception e) { + logger.error("queryOfsOrder方法抛出异常", e); + } + return allHeaderDetailsDtoArrayList; + } + + /** + * 代码匹配销售订单 + * + * @param ofsSaleOrder ofs销售订单集合 + * @param ofsSaleOutOrder ofs销售出库单集合 + * @author liuyang + */ + private void findMatchingOfsOrder(List ofsSaleOrder, List 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 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 details1 = headerDetailsDto1.getDetails(); + if (header1.getCode().equals(targetRefOrderCode)) { + header.setHeaderDetailsDto(headerDetailsDto1); + } + } + } + } catch (Exception e) { + logger.error("findMatchingOfsOrder方法抛出异常", e); + } + } + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java index f2981a07..f6e935fc 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToB.java @@ -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 stringArrayList = new ArrayList<>(); + List dateRange = getDateRange(startDate, endDate); + if (dateRange != null && dateRange.size() > 0) { + for (int i = 0; i < dateRange.size(); i++) { + String dateStr = dateRange.get(i); + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(dateStr); + stringBuffer.append(" 00:00:00"); + stringBuffer.append(","); + stringBuffer.append(dateStr); + stringBuffer.append(" 23:59:59"); + stringArrayList.add(stringBuffer.toString()); + } + } + String collectDateStr = stringArrayList.stream().collect(Collectors.joining("*")); + logger.info("类型:time_frame 生成的日期范围:" + collectDateStr); + return collectDateStr; + } + return null; + } + + /** + * 计算日期范围 + * + * @author liuyang + */ + private List getDateRange(LocalDate startDate, LocalDate endDate) { + List dateRange = new ArrayList<>(); + LocalDate currentDate = startDate; + while (!currentDate.isAfter(endDate)) { + dateRange.add(currentDate.format(DateTimeFormatter.ISO_DATE)); + currentDate = currentDate.plusDays(1); + } + return dateRange; + } + + /** + * 分割日期之后,再进行推送 + * + * @param 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); + } + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDto.java index 6ec2b7f0..560b112f 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/ErrorHeaderDetailsDtoDto.java @@ -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; } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java index 17289f5e..323ad8ec 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java @@ -73,4 +73,7 @@ public class SonDetailsDto extends DetailsDto { //存货税率 private BdTaxitemsEntity bdTaxitemsEntity; + + //对应的OFS销售订单 + private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java index d6cdad27..76e248e9 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsStandardUtil.java @@ -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 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 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)); + } + } +} \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java index 1b319e21..50d1601d 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java @@ -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); } } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsStandardUtilTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsStandardUtilTest.java index fa7f67b5..74c194b6 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsStandardUtilTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsStandardUtilTest.java @@ -49,4 +49,22 @@ public class OfsStandardUtilTest { e.printStackTrace(); } } + + /** + * 测试销售订单 + */ + @Test + public void getOfsOrder() { + try { + List 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(); + } + } } \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java index cc4379de..82ddd9bc 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/DetailsDto.java @@ -49,4 +49,8 @@ public class DetailsDto { * 额外参数:(销售)交易成功(蓝)是否成功 */ private String newState3; + /** + * (销售)交易成功(TOB发票)是否成功 + */ + private String newState4; } \ No newline at end of file diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java index 80800a22..ec203bb0 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssaleorderoutsearch/HeaderDto.java @@ -73,4 +73,7 @@ public class HeaderDto { //出库类型 private String shipmentType; + + //OFS销售订单 + private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; } \ No newline at end of file