提交保存mysql低表代码

This commit is contained in:
liuy 2024-08-02 18:16:30 +08:00
parent 0be04bb37f
commit 4464c67e83
10 changed files with 201 additions and 52 deletions

View File

@ -1,7 +1,9 @@
package com.hzya.frame.plugin.lets.ofs.dao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.basedao.dao.IBaseDao;
import java.util.List;
/**
* root(tocofs_saleout: table)表数据库访问层
@ -10,6 +12,10 @@ import com.hzya.frame.basedao.dao.IBaseDao;
* @since 2024-08-01 17:01:32
*/
public interface ITocofsSaleoutDao extends IBaseDao<TocofsSaleoutEntity, String> {
}
/**
* 批量插入主表信息
*
* @author liuyang
*/
void entityInsertBatchV2(List<TocofsSaleoutEntity> tocofsSaleoutEntityList) throws Exception;
}

View File

@ -1,7 +1,9 @@
package com.hzya.frame.plugin.lets.ofs.dao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.basedao.dao.IBaseDao;
import java.util.List;
/**
* tocofs_saleout_detailed(tocofs_saleout_detailed: table)表数据库访问层
@ -11,5 +13,11 @@ import com.hzya.frame.basedao.dao.IBaseDao;
*/
public interface ITocofsSaleoutDetailedDao extends IBaseDao<TocofsSaleoutDetailedEntity, String> {
/**
* 批量查询明细信息
*
* @author liuyang
*/
void entityInsertBatchV2(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntity) throws Exception;
}

View File

@ -4,13 +4,18 @@ import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDao;
import org.springframework.stereotype.Repository;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import java.util.List;
/**
* root(TocofsSaleout)表数据库访问层
*
* @author makejava
* @since 2024-08-01 17:01:32
*/
public class TocofsSaleoutDaoImpl extends MybatisGenericDao<TocofsSaleoutEntity, String> implements ITocofsSaleoutDao{
}
public class TocofsSaleoutDaoImpl extends MybatisGenericDao<TocofsSaleoutEntity, String> implements ITocofsSaleoutDao {
@Override
public void entityInsertBatchV2(List<TocofsSaleoutEntity> tocofsSaleoutEntityList) throws Exception {
this.insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDaoImpl.entityInsertBatchV2", tocofsSaleoutEntityList);
}
}

View File

@ -4,13 +4,18 @@ import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
import org.springframework.stereotype.Repository;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import java.util.List;
/**
* tocofs_saleout_detailed(TocofsSaleoutDetailed)表数据库访问层
*
* @author makejava
* @since 2024-08-01 17:01:53
*/
public class TocofsSaleoutDetailedDaoImpl extends MybatisGenericDao<TocofsSaleoutDetailedEntity, String> implements ITocofsSaleoutDetailedDao{
}
public class TocofsSaleoutDetailedDaoImpl extends MybatisGenericDao<TocofsSaleoutDetailedEntity, String> implements ITocofsSaleoutDetailedDao {
@Override
public void entityInsertBatchV2(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntity) throws Exception {
this.insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertBatchV2", tocofsSaleoutDetailedEntity);
}
}

View File

