提交TOB业务优化流程

This commit is contained in:
liuy 2024-08-13 18:21:50 +08:00
parent d5af8daf77
commit a80fea45ed
12 changed files with 1174 additions and 38 deletions

View File

@ -0,0 +1,22 @@
package com.hzya.frame.plugin.lets.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.constant
* @ProjectkangarooDataCenterV3
* @nameExportConstant
* @Date2024/8/13 18:00
* @FilenameExportConstant
*/
public class ExportConstant {
public static final Map<String, String> exportConstant = new HashMap<>();
static {
exportConstant.put("xuni-intoyou-japan", "xuni-intoyou-japan");
exportConstant.put("B2BFX20240001", "B2BFX20240001");
}
}

View File

@ -149,10 +149,21 @@ public class TocofsReturngoodsDetailedEntity extends BaseEntity {
* 业务日期
*/
private String businessDate;
/**
* 主表主键
*/
private String returngoodsId;
// private String returngoodsId;
private String businessType;
public String getBusinessType() {
return businessType;
}
public void setBusinessType(String businessType) {
this.businessType = businessType;
}
public String getReceiptId() {
return receiptId;
@ -434,12 +445,12 @@ public class TocofsReturngoodsDetailedEntity extends BaseEntity {
this.businessDate = businessDate;
}
public String getReturngoodsId() {
return returngoodsId;
}
public void setReturngoodsId(String returngoodsId) {
this.returngoodsId = returngoodsId;
}
// public String getReturngoodsId() {
// return returngoodsId;
// }
//
// public void setReturngoodsId(String returngoodsId) {
// this.returngoodsId = returngoodsId;
// }
}

View File

@ -39,8 +39,9 @@
<result property="newSystemPrimary" column="new_system_primary" jdbcType="VARCHAR"/>
<result property="primaryKey" column="primary_key" jdbcType="VARCHAR"/>
<result property="businessDate" column="business_date" jdbcType="VARCHAR"/>
<result property="returngoodsId" column="returngoods_id" jdbcType="VARCHAR"/>
<result property="businessType" column="business_type" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "TocofsReturngoodsDetailedEntity_Base_Column_List">
id
@ -78,9 +79,10 @@
,new_system_number
,new_system_primary
,primary_key
,business_date
,returngoods_id
,business_date
,business_type
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-TocofsReturngoodsDetailedEntity-result" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity">
select
@ -123,7 +125,7 @@
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and new_system_primary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> and primary_key = #{primaryKey} </if>
<if test="businessDate != null and businessDate != ''"> and business_date = #{businessDate} </if>
<if test="returngoodsId != null and returngoodsId != ''"> and returngoods_id = #{returngoodsId} </if>
<if test="businessType != null and businessType != ''"> and business_type = #{businessType} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -170,7 +172,7 @@
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and new_system_primary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> and primary_key = #{primaryKey} </if>
<if test="businessDate != null and businessDate != ''"> and business_date = #{businessDate} </if>
<if test="returngoodsId != null and returngoodsId != ''"> and returngoods_id = #{returngoodsId} </if>
<if test="businessType != null and businessType != ''"> and business_type = #{businessType} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -219,7 +221,7 @@
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and new_system_primary like concat('%',#{newSystemPrimary},'%') </if>
<if test="primaryKey != null and primaryKey != ''"> and primary_key like concat('%',#{primaryKey},'%') </if>
<if test="businessDate != null and businessDate != ''"> and business_date like concat('%',#{businessDate},'%') </if>
<if test="returngoodsId != null and returngoodsId != ''"> and returngoods_id like concat('%',#{returngoodsId},'%') </if>
<if test="businessType != null and businessType != ''"> and business_type like concat('%',#{businessType},'%') </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -268,7 +270,7 @@
<if test="newSystemPrimary != null and newSystemPrimary != ''"> or new_system_primary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> or primary_key = #{primaryKey} </if>
<if test="businessDate != null and businessDate != ''"> or business_date = #{businessDate} </if>
<if test="returngoodsId != null and returngoodsId != ''"> or returngoods_id = #{returngoodsId} </if>
<if test="businessType != null and businessType != ''"> or business_type = #{businessType} </if>
and sts='Y'
</trim>
<if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>
@ -315,7 +317,7 @@
<if test="newSystemPrimary != null and newSystemPrimary != ''"> new_system_primary , </if>
<if test="primaryKey != null and primaryKey != ''"> primary_key , </if>
<if test="businessDate != null and businessDate != ''"> business_date , </if>
<if test="returngoodsId != null and returngoodsId != ''"> returngoods_id , </if>
<if test="businessType != null and businessType != ''"> business_type , </if>
<if test="sorts == null ">sorts,</if>
<if test="sts == null ">sts,</if>
</trim>
@ -357,7 +359,7 @@
<if test="newSystemPrimary != null and newSystemPrimary != ''"> #{newSystemPrimary} ,</if>
<if test="primaryKey != null and primaryKey != ''"> #{primaryKey} ,</if>
<if test="businessDate != null and businessDate != ''"> #{businessDate} ,</if>
<if test="returngoodsId != null and returngoodsId != ''"> #{returngoodsId} ,</if>
<if test="businessType != null and businessType != ''"> #{businessType} ,</if>
<if test="sorts == null ">(select (max(IFNULL( a.sorts, 0 )) + 1) as sort from tocofs_returngoods_detailed a WHERE a.sts = 'Y' ),</if>
<if test="sts == null ">'Y',</if>
</trim>
@ -365,28 +367,28 @@
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_returngoods_detailed(receipt_id, receipt_code, ref_order_id, ref_order_detail_id, source_order_code, client_code, company_code, facility_code, sku_code, sku_name, request_qty, received_qty, open_qty, quantity_u_m, total_weight, total_volume, total_volume_weight, total_amount, weight_u_m, volume_u_m, inventory_sts, in_trans_inv_id, closed, created, created_by, last_updated, last_updated_by, discount_price, new_transmitInfo, new_pushDate, new_state, new_system_number, new_system_primary, primary_key, business_date, returngoods_id, sts)
insert into tocofs_returngoods_detailed(receipt_id, receipt_code, ref_order_id, ref_order_detail_id, source_order_code, client_code, company_code, facility_code, sku_code, sku_name, request_qty, received_qty, open_qty, quantity_u_m, total_weight, total_volume, total_volume_weight, total_amount, weight_u_m, volume_u_m, inventory_sts, in_trans_inv_id, closed, created, created_by, last_updated, last_updated_by, discount_price, new_transmitInfo, new_pushDate, new_state, new_system_number, new_system_primary, primary_key, business_date,business_type)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.receiptId},#{entity.receiptCode},#{entity.refOrderId},#{entity.refOrderDetailId},#{entity.sourceOrderCode},#{entity.clientCode},#{entity.companyCode},#{entity.facilityCode},#{entity.skuCode},#{entity.skuName},#{entity.requestQty},#{entity.receivedQty},#{entity.openQty},#{entity.quantityUM},#{entity.totalWeight},#{entity.totalVolume},#{entity.totalVolumeWeight},#{entity.totalAmount},#{entity.weightUM},#{entity.volumeUM},#{entity.inventorySts},#{entity.inTransInvId},#{entity.closed},#{entity.created},#{entity.createdBy},#{entity.lastUpdated},#{entity.lastUpdatedBy},#{entity.discountPrice},#{entity.newTransmitinfo},#{entity.newPushdate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessDate},#{entity.returngoodsId}, 'Y')
(#{entity.receiptId},#{entity.receiptCode},#{entity.refOrderId},#{entity.refOrderDetailId},#{entity.sourceOrderCode},#{entity.clientCode},#{entity.companyCode},#{entity.facilityCode},#{entity.skuCode},#{entity.skuName},#{entity.requestQty},#{entity.receivedQty},#{entity.openQty},#{entity.quantityUM},#{entity.totalWeight},#{entity.totalVolume},#{entity.totalVolumeWeight},#{entity.totalAmount},#{entity.weightUM},#{entity.volumeUM},#{entity.inventorySts},#{entity.inTransInvId},#{entity.closed},#{entity.created},#{entity.createdBy},#{entity.lastUpdated},#{entity.lastUpdatedBy},#{entity.discountPrice},#{entity.newTransmitinfo},#{entity.newPushdate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessDate},#{entity.businessType})
</foreach>
</insert>
<!-- 批量新增 -->
<insert id="entityInsertBatchV2" keyProperty="id" useGeneratedKeys="true">
insert IGNORE into tocofs_returngoods_detailed(receipt_id, receipt_code, ref_order_id, ref_order_detail_id, source_order_code, client_code, company_code, facility_code, sku_code, sku_name, request_qty, received_qty, open_qty, quantity_u_m, total_weight, total_volume, total_volume_weight, total_amount, weight_u_m, volume_u_m, inventory_sts, in_trans_inv_id, closed, created, created_by, last_updated, last_updated_by, discount_price, new_transmitInfo, new_pushDate, new_state, new_system_number, new_system_primary, primary_key, business_date, returngoods_id)
insert IGNORE into tocofs_returngoods_detailed(receipt_id, receipt_code, ref_order_id, ref_order_detail_id, source_order_code, client_code, company_code, facility_code, sku_code, sku_name, request_qty, received_qty, open_qty, quantity_u_m, total_weight, total_volume, total_volume_weight, total_amount, weight_u_m, volume_u_m, inventory_sts, in_trans_inv_id, closed, created, created_by, last_updated, last_updated_by, discount_price, new_transmitInfo, new_pushDate, new_state, new_system_number, new_system_primary, primary_key, business_date,business_type)
values
<foreach collection="list" item="entity" separator=",">
(#{entity.receiptId},#{entity.receiptCode},#{entity.refOrderId},#{entity.refOrderDetailId},#{entity.sourceOrderCode},#{entity.clientCode},#{entity.companyCode},#{entity.facilityCode},#{entity.skuCode},#{entity.skuName},#{entity.requestQty},#{entity.receivedQty},#{entity.openQty},#{entity.quantityUM},#{entity.totalWeight},#{entity.totalVolume},#{entity.totalVolumeWeight},#{entity.totalAmount},#{entity.weightUM},#{entity.volumeUM},#{entity.inventorySts},#{entity.inTransInvId},#{entity.closed},#{entity.created},#{entity.createdBy},#{entity.lastUpdated},#{entity.lastUpdatedBy},#{entity.discountPrice},#{entity.newTransmitinfo},#{entity.newPushdate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessDate},#{entity.returngoodsId})
(#{entity.receiptId},#{entity.receiptCode},#{entity.refOrderId},#{entity.refOrderDetailId},#{entity.sourceOrderCode},#{entity.clientCode},#{entity.companyCode},#{entity.facilityCode},#{entity.skuCode},#{entity.skuName},#{entity.requestQty},#{entity.receivedQty},#{entity.openQty},#{entity.quantityUM},#{entity.totalWeight},#{entity.totalVolume},#{entity.totalVolumeWeight},#{entity.totalAmount},#{entity.weightUM},#{entity.volumeUM},#{entity.inventorySts},#{entity.inTransInvId},#{entity.closed},#{entity.created},#{entity.createdBy},#{entity.lastUpdated},#{entity.lastUpdatedBy},#{entity.discountPrice},#{entity.newTransmitinfo},#{entity.newPushdate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessDate},#{entity.businessType})
</foreach>
</insert>
<!-- 批量新增或者修改-->
<insert id="entityInsertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into tocofs_returngoods_detailed(receipt_id, receipt_code, ref_order_id, ref_order_detail_id, source_order_code, client_code, company_code, facility_code, sku_code, sku_name, request_qty, received_qty, open_qty, quantity_u_m, total_weight, total_volume, total_volume_weight, total_amount, weight_u_m, volume_u_m, inventory_sts, in_trans_inv_id, closed, created, created_by, last_updated, last_updated_by, discount_price, new_transmitInfo, new_pushDate, new_state, new_system_number, new_system_primary, primary_key, business_date, returngoods_id)
insert into tocofs_returngoods_detailed(receipt_id, receipt_code, ref_order_id, ref_order_detail_id, source_order_code, client_code, company_code, facility_code, sku_code, sku_name, request_qty, received_qty, open_qty, quantity_u_m, total_weight, total_volume, total_volume_weight, total_amount, weight_u_m, volume_u_m, inventory_sts, in_trans_inv_id, closed, created, created_by, last_updated, last_updated_by, discount_price, new_transmitInfo, new_pushDate, new_state, new_system_number, new_system_primary, primary_key, business_date,business_type)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.receiptId},#{entity.receiptCode},#{entity.refOrderId},#{entity.refOrderDetailId},#{entity.sourceOrderCode},#{entity.clientCode},#{entity.companyCode},#{entity.facilityCode},#{entity.skuCode},#{entity.skuName},#{entity.requestQty},#{entity.receivedQty},#{entity.openQty},#{entity.quantityUM},#{entity.totalWeight},#{entity.totalVolume},#{entity.totalVolumeWeight},#{entity.totalAmount},#{entity.weightUM},#{entity.volumeUM},#{entity.inventorySts},#{entity.inTransInvId},#{entity.closed},#{entity.created},#{entity.createdBy},#{entity.lastUpdated},#{entity.lastUpdatedBy},#{entity.discountPrice},#{entity.newTransmitinfo},#{entity.newPushdate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessDate},#{entity.returngoodsId})
(#{entity.receiptId},#{entity.receiptCode},#{entity.refOrderId},#{entity.refOrderDetailId},#{entity.sourceOrderCode},#{entity.clientCode},#{entity.companyCode},#{entity.facilityCode},#{entity.skuCode},#{entity.skuName},#{entity.requestQty},#{entity.receivedQty},#{entity.openQty},#{entity.quantityUM},#{entity.totalWeight},#{entity.totalVolume},#{entity.totalVolumeWeight},#{entity.totalAmount},#{entity.weightUM},#{entity.volumeUM},#{entity.inventorySts},#{entity.inTransInvId},#{entity.closed},#{entity.created},#{entity.createdBy},#{entity.lastUpdated},#{entity.lastUpdatedBy},#{entity.discountPrice},#{entity.newTransmitinfo},#{entity.newPushdate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessDate},#{entity.businessType})
</foreach>
on duplicate key update
receipt_id = values(receipt_id),
@ -424,7 +426,9 @@
new_system_primary = values(new_system_primary),
primary_key = values(primary_key),
business_date = values(business_date),
returngoods_id = values(returngoods_id)</insert>
business_type = values(business_type)
</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity" >
update tocofs_returngoods_detailed set
@ -464,15 +468,17 @@ update tocofs_returngoods_detailed set
<if test="newSystemPrimary != null and newSystemPrimary != ''"> new_system_primary = #{newSystemPrimary},</if>
<if test="primaryKey != null and primaryKey != ''"> primary_key = #{primaryKey},</if>
<if test="businessDate != null and businessDate != ''"> business_date = #{businessDate},</if>
<if test="returngoodsId != null and returngoodsId != ''"> returngoods_id = #{returngoodsId},</if>
<if test="businessType != null and businessType != ''"> business_type = #{businessType}</if>
</trim>
where id = #{id}
</update>
<!-- 逻辑删除 -->
<update id="entity_logicDelete" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsReturngoodsDetailedEntity" >
update tocofs_returngoods_detailed 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.TocofsReturngoodsDetailedEntity" >
update tocofs_returngoods_detailed set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id}
@ -513,10 +519,11 @@ update tocofs_returngoods_detailed set sts= 'N' ,modify_time = #{modify_time},m
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and new_system_primary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> and primary_key = #{primaryKey} </if>
<if test="businessDate != null and businessDate != ''"> and business_date = #{businessDate} </if>
<if test="returngoodsId != null and returngoodsId != ''"> and returngoods_id = #{returngoodsId} </if>
<if test="businessType != null and businessType != ''"> and business_type = #{businessType} </if>
and sts='Y'
</trim>
</update>
<!--通过主键删除-->
<delete id="entity_delete">
delete from tocofs_returngoods_detailed where id = #{id}

View File

@ -144,8 +144,37 @@ public class TocofsSaleoutDetailedEntity extends BaseEntity {
private String newSystemPrimary;
/**
* 主表主键
*/
private String primaryKey;
/**
* 业务类型
*/
private String businessType;
/**
* 业务日期
*/
private String businessDate;
public String getBusinessDate() {
return businessDate;
}
public void setBusinessDate(String businessDate) {
this.businessDate = businessDate;
}
public String getBusinessType() {
return businessType;
}
public void setBusinessType(String businessType) {
this.businessType = businessType;
}
public String getNewTransmitInfo() {
return newTransmitInfo;
}

View File

@ -38,9 +38,12 @@
<result property="newState" column="newState" jdbcType="VARCHAR"/>
<result property="newSystemNumber" column="newSystemNumber" jdbcType="VARCHAR"/>
<result property="newSystemPrimary" column="newSystemPrimary" jdbcType="VARCHAR"/>
<result property="primaryKey" column="primaryKey" jdbcType="VARCHAR"/>
<result property="businessType" column="businessType" jdbcType="VARCHAR"/>
<result property="businessDate" column="businessDate" jdbcType="VARCHAR"/>
</resultMap>
<!-- 查询的字段-->
<sql id = "TocofsSaleoutDetailedEntity_Base_Column_List">
clientCode
@ -77,7 +80,10 @@
,newSystemNumber
,newSystemPrimary
,primaryKey
,businessType
,businessDate
</sql>
<!-- 查询 采用==查询 -->
<select id="entity_list_base" resultMap="get-TocofsSaleoutDetailedEntity-result" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity">
select
@ -120,6 +126,8 @@
<if test="newSystemNumber != null and newSystemNumber != ''"> and newSystemNumber = #{newSystemNumber} </if>
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and newSystemPrimary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> and primaryKey = #{primaryKey} </if>
<if test="businessType != null and businessType != ''"> and businessType = #{businessType} </if>
<if test="businessDate != null and businessDate != ''"> and businessDate = #{businessDate} </if>
</trim>
<!-- <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>-->
<!-- <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>-->
@ -165,6 +173,8 @@
<if test="newSystemNumber != null and newSystemNumber != ''"> and newSystemNumber = #{newSystemNumber} </if>
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and newSystemPrimary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> and primaryKey = #{primaryKey} </if>
<if test="businessType != null and businessType != ''"> and businessType = #{businessType} </if>
<if test="businessDate != null and businessDate != ''"> and businessDate = #{businessDate} </if>
</trim>
<!-- <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>-->
<!-- <if test=" sort !='' and sort!=null and order !='' and order!=null "> order by ${sort} ${order}</if>-->
@ -212,6 +222,8 @@
<if test="newSystemNumber != null and newSystemNumber != ''"> and newSystemNumber like concat('%',#{newSystemNumber},'%') </if>
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and newSystemPrimary like concat('%',#{newSystemPrimary},'%') </if>
<if test="primaryKey != null and primaryKey != ''"> and primaryKey like concat('%',#{primaryKey},'%') </if>
<if test="businessType != null and businessType != ''"> and businessType like concat('%',#{businessType},'%') </if>
<if test="businessDate != null and businessDate != ''"> and businessDate like concat('%',#{businessDate},'%') </if>
</trim>
<!-- <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>-->
<!-- <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>-->
@ -259,6 +271,8 @@
<if test="newSystemNumber != null and newSystemNumber != ''"> or newSystemNumber = #{newSystemNumber} </if>
<if test="newSystemPrimary != null and newSystemPrimary != ''"> or newSystemPrimary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> or primaryKey = #{primaryKey} </if>
<if test="businessType != null and businessType != ''"> or businessType = #{businessType} </if>
<if test="businessDate != null and businessDate != ''"> or businessDate = #{businessDate} </if>
</trim>
<!-- <if test=" sort == null or sort == ''.toString() "> order by sorts asc</if>-->
<!-- <if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>-->
@ -348,19 +362,19 @@
<!-- 批量新增 -->
<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,newTransmitInfo,newPushDate,newState,newSystemNumber,newSystemPrimary,primaryKey)
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,newTransmitInfo,newPushDate,newState,newSystemNumber,newSystemPrimary,primaryKey,businessType,businessDate)
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},#{entity.newTransmitInfo},#{entity.newPushDate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey})
(#{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},#{entity.newTransmitInfo},#{entity.newPushDate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessType},#{entity.businessDate})
</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,newTransmitInfo,newPushDate,newState,newSystemNumber,newSystemPrimary,primaryKey)
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,newTransmitInfo,newPushDate,newState,newSystemNumber,newSystemPrimary,primaryKey,businessType,businessDate)
values
<foreach collection="entities" 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.lastupdatedby},#{entity.lastupdated},#{entity.newTransmitInfo},#{entity.newPushDate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey})
(#{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.lastupdatedby},#{entity.lastupdated},#{entity.newTransmitInfo},#{entity.newPushDate},#{entity.newState},#{entity.newSystemNumber},#{entity.newSystemPrimary},#{entity.primaryKey},#{entity.businessType},#{entity.businessDate})
</foreach>
on duplicate key update
clientCode = values(clientCode),
@ -396,8 +410,11 @@
newState = values(newState),
newSystemNumber = values(newSystemNumber),
newSystemPrimary = values(newSystemPrimary),
primaryKey = values(primaryKey)
primaryKey = values(primaryKey),
businessType = values(businessType),
businessDate = values(businessDate)
</insert>
<!--通过主键修改方法-->
<update id="entity_update" parameterType = "com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity" >
update tocofs_saleout_detailed set
@ -436,6 +453,8 @@ update tocofs_saleout_detailed set
<if test="newSystemNumber != null and newSystemNumber != ''"> newSystemNumber = #{newSystemNumber},</if>
<if test="newSystemPrimary != null and newSystemPrimary != ''"> newSystemPrimary = #{newSystemPrimary},</if>
<if test="primaryKey != null and primaryKey != ''"> primaryKey = #{primaryKey},</if>
<if test="businessType != null and businessType != ''"> businessType = #{businessType},</if>
<if test="businessDate != null and businessDate != ''"> businessDate = #{businessDate}</if>
</trim>
where rootId = #{rootid}
</update>
@ -484,6 +503,8 @@ update tocofs_saleout_detailed set sts= 'N' ,modify_time = #{modify_time},modif
<if test="newSystemNumber != null and newSystemNumber != ''"> and newSystemNumber = #{newSystemNumber} </if>
<if test="newSystemPrimary != null and newSystemPrimary != ''"> and newSystemPrimary = #{newSystemPrimary} </if>
<if test="primaryKey != null and primaryKey != ''"> and primaryKey = #{primaryKey} </if>
<if test="businessType != null and businessType != ''"> and businessType = #{businessType} </if>
<if test="businessDate != null and businessDate != ''"> and businessDate = #{businessDate} </if>
</trim>
</update>
<!--通过主键删除-->

View File

@ -0,0 +1,937 @@
package com.hzya.frame.plugin.lets.plugin.sales;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
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.constant.ExportConstant;
import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant;
import com.hzya.frame.plugin.lets.dao.*;
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.resultvo.CalculateDateVo;
import com.hzya.frame.plugin.lets.u8cdto.*;
import com.hzya.frame.plugin.lets.util.DateStrUtil;
import com.hzya.frame.plugin.lets.util.QueryBdBusitypeUtil;
import com.hzya.frame.plugin.lets.util.TocOrderBasicArchivesCacheUtil;
import com.hzya.frame.split.SplitListByCountUtil;
import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
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.service.OfsUnifiedService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* OFS销售出库单(TOB)生成U8C销售订单
*
* @author makejava
* @since 2024年8月12日 15:03:51
*/
public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(SoSaleOutPluginInitializerToB.class);
private static final ReentrantLock LOCK = new ReentrantLock(true);
@Autowired
private IBdCorpDao iBdCorpDao;
@Autowired
private IBdInvbasdocDao iBdInvbasdocDao;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "com.hzya.frame.plugin.lets.plugin.sales.SoSaleOutPluginInitializerToB";
}
@Override
public String getPluginName() {
return "OFS销售出库单(TOB)生成U8C销售订单";
}
@Override
public String getPluginLabel() {
return "OFS销售出库单(TOB)生成U8C销售订单";
}
@Override
public String getPluginType() {
return "3";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
return null;
}
@Autowired
private OfsUnifiedService ofsUnifiedService;
@Autowired
private IBdTaxitemsDao iBdTaxitemsDao;
@Autowired
private IBdCalbodyDao iBdCalbodyDao;
@Autowired
private TocOrderBasicArchivesCacheUtil basicArchivesCacheUtil;
@Autowired
private ITocofsSaleoutDao iTocofsSaleoutDao;
@Autowired
private ITocofsSaleoutDetailedDao iTocofsSaleoutDetailedDao;
@Autowired
private QueryBdBusitypeUtil queryBdBusitypeUtil;
@Autowired
private IBdStordocDao iBdStordocDao;
@Autowired
private IBdSalestruDao iBdSalestruDao;
private static final String NOTHING = "";
private static final String ADD = "+";
@Autowired
private IBdCumandocDao iBdCumandocDao;
@Autowired
private IBdDeptdocDao iBdDeptdocDao;
@Autowired
private IBdCubasdocDao iBdCubasdocDao;
@Autowired
private IBdDefdocDao iBdDefdocDao;
@Autowired
private IBdInvmandocDao iBdInvmandocDao;
/**
* 按指定时间拉取
*
* @author liuyang
*/
public void startImplement(String dateStr, String summaryOrderNumber) {
String threadNameStr = StrUtil.format("OFS销售出库(TOB)同步U8C销售订单 同步日期:{} 汇总维度:{}", dateStr, summaryOrderNumber);
logger.info(threadNameStr);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
LOCK.lock();
try {
// TODO 注意过滤TOB店铺
CalculateDateVo calculateDateVo = DateStrUtil.calculateCalculateEntireDayPeriod(dateStr);
List<HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
queryOfsSoSaleOutVo.setCreated_start("2024-01-02 00:58:22");
queryOfsSoSaleOutVo.setCreated_end("2024-01-02 11:58:23");
queryOfsSoSaleOutVo.setClientCode("LETS");
// queryOfsSoSaleOutVo.setInternalInstructionType("SALES");
queryOfsSoSaleOutVo.setCompanyCode("SHLZ");
// queryOfsSoSaleOutVo.setStatus(900L);
queryOfsSoSaleOutVo.setPageNo(1L);
queryOfsSoSaleOutVo.setPageSize(50L);
queryOfsSoSaleOutVo.setCode("LETS-SH2024010200000004");
queryOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoList, 1L);
logger.info("数据返回行数:{}", headerDetailsDtoList.size());
if (headerDetailsDtoList.size() > 0) {
//保存到mysql
batchInsert(headerDetailsDtoList);
//过滤成功的数据
List<HeaderDetailsDto> headerDetailsDtos = filterData(headerDetailsDtoList);
//执行推送主逻辑
implement(headerDetailsDtos);
} else {
logger.info("没有查询到任何数据!不需要同步");
}
} catch (Exception e) {
logger.error("startImplement方法抛出异常", e);
} finally {
LOCK.unlock();
}
}
}, threadNameStr);
thread.start();
try {
thread.join();
} catch (Exception e) {
logger.error("thread.join()异常", e);
}
}
/**
* 过滤掉成功的数据
*
* @author liuyang
*/
private List<HeaderDetailsDto> filterData(List<HeaderDetailsDto> headerDetailsDtoList) {
List<HeaderDetailsDto> headerDetailsDtoList1 = new ArrayList<>();
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
//TODO 出库单明细主键需要O返回目前没有已经提需求
headerDetailsDtoList1.addAll(headerDetailsDtoList);
}
return headerDetailsDtoList1;
}
/**
* 保存抓取到的数据到mysql底表如果底表里已经存在则会忽略
*
* @param headerDetailsDtoList 数据行
*/
private void batchInsert(List<HeaderDetailsDto> headerDetailsDtoList) throws Exception {
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
List<HeaderDto> headerDetailsDtoList1 = new ArrayList<>();
List<DetailsDto> headerDetailsDtoList2 = new ArrayList<>();
for (HeaderDetailsDto index : headerDetailsDtoList) {
HeaderDto header = index.getHeader();// 主表
List<DetailsDto> details = index.getDetails();//明细表
headerDetailsDtoList1.add(header);
headerDetailsDtoList2.addAll(details);
}
//每250作为一个批次插入主表根据主键id判断是否重复如果重复的则不进行插入
List<List<HeaderDto>> ofssaleorderoutsearchList = SplitListByCountUtil.splitListByCount(headerDetailsDtoList1, 250);
for (int i = 0; i < ofssaleorderoutsearchList.size(); i++) {
List<HeaderDto> headerDtoList = ofssaleorderoutsearchList.get(i);
List<TocofsSaleoutEntity> tocofsSaleoutEntityList = copyHeaderDto(headerDtoList);
if (tocofsSaleoutEntityList.size() > 0) {
logger.info("TOBofsSaleoutDetailedEntities插入底表{}个对象(表头)", tocofsSaleoutEntityList.size());
iTocofsSaleoutDao.entityInsertBatchV2(tocofsSaleoutEntityList);
} else {
logger.info("TOBofsSaleoutEntityList没有对象被插入表头底表");
}
}
//插入明细表
List<List<DetailsDto>> detailsDtoList = SplitListByCountUtil.splitListByCount(headerDetailsDtoList2, 250);
for (int i = 0; i < detailsDtoList.size(); i++) {
List<DetailsDto> detailsDtos = detailsDtoList.get(i);
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities = copyDetailsDto(detailsDtos);
if (tocofsSaleoutDetailedEntities.size() > 0) {
logger.info("TOBofsSaleoutDetailedEntities插入底表{}个对象(表体)", tocofsSaleoutDetailedEntities.size());
iTocofsSaleoutDetailedDao.entityInsertBatchV2(tocofsSaleoutDetailedEntities);
} else {
logger.info("TOBofsSaleoutDetailedEntities没有对象被插入表头底表");
}
}
}
}
/**
* 查询OFS结果集
*
* @param queryOfsSoSaleOutVo 查询参数
* @param headerDetailsDtoList 查询结果集
* @param pageNo 从第pageNo页开始查询
*/
private void queryOfsSaleOrder(QueryOfsSoSaleOutVo queryOfsSoSaleOutVo, List<HeaderDetailsDto> headerDetailsDtoList, Long pageNo) throws Exception {
Long pageSize = 200L;
queryOfsSoSaleOutVo.setPageNo(pageNo);
queryOfsSoSaleOutVo.setPageSize(pageSize);
InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
interfaceParamDto.setApi("ofs.shipment.search");
interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
if (saleOutReturnMessageDto != null) {
if ("false".equals(saleOutReturnMessageDto.getError()) && "0".equals(saleOutReturnMessageDto.getCode()) && "Success".equals(saleOutReturnMessageDto.getMsg())) {
List<HeaderDetailsDto> headerDetailsDtoList1 = saleOutReturnMessageDto.getData();
if (headerDetailsDtoList1 != null && headerDetailsDtoList1.size() > 0) {
headerDetailsDtoList.addAll(headerDetailsDtoList1);
//TODO OFS没有提供分页字段
}
} else {
//2024年7月30日 13:47:04 查询失败
logger.error("查询失败,失败原因:{}", JSON.toJSON(saleOutReturnMessageDto));
}
} else {
logger.error("returnMessageBasics为空queryOfsSoSaleOutVo对象结果{}", JSON.toJSON(queryOfsSoSaleOutVo));
}
}
// public void queryOfsSaleOrder() throws Exception {
// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
// queryOfsSoSaleOutVo.setCreated_start("2024-07-05 16:38:00");
// queryOfsSoSaleOutVo.setCreated_end("2024-07-05 16:40:30");
// queryOfsSoSaleOutVo.setClientCode("LETS");
//// queryOfsSoSaleOutVo.setInternalInstructionType("SALES");
// queryOfsSoSaleOutVo.setCompanyCode("SHLZ");
//// queryOfsSoSaleOutVo.setStatus(900L);
// queryOfsSoSaleOutVo.setPageNo(1L);
// queryOfsSoSaleOutVo.setPageSize(50L);
// queryOfsSoSaleOutVo.setCode("LETS-SH2024070500000003");
//
// InterfaceParamDto interfaceParamDto = new InterfaceParamDto();
// interfaceParamDto.setApi("ofs.shipment.search");
// interfaceParamDto.setData(JSON.toJSONString(queryOfsSoSaleOutVo));
// SaleOutReturnMessageDto saleOutReturnMessageDto = (SaleOutReturnMessageDto) ofsUnifiedService.unified(interfaceParamDto);
// System.out.println(saleOutReturnMessageDto);
// }
/**
* 代码同步逻辑
*
* @param headerDetailsDtos 查询得到的O出库单对象
* @author liuyang
*/
private void implement(List<HeaderDetailsDto> headerDetailsDtos) throws Exception {
if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) {
try {
// 查询基本档案
List<OrderOutTobHeaderDto> orderOutTobHeaderDtos = queryBasicArchives(headerDetailsDtos);
// 查询U8C业务流程
BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow();
try {
for (int i = 0; i < orderOutTobHeaderDtos.size(); i++) {
OrderOutTobHeaderDto orderOutTobHeaderDto = orderOutTobHeaderDtos.get(i);
HeaderDto header = orderOutTobHeaderDto.getHeader();
List<DetailsDto> details = orderOutTobHeaderDto.getDetails();
//销售公司发货公司
BdCorpEntity bdCorpEntity = orderOutTobHeaderDto.getBdCorpEntity();
//发货库存组织
BdCalbodyEntity bdCalbodyEntity = orderOutTobHeaderDto.getBdCalbodyEntity();
//入库参数
BdStordocEntity bdStordocEntity = orderOutTobHeaderDto.getBdStordocEntity();
//销售组织
BdSalestruEntity bdSalestruEntity = orderOutTobHeaderDto.getBdSalestruEntity();
//业务部门
BdDeptdocEntity bdDeptdocEntity = orderOutTobHeaderDto.getBdDeptdocEntity();
//客商基本档案
BdCubasdocEntity bdCubasdocEntity = orderOutTobHeaderDto.getBdCubasdocEntity();
//客商基本档案
BdCumandocEntity bdCumandocEntity = orderOutTobHeaderDto.getBdCumandocEntity();
//发货公司
BdCorpEntity deliverGoodsCorp = orderOutTobHeaderDto.getDeliverGoodsCorp();
//平台档案
BdDefdocEntity platformArchives = orderOutTobHeaderDto.getPlatformArchives();
//生成业务日期
String generateBusinessDate = createGenerateBusinessDate(orderOutTobHeaderDto);
SaleorderRequestDto saleorderRequestDto = new SaleorderRequestDto();
SaleorderRequestParentDto saleorderRequestParentDto = new SaleorderRequestParentDto();
saleorderRequestParentDto.setDbilldate(generateBusinessDate);//单据日期
saleorderRequestParentDto.setBretinvflag("N");//退货标记
saleorderRequestParentDto.setCbiztype(bdBusitypeEntity.getPkBusitype());//业务流程
saleorderRequestParentDto.setCcalbodyid(bdCalbodyEntity.getPkCalbody());//库存组织
saleorderRequestParentDto.setCcustomerid(bdCumandocEntity.getPkCumandoc());//客户=开票单位=收货单位=表体收货单位=收货单位
saleorderRequestParentDto.setCdeptid(bdDeptdocEntity.getPkDeptdoc());//部门
saleorderRequestParentDto.setCemployeeid(null);//业务员
saleorderRequestParentDto.setCoperatorid("0001A110000000000U3D");//制单人
saleorderRequestParentDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//开票单位
saleorderRequestParentDto.setCreceiptcustomerid(bdCumandocEntity.getPkCumandoc());//收货单位
saleorderRequestParentDto.setCsalecorpid(bdSalestruEntity.getCsalestruid());//销售组织
saleorderRequestParentDto.setCwarehouseid(bdStordocEntity.getPkStordoc());//仓库
saleorderRequestParentDto.setDapprovedate(generateBusinessDate);//审核日期
saleorderRequestParentDto.setNdiscountrate("100.000000");//整单折扣
saleorderRequestParentDto.setPk_corp(bdCorpEntity.getPkCorp());//公司id
//原单单号原单主键
saleorderRequestParentDto.setVdef19(header.getCode());
saleorderRequestParentDto.setVdef20(header.getId());
//平台
saleorderRequestParentDto.setPk_defdoc2(platformArchives.getPkDefdoc());
saleorderRequestParentDto.setVdef2(platformArchives.getDocname());
//TODO 2024年8月8日 17:17:58 店铺档案自定义项1先不传后续维护好之后再传!
saleorderRequestDto.setParentvo(saleorderRequestParentDto);
List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList = new ArrayList<>();
saleorderRequestDto.setChildrenvo(saleorderRequestChildrenDtoList);
//把汇总好的出库单明细行合并成一行
for (int j = 0; j < details.size(); j++) {
DetailsDto detailsDto = details.get(j);
//存货管理档案取发货公司的存货管理档案
BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(detailsDto, bdCalbodyEntity.getPkCorp());
//存货基础档案
BdInvbasdocEntity bdInvbasdocEntity = queryStockBasicArchives(bdInvmandocEntity.getPkInvmandoc(), deliverGoodsCorp.getPkCorp());
//根据存货基础档案编码查询当前存货的税率
BdTaxitemsEntity bdTaxitemsEntity1 = queryBdTaxitems(bdInvbasdocEntity.getInvcode());
String tax = "0." + new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString();
// 如果是海外的店铺则税率为零
String exportVaue = ExportConstant.exportConstant.get(header.getStoreCode());
if (exportVaue != null) {
tax = "0";
}
BigDecimal noriginalcurprice = null;//无税单价
BigDecimal noriginalcurmny = null;//无税金额
BigDecimal noriginalcurtaxprice = null;//含税单价
BigDecimal noriginalcursummny = null;//价税合计
BigDecimal noriginalcurtaxmny = null;//税额
try {
noriginalcurtaxprice = new BigDecimal(detailsDto.getTotalPayAmount()).divide(new BigDecimal(detailsDto.getShipQty()), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurmny = noriginalcurprice.multiply(new BigDecimal(detailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcursummny = noriginalcurtaxprice.multiply(new BigDecimal(detailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurtaxmny = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) {
logger.error("TOB金额计算错误", e);
Assert.state(false, "TOB金额计算错误原因{}", e.getMessage());
}
//判断是否为赠品
String isblargessflag = "N";
if (noriginalcursummny.longValue() == 0) {
isblargessflag = "Y";
}
SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto();
saleorderRequestChildrenDto.setBlargessflag(isblargessflag);//是否赠品
saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
saleorderRequestChildrenDto.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码这个字段不需要给openapi接口而是提供给下游方法使用
saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种
saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id
saleorderRequestChildrenDto.setCinventorycode(bdInvbasdocEntity.getInvcode());//存货编码
saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期
saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);//要求收货日期
saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率
saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣
saleorderRequestChildrenDto.setNnumber(detailsDto.getShipQty());//数量
saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额
// saleorderRequestChildrenDto.setNoriginalcurmny(noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额
// saleorderRequestChildrenDto.setNoriginalcurnetprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税净价*
// saleorderRequestChildrenDto.setNoriginalcurprice(noriginalcurprice.stripTrailingZeros().toPlainString());//无税单价*
// saleorderRequestChildrenDto.setNoriginalcursummny(noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计
// saleorderRequestChildrenDto.setNoriginalcurtaxmny(noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额
// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价
saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价
saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
}
//记录成功
//销售订单单据推送到u8c
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
saleorderRequestDtoList.add(saleorderRequestDto);
Map<String, List<SaleorderRequestDto>> stringStringMap = new HashMap<>();
stringStringMap.put("saleorder", saleorderRequestDtoList);
SoSaleResultRootDto soSaleResultRootDto = sendU8CTOCOrder(JSON.toJSONString(stringStringMap));
logger.info("TOB销售订单编号{} 销售公司:{}", soSaleResultRootDto.getParentvo().getVreceiptcode(), soSaleResultRootDto.getParentvo().getPk_corp());
}
} catch (Exception e) {
logger.error("TOB业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e);
//记录失败
}
} catch (Exception e) {
logger.error("TOB外层转换逻辑抛出异常", e);
// 记录失败
}
}
}
/**
* 2024年7月31日 10:34:09
* 生成业务日期以发货时间作为业务日期
*
* @author liuyang
*/
private String createGenerateBusinessDate(OrderOutTobHeaderDto orderOutTobHeaderDto) {
return "2024-08-13";
//TODO 测试
// if (orderOutTobHeaderDto != null && orderOutTobHeaderDto.getHeader() != null && orderOutTobHeaderDto.getHeader().getShipAt() != null) {
// HeaderDto header = orderOutTobHeaderDto.getHeader();
// String shipAt = header.getShipAt();
// String businessFormat = null;
// try {
// Date dbill = DateUtil.parse(shipAt);
// businessFormat = DateUtil.format(dbill, "yyyy-MM-dd");
// } catch (Exception e) {
// logger.error("业务日期生成失败", e);
// }
// return businessFormat;
// } else {
// logger.error("生成出库日期失败或者shipAt为空! json{}", JSON.toJSON(orderOutTobHeaderDto));
// Assert.state(false, "生成出库日期失败或者shipAt为空! json{}", JSON.toJSON(orderOutTobHeaderDto));
// return null;
// }
}
/**
* 档案转换
*
* @author liuyang
*/
private List<OrderOutTobHeaderDto> queryBasicArchives(List<HeaderDetailsDto> headerDetailsDtoList) {
List<OrderOutTobHeaderDto> orderOutTobHeaderDtoArrayList = new ArrayList<>();
if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
try {
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
HeaderDto header = headerDetailsDto.getHeader();
List<DetailsDto> details = headerDetailsDto.getDetails();
// 销售公司发货公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
List<BdCorpEntity> 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<BdCalbodyEntity> 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<BdStordocEntity> bdStordocEntityList = iBdStordocDao.query(bdStordocEntity);
if (bdStordocEntityList.size() == 0) {
Assert.state(false, "根据O仓库编码+U8C发货库存组织主键无法匹配到U8C仓库", facilityCode, bdCalbodyEntities.get(0).getPkCalbody());
} else if (bdStordocEntityList.size() >= 2) {
Assert.state(false, "根据O仓库编码+U8C发货库存组织主键匹配到U8C仓库多个", facilityCode, bdCalbodyEntities.get(0).getPkCalbody());
}
//销售组织
//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<BdSalestruEntity> 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());
}
//业务部门
String deptName = "其他部门";
BdDeptdocEntity bdDeptdocEntity = new BdDeptdocEntity();
bdDeptdocEntity.setDataSourceCode("lets_u8c");
bdDeptdocEntity.setDr(0);
bdDeptdocEntity.setDeptname(deptName);
bdDeptdocEntity.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
List<BdDeptdocEntity> 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());
}
//客商基本档案
String custName = "天猫intoyou旗舰店-自营";
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setCustname(custName);
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
bdCumandocEntity1.setDataSourceCode("lets_u8c");
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
//查找平台
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<BdDefdocEntity> 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);
}
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.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");
}
return orderOutTobHeaderDtoArrayList;
}
/**
* bean copy
* 2024年7月31日 10:34:09
*/
private List<TocofsSaleoutEntity> copyHeaderDto(List<HeaderDto> headerDtoList) {
List<TocofsSaleoutEntity> tocofsSaleoutEntityList = new ArrayList<>();
if (headerDtoList != null && headerDtoList.size() > 0) {
for (int i = 0; i < headerDtoList.size(); i++) {
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<DetailsDto> detailsDtos) {
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityArrayList = new ArrayList<>();
if (detailsDtos != null && detailsDtos.size() > 0) {
for (int i = 0; i < detailsDtos.size(); i++) {
DetailsDto detailsDto = detailsDtos.get(i);
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
tocofsSaleoutDetailedEntity.setBusinessType("TOB_ORDER");
// BeanUtils.copyProperties(detailsDto, tocofsSaleoutDetailedEntity);
BeanUtil.copyPropertiesV2(detailsDto, tocofsSaleoutDetailedEntity);
tocofsSaleoutDetailedEntityArrayList.add(tocofsSaleoutDetailedEntity);
}
}
return tocofsSaleoutDetailedEntityArrayList;
}
/**
* 分组汇总公司+店铺+仓库+SKU+出库类型数量合并相加
*
* @author liuyang
*/
private Map<String, List<SonDetailsDto>> groupSummary(List<SonDetailsDto> sonDetailsDtoList) {
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
//2024年8月6日 10:35:25表头对象用于带出表头相关的分组汇总信息
HeaderDto header = sonDetailsDto.getHeader();
//公司
BdCorpEntity bdCorpEntity = sonDetailsDto.getBdCorpEntity();
//店铺主要是店铺编码
String storeCode = header.getStoreCode();
//仓库
String facilityCode = header.getFacilityCode();
//SKU
String skuCode = sonDetailsDto.getSkuCode();
//出库类型
String refOrderType = header.getRefOrderType();
StringBuffer summaryDimensionStr = new StringBuffer();
if (bdCorpEntity != null && bdCorpEntity.getPkCorp() != null) {
summaryDimensionStr.append(bdCorpEntity.getPkCorp());
} else {
summaryDimensionStr.append(NOTHING);
}
summaryDimensionStr.append(ADD);
if (storeCode != null && !"".equals(storeCode)) {
summaryDimensionStr.append(storeCode);
} else {
summaryDimensionStr.append(NOTHING);
}
summaryDimensionStr.append(ADD);
if (facilityCode != null && !"".equals(facilityCode)) {
summaryDimensionStr.append(facilityCode);
} else {
summaryDimensionStr.append(NOTHING);
}
summaryDimensionStr.append(ADD);
if (skuCode != null && !"".equals(skuCode)) {
summaryDimensionStr.append(skuCode);
} else {
summaryDimensionStr.append(NOTHING);
}
summaryDimensionStr.append(ADD);
if (refOrderType != null && !"".equals(refOrderType)) {
summaryDimensionStr.append(refOrderType);
} else {
summaryDimensionStr.append(NOTHING);
}
sonDetailsDto.setSummaryDimensionStr(summaryDimensionStr.toString());
}
logger.info("TOB{}个出库单对象需要汇总", sonDetailsDtoList.size());
return sonDetailsDtoList.stream().collect(Collectors.groupingBy(SonDetailsDto::getSummaryDimensionStr));
}
logger.info("TOB0个对象需要汇总");
return null;
}
/**
* 2024年8月6日 10:59:03 查询U8C业务流程
*
* @author liuyang
*/
private BdBusitypeEntity u8cOperationFlow() throws Exception {
//查询业务流程
//2024年8月6日 11:33:07 具体的业务流程名称还需要实施提供
String processName = "TOB销售";
BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName);
Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName);
return bdBusitypeEntity;
}
/**
* 检查参数是否为空
* 2024年8月6日 11:40:19 保险的做法最好还是验证一下
*
* @author liuyang
*/
private void checkArchives(SonDetailsDto sonDetailsDto) {
Assert.notNull(sonDetailsDto, "sonDetailsDto不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getHeader(), "header对象不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdCorpEntity(), "表头公司不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdCalbodyEntity(), "发货库存组织不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdStordocEntity(), "发货仓库不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdCalbodyEntity1(), "收货库存组织不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdStordocEntity1(), "收货库存不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdSalestruEntity(), "销售组织不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdDeptdocEntity(), "业务部门不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getBdCumandocEntity(), "客商档案不能为空 对象json{}", JSON.toJSONString(sonDetailsDto));
}
/**
* 查询存货管理档案
*
* @param pkCorp 发货公司主键
* @param detailsDto 出库单存货明细行
* @author liuyang
*/
private BdInvmandocEntity queryInventoryMan(DetailsDto detailsDto, String pkCorp) throws Exception {
Assert.notNull(detailsDto, "sonDetailsDto不能为空");
Assert.notNull(detailsDto.getSkuCode(), "O存货商家编码不能为空");
Assert.notNull(pkCorp, "发货公司主键不能为空");
BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
bdInvmandocEntity.setInvcode(detailsDto.getSkuCode());
bdInvmandocEntity.setPkCorp(pkCorp);
List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
if (bdInvmandocEntity2.size() == 0) {
Assert.state(false, "根据O商家编码{} U8C发货公司主键{}没有查询到存货管理档案", detailsDto.getSkuCode(), pkCorp);
} else if (bdInvmandocEntity2.size() >= 2) {
Assert.state(false, "根据O商家编码{} U8C发货公司主键{}没有查询到存货管理档案", detailsDto.getSkuCode(), pkCorp);
}
return bdInvmandocEntity2.get(0);
}
/**
* 合并明细行
* 单价计算公式sum(实付金额/实发数量) 最后除以条数
*
* @author liuyang
*/
private SonDetailsDto groupMergeDetailedRows(List<SonDetailsDto> sonDetailsDtoList) throws Exception {
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
BigDecimal groupTotalPayAmount = new BigDecimal("0");
BigDecimal groupShipQty = new BigDecimal("0");
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
//实付金额/实发数量
Assert.notNull(sonDetailsDto.getTotalPayAmount(), "实付金额不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
BigDecimal totalPayAmountBigDecimal = new BigDecimal(sonDetailsDto.getTotalPayAmount());
BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty());
groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal);
groupShipQty = groupShipQty.add(shipQtyBigDecimal);
}
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0);
sonDetailsDto.setGroupShipQty(groupShipQty);
sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount);
logger.info("{}个明细行发生了合并!", sonDetailsDtoList.size());
return sonDetailsDto;
} else {
logger.info("sonDetailsDtoList集合是空的");
}
return null;
}
/**
* 2024年8月7日 10:25:29
* 查询基础档案根据公司管理档案主键查询
*
* @author liuyang
*/
private BdInvbasdocEntity queryStockBasicArchives(String pkInvmandoc, String pkCorp) throws Exception {
Assert.notNull(pkInvmandoc, "存货管理档案不能为空");
Assert.notNull(pkCorp, "公司档案不能为空");
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setPk_invmandoc(pkInvmandoc);
bdInvbasdocEntity.setPk_corp(pkCorp);
List<BdInvbasdocEntity> bdInvbasdocEntity2 = iBdInvbasdocDao.queryBdInvbasdocByPkInvmandocV2(bdInvbasdocEntity);
if (bdInvbasdocEntity2.size() == 0) {
Assert.state(false, "根据存货管理档案主键{}和公司档案主键{}没有查询到U8C基础档案", pkInvmandoc, pkCorp);
} else if (bdInvbasdocEntity2.size() >= 2) {
Assert.state(false, "根据存货管理档案主键{}和公司档案主键{}没有查询到U8C基础档案", pkInvmandoc, pkCorp);
}
return bdInvbasdocEntity;
}
/**
* 2024年8月7日 14:58:34
* 查询税目档案
*
* @author liuyang
*/
private BdTaxitemsEntity queryBdTaxitems(String invcode) throws Exception {
Assert.notNull(invcode, "存货编码不能为空");
BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity();
bdTaxitemsEntity.setInvcode(invcode);
List<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
if (bdTaxitemsEntityList.size() == 0) {
Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode);
} else if (bdTaxitemsEntityList.size() >= 2) {
Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode);
}
return bdTaxitemsEntityList.get(0);
}
/**
* 2024年8月8日 10:54:48
* 推送U8C销售订单方法
*
* @author liuyang
*/
public SoSaleResultRootDto sendU8CTOCOrder(String param) {
long startLong = System.currentTimeMillis();
logger.info("TOB推送开始推送参数" + param + ",U8C_URL:" + ProfilesActiveConstant.U8C_URL);
String result = HttpRequest.post(ProfilesActiveConstant.U8C_URL).header("appId", "800037")//头信息多个头信息多次调用此方法即可
.header("usercode", "admin").header("password", "21232f297a57a5a743894a0e4a801fc3").header("system", "lz").header("trantype", "PK").header("apiCode", "8000370006")//头信息多个头信息多次调用此方法即可
.header("publicKey", "ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")//头信息多个头信息多次调用此方法即可
.header("secretKey", "fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//头信息多个头信息多次调用此方法即可
.body(param)//表单内容
.timeout(20000)//超时毫秒
.execute().body();
logger.info("TOB推送结束返回参数" + result);
long endLong = System.currentTimeMillis();
logger.info("TOB接口请求耗时" + (endLong - startLong));
JSONObject jsonObject = JSON.parseObject(result);
result = String.valueOf(jsonObject.get("attribute"));
boolean isSuccess = false;
SoSaleResultRootDto soSaleResultRootDto = null;
if (result != null && !"".equals(result)) {
ReusltStrDto reusltStrDto = JSON.parseObject(result, ReusltStrDto.class);
if ("success".equals(reusltStrDto.getStatus())) {
soSaleResultRootDto = resultDataHandle(reusltStrDto.getData());
isSuccess = true;
}
}
if (!isSuccess) {
Assert.state(false, "TOB业务O出库单推送U8C销售订单失败 接口返回结果:{}", result);
}
return soSaleResultRootDto;
}
/**
* 返回结果解析处理在确认了success后调用
*
* @author liuyang
*/
private SoSaleResultRootDto resultDataHandle(String resultData) {
try {
if (resultData != null && !"".equals(resultData)) {
if (resultData.contains("[")) {
resultData = resultData.substring(1, resultData.length() - 1);
}
return JSON.parseObject(resultData, SoSaleResultRootDto.class);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("解析返回参数失败的错误", e);
//如果解析失败记录原因但是不能影响结果的记录
}
return null;
}
}

View File

@ -455,7 +455,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
Date dbill = DateUtil.parse(shipAt);
businessFormat = DateUtil.format(dbill, "yyyy-MM-dd");
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
logger.error("业务日期转换失败", e);
}
return businessFormat;
@ -593,6 +593,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
for (int i = 0; i < detailsDtos.size(); i++) {
com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto detailsDto = detailsDtos.get(i);
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
tocofsSaleoutDetailedEntity.setBusinessType("TOC_ORDER");
// BeanUtils.copyProperties(detailsDto, tocofsSaleoutDetailedEntity);
BeanUtil.copyPropertiesV2(detailsDto, tocofsSaleoutDetailedEntity);
tocofsSaleoutDetailedEntityArrayList.add(tocofsSaleoutDetailedEntity);
@ -676,7 +677,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
private BdBusitypeEntity u8cOperationFlow() throws Exception {
//查询业务流程
//2024年8月6日 11:33:07 具体的业务流程名称还需要实施提供
String processName = "TOC销售业务流程";
String processName = "TOC销售";
BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName);
Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName);
return bdBusitypeEntity;
@ -837,6 +838,4 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
}
return null;
}
}

