Commit 6db04e67 by chenxi

5.8.6版本 采购、调拨全链路增加产品ID字段

1 parent 8e97c574
Showing 16 changed files with 126 additions and 5 deletions
...@@ -86,4 +86,7 @@ public class GoodsWarehousingInfoDTO extends GoodsWarehousingInfo{ ...@@ -86,4 +86,7 @@ public class GoodsWarehousingInfoDTO extends GoodsWarehousingInfo{
@ApiModelProperty(notes="所属商户(主服务商)商户名称") @ApiModelProperty(notes="所属商户(主服务商)商户名称")
private String partnerMerchantName; private String partnerMerchantName;
@ApiModelProperty(notes = "产品ID")
private String commodityCode;
} }
...@@ -24,6 +24,8 @@ public class MerchantGoodsStockReduceRecordDTO extends MerchantGoodsStockReduceR ...@@ -24,6 +24,8 @@ public class MerchantGoodsStockReduceRecordDTO extends MerchantGoodsStockReduceR
@ApiModelProperty(notes="商品名称") @ApiModelProperty(notes="商品名称")
private String upgradeGoodsName; private String upgradeGoodsName;
private String commodityCode;
@ApiModelProperty(notes="系列") @ApiModelProperty(notes="系列")
private String goodsSeries; private String goodsSeries;
......
...@@ -208,5 +208,9 @@ public class StockAllocateDeliveryListDTO implements Serializable { ...@@ -208,5 +208,9 @@ public class StockAllocateDeliveryListDTO implements Serializable {
@ApiModelProperty(notes = "关联采购订单编号") @ApiModelProperty(notes = "关联采购订单编号")
private String purchaseOrderCode; private String purchaseOrderCode;
/**
* 产品ID(升级商品编码),模糊匹配采购订单商品
*/
@ApiModelProperty(notes = "产品ID")
private String commodityCode;
} }
...@@ -79,4 +79,9 @@ public class StockAllocateDeliveryPageDTO implements Serializable { ...@@ -79,4 +79,9 @@ public class StockAllocateDeliveryPageDTO implements Serializable {
@ApiModelProperty(notes = "关联采购订单编号") @ApiModelProperty(notes = "关联采购订单编号")
private String purchaseOrderCode; private String purchaseOrderCode;
/**
* 产品ID(升级商品编码),模糊匹配采购订单商品
*/
private String commodityCode;
} }
...@@ -94,4 +94,10 @@ public class StockAllocateRecordDTO extends StockAllocateRecord implements Seria ...@@ -94,4 +94,10 @@ public class StockAllocateRecordDTO extends StockAllocateRecord implements Seria
*/ */
@ApiModelProperty(notes = "关联采购订单编号") @ApiModelProperty(notes = "关联采购订单编号")
private String purchaseOrderCode; private String purchaseOrderCode;
/**
* 产品ID(升级商品编码),模糊匹配采购订单商品
*/
private String commodityCode;
} }
...@@ -60,4 +60,6 @@ public class StockAllocateRecordExportDTO extends StockAllocateRecord implements ...@@ -60,4 +60,6 @@ public class StockAllocateRecordExportDTO extends StockAllocateRecord implements
@ApiModelProperty(notes = "0-未发货,1-全部发货,2-部分发货") @ApiModelProperty(notes = "0-未发货,1-全部发货,2-部分发货")
private String deliveryStatusName; private String deliveryStatusName;
private String commodityCode;
} }
...@@ -46,6 +46,12 @@ public class StockFlowDTO implements Serializable { ...@@ -46,6 +46,12 @@ public class StockFlowDTO implements Serializable {
private String upgradeGoodsName; private String upgradeGoodsName;
/** /**
* 产品ID
*/
@ApiModelProperty(notes = "产品ID")
private String commodityCode;
/**
* 商品编码 * 商品编码
*/ */
@ApiModelProperty(notes = "商品编码") @ApiModelProperty(notes = "商品编码")
......
...@@ -164,4 +164,6 @@ public class PurchaseOrderGoodsPageDTO extends PurchaseOrderGoods { ...@@ -164,4 +164,6 @@ public class PurchaseOrderGoodsPageDTO extends PurchaseOrderGoods {
private List<Integer> signStatusList; private List<Integer> signStatusList;
private String signStatusStr; private String signStatusStr;
private String commodityCode;
} }
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
<result column="goods_type_name" jdbcType="VARCHAR" property="goodsTypeName" /> <result column="goods_type_name" jdbcType="VARCHAR" property="goodsTypeName" />
<result column="goods_type" jdbcType="INTEGER" property="goodsType" /> <result column="goods_type" jdbcType="INTEGER" property="goodsType" />
<result column="product_code" jdbcType="VARCHAR" property="productCode"/> <result column="product_code" jdbcType="VARCHAR" property="productCode"/>
<result column="commodity_code" jdbcType="VARCHAR" property="commodityCode"/>
<result column="dclsar_call_out_yq_merchant_id" jdbcType="INTEGER" property="stockAllocateCallOutYqMerchantId" /> <result column="dclsar_call_out_yq_merchant_id" jdbcType="INTEGER" property="stockAllocateCallOutYqMerchantId" />
<result column="specification_data" property="specificationData"/> <result column="specification_data" property="specificationData"/>
<result column="specification_type_sequence" property="specificationTypeSequence"/> <result column="specification_type_sequence" property="specificationTypeSequence"/>
...@@ -90,6 +91,10 @@ ...@@ -90,6 +91,10 @@
<if test="upgradeGoodsName !=null and upgradeGoodsName !=''"> <if test="upgradeGoodsName !=null and upgradeGoodsName !=''">
and dclug.upgrade_goods_name like concat('%', #{upgradeGoodsName}, '%') and dclug.upgrade_goods_name like concat('%', #{upgradeGoodsName}, '%')
</if> </if>
<if test="commodityCode !=null and commodityCode !=''">
and dclug.commodity_code like concat('%', #{commodityCode}, '%')
</if>
<if test="yqMerchantId !=null and yqMerchantId !='' "> <if test="yqMerchantId !=null and yqMerchantId !='' ">
and dclgwi.yq_merchant_id = #{yqMerchantId} and dclgwi.yq_merchant_id = #{yqMerchantId}
</if> </if>
...@@ -165,7 +170,7 @@ ...@@ -165,7 +170,7 @@
delivery_number, yq_merchant_id, yq_merchant_name, shop_type, dclgwi.merchant_id, merchant_name,dclgwi.upgrade_flag, dclgwi.delivery_detail_id, delivery_number, yq_merchant_id, yq_merchant_name, shop_type, dclgwi.merchant_id, merchant_name,dclgwi.upgrade_flag, dclgwi.delivery_detail_id,
dclgwi.purchase_order_goods_id,dclgwi.allocate_order_goods_id, dclgwi.purchase_order_goods_id,dclgwi.allocate_order_goods_id,
dclgwi.created_by, dclgwi.created_date, dclgwi.updated_by, dclgwi.updated_date, dclgwi.deleted_flag, dclgwi.updated_user_name, dclug.type as product_code, dclgwi.created_by, dclgwi.created_date, dclgwi.updated_by, dclgwi.updated_date, dclgwi.deleted_flag, dclgwi.updated_user_name, dclug.type as product_code,
dclug.specification_data,dclug.specification_type_sequence, dclgwi.inventory_type, dclgwi.warehousing_method dclug.specification_data,dclug.specification_type_sequence, dclug.commodity_code, dclgwi.inventory_type, dclgwi.warehousing_method
from dj_car_life_goods_warehousing_info dclgwi from dj_car_life_goods_warehousing_info dclgwi
left join dj_car_life_upgrade_goods dclug on dclgwi.upgrade_goods_id = dclug.id left join dj_car_life_upgrade_goods dclug on dclgwi.upgrade_goods_id = dclug.id
left join dj_car_life_goods_info dclgi on dclgi.deleted_flag = 'N' and dclgi.goods_code = dclug.goods_code left join dj_car_life_goods_info dclgi on dclgi.deleted_flag = 'N' and dclgi.goods_code = dclug.goods_code
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="DTOResultMap" type="cn.com.glsx.dj.smartcarlife.dto.MerchantGoodsStockReduceRecordDTO"> <resultMap extends="BaseResultMap" id="DTOResultMap" type="cn.com.glsx.dj.smartcarlife.dto.MerchantGoodsStockReduceRecordDTO">
<result column="upgrade_goods_name" jdbcType="VARCHAR" property="upgradeGoodsName" /> <result column="upgrade_goods_name" jdbcType="VARCHAR" property="upgradeGoodsName" />
<result column="commodity_code" jdbcType="VARCHAR" property="commodityCode" />
<result column="goods_series" jdbcType="VARCHAR" property="goodsSeries" /> <result column="goods_series" jdbcType="VARCHAR" property="goodsSeries" />
<result column="goods_type_name" jdbcType="VARCHAR" property="goodsTypeName" /> <result column="goods_type_name" jdbcType="VARCHAR" property="goodsTypeName" />
<result column="goods_type" jdbcType="INTEGER" property="goodsType" /> <result column="goods_type" jdbcType="INTEGER" property="goodsType" />
...@@ -82,6 +83,9 @@ ...@@ -82,6 +83,9 @@
<if test="upgradeGoodsName != null and upgradeGoodsName != ''"> <if test="upgradeGoodsName != null and upgradeGoodsName != ''">
and dclug.upgrade_goods_name like CONCAT('%', #{upgradeGoodsName},'%') and dclug.upgrade_goods_name like CONCAT('%', #{upgradeGoodsName},'%')
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
and dclug.commodity_code like CONCAT('%', #{commodityCode},'%')
</if>
<if test="yqMerchantId != null"> <if test="yqMerchantId != null">
and dclmgsrr.yq_merchant_id = #{yqMerchantId} and dclmgsrr.yq_merchant_id = #{yqMerchantId}
</if> </if>
...@@ -127,7 +131,7 @@ ...@@ -127,7 +131,7 @@
reduce_stock_money, business_code,dclmgsrr.upgrade_flag, dclmgsrr.film_roll_no, reduce_stock_money, business_code,dclmgsrr.upgrade_flag, dclmgsrr.film_roll_no,
event_type, dclmgsrr.technician_phone,dclmgsrr.technician_name,dclmgsrr.remark, dclmgsrr.inventory_type, event_type, dclmgsrr.technician_phone,dclmgsrr.technician_name,dclmgsrr.remark, dclmgsrr.inventory_type,
dclmgsrr.created_by, dclmgsrr.created_date, dclmgsrr.updated_by,dclmgsrr.updated_user_name, dclmgsrr.updated_date, dclmgsrr.created_by, dclmgsrr.created_date, dclmgsrr.updated_by,dclmgsrr.updated_user_name, dclmgsrr.updated_date,
dclmgsrr.deleted_flag, dclmgsrr.store_usage, dclmgsrr.order_upgrade_goods_id, dclug.upgrade_goods_name, dclug.type as product_code, dclmgsrr.deleted_flag, dclmgsrr.store_usage, dclmgsrr.order_upgrade_goods_id, dclug.upgrade_goods_name, dclug.commodity_code, dclug.type as product_code,
dclug.specification_data,dclug.specification_type_sequence, dclmgsrr.inventory_type,po.success_date,dclmgsrr.reduce_method dclug.specification_data,dclug.specification_type_sequence, dclmgsrr.inventory_type,po.success_date,dclmgsrr.reduce_method
from dj_car_life_merchant_goods_stock_reduce_record dclmgsrr from dj_car_life_merchant_goods_stock_reduce_record dclmgsrr
left join dj_car_life_upgrade_goods dclug on dclmgsrr.upgrade_goods_id = dclug.id left join dj_car_life_upgrade_goods dclug on dclmgsrr.upgrade_goods_id = dclug.id
......
...@@ -225,6 +225,22 @@ ...@@ -225,6 +225,22 @@
<if test="orderDeliveryId != null"> <if test="orderDeliveryId != null">
and dclpodd.order_delivery_id = #{orderDeliveryId} and dclpodd.order_delivery_id = #{orderDeliveryId}
</if> </if>
<if test="upgradeCommodityCode != null and upgradeCommodityCode != ''">
and exists (
select 1
from dj_car_life_purchase_order_delivery_detail dd2
left join dj_car_life_purchase_order_goods og2
on og2.order_code = dd2.order_code
and og2.id = dd2.purchase_order_goods_id
and og2.deleted_flag = 'N'
where dd2.deleted_flag = 'N'
and dd2.order_delivery_id = dclpodd.order_delivery_id
and og2.upgrade_goods_commodity_code like CONCAT('%', #{upgradeCommodityCode},'%')
)
</if>
</where> </where>
order by dclpod.delivery_date desc, dclpodd.id desc order by dclpod.delivery_date desc, dclpodd.id desc
</select> </select>
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
<result column="detail_purchase_goods_name" jdbcType="VARCHAR" property="purchaseGoodsName" /> <result column="detail_purchase_goods_name" jdbcType="VARCHAR" property="purchaseGoodsName" />
<result column="detail_third_party_code" jdbcType="VARCHAR" property="thirdPartyCode" /> <result column="detail_third_party_code" jdbcType="VARCHAR" property="thirdPartyCode" />
<result column="detail_third_party_name" jdbcType="VARCHAR" property="thirdPartyName" /> <result column="detail_third_party_name" jdbcType="VARCHAR" property="thirdPartyName" />
<result column="detail_upgrade_goods_commodity_code" jdbcType="VARCHAR" property="upgradeCommodityCode" />
</collection> </collection>
</resultMap> </resultMap>
...@@ -116,6 +117,7 @@ ...@@ -116,6 +117,7 @@
dd.purchase_goods_name as detail_purchase_goods_name, dd.purchase_goods_name as detail_purchase_goods_name,
dd.third_party_code as detail_third_party_code, dd.third_party_code as detail_third_party_code,
dd.third_party_name as detail_third_party_name, dd.third_party_name as detail_third_party_name,
dclpog.upgrade_goods_commodity_code as detail_upgrade_goods_commodity_code,
dclpog.specification_data as detail_specification_data dclpog.specification_data as detail_specification_data
from (select id, from (select id,
order_code, order_code,
...@@ -179,6 +181,7 @@ ...@@ -179,6 +181,7 @@
dd.purchase_goods_name as detail_purchase_goods_name, dd.purchase_goods_name as detail_purchase_goods_name,
dd.third_party_code as detail_third_party_code, dd.third_party_code as detail_third_party_code,
dd.third_party_name as detail_third_party_name, dd.third_party_name as detail_third_party_name,
dclpog.upgrade_goods_commodity_code as detail_upgrade_goods_commodity_code,
if(main.order_type = 1, sar.remark, po.remark) as purchase_order_remark, if(main.order_type = 1, sar.remark, po.remark) as purchase_order_remark,
concat(ifnull(if(main.order_type = 1, sar.remark, po.remark), ''), ifnull(dd.delivery_remark, '')) as detail_delivery_remark, concat(ifnull(if(main.order_type = 1, sar.remark, po.remark), ''), ifnull(dd.delivery_remark, '')) as detail_delivery_remark,
if(main.order_type = 1, sad.specification_data, dclpog.specification_data) as detail_specification_data, if(main.order_type = 1, sad.specification_data, dclpog.specification_data) as detail_specification_data,
...@@ -254,6 +257,7 @@ ...@@ -254,6 +257,7 @@
sad.specification_data as detail_specification_data, sad.specification_data as detail_specification_data,
dd.purchase_order_goods_id as detail_purchase_order_goods_id, dd.purchase_order_goods_id as detail_purchase_order_goods_id,
dd.allocate_order_goods_id as detail_allocate_order_goods_id, dd.allocate_order_goods_id as detail_allocate_order_goods_id,
dclpog.upgrade_goods_commodity_code as detail_upgrade_goods_commodity_code,
sar.created_by as allocate_createdBy, sar.created_by as allocate_createdBy,
sar.call_in_merchant_id as allocate_callInMerchantId, sar.call_in_merchant_id as allocate_callInMerchantId,
sar.call_in_merchant_name as allocate_callInMerchantName, sar.call_in_merchant_name as allocate_callInMerchantName,
...@@ -297,6 +301,7 @@ ...@@ -297,6 +301,7 @@
) main ) main
left join dj_car_life_purchase_order_delivery_detail dd on dd.deleted_flag = 'N' and main.id = dd.order_delivery_id left join dj_car_life_purchase_order_delivery_detail dd on dd.deleted_flag = 'N' and main.id = dd.order_delivery_id
left join dj_car_life_stock_allocate_detail sad on sad.deleted_flag = 'N' and sad.allocate_code = dd.order_code and sad.goods_id = dd.upgrade_goods_id left join dj_car_life_stock_allocate_detail sad on sad.deleted_flag = 'N' and sad.allocate_code = dd.order_code and sad.goods_id = dd.upgrade_goods_id
left join dj_car_life_purchase_order_goods dclpog on dclpog.id = dd.purchase_order_goods_id and dclpog.deleted_flag = 'N'
left join dj_car_life_stock_allocate_record sar on sar.allocate_code = sad.allocate_code and sar.deleted_flag = 'N' left join dj_car_life_stock_allocate_record sar on sar.allocate_code = sad.allocate_code and sar.deleted_flag = 'N'
order by main.delivery_date desc order by main.delivery_date desc
/*customLimitPlace*/ /*customLimitPlace*/
......
...@@ -718,6 +718,16 @@ ...@@ -718,6 +718,16 @@
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
and exists(
select 1
from dj_car_life_purchase_order_goods og2
where og2.order_code = po.order_code
and og2.deleted_flag = 'N'
and og2.is_allocate = 0
and og2.upgrade_goods_commodity_code like CONCAT('%', #{commodityCode},'%')
)
</if>
</where> </where>
</sql> </sql>
......
...@@ -657,6 +657,15 @@ ...@@ -657,6 +657,15 @@
<if test="onlyAllocateOrder != null and onlyAllocateOrder"> <if test="onlyAllocateOrder != null and onlyAllocateOrder">
and dclpog.is_allocate = 1 and dclpog.is_allocate = 1
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
and exists (
select 1
from dj_car_life_purchase_order_goods pog2
where pog2.deleted_flag = 'N'
and pog2.order_code = po.order_code
and pog2.upgrade_goods_commodity_code like concat('%',#{commodityCode},'%')
)
</if>
</where> </where>
order by (case when po.status = 1 then 3 order by (case when po.status = 1 then 3
when po.status in (2,5,8,10) then 2 when po.status in (2,5,8,10) then 2
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
<result column="type" jdbcType="VARCHAR" property="productCode"/> <result column="type" jdbcType="VARCHAR" property="productCode"/>
<result column="specification_data" property="specificationData"/> <result column="specification_data" property="specificationData"/>
<result column="specification_type_sequence" property="specificationTypeSequence"/> <result column="specification_type_sequence" property="specificationTypeSequence"/>
<result column="commodity_code" property="commodityCode"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -130,6 +131,16 @@ ...@@ -130,6 +131,16 @@
<if test="purchaseOrderCode != null and purchaseOrderCode != ''"> <if test="purchaseOrderCode != null and purchaseOrderCode != ''">
and ar.purchase_order_code like concat('%',#{purchaseOrderCode},'%') and ar.purchase_order_code like concat('%',#{purchaseOrderCode},'%')
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
and exists (
select 1
from dj_car_life_stock_allocate_detail ad
left join dj_car_life_upgrade_goods ug on ug.id = ad.goods_id and ug.deleted_flag = 'N'
where ad.deleted_flag = 'N'
and ad.allocate_code = ar.allocate_code
and ug.commodity_code like concat('%',#{commodityCode},'%')
)
</if>
</where> </where>
</sql> </sql>
...@@ -161,7 +172,7 @@ ...@@ -161,7 +172,7 @@
ad.goods_type_name as ad_goods_type_name, ad.allocate_number as ad_allocate_number, ad.goods_type_name as ad_goods_type_name, ad.allocate_number as ad_allocate_number,
ad.film_roll_no as ad_film_roll_no, ad.film_roll_no as ad_film_roll_no,
ug.specification_data,ug.specification_type_sequence,ug.type ug.specification_data,ug.specification_type_sequence,ug.type, ug.commodity_code
from dj_car_life_stock_allocate_detail ad from dj_car_life_stock_allocate_detail ad
left join dj_car_life_stock_allocate_record ar on ar.allocate_code = ad.allocate_code and ar.deleted_flag = 'N' left join dj_car_life_stock_allocate_record ar on ar.allocate_code = ad.allocate_code and ar.deleted_flag = 'N'
...@@ -217,9 +228,11 @@ ...@@ -217,9 +228,11 @@
b.address as address, b.address as address,
a.delivery_status as deliveryStatus, a.delivery_status as deliveryStatus,
b.bill_status as billStatus, b.bill_status as billStatus,
b.remark as remark b.remark as remark,
dclpog.commodity_code as commodityCode
from dj_car_life_stock_allocate_detail a from dj_car_life_stock_allocate_detail a
left join dj_car_life_upgrade_goods dclpog on a.goods_id = dclpog.id and dclpog.deleted_flag = 'N'
left join dj_car_life_stock_allocate_record b left join dj_car_life_stock_allocate_record b
on a.allocate_code = b.allocate_code and b.deleted_flag = 'N' on a.allocate_code = b.allocate_code and b.deleted_flag = 'N'
where a.deleted_flag = 'N' where a.deleted_flag = 'N'
...@@ -251,6 +264,16 @@ ...@@ -251,6 +264,16 @@
<if test="purchaseOrderCode != null and purchaseOrderCode != ''"> <if test="purchaseOrderCode != null and purchaseOrderCode != ''">
and a.purchase_order_code like concat('%',#{purchaseOrderCode},'%') and a.purchase_order_code like concat('%',#{purchaseOrderCode},'%')
</if> </if>
<if test="commodityCode !=null and commodityCode !=''">
and exists (
select 1
from dj_car_life_stock_allocate_detail ad2
left join dj_car_life_upgrade_goods ug2 on ad2.goods_id = ug2.id and ug2.deleted_flag = 'N'
where ad2.deleted_flag = 'N'
and ad2.allocate_code = b.allocate_code
and ug2.commodity_code like concat('%', #{commodityCode}, '%')
)
</if>
and b.bill_status in (5, 7) and b.bill_status in (5, 7)
order by b.allocate_time desc order by b.allocate_time desc
</select> </select>
...@@ -327,6 +350,16 @@ ...@@ -327,6 +350,16 @@
<if test="purchaseOrderCode != null and purchaseOrderCode != ''"> <if test="purchaseOrderCode != null and purchaseOrderCode != ''">
and ar.purchase_order_code like concat('%',#{purchaseOrderCode},'%') and ar.purchase_order_code like concat('%',#{purchaseOrderCode},'%')
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
and exists (
select 1
from dj_car_life_stock_allocate_detail ad2
left join dj_car_life_upgrade_goods ug2 on ug2.id = ad2.goods_id and ug2.deleted_flag = 'N'
where ad2.deleted_flag = 'N'
and ad2.allocate_code = ar.allocate_code
and ug2.commodity_code like concat('%',#{commodityCode},'%')
)
</if>
</where> </where>
</sql> </sql>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<result column="operate_time" property="operateTime" jdbcType="TIMESTAMP"/> <result column="operate_time" property="operateTime" jdbcType="TIMESTAMP"/>
<result column="flow_time" property="flowTime" jdbcType="TIMESTAMP"/> <result column="flow_time" property="flowTime" jdbcType="TIMESTAMP"/>
<result column="upgrade_goods_name" property="upgradeGoodsName" jdbcType="VARCHAR"/> <result column="upgrade_goods_name" property="upgradeGoodsName" jdbcType="VARCHAR"/>
<result column="commodity_code" property="commodityCode" jdbcType="VARCHAR"/>
<result column="product_code" property="productCode" jdbcType="VARCHAR"/> <result column="product_code" property="productCode" jdbcType="VARCHAR"/>
<result column="specification_data" property="specificationData" jdbcType="VARCHAR"/> <result column="specification_data" property="specificationData" jdbcType="VARCHAR"/>
<result column="specification_type_sequence" property="specificationTypeSequence" jdbcType="VARCHAR"/> <result column="specification_type_sequence" property="specificationTypeSequence" jdbcType="VARCHAR"/>
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
i.created_date AS flow_time, i.created_date AS flow_time,
i.increase_time AS operate_time, i.increase_time AS operate_time,
ug.upgrade_goods_name, ug.upgrade_goods_name,
ug.commodity_code,
ug.type AS product_code, ug.type AS product_code,
ug.specification_data, ug.specification_data,
ug.specification_type_sequence, ug.specification_type_sequence,
...@@ -71,6 +73,9 @@ ...@@ -71,6 +73,9 @@
<if test="upgradeGoodsName != null and upgradeGoodsName != ''"> <if test="upgradeGoodsName != null and upgradeGoodsName != ''">
AND ug.upgrade_goods_name LIKE CONCAT('%', #{upgradeGoodsName}, '%') AND ug.upgrade_goods_name LIKE CONCAT('%', #{upgradeGoodsName}, '%')
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
AND ug.commodity_code LIKE CONCAT('%', #{commodityCode}, '%')
</if>
<if test="productCode != null and productCode != ''"> <if test="productCode != null and productCode != ''">
AND ug.type LIKE CONCAT('%', #{productCode}, '%') AND ug.type LIKE CONCAT('%', #{productCode}, '%')
</if> </if>
...@@ -99,6 +104,7 @@ ...@@ -99,6 +104,7 @@
r.created_date AS flow_time, r.created_date AS flow_time,
r.reduce_date AS operate_time, r.reduce_date AS operate_time,
ug.upgrade_goods_name, ug.upgrade_goods_name,
ug.commodity_code,
ug.`type` AS product_code, ug.`type` AS product_code,
ug.specification_data, ug.specification_data,
ug.specification_type_sequence, ug.specification_type_sequence,
...@@ -134,6 +140,9 @@ ...@@ -134,6 +140,9 @@
<if test="upgradeGoodsName != null and upgradeGoodsName != ''"> <if test="upgradeGoodsName != null and upgradeGoodsName != ''">
AND ug.upgrade_goods_name LIKE CONCAT('%', #{upgradeGoodsName}, '%') AND ug.upgrade_goods_name LIKE CONCAT('%', #{upgradeGoodsName}, '%')
</if> </if>
<if test="commodityCode != null and commodityCode != ''">
AND ug.commodity_code LIKE CONCAT('%', #{commodityCode}, '%')
</if>
<if test="productCode != null and productCode != ''"> <if test="productCode != null and productCode != ''">
AND ug.type LIKE CONCAT('%', #{productCode}, '%') AND ug.type LIKE CONCAT('%', #{productCode}, '%')
</if> </if>
......
  • @wangxw1
    commented
    Master

    这是一份针对您提交代码的专业审查报告。代码整体逻辑清晰,提交信息明确,但在数据库查询规范、性能以及API规范上存在几个需要重点关注的问题。

    一、关键问题与优化建议(Top 3)

    1. 严重违规:MyBatis SQL 语句中使用了被禁止的子查询(最高优先级)

    • 问题描述:在 PurchaseOrderDeliveryDetailMapper.xml、PurchaseOrderGoodsMapper.xml、PurchaseOrderMapper.xml 以及 StockAllocateRecordMapper.xml 等多个文件中,为了实现 commodityCode 的过滤,大量使用了 EXISTS (select 1 ...) 子查询。这直接违反了“mybatis的sql语句不允许使用子查询”的强制架构规则。
    • 影响分析:子查询(尤其是相关子查询)在数据量增大时会导致严重的性能衰退,且不利于 DBA 进行慢查询优化和索引命中分析。
    • 优化建议:将 EXISTS 子查询改写为在主查询中使用 JOIN(如 INNER JOIN 或 LEFT JOIN),并配合 DISTINCT 或 GROUP BY 来去重主表记录。 代码示例(思路): ```xml <!-- 错误示范 (当前实现) --> and exists (select 1 from dj_car_life_purchase_order_goods og2 where og2.order_code = po.order_code and og2.upgrade_goods_commodity_code like ...)

    <!-- 建议改写 (需在主 SQL 的 FROM 处引入 JOIN) --> <!-- 主 SQL 中加入: LEFT JOIN dj_car_life_purchase_order_goods og ON og.order_code = po.order_code --> and og.upgrade_goods_commodity_code = #{commodityCode} <!-- 注意:使用 JOIN 后如果一对多会导致主表数据重复,请在 SELECT 处使用 DISTINCT 或在末尾 GROUP BY 主键 -->

    
    **2. 性能隐患:全表扫描风险(双前缀模糊查询)**
    - **问题描述**:所有新增的 `commodityCode` 查询条件均使用了 `LIKE CONCAT('%', #{commodityCode}, '%')`。
    - **影响分析**:`commodityCode`(产品ID)通常具有唯一性或高区分度。使用前导通配符(`%` 开头)会导致数据库无法使用该字段的 B-Tree 索引,直接引发全表扫描。在订单、流水等核心大表中,极易引发数据库 CPU 飙升和慢查询,拖垮整体服务稳定性。
    - **优化建议**:对于产品ID/编码这种字段,业务上通常是精确查找。强烈建议改为精确匹配 ` = #{commodityCode}`。如果业务确实要求支持模糊输入,请改为右模糊 `LIKE CONCAT(#{commodityCode}, '%')` 以保证索引能够命中。
    
    **3. 最佳实践:RPC API DTO 注释缺失与命名一致性**
    - **问题描述**:
      1. 此次修改涉及 `rpc-dj-smartcarlife-api` 下的多个 DTO。虽然是新增字段(未违反“变更已有参数”的红线),但部分类(如 `StockAllocateRecordExportDTO`、`MerchantGoodsStockReduceRecordDTO`、`StockAllocateDeliveryPageDTO`)中新增的 `commodityCode` 缺少 `@ApiModelProperty` 注解。
      2. 命名不完全一致:在 XML 映射中,部分地方别名被定义为 `upgradeCommodityCode`,而 DTO 中统一定义为 `commodityCode`,可能在对象映射时产生混淆。
    - **影响分析**:缺失注解会导致下游调用方(或前端)无法通过 Swagger/API 文档获知该字段的含义,增加沟通成本。
    - **优化建议**:为所有 DTO 中的 `commodityCode` 补全 `@ApiModelProperty(notes = "产品ID")` 注解;检查 MyBatis 返回的列名与 DTO 属性名是否完全一致,确保反序列化映射成功。
    
    ---
    
    #### 二、评分明细
    
    - **功能实现的正确性与健壮性(20/40分)**:
      *扣分原因*:严重违反了“MyBatis 不允许使用子查询”的硬性规定,多处使用了 `EXISTS` 语句,存在功能在生产环境大数据量下超时的风险。新增 RPC 字段未破坏已有字段,符合兼容性要求。
    - **安全性与潜在风险(25/30分)**:
      *扣分原因*:使用了安全的 `#{}` 防止了 SQL 注入,但大量使用 `%keyword%` 模糊查询核心业务表,存在引发数据库慢查询拖垮服务的可用性风险(可用性属于广义安全性)。
    - **最佳实践与可维护性(15/20分)**:
      *扣分原因*:API 包下的 DTO 缺少必要的 Swagger 注解,且部分 SQL 别名与 DTO 字段命名风格存在细微割裂,影响可读性与文档生成。
    - **性能与资源利用(1/5分)**:
      *扣分原因*:`EXISTS` 相关子查询叠加全表扫描的 `LIKE '%...%'`,是对数据库性能极不友好的组合,必须整改。
    - **提交信息质量(5/5分)**:
      *得分原因*:Commit 信息“5.8.6版本 采购、调拨全链路增加产品ID字段”清晰、准确,指明了版本号、业务范围和具体改动,可追溯性极强。
    
    总分:66分
    
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!