@ -12,7 +12,7 @@ public class TocofsSaleoutDetailedEntity extends BaseEntity {
/**
* rootId
*/
private Long rootid;
// private Long rootid;
/**
* LETS
*/
@ -126,14 +126,13 @@ public class TocofsSaleoutDetailedEntity extends BaseEntity {
*/
private String lastupdatedby;
public Long getRootid() {
return rootid;
}
public void setRootid(Long rootid) {
this.rootid = rootid;
}
// public Long getRootid() {
// return rootid;
// }
//
// public void setRootid(Long rootid) {
// this.rootid = rootid;
// }
public String getClientcode() {
return clientcode;

View File

@ -3,7 +3,7 @@
<mapper namespace="com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl">
<resultMap id="get-TocofsSaleoutDetailedEntity-result" type="com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity" >
<result property="rootid" column="rootId" jdbcType="INTEGER"/>
<!-- <result property="rootid" column="rootId" jdbcType="INTEGER"/>-->
<result property="clientcode" column="clientCode" jdbcType="VARCHAR"/>
<result property="companycode" column="companyCode" jdbcType="VARCHAR"/>
<result property="facilitycode" column="facilityCode" jdbcType="VARCHAR"/>
@ -35,8 +35,7 @@
</resultMap>
<!-- 查询的字段-->
<sql id = "TocofsSaleoutDetailedEntity_Base_Column_List">
rootId
,clientCode
clientCode
,companyCode
,facilityCode
,shipmentCode
@ -71,7 +70,7 @@
<include refid="TocofsSaleoutDetailedEntity_Base_Column_List" />
from tocofs_saleout_detailed
<trim prefix="where" prefixOverrides="and">
<if test="rootid != null"> and rootId = #{rootid} </if>
-- <if test="rootid != null"> and rootId = #{rootid} </if>
<if test="clientcode != null and clientcode != ''"> and clientCode = #{clientcode} </if>
<if test="companycode != null and companycode != ''"> and companyCode = #{companycode} </if>
<if test="facilitycode != null and facilitycode != ''"> and facilityCode = #{facilitycode} </if>
@ -110,7 +109,7 @@
<select id="entity_count" resultType="Integer" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity">
select count(1) from tocofs_saleout_detailed
<trim prefix="where" prefixOverrides="and">
<if test="rootid != null"> and rootId = #{rootid} </if>
-- <if test="rootid != null"> and rootId = #{rootid} </if>
<if test="clientcode != null and clientcode != ''"> and clientCode = #{clientcode} </if>
<if test="companycode != null and companycode != ''"> and companyCode = #{companycode} </if>
<if test="facilitycode != null and facilitycode != ''"> and facilityCode = #{facilitycode} </if>
@ -151,7 +150,7 @@
<include refid="TocofsSaleoutDetailedEntity_Base_Column_List" />
from tocofs_saleout_detailed
<trim prefix="where" prefixOverrides="and">
<if test="rootid != null"> and rootId like concat('%',#{rootid},'%') </if>
-- <if test="rootid != null"> and rootId like concat('%',#{rootid},'%') </if>
<if test="clientcode != null and clientcode != ''"> and clientCode like concat('%',#{clientcode},'%') </if>
<if test="companycode != null and companycode != ''"> and companyCode like concat('%',#{companycode},'%') </if>
<if test="facilitycode != null and facilitycode != ''"> and facilityCode like concat('%',#{facilitycode},'%') </if>
@ -192,7 +191,7 @@
<include refid="TocofsSaleoutDetailedEntity_Base_Column_List" />
from tocofs_saleout_detailed
<trim prefix="where" prefixOverrides="and">
<if test="rootid != null"> or rootId = #{rootid} </if>
-- <if test="rootid != null"> or rootId = #{rootid} </if>
<if test="clientcode != null and clientcode != ''"> or clientCode = #{clientcode} </if>
<if test="companycode != null and companycode != ''"> or companyCode = #{companycode} </if>
<if test="facilitycode != null and facilitycode != ''"> or facilityCode = #{facilitycode} </if>
@ -231,7 +230,7 @@
<insert id="entity_insert" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity" keyProperty="rootid" useGeneratedKeys="true">
insert into tocofs_saleout_detailed(
<trim suffix="" suffixOverrides=",">
<if test="rootid != null"> rootId , </if>
-- <if test="rootid != null"> rootId , </if>
<if test="clientcode != null and clientcode != ''"> clientCode , </if>
<if test="companycode != null and companycode != ''"> companyCode , </if>
<if test="facilitycode != null and facilitycode != ''"> facilityCode , </if>
@ -265,7 +264,7 @@
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="rootid != null"> #{rootid} ,</if>
-- <if test="rootid != null"> #{rootid} ,</if>
<if test="clientcode != null and clientcode != ''"> #{clientcode} ,</if>
<if test="companycode != null and companycode != ''"> #{companycode} ,</if>
<if test="facilitycode != null and facilitycode != ''"> #{facilitycode} ,</if>
@ -307,6 +306,16 @@
(#{entity.clientcode},#{entity.companycode},#{entity.facilitycode},#{entity.shipmentcode},#{entity.reforderid},#{entity.reforderdetailid},#{entity.refordercode},#{entity.allocinvid},#{entity.skucode},#{entity.skuname},#{entity.sourceordercode},#{entity.inventorysts},#{entity.isgift},#{entity.requestqty},#{entity.shipqty},#{entity.quantityum},#{entity.listprice},#{entity.itemtotalamount},#{entity.totalpayamount},#{entity.totalweight},#{entity.totalvolume},#{entity.totalvolumeweight},#{entity.weightum},#{entity.volumeum},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby}, 'Y')
</foreach>
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatchV2" keyProperty="refOrderDetailId" useGeneratedKeys="true">
insert IGNORE into tocofs_saleout_detailed(clientCode, companyCode, facilityCode, shipmentCode, refOrderId, refOrderDetailId, refOrderCode, allocInvId, skuCode, skuName, sourceOrderCode, inventorySts, isGift, requestQty, shipQty, quantityUM, listPrice, itemTotalAmount, totalPayAmount, totalWeight, totalVolume, totalVolumeWeight, weightUM, volumeUM, created, createdBy, lastUpdated, lastUpdatedBy)
values
<foreach collection="list" item="entity" separator=",">
(#{entity.clientcode},#{entity.companycode},#{entity.facilitycode},#{entity.shipmentcode},#{entity.reforderid},#{entity.reforderdetailid},#{entity.refordercode},#{entity.allocinvid},#{entity.skucode},#{entity.skuname},#{entity.sourceordercode},#{entity.inventorysts},#{entity.isgift},#{entity.requestqty},#{entity.shipqty},#{entity.quantityum},#{entity.listprice},#{entity.itemtotalamount},#{entity.totalpayamount},#{entity.totalweight},#{entity.totalvolume},#{entity.totalvolumeweight},#{entity.weightum},#{entity.volumeum},#{entity.created},#{entity.createdby},#{entity.lastupdated},#{entity.lastupdatedby})
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="rootid" useGeneratedKeys="true">
insert into tocofs_saleout_detailed(clientCode, companyCode, facilityCode, shipmentCode, refOrderId, refOrderDetailId, refOrderCode, allocInvId, skuCode, skuName, sourceOrderCode, inventorySts, isGift, requestQty, shipQty, quantityUM, listPrice, itemTotalAmount, totalPayAmount, totalWeight, totalVolume, totalVolumeWeight, weightUM, volumeUM, created, createdBy, lastUpdated, lastUpdatedBy)

View File

@ -64,6 +64,7 @@
<result property="shiptocityname" column="shipToCityName" jdbcType="VARCHAR"/>
<result property="shiptodistrictname" column="shipToDistrictName" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "TocofsSaleoutEntity_Base_Column_List">
id
@ -127,6 +128,7 @@
,shipToCityName
,shipToDistrictName
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-TocofsSaleoutEntity-result" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity">
select
@ -547,6 +549,7 @@
</trim>
)
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_saleout(clientCode, companyCode, storeCode, facilityCode, code, refOrderId, refOrderCode, refOrderType, status, consolidated, internalInstructionType, bizChannel, sourcePlatformCode, processType, sourceOrderId, sourceOrderCode, sourceUserAccount, shipToAttentionTo, shipToAddress, shipToCountry, shipToState, shipToCity, shipToDistrict, shipToMobile, totalLines, totalQty, totalContainers, totalCases, totalWeight, totalVolume, totalVolumeWeight, weightUM, volumeUM, totalAmount, totalPayAmount, postageAmount, itemTotalAmount, carrierCode, paymentStatus, codRequired, invoiceRequired, paidAt, shipFromAttentionTo, shipFromAddress, shipFromDistrict, shipFromCity, shipFromState, shipFromCountry, shipFromPostalCode, shipFromPhone, shipFromMobile, shipFromFax, shipFromEmail, codAmount, tax, taxPaid, shipToStateName, shipToCityName, shipToDistrictName, sts)
@ -555,6 +558,16 @@
(#{entity.clientcode},#{entity.companycode},#{entity.storecode},#{entity.facilitycode},#{entity.code},#{entity.reforderid},#{entity.refordercode},#{entity.refordertype},#{entity.status},#{entity.consolidated},#{entity.internalinstructiontype},#{entity.bizchannel},#{entity.sourceplatformcode},#{entity.processtype},#{entity.sourceorderid},#{entity.sourceordercode},#{entity.sourceuseraccount},#{entity.shiptoattentionto},#{entity.shiptoaddress},#{entity.shiptocountry},#{entity.shiptostate},#{entity.shiptocity},#{entity.shiptodistrict},#{entity.shiptomobile},#{entity.totallines},#{entity.totalqty},#{entity.totalcontainers},#{entity.totalcases},#{entity.totalweight},#{entity.totalvolume},#{entity.totalvolumeweight},#{entity.weightum},#{entity.volumeum},#{entity.totalamount},#{entity.totalpayamount},#{entity.postageamount},#{entity.itemtotalamount},#{entity.carriercode},#{entity.paymentstatus},#{entity.codrequired},#{entity.invoicerequired},#{entity.paidat},#{entity.shipfromattentionto},#{entity.shipfromaddress},#{entity.shipfromdistrict},#{entity.shipfromcity},#{entity.shipfromstate},#{entity.shipfromcountry},#{entity.shipfrompostalcode},#{entity.shipfromphone},#{entity.shipfrommobile},#{entity.shipfromfax},#{entity.shipfromemail},#{entity.codamount},#{entity.tax},#{entity.taxpaid},#{entity.shiptostatename},#{entity.shiptocityname},#{entity.shiptodistrictname}, 'Y')
</foreach>
</insert>
<!-- 批量新增v2 -->
<insert id="entityInsertBatchV2" keyProperty="id" useGeneratedKeys="true">
insert IGNORE into tocofs_saleout(id,clientCode, companyCode, storeCode, facilityCode, code, refOrderId, refOrderCode, refOrderType, status, consolidated, internalInstructionType, bizChannel, sourcePlatformCode, processType, sourceOrderId, sourceOrderCode, sourceUserAccount, shipToAttentionTo, shipToAddress, shipToCountry, shipToState, shipToCity, shipToDistrict, shipToMobile, totalLines, totalQty, totalContainers, totalCases, totalWeight, totalVolume, totalVolumeWeight, weightUM, volumeUM, totalAmount, totalPayAmount, postageAmount, itemTotalAmount, carrierCode, paymentStatus, codRequired, invoiceRequired, paidAt, shipFromAttentionTo, shipFromAddress, shipFromDistrict, shipFromCity, shipFromState, shipFromCountry, shipFromPostalCode, shipFromPhone, shipFromMobile, shipFromFax, shipFromEmail, codAmount, tax, taxPaid, shipToStateName, shipToCityName, shipToDistrictName)
values
<foreach collection="list" item="entity" separator=",">
(#{entity.id},#{entity.clientcode},#{entity.companycode},#{entity.storecode},#{entity.facilitycode},#{entity.code},#{entity.reforderid},#{entity.refordercode},#{entity.refordertype},#{entity.status},#{entity.consolidated},#{entity.internalinstructiontype},#{entity.bizchannel},#{entity.sourceplatformcode},#{entity.processtype},#{entity.sourceorderid},#{entity.sourceordercode},#{entity.sourceuseraccount},#{entity.shiptoattentionto},#{entity.shiptoaddress},#{entity.shiptocountry},#{entity.shiptostate},#{entity.shiptocity},#{entity.shiptodistrict},#{entity.shiptomobile},#{entity.totallines},#{entity.totalqty},#{entity.totalcontainers},#{entity.totalcases},#{entity.totalweight},#{entity.totalvolume},#{entity.totalvolumeweight},#{entity.weightum},#{entity.volumeum},#{entity.totalamount},#{entity.totalpayamount},#{entity.postageamount},#{entity.itemtotalamount},#{entity.carriercode},#{entity.paymentstatus},#{entity.codrequired},#{entity.invoicerequired},#{entity.paidat},#{entity.shipfromattentionto},#{entity.shipfromaddress},#{entity.shipfromdistrict},#{entity.shipfromcity},#{entity.shipfromstate},#{entity.shipfromcountry},#{entity.shipfrompostalcode},#{entity.shipfromphone},#{entity.shipfrommobile},#{entity.shipfromfax},#{entity.shipfromemail},#{entity.codamount},#{entity.tax},#{entity.taxpaid},#{entity.shiptostatename},#{entity.shiptocityname},#{entity.shiptodistrictname})
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_saleout(clientCode, companyCode, storeCode, facilityCode, code, refOrderId, refOrderCode, refOrderType, status, consolidated, internalInstructionType, bizChannel, sourcePlatformCode, processType, sourceOrderId, sourceOrderCode, sourceUserAccount, shipToAttentionTo, shipToAddress, shipToCountry, shipToState, shipToCity, shipToDistrict, shipToMobile, totalLines, totalQty, totalContainers, totalCases, totalWeight, totalVolume, totalVolumeWeight, weightUM, volumeUM, totalAmount, totalPayAmount, postageAmount, itemTotalAmount, carrierCode, paymentStatus, codRequired, invoiceRequired, paidAt, shipFromAttentionTo, shipFromAddress, shipFromDistrict, shipFromCity, shipFromState, shipFromCountry, shipFromPostalCode, shipFromPhone, shipFromMobile, shipFromFax, shipFromEmail, codAmount, tax, taxPaid, shipToStateName, shipToCityName, shipToDistrictName)
@ -622,6 +635,7 @@
shipToStateName = values(shipToStateName),
shipToCityName = values(shipToCityName),
shipToDistrictName = values(shipToDistrictName)</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity" >
update tocofs_saleout set
@ -688,16 +702,18 @@ update tocofs_saleout set
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity" >
update tocofs_saleout set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
where id = #{id}
</update>
<!-- 多条件逻辑删除 -->
<update id="entity_logicDelete_Multi_Condition" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity" >
update tocofs_saleout set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
<trim prefix="where" prefixOverrides="and">
<if test="id != null"> and id = #{id} </if>
<trim prefix="where" prefixOverrides="and">
<if test="id != null"> and id = #{id} </if>
<if test="clientcode != null and clientcode != ''"> and clientCode = #{clientcode} </if>
<if test="companycode != null and companycode != ''"> and companyCode = #{companycode} </if>
<if test="storecode != null and storecode != ''"> and storeCode = #{storecode} </if>
@ -760,6 +776,7 @@ update tocofs_saleout set sts= 'N' ,modify_time = #{modify_time},modify_user_id
and sts='Y'
</trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
delete from tocofs_saleout where id = #{id}

View File

@ -2,11 +2,14 @@ package com.hzya.frame.plugin.lets.ofs.service;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity;
import com.hzya.frame.basedao.service.IBaseService;
/**
* root(TocofsSaleout)表服务接口
*
* @author makejava
* @since 2024-08-01 17:01:32
*/
public interface ITocofsSaleoutService extends IBaseService<TocofsSaleoutEntity, String>{
public interface ITocofsSaleoutService extends IBaseService<TocofsSaleoutEntity, String> {
}

View File

@ -6,12 +6,19 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.beanutil.BeanUtil;
import com.hzya.frame.plugin.lets.entity.*;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDao;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity;
import com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutEntity;
import com.hzya.frame.plugin.lets.ofs.service.ITocofsSaleoutService;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo;
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleVo;
import com.hzya.frame.plugin.lets.resultvo.CalculateDateVo;
import com.hzya.frame.plugin.lets.util.BasicArchivesCacheUtil;
import com.hzya.frame.plugin.lets.util.DateStrUtil;
import com.hzya.frame.split.SplitListByCountUtil;
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.SaleOutReturnMessageDto;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto;
@ -22,6 +29,7 @@ import com.hzya.frame.ttxofs.service.OfsUnifiedService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@ -80,6 +88,15 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
@Autowired
private BasicArchivesCacheUtil basicArchivesCacheUtil;
@Autowired
private ITocofsSaleoutService iTocofsSaleoutService;
@Autowired
private ITocofsSaleoutDao iTocofsSaleoutDao;
@Autowired
private ITocofsSaleoutDetailedDao iTocofsSaleoutDetailedDao;
/**
* 按指定时间拉取
*
@ -97,18 +114,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
// TODO 注意过滤TOC店铺
CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr);
List<HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
QueryOfsSoSaleVo queryOfsSoSaleOutVo = new QueryOfsSoSaleVo();
queryOfsSoSaleOutVo.setCreated_start(calculateDateVo.getStart_time());
queryOfsSoSaleOutVo.setCreated_end(calculateDateVo.getEnd_time());
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
queryOfsSoSaleOutVo.setCreated_start("2024-03-27 12:03:30");
queryOfsSoSaleOutVo.setCreated_end("2024-03-27 12:04:00");
queryOfsSoSaleOutVo.setClientCode("LETS");
queryOfsSoSaleOutVo.setCompanyCode("SHLZ");
queryOfsSoSaleOutVo.setStatus(900L);
// queryOfsSoSaleOutVo.setInternalInstructionType("SALES");
queryOfsSoSaleOutVo.setCompanyCode("LETS");
// queryOfsSoSaleOutVo.setStatus(900L);
queryOfsSoSaleOutVo.setPageNo(1L);
queryOfsSoSaleOutVo.setPageSize(50L);
queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L);
logger.info("数据返回行数:{}", headerDetailsDtoList.size());
if (headerDetailsDtoList.size() > 0) {
//保存到mysql
batchInsert(headerDetailsDtoList);
//过滤成功的数据
//执行推送主逻辑
} else {
logger.info("没有查询到任何数据!不需要同步");
}
@ -123,11 +145,50 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
try {
thread.join();
} catch (Exception e) {
e.printStackTrace();
logger.error("thread.join()异常", e);
}
}
/**
* 保存抓取到的数据到mysql底表
*
* @param headerDetailsDtoList 数据行
*/
private void batchInsert(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList) throws Exception {
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto> headerDetailsDtoList1 = new ArrayList<>();
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto> headerDetailsDtoList2 = new ArrayList<>();
for (com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto index : headerDetailsDtoList) {
com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto header = index.getHeader();// 主表
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto> details = index.getDetails();//明细表
headerDetailsDtoList1.add(header);
headerDetailsDtoList2.addAll(details);
}
//每250作为一个批次插入主表根据主键id判断是否重复如果重复的则不进行插入
List<List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto>> ofssaleorderoutsearchList = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 250);
for (int i = 0; i < ofssaleorderoutsearchList.size(); i++) {
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto> headerDtoList = ofssaleorderoutsearchList.get(i);
List<TocofsSaleoutEntity> tocofsSaleoutEntityList = copyHeaderDto(headerDtoList);
if (tocofsSaleoutEntityList.size() > 0) {
iTocofsSaleoutDao.entityInsertBatchV2(tocofsSaleoutEntityList);
}
}
//插入明细表
List<List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto>> detailsDtoList = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 250);
for (int i = 0; i < detailsDtoList.size(); i++) {
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto> detailsDtos = detailsDtoList.get(i);
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities = copyDetailsDto(detailsDtos);
if (tocofsSaleoutDetailedEntities.size() > 0) {
iTocofsSaleoutDetailedDao.entityInsertBatchV2(tocofsSaleoutDetailedEntities);
}
}
}
}
/**
* 查询OFS结果集
*
@ -135,19 +196,19 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
* @param headerDetailsDtoList 查询结果集
* @param pageNo 从第pageNo页开始查询
*/
private void queryOfsSaleOrder(QueryOfsSoSaleVo queryOfsSoSaleOutVo, List<HeaderDetailsDto> headerDetailsDtoList, Long pageNo) throws Exception {
private void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList, Long pageNo) throws Exception {
Long pageSize = 200L;
queryOfsSoSaleOutVo.setPageNo(pageNo);
queryOfsSoSaleOutVo.setPageSize(pageSize);
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
interfaceParamDto.setApi("ofs.salesOrder.search");
interfaceParamDto.setApi("ofs.shipment.search");
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
SaleReturnMessageDto returnMessageBasics = (SaleReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
if (returnMessageBasics != null) {
if ("false".equals(returnMessageBasics.getError()) && "0".equals(returnMessageBasics.getCode()) && "Success".equals(returnMessageBasics.getMsg())) {
List<HeaderDetailsDto> headerDetailsDtoList1 = returnMessageBasics.getData();
SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
if (saleOutReturnMessageDto != null) {
if ("false".equals(saleOutReturnMessageDto.getError()) && "0".equals(saleOutReturnMessageDto.getCode()) && "Success".equals(saleOutReturnMessageDto.getMsg())) {
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtoList1 = saleOutReturnMessageDto.getData();
if (headerDetailsDtoList1 != null && headerDetailsDtoList1.size() > 0) {
headerDetailsDtoList.addAll(headerDetailsDtoList1);
@ -155,7 +216,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
}
} else {
//2024年7月30日 13:47:04 查询失败
logger.error("查询失败,失败原因:{}", JSON.toJSON(returnMessageBasics));
logger.error("查询失败,失败原因:{}", JSON.toJSON(saleOutReturnMessageDto));
}
} else {
logger.error("returnMessageBasics为空queryOfsSoSaleOutVo对象结果{}", JSON.toJSON(queryOfsSoSaleOutVo));
@ -271,4 +332,40 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
logger.info("queryBasicArchives方法headerDetailsDtoList.size为0");
}
}
/**
* bean copy
* 2024年7月31日 10:34:09
*/
private List<TocofsSaleoutEntity> copyHeaderDto(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto> headerDtoList) {
List<TocofsSaleoutEntity> tocofsSaleoutEntityList = new ArrayList<>();
if (headerDtoList != null && headerDtoList.size() > 0) {
for (int i = 0; i < headerDtoList.size(); i++) {
com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto headerDto = headerDtoList.get(i);
TocofsSaleoutEntity tocofsSaleoutEntity = new TocofsSaleoutEntity();
// BeanUtils.copyProperties(headerDto, tocofsSaleoutEntity);
BeanUtil.copyPropertiesV2(headerDto, tocofsSaleoutEntity);
tocofsSaleoutEntityList.add(tocofsSaleoutEntity);
}
}
return tocofsSaleoutEntityList;
}
/**
* bean copy
* 2024年8月2日 16:04:11
*/
private List<TocofsSaleoutDetailedEntity> copyDetailsDto(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto> detailsDtos) {
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityArrayList = new ArrayList<>();
if (detailsDtos != null && detailsDtos.size() > 0) {
for (int i = 0; i < detailsDtos.size(); i++) {
com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto detailsDto = detailsDtos.get(i);
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
// BeanUtils.copyProperties(detailsDto, tocofsSaleoutDetailedEntity);
BeanUtil.copyPropertiesV2(detailsDto, tocofsSaleoutDetailedEntity);
tocofsSaleoutDetailedEntityArrayList.add(tocofsSaleoutDetailedEntity);
}
}
return tocofsSaleoutDetailedEntityArrayList;
}
}

View File

@ -26,7 +26,7 @@ class SoSaleOutPluginInitializerToCTest {
@Test
void startImplement() throws Exception {
// soSaleOutPluginInitializerToC.startImplement("2024-07-05", null);
soSaleOutPluginInitializerToC.queryOfsSaleOrder();
soSaleOutPluginInitializerToC.startImplement(null, null);
// soSaleOutPluginInitializerToC.queryOfsSaleOrder();
}
}