View File

@ -365,6 +365,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
BigDecimal noriginalcursummny = null;//价税合计
BigDecimal noriginalcurtaxmny = null;//税额=价税合计-无税金额
try {
//TODO 这个金额取错了需要取售后订单的退款金额
noriginalcurtaxprice = goodsRertunSonDetailsDto.getGroupTotalPayAmount().divide(goodsRertunSonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurmny = noriginalcurprice.multiply(goodsRertunSonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP);
@ -586,6 +587,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
ReturnGoodSearchDetailsDto returnGoodSearchDetailsDto = headerDetailsDtoList2.get(i);
TocofsReturngoodsDetailedEntity tocofsReturngoodsDetailedEntity = new TocofsReturngoodsDetailedEntity();
tocofsReturngoodsDetailedEntity.setBusinessType("TOC_RETURN");
BeanUtil.copyPropertiesV2(returnGoodSearchDetailsDto, tocofsReturngoodsDetailedEntity);
tocofsSaleoutDetailedEntityArrayList.add(tocofsReturngoodsDetailedEntity);
}
@ -670,7 +672,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
private BdBusitypeEntity u8cOperationFlow() throws Exception {
//查询业务流程
//2024年8月6日 11:33:07 具体的业务流程名称还需要实施提供
String processName = "TOC销售业务流程";
String processName = "TOC销售";
BdBusitypeEntity bdBusitypeEntity = queryBdBusitypeUtil.queryBdBusitype(processName);
Assert.notNull(bdBusitypeEntity, "根据业务流程名称({})没有查询到业务流程", processName);
return bdBusitypeEntity;

View File

@ -0,0 +1,74 @@
package com.hzya.frame.plugin.lets.u8cdto;
import com.hzya.frame.plugin.lets.entity.*;
import com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto;
import lombok.Data;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.u8cdto
* @ProjectkangarooDataCenterV3
* @nameOrderOutTobHeaderDto
* @Date2024/8/12 18:07
* @FilenameOrderOutTobHeaderDto
*/
@Data
public class OrderOutTobHeaderDto extends HeaderDetailsDto {
/**
* 表头公司销售公司视为发货公司
*/
private BdCorpEntity bdCorpEntity;
/**
* 发货库存组织
*/
private BdCalbodyEntity bdCalbodyEntity;
/**
* 入库仓库
*/
private BdStordocEntity bdStordocEntity;
/**
* 收货库存组织
*/
// private BdCalbodyEntity bdCalbodyEntity1;
/**
* 收货仓库
*/
// private BdStordocEntity bdStordocEntity1;
/**
* 销售组织
*/
private BdSalestruEntity bdSalestruEntity;
/**
* 业务部门
*/
private BdDeptdocEntity bdDeptdocEntity;
/**
* 客商管理档案
*/
private BdCumandocEntity bdCumandocEntity;
/**
* 客商基本档案
*/
private BdCubasdocEntity bdCubasdocEntity;
/**
* 发货公司
*/
private BdCorpEntity deliverGoodsCorp;
/**
* U8C平台档案
*/
private BdDefdocEntity platformArchives;
}

View File

@ -21,4 +21,7 @@
<!--调整-->
<bean name="adjustInPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.adjust.AdjustInPluginInitializer"/>
<bean name="adjustOutPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.adjust.AdjustOutPluginInitializer"/>
</beans>
<!--插入-->
<bean name="soSaleOutPluginInitializerToB" class="com.hzya.frame.plugin.lets.plugin.sales.SoSaleOutPluginInitializerToB"/>
</beans>

View File

@ -0,0 +1,31 @@
package com.hzya.frame.plugin.lets.plugin.sales;
import com.hzya.frame.WebappApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.plugin.sales
* @ProjectkangarooDataCenterV3
* @nameSoSaleOutPluginInitializerToBTest
* @Date2024/8/13 15:59
* @FilenameSoSaleOutPluginInitializerToBTest
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebappApplication.class)
public class SoSaleOutPluginInitializerToBTest {
@Autowired
private SoSaleOutPluginInitializerToB soSaleOutPluginInitializerToB;
@Test
public void startImplement() {
soSaleOutPluginInitializerToB.startImplement(null, null);
}
}

View File

@ -15,7 +15,7 @@ import com.hzya.frame.ttxofs.dto.InterfaceParamDto;
*/
public interface OfsUnifiedService {
/**
* OFS出库单查询
* OFS接口入库
*
* @author liuyang
*/