|
@@ -37,7 +37,7 @@
|
|
|
c.comp_name as compName,
|
|
|
a.warehouse_name as warehouseName,
|
|
|
q.bin_number as binNumber,
|
|
|
- a.create_date as createDate,
|
|
|
+ a.settlement_date as createDate,
|
|
|
a.contract_no as contractNo,
|
|
|
a.payment_no as paymentNo,
|
|
|
a.customer_name as customerName,
|
|
@@ -68,7 +68,7 @@
|
|
|
ROUND(a.gross_weight/1000,2) as grossWeight,
|
|
|
ROUND(a.tare/1000,2) as tare,
|
|
|
ROUND(a.weight_deduction/1000,2) as buckleWeight,
|
|
|
- ROUND(a.net_weight/1000,3) as netWeight,
|
|
|
+ ROUND(a.net_weight/1000,5) as netWeight,
|
|
|
a.unit_deduction as unitDeduction,
|
|
|
a.solid_grain_price as pureWeightPrice,
|
|
|
case when a.goods_name like '%潮粮%' then a.pure_weight else a.net_weight end as pureWeight,
|
|
@@ -79,7 +79,8 @@
|
|
|
i.bank_deposit as bankDeposit,
|
|
|
i.bank_deposit_branch as bankDepositBranch
|
|
|
FROM payment_management a
|
|
|
- left join quality_inspection_management q on q.relation_id = a.relation_id and q.comp_id = a.comp_id and q.delete_flag = 0
|
|
|
+ left join quality_inspection_management q on q.relation_id = a.relation_id and q.comp_id = a.comp_id and
|
|
|
+ q.delete_flag = 0
|
|
|
left join weighing_management w on w.relation_id = a.relation_id and w.comp_id = a.comp_id and w.delete_flag = 0
|
|
|
left join common_company c on c.comp_id = a.comp_id and c.delete_flag = 0
|
|
|
left join identity_authentication_info i on i.customer_name = a.customer_name
|
|
@@ -96,18 +97,18 @@
|
|
|
</if>
|
|
|
<if test="startDate != null">
|
|
|
AND (DATE_FORMAT(a.settlement_date,"%Y%m%d%H%m%s") >=
|
|
|
- DATE_FORMAT(#{startDate},"%Y%m%d"))
|
|
|
+ DATE_FORMAT(#{startDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
<if test="endDate != null">
|
|
|
AND (DATE_FORMAT(a.settlement_date,"%Y%m%d%H%m%s") <=
|
|
|
- DATE_FORMAT(#{endDate},"%Y%m%d"))
|
|
|
+ DATE_FORMAT(#{endDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
m.buyer as compName,
|
|
|
s.warehouse_name as warehouseName,
|
|
|
w.bin_number as binNumber,
|
|
|
- s.create_date as createDate,
|
|
|
+ w.update_date as createDate,
|
|
|
s.contract_no as contractNo,
|
|
|
'' as paymentNo,
|
|
|
m.seller as customerName,
|
|
@@ -149,8 +150,7 @@
|
|
|
i.bank_deposit_branch as bankDepositBranch
|
|
|
FROM stock_purchase_receipt_report s
|
|
|
left join warehouse_in_out_info w on w.id = s.warehouse_record_id and w.delete_flag = 0
|
|
|
- left join quality_inspection_management q on q.warehouse_in_out_id = w.id and
|
|
|
- q.delete_flag = 0
|
|
|
+ left join quality_inspection_management q on q.warehouse_in_out_id = w.id and q.delete_flag = 0
|
|
|
left join warehouse_in_out_detail wd on wd.info_id = w.id
|
|
|
left join tran_car_info t on t.contract_no = w.contract_no and t.delete_flag = 0 and t.tran_car_no =
|
|
|
w.tran_car_no and t.car_no = w.car_no
|
|
@@ -168,19 +168,19 @@
|
|
|
AND s.warehouse_name= #{warehouseName}
|
|
|
</if>
|
|
|
<if test="startDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") >=
|
|
|
- DATE_FORMAT(#{startDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") >=
|
|
|
+ DATE_FORMAT(#{startDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
<if test="endDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") <=
|
|
|
- DATE_FORMAT(#{endDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") <=
|
|
|
+ DATE_FORMAT(#{endDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
c.comp_name as compName,
|
|
|
w.warehouse_name as warehouseName,
|
|
|
w.bin_number as binNumber,
|
|
|
- w.in_out_date as createDate,
|
|
|
+ w.update_date as createDate,
|
|
|
w.contract_no as contractNo,
|
|
|
'' as paymentNo,
|
|
|
IFNULL(cmi.seller,'') as customerName,
|
|
@@ -214,8 +214,9 @@
|
|
|
IFNULL(q.deduction_amount,0) as unitDeduction,
|
|
|
'' as pureWeightPrice,
|
|
|
case when w.goods_name like '%潮粮%' then w.pure_weight else w.net_weight*1000 end as pureWeight,
|
|
|
--- ROUND(IFNULL(r.amount_ing_payable,(w.cost+IFNULL(t.tran_price,0))*t.load_net_weight),2) as amountIngPayable,
|
|
|
- case when cmi.settlement_weight_method = '1' then ROUND((w.cost-IFNULL(q.deduction_amount,0))*t.load_net_weight,2)
|
|
|
+ -- ROUND(IFNULL(r.amount_ing_payable,(w.cost+IFNULL(t.tran_price,0))*t.load_net_weight),2) as amountIngPayable,
|
|
|
+ case when cmi.settlement_weight_method = '1' then
|
|
|
+ ROUND((w.cost-IFNULL(q.deduction_amount,0))*t.load_net_weight,2)
|
|
|
else ROUND((w.cost-IFNULL(q.deduction_amount,0))*w.net_weight,2) end as amountIngPayable,
|
|
|
0 as amountEdPayable,
|
|
|
'' as payeeName,
|
|
@@ -249,12 +250,12 @@
|
|
|
AND w.warehouse_name= #{warehouseName}
|
|
|
</if>
|
|
|
<if test="startDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") >=
|
|
|
- DATE_FORMAT(#{startDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") >=
|
|
|
+ DATE_FORMAT(#{startDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
<if test="endDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") <=
|
|
|
- DATE_FORMAT(#{endDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") <=
|
|
|
+ DATE_FORMAT(#{endDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
group by w.id
|
|
|
UNION ALL
|
|
@@ -262,7 +263,7 @@
|
|
|
c.comp_name as compName,
|
|
|
w.warehouse_name as warehouseName,
|
|
|
w.bin_number as binNumber,
|
|
|
- w.create_date as createDate,
|
|
|
+ w.update_date as createDate,
|
|
|
w.contract_no as contractNo,
|
|
|
'' as paymentNo,
|
|
|
'' as customerName,
|
|
@@ -315,12 +316,12 @@
|
|
|
AND w.warehouse_name= #{warehouseName}
|
|
|
</if>
|
|
|
<if test="startDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") >=
|
|
|
- DATE_FORMAT(#{startDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") >=
|
|
|
+ DATE_FORMAT(#{startDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
<if test="endDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") <=
|
|
|
- DATE_FORMAT(#{endDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") <=
|
|
|
+ DATE_FORMAT(#{endDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
group by w.id
|
|
|
</select>
|
|
@@ -331,9 +332,9 @@
|
|
|
'' as compName,
|
|
|
w.warehouse_name as warehouseName,
|
|
|
w.bin_number as binNumber,
|
|
|
- w.create_date as createDate,
|
|
|
+ w.update_date as createDate,
|
|
|
IFNULL(m.unit_contract_price,IFNULL(w.cost,0)) as costPrice,
|
|
|
--- w.warehouse_name as contractNo,
|
|
|
+ -- w.warehouse_name as contractNo,
|
|
|
case when m.contract_type = '1' then m.contract_no else '' end as contractNo,
|
|
|
IFNULL(m.seller,'') as customerName,
|
|
|
'' as remark,
|
|
@@ -378,12 +379,10 @@
|
|
|
tti.receive_warehouse as receiveWarehouse
|
|
|
FROM warehouse_in_out_info w
|
|
|
left join warehouse_in_out_detail d on w.id=d.info_id and d.delete_flag = 0
|
|
|
- left join tran_car_info t on t.contract_no = w.contract_no and t.delete_flag = 0 and t.tran_car_no =
|
|
|
- w.tran_car_no and t.car_no = w.car_no
|
|
|
+ left join tran_car_info t on t.contract_no = w.contract_no and t.delete_flag = 0 and t.tran_car_no = w.tran_car_no and t.car_no = w.car_no
|
|
|
left join tran_task_info tti on tti.id = t.info_id and tti.delete_flag = 0
|
|
|
left join warehouse_base_info b on b.id=w.base_id and b.delete_flag = 0
|
|
|
- left join contract_management_info m on m.comp_id = b.comp_id and m.contract_no = w.warehouse_name and
|
|
|
- m.delete_flag = 0
|
|
|
+ left join contract_management_info m on m.comp_id = b.comp_id and m.contract_no = w.warehouse_name and m.delete_flag = 0
|
|
|
WHERE w.delete_flag = '0'
|
|
|
AND b.comp_id = #{compId}
|
|
|
and w.in_out_flag = 1
|
|
@@ -393,12 +392,12 @@
|
|
|
AND w.warehouse_name= #{warehouseName}
|
|
|
</if>
|
|
|
<if test="startDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") >=
|
|
|
- DATE_FORMAT(#{startDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") >=
|
|
|
+ DATE_FORMAT(#{startDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
<if test="endDate != null">
|
|
|
- AND (DATE_FORMAT(w.in_out_date,"%Y%m%d") <=
|
|
|
- DATE_FORMAT(#{endDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(w.update_date,"%Y%m%d%H%m%s") <=
|
|
|
+ DATE_FORMAT(#{endDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
UNION ALL
|
|
|
SELECT
|
|
@@ -456,8 +455,7 @@
|
|
|
left join weighing_management wm on wm.warehouse_in_out_id = w.id and wm.delete_flag = 0
|
|
|
left join tran_process_info p on p.id = s.process_id and p.delete_flag = 0
|
|
|
left join tran_task_info t on t.id = p.info_id and t.delete_flag = 0
|
|
|
- left join tran_car_info i on i.process_id = p.id and i.delete_flag = 0 and i.tran_car_no = s.tran_car_no and
|
|
|
- i.car_no = s.car_no
|
|
|
+ left join tran_car_info i on i.process_id = p.id and i.delete_flag = 0 and i.tran_car_no = s.tran_car_no and i.car_no = s.car_no
|
|
|
left join tran_settlement_report r on r.car_id = i.id and r.delete_flag = 0
|
|
|
left join cost_management_info cm on cm.warehouse_name = t.send_warehouse and cm.comp_id = t.comp_id and
|
|
|
cm.goods_name = t.goods_name and cm.delete_flag = 0
|
|
@@ -469,12 +467,12 @@
|
|
|
AND s.warehouse_name= #{warehouseName}
|
|
|
</if>
|
|
|
<if test="startDate != null">
|
|
|
- AND (DATE_FORMAT(s.delivery_date,"%Y%m%d") >=
|
|
|
- DATE_FORMAT(#{startDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(s.delivery_date,"%Y%m%d%H%m%s") >=
|
|
|
+ DATE_FORMAT(#{startDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
<if test="endDate != null">
|
|
|
- AND (DATE_FORMAT(s.delivery_date,"%Y%m%d") <=
|
|
|
- DATE_FORMAT(#{endDate},"%Y%m%d"))
|
|
|
+ AND (DATE_FORMAT(s.delivery_date,"%Y%m%d%H%m%s") <=
|
|
|
+ DATE_FORMAT(#{endDate},"%Y%m%d%H%m%s"))
|
|
|
</if>
|
|
|
GROUP BY w.id
|
|
|
ORDER BY contractNo
|
|
@@ -696,7 +694,7 @@
|
|
|
COUNT(w.id)
|
|
|
FROM
|
|
|
warehouse_base_info w
|
|
|
- LEFT JOIN warehousing_order war ON war.base_id = w.id AND war.in_type = '收购入库'
|
|
|
+ LEFT JOIN warehousing_order war ON war.base_id = w.id AND war.in_type = '收购入库'
|
|
|
AND war.delete_flag = '0'
|
|
|
WHERE
|
|
|
w.comp_id = #{compId}
|
|
@@ -717,7 +715,7 @@
|
|
|
WHEN w.delete_flag = '1' THEN
|
|
|
CONCAT( w.warehouse_name, '(已删)' ) ELSE w.warehouse_name
|
|
|
END AS warehouseName,
|
|
|
- sum( war.in_warehouse_weight ) AS acquisitionWeight,
|
|
|
+ sum( war.in_warehouse_weight ) AS acquisitionWeight,
|
|
|
(SELECT
|
|
|
sum(ssrr.settlement_weight)*sri.proportion
|
|
|
FROM
|
|
@@ -773,24 +771,24 @@
|
|
|
) AS cost
|
|
|
FROM
|
|
|
warehouse_base_info w
|
|
|
- LEFT JOIN warehousing_order war ON war.base_id = w.id AND war.in_type = '收购入库'
|
|
|
+ LEFT JOIN warehousing_order war ON war.base_id = w.id AND war.in_type = '收购入库'
|
|
|
AND war.delete_flag = '0'
|
|
|
--- LEFT JOIN source_relation_info sri ON sri.source_id = war.id
|
|
|
--- AND sri.delete_flag = '0'
|
|
|
--- LEFT JOIN in_out_warehouse_task iowt ON iowt.id = sri.task_id
|
|
|
--- AND iowt.in_out_flag = 1
|
|
|
--- AND iowt.in_out_type_key = 1
|
|
|
--- AND iowt.delete_flag = '0'
|
|
|
--- LEFT JOIN warehouse_in_out_info wioi1 ON wioi1.in_out_task_no = iowt.in_out_task_no
|
|
|
--- AND wioi1.car_no = sri.car_no
|
|
|
--- AND wioi1.delete_flag = 0
|
|
|
--- AND wioi1.status_flag = 3
|
|
|
--- LEFT JOIN stock_sale_receipt_report ssrr ON ssrr.contract_no = iowt.contract_no
|
|
|
--- AND ssrr.warehouse_record_id = wioi1.id
|
|
|
--- AND ssrr.delete_flag = 0
|
|
|
--- LEFT JOIN expense_info ei ON ei.warehouse_id = w.id and ei.delete_flag = '0'
|
|
|
--- AND ei.expenses_type = '2'
|
|
|
--- AND ei.expenses_purpose = '3'
|
|
|
+ -- LEFT JOIN source_relation_info sri ON sri.source_id = war.id
|
|
|
+ -- AND sri.delete_flag = '0'
|
|
|
+ -- LEFT JOIN in_out_warehouse_task iowt ON iowt.id = sri.task_id
|
|
|
+ -- AND iowt.in_out_flag = 1
|
|
|
+ -- AND iowt.in_out_type_key = 1
|
|
|
+ -- AND iowt.delete_flag = '0'
|
|
|
+ -- LEFT JOIN warehouse_in_out_info wioi1 ON wioi1.in_out_task_no = iowt.in_out_task_no
|
|
|
+ -- AND wioi1.car_no = sri.car_no
|
|
|
+ -- AND wioi1.delete_flag = 0
|
|
|
+ -- AND wioi1.status_flag = 3
|
|
|
+ -- LEFT JOIN stock_sale_receipt_report ssrr ON ssrr.contract_no = iowt.contract_no
|
|
|
+ -- AND ssrr.warehouse_record_id = wioi1.id
|
|
|
+ -- AND ssrr.delete_flag = 0
|
|
|
+ -- LEFT JOIN expense_info ei ON ei.warehouse_id = w.id and ei.delete_flag = '0'
|
|
|
+ -- AND ei.expenses_type = '2'
|
|
|
+ -- AND ei.expenses_purpose = '3'
|
|
|
WHERE
|
|
|
w.comp_id = #{compId}
|
|
|
AND w.warehouse_type = '1'
|