Commit 27b269c1efdead67b006d8060d0651cc4a9c4eae

Authored by 房远帅
1 parent 3829c3f3

过磅码单、化验送样单:增加数据权限查询

@@ -112,6 +112,12 @@ public GetXxxBo(Xxx dto) { @@ -112,6 +112,12 @@ public GetXxxBo(Xxx dto) {
112 **后果**:DB 列 → 实体 → VO/Bo → XML → 前端字段各层对不上,联调时前端要额外记忆映射关系,后续维护者搜字段名搜不全,返工改名牵扯全链路(SQL/实体/VO/Bo/XML/前端传参全要动)。 112 **后果**:DB 列 → 实体 → VO/Bo → XML → 前端字段各层对不上,联调时前端要额外记忆映射关系,后续维护者搜字段名搜不全,返工改名牵扯全链路(SQL/实体/VO/Bo/XML/前端传参全要动)。
113 **正确做法**:动手前先 Grep 源表字段在项目里的既有命名,新表字段、实体属性、VO/Bo 字段、XML 列名、前端传参**全部沿用同一名字**;仅在语义确实不同(如"品种代号 category"与"品种ID product_id"是两个东西)时才用不同字段名。 113 **正确做法**:动手前先 Grep 源表字段在项目里的既有命名,新表字段、实体属性、VO/Bo 字段、XML 列名、前端传参**全部沿用同一名字**;仅在语义确实不同(如"品种代号 category"与"品种ID product_id"是两个东西)时才用不同字段名。
114 114
  115 +## 19. XML 里主表别名统一用 tb,禁止自创缩写别名
  116 +
  117 +**坑**:写新查询时自创主表缩写别名(如 `pwt`/`paa`),甚至 FROM 定义的别名与 SELECT/WHERE 用的不一致——`FROM procurement_weighing_ticket AS tb` 但各处引用 `pwt.xxx`,运行时报"Unknown column 'pwt.id'"。项目全库(30+ 个 Mapper XML)惯例是**主表别名一律 `tb`**。
  118 +**后果**:SQL 运行时才报错(Java 诊断查不出);别名不一致的 SQL 拷贝拼接时极易引入此类错误。
  119 +**正确做法**:任何 XML 的主表(业务单据自身表)统一写 `FROM 表名 AS tb`,SELECT/WHERE/JOIN ON/ORDER BY 全部用 `tb.` 前缀;只有 JOIN 进来的关联表才用有区分度的别名(如 `ws`、`bdcs`、子表 `pwtp`、明细 `pwtl`)。新写 SQL 前先看同目录既有 XML 的别名写法,保持一致。
  120 +
115 --- 121 ---
116 122
117 ## 回写模板(新增踩坑时复制) 123 ## 回写模板(新增踩坑时复制)
1 package com.lframework.xingyun.sc.procurement.mappers.weighing; 1 package com.lframework.xingyun.sc.procurement.mappers.weighing;
2 2
  3 +import com.lframework.starter.web.core.annotations.permission.DataPermission;
  4 +import com.lframework.starter.web.core.annotations.permission.DataPermissions;
3 import com.lframework.starter.web.core.mapper.BaseMapper; 5 import com.lframework.starter.web.core.mapper.BaseMapper;
  6 +import com.lframework.starter.web.inner.components.permission.OrderDataPermissionDataPermissionType;
4 import com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo; 7 import com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo;
5 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply; 8 import com.lframework.xingyun.sc.procurement.entity.weighing.ProcurementAssayApply;
6 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryAssaySelectableTicketVo; 9 import com.lframework.xingyun.sc.procurement.vo.weighing.QueryAssaySelectableTicketVo;
@@ -10,6 +13,9 @@ import org.apache.ibatis.annotations.Param; @@ -10,6 +13,9 @@ import org.apache.ibatis.annotations.Param;
10 13
11 public interface ProcurementAssayApplyMapper extends BaseMapper<ProcurementAssayApply> { 14 public interface ProcurementAssayApplyMapper extends BaseMapper<ProcurementAssayApply> {
12 15
  16 + @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = {
  17 + @DataPermission(template = "order", alias = "tb")
  18 + })
13 List<ProcurementAssayApply> query(@Param("vo") QueryProcurementAssayApplyVo vo); 19 List<ProcurementAssayApply> query(@Param("vo") QueryProcurementAssayApplyVo vo);
14 20
15 ProcurementAssayApply findById(@Param("id") String id); 21 ProcurementAssayApply findById(@Param("id") String id);
1 package com.lframework.xingyun.sc.procurement.mappers.weighing; 1 package com.lframework.xingyun.sc.procurement.mappers.weighing;
2 2
  3 +import com.lframework.starter.web.core.annotations.permission.DataPermission;
  4 +import com.lframework.starter.web.core.annotations.permission.DataPermissions;
3 import com.lframework.starter.web.core.mapper.BaseMapper; 5 import com.lframework.starter.web.core.mapper.BaseMapper;
  6 +import com.lframework.starter.web.inner.components.permission.OrderDataPermissionDataPermissionType;
4 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo; 7 import com.lframework.xingyun.sc.bo.procurement.WeighingTicketPlanBo;
5 import com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto; 8 import com.lframework.xingyun.sc.dto.PlanWeighedQuantityDto;
6 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan; 9 import com.lframework.xingyun.sc.procurement.entity.ProcurementPlan;
@@ -12,6 +15,9 @@ import org.apache.ibatis.annotations.Param; @@ -12,6 +15,9 @@ import org.apache.ibatis.annotations.Param;
12 15
13 public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementWeighingTicket> { 16 public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementWeighingTicket> {
14 17
  18 + @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = {
  19 + @DataPermission(template = "order", alias = "tb")
  20 + })
15 List<ProcurementWeighingTicket> query(@Param("vo") QueryProcurementWeighingTicketVo vo); 21 List<ProcurementWeighingTicket> query(@Param("vo") QueryProcurementWeighingTicketVo vo);
16 22
17 ProcurementWeighingTicket findById(@Param("id") String id); 23 ProcurementWeighingTicket findById(@Param("id") String id);
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 26
27 <sql id="PAA_sql"> 27 <sql id="PAA_sql">
28 SELECT 28 SELECT
29 - paa.id,  
30 - paa.weighing_ticket_id,  
31 - paa.weighing_ticket_code,  
32 - paa.workshop_id,  
33 - paa.workshop_name, 29 + tb.id,
  30 + tb.weighing_ticket_id,
  31 + tb.weighing_ticket_code,
  32 + tb.workshop_id,
  33 + tb.workshop_name,
34 ws.code AS workshop_code, 34 ws.code AS workshop_code,
35 - paa.procurement_plan_id,  
36 - paa.plan_code,  
37 - paa.product_id,  
38 - paa.product_name,  
39 - paa.department,  
40 - paa.approval_status,  
41 - paa.deleted,  
42 - paa.create_by_id,  
43 - paa.create_by,  
44 - paa.update_by_id,  
45 - paa.update_by,  
46 - paa.create_time,  
47 - paa.update_time  
48 - FROM procurement_assay_apply AS paa  
49 - LEFT JOIN base_data_workshop AS ws ON ws.id = paa.workshop_id 35 + tb.procurement_plan_id,
  36 + tb.plan_code,
  37 + tb.product_id,
  38 + tb.product_name,
  39 + tb.department,
  40 + tb.approval_status,
  41 + tb.deleted,
  42 + tb.create_by_id,
  43 + tb.create_by,
  44 + tb.update_by_id,
  45 + tb.update_by,
  46 + tb.create_time,
  47 + tb.update_time
  48 + FROM procurement_assay_apply AS tb
  49 + LEFT JOIN base_data_workshop AS ws ON ws.id = tb.workshop_id
50 </sql> 50 </sql>
51 51
52 <select id="query" resultMap="ProcurementAssayApplyResult"> 52 <select id="query" resultMap="ProcurementAssayApplyResult">
@@ -54,46 +54,46 @@ @@ -54,46 +54,46 @@
54 <where> 54 <where>
55 <choose> 55 <choose>
56 <when test="vo.deleted != null"> 56 <when test="vo.deleted != null">
57 - AND paa.deleted = #{vo.deleted} 57 + AND tb.deleted = #{vo.deleted}
58 </when> 58 </when>
59 <otherwise> 59 <otherwise>
60 - AND paa.deleted = 0 60 + AND tb.deleted = 0
61 </otherwise> 61 </otherwise>
62 </choose> 62 </choose>
63 <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''"> 63 <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''">
64 - AND paa.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%') 64 + AND tb.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%')
65 </if> 65 </if>
66 <if test="vo.productName != null and vo.productName != ''"> 66 <if test="vo.productName != null and vo.productName != ''">
67 - AND paa.product_name LIKE CONCAT('%', #{vo.productName}, '%') 67 + AND tb.product_name LIKE CONCAT('%', #{vo.productName}, '%')
68 </if> 68 </if>
69 <if test="vo.planCode != null and vo.planCode != ''"> 69 <if test="vo.planCode != null and vo.planCode != ''">
70 - AND paa.plan_code LIKE CONCAT('%', #{vo.planCode}, '%') 70 + AND tb.plan_code LIKE CONCAT('%', #{vo.planCode}, '%')
71 </if> 71 </if>
72 <if test="vo.approvalStatus != null and vo.approvalStatus != ''"> 72 <if test="vo.approvalStatus != null and vo.approvalStatus != ''">
73 - AND paa.approval_status = #{vo.approvalStatus} 73 + AND tb.approval_status = #{vo.approvalStatus}
74 </if> 74 </if>
75 <if test="vo.createBy != null and vo.createBy != ''"> 75 <if test="vo.createBy != null and vo.createBy != ''">
76 - AND paa.create_by LIKE CONCAT('%', #{vo.createBy}, '%') 76 + AND tb.create_by LIKE CONCAT('%', #{vo.createBy}, '%')
77 </if> 77 </if>
78 <if test="vo.startTime != null"> 78 <if test="vo.startTime != null">
79 - AND paa.create_time &gt;= #{vo.startTime} 79 + AND tb.create_time &gt;= #{vo.startTime}
80 </if> 80 </if>
81 <if test="vo.endTime != null"> 81 <if test="vo.endTime != null">
82 - AND paa.create_time &lt;= #{vo.endTime} 82 + AND tb.create_time &lt;= #{vo.endTime}
83 </if> 83 </if>
84 <if test="vo.createByIdList != null and vo.createByIdList.size() > 0"> 84 <if test="vo.createByIdList != null and vo.createByIdList.size() > 0">
85 - AND paa.create_by_id IN 85 + AND tb.create_by_id IN
86 <foreach collection="vo.createByIdList" item="item" open="(" separator="," close=")"> 86 <foreach collection="vo.createByIdList" item="item" open="(" separator="," close=")">
87 #{item} 87 #{item}
88 </foreach> 88 </foreach>
89 </if> 89 </if>
90 </where> 90 </where>
91 - ORDER BY paa.create_time DESC 91 + ORDER BY tb.create_time DESC
92 </select> 92 </select>
93 93
94 <select id="findById" resultMap="ProcurementAssayApplyResult"> 94 <select id="findById" resultMap="ProcurementAssayApplyResult">
95 <include refid="PAA_sql"/> 95 <include refid="PAA_sql"/>
96 - WHERE paa.id = #{id} 96 + WHERE tb.id = #{id}
97 </select> 97 </select>
98 98
99 <resultMap id="AssaySelectableTicketResult" type="com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo"> 99 <resultMap id="AssaySelectableTicketResult" type="com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo">
@@ -109,23 +109,23 @@ @@ -109,23 +109,23 @@
109 <!-- 化验送样选择码单弹窗:审核通过 + 已上传签字凭证(完成时间非空)+ 未作废 --> 109 <!-- 化验送样选择码单弹窗:审核通过 + 已上传签字凭证(完成时间非空)+ 未作废 -->
110 <select id="querySelectableTickets" resultMap="AssaySelectableTicketResult"> 110 <select id="querySelectableTickets" resultMap="AssaySelectableTicketResult">
111 SELECT 111 SELECT
112 - pwt.id,  
113 - pwt.code,  
114 - pwt.supplier_name,  
115 - pwt.workshop_id,  
116 - pwt.workshop_name,  
117 - pwt.complete_time,  
118 - pwt.create_by  
119 - FROM procurement_weighing_ticket AS pwt  
120 - WHERE pwt.deleted = 0  
121 - AND pwt.approval_status = 'PASS'  
122 - AND pwt.complete_time IS NOT NULL 112 + tb.id,
  113 + tb.code,
  114 + tb.supplier_name,
  115 + tb.workshop_id,
  116 + tb.workshop_name,
  117 + tb.complete_time,
  118 + tb.create_by
  119 + FROM procurement_weighing_ticket AS tb
  120 + WHERE tb.deleted = 0
  121 + AND tb.approval_status = 'PASS'
  122 + AND tb.complete_time IS NOT NULL
123 <if test="vo.code != null and vo.code != ''"> 123 <if test="vo.code != null and vo.code != ''">
124 - AND pwt.code LIKE CONCAT('%', #{vo.code}, '%') 124 + AND tb.code LIKE CONCAT('%', #{vo.code}, '%')
125 </if> 125 </if>
126 <if test="vo.workshopId != null and vo.workshopId != ''"> 126 <if test="vo.workshopId != null and vo.workshopId != ''">
127 - AND pwt.workshop_id = #{vo.workshopId} 127 + AND tb.workshop_id = #{vo.workshopId}
128 </if> 128 </if>
129 - ORDER BY pwt.complete_time DESC, pwt.create_time DESC 129 + ORDER BY tb.complete_time DESC, tb.create_time DESC
130 </select> 130 </select>
131 </mapper> 131 </mapper>
@@ -55,64 +55,64 @@ @@ -55,64 +55,64 @@
55 55
56 <sql id="PWT_sql"> 56 <sql id="PWT_sql">
57 SELECT 57 SELECT
58 - pwt.id,  
59 - pwt.code,  
60 - pwt.type,  
61 - pwt.origin_weighing_ticket_id,  
62 - pwt.unit,  
63 - pwt.first_gross_weight_time,  
64 - pwt.complete_time,  
65 - pwt.supplier_id,  
66 - pwt.supplier_name,  
67 - pwt.company_short_id,  
68 - pwt.company_short_name,  
69 - pwt.workshop_id,  
70 - pwt.workshop_name, 58 + tb.id,
  59 + tb.code,
  60 + tb.type,
  61 + tb.origin_weighing_ticket_id,
  62 + tb.unit,
  63 + tb.first_gross_weight_time,
  64 + tb.complete_time,
  65 + tb.supplier_id,
  66 + tb.supplier_name,
  67 + tb.company_short_id,
  68 + tb.company_short_name,
  69 + tb.workshop_id,
  70 + tb.workshop_name,
71 ws.code AS workshop_code, 71 ws.code AS workshop_code,
72 - pwt.buyout,  
73 - pwt.material_name,  
74 - pwt.total_gross_weight,  
75 - pwt.actual_impurity_weight,  
76 - pwt.net_weight,  
77 - pwt.net_weight_upper,  
78 - pwt.deduction_types,  
79 - pwt.supplier_stock_material,  
80 - pwt.logistics_stock_material,  
81 - pwt.plate_number,  
82 - pwt.business_summary,  
83 - pwt.special_note,  
84 - pwt.document_remark,  
85 - pwt.approval_status,  
86 - pwt.sign_attachment_file_ids,  
87 - pwt.sign_attachment_file_names,  
88 - pwt.delay_attachment_file_ids,  
89 - pwt.delay_attachment_file_names,  
90 - pwt.reweigh_attachment_file_ids,  
91 - pwt.reweigh_attachment_file_names,  
92 - pwt.weigher_id,  
93 - pwt.weigher_name,  
94 - pwt.quality_inspector_id,  
95 - pwt.quality_inspector_name,  
96 - pwt.driver,  
97 - pwt.deleted,  
98 - pwt.create_by_id,  
99 - pwt.create_by,  
100 - pwt.update_by_id,  
101 - pwt.update_by,  
102 - pwt.create_time,  
103 - pwt.update_time, 72 + tb.buyout,
  73 + tb.material_name,
  74 + tb.total_gross_weight,
  75 + tb.actual_impurity_weight,
  76 + tb.net_weight,
  77 + tb.net_weight_upper,
  78 + tb.deduction_types,
  79 + tb.supplier_stock_material,
  80 + tb.logistics_stock_material,
  81 + tb.plate_number,
  82 + tb.business_summary,
  83 + tb.special_note,
  84 + tb.document_remark,
  85 + tb.approval_status,
  86 + tb.sign_attachment_file_ids,
  87 + tb.sign_attachment_file_names,
  88 + tb.delay_attachment_file_ids,
  89 + tb.delay_attachment_file_names,
  90 + tb.reweigh_attachment_file_ids,
  91 + tb.reweigh_attachment_file_names,
  92 + tb.weigher_id,
  93 + tb.weigher_name,
  94 + tb.quality_inspector_id,
  95 + tb.quality_inspector_name,
  96 + tb.driver,
  97 + tb.deleted,
  98 + tb.create_by_id,
  99 + tb.create_by,
  100 + tb.update_by_id,
  101 + tb.update_by,
  102 + tb.create_time,
  103 + tb.update_time,
104 ( 104 (
105 SELECT GROUP_CONCAT(DISTINCT pwtp.plan_code ORDER BY pwtp.order_no SEPARATOR ',') 105 SELECT GROUP_CONCAT(DISTINCT pwtp.plan_code ORDER BY pwtp.order_no SEPARATOR ',')
106 FROM procurement_weighing_ticket_plan pwtp 106 FROM procurement_weighing_ticket_plan pwtp
107 - WHERE pwtp.weighing_ticket_id = pwt.id 107 + WHERE pwtp.weighing_ticket_id = tb.id
108 ) AS plan_codes, 108 ) AS plan_codes,
109 ( 109 (
110 SELECT GROUP_CONCAT(DISTINCT pwtpi.procurement_plan_id SEPARATOR ',') 110 SELECT GROUP_CONCAT(DISTINCT pwtpi.procurement_plan_id SEPARATOR ',')
111 FROM procurement_weighing_ticket_plan pwtpi 111 FROM procurement_weighing_ticket_plan pwtpi
112 - WHERE pwtpi.weighing_ticket_id = pwt.id 112 + WHERE pwtpi.weighing_ticket_id = tb.id
113 ) AS plan_ids 113 ) AS plan_ids
114 - FROM procurement_weighing_ticket AS pwt  
115 - LEFT JOIN base_data_workshop ws ON ws.id = pwt.workshop_id 114 + FROM procurement_weighing_ticket AS tb
  115 + LEFT JOIN base_data_workshop ws ON ws.id = tb.workshop_id
116 </sql> 116 </sql>
117 117
118 <select id="query" resultMap="ProcurementWeighingTicketResult"> 118 <select id="query" resultMap="ProcurementWeighingTicketResult">
@@ -120,65 +120,65 @@ @@ -120,65 +120,65 @@
120 <where> 120 <where>
121 <choose> 121 <choose>
122 <when test="vo.deleted != null"> 122 <when test="vo.deleted != null">
123 - AND pwt.deleted = #{vo.deleted} 123 + AND tb.deleted = #{vo.deleted}
124 </when> 124 </when>
125 <otherwise> 125 <otherwise>
126 - AND pwt.deleted = 0 126 + AND tb.deleted = 0
127 </otherwise> 127 </otherwise>
128 </choose> 128 </choose>
129 <if test="vo != null"> 129 <if test="vo != null">
130 <if test="vo.code != null and vo.code != ''"> 130 <if test="vo.code != null and vo.code != ''">
131 - AND pwt.code LIKE CONCAT('%', #{vo.code}, '%') 131 + AND tb.code LIKE CONCAT('%', #{vo.code}, '%')
132 </if> 132 </if>
133 <if test="vo.planCode != null and vo.planCode != ''"> 133 <if test="vo.planCode != null and vo.planCode != ''">
134 AND EXISTS ( 134 AND EXISTS (
135 SELECT 1 FROM procurement_weighing_ticket_plan pwtp 135 SELECT 1 FROM procurement_weighing_ticket_plan pwtp
136 - WHERE pwtp.weighing_ticket_id = pwt.id 136 + WHERE pwtp.weighing_ticket_id = tb.id
137 AND pwtp.plan_code LIKE CONCAT('%', #{vo.planCode}, '%') 137 AND pwtp.plan_code LIKE CONCAT('%', #{vo.planCode}, '%')
138 ) 138 )
139 </if> 139 </if>
140 <if test="vo.supplierName != null and vo.supplierName != ''"> 140 <if test="vo.supplierName != null and vo.supplierName != ''">
141 - AND pwt.supplier_name LIKE CONCAT('%', #{vo.supplierName}, '%') 141 + AND tb.supplier_name LIKE CONCAT('%', #{vo.supplierName}, '%')
142 </if> 142 </if>
143 <if test="vo.companyShortId != null and vo.companyShortId != ''"> 143 <if test="vo.companyShortId != null and vo.companyShortId != ''">
144 - AND pwt.company_short_id = #{vo.companyShortId} 144 + AND tb.company_short_id = #{vo.companyShortId}
145 </if> 145 </if>
146 <if test="vo.approvalStatus != null and vo.approvalStatus != ''"> 146 <if test="vo.approvalStatus != null and vo.approvalStatus != ''">
147 - AND pwt.approval_status = #{vo.approvalStatus} 147 + AND tb.approval_status = #{vo.approvalStatus}
148 </if> 148 </if>
149 <if test="vo.startTime != null"> 149 <if test="vo.startTime != null">
150 - AND pwt.first_gross_weight_time <![CDATA[ >= ]]> #{vo.startTime} 150 + AND tb.first_gross_weight_time <![CDATA[ >= ]]> #{vo.startTime}
151 </if> 151 </if>
152 <if test="vo.endTime != null"> 152 <if test="vo.endTime != null">
153 - AND pwt.first_gross_weight_time <![CDATA[ <= ]]> #{vo.endTime} 153 + AND tb.first_gross_weight_time <![CDATA[ <= ]]> #{vo.endTime}
154 </if> 154 </if>
155 <if test="vo.createBy != null and vo.createBy != ''"> 155 <if test="vo.createBy != null and vo.createBy != ''">
156 - AND pwt.create_by LIKE CONCAT('%', #{vo.createBy}, '%') 156 + AND tb.create_by LIKE CONCAT('%', #{vo.createBy}, '%')
157 </if> 157 </if>
158 <if test="vo.createById != null and vo.createById != ''"> 158 <if test="vo.createById != null and vo.createById != ''">
159 - AND pwt.create_by_id = #{vo.createById} 159 + AND tb.create_by_id = #{vo.createById}
160 </if> 160 </if>
161 <if test="vo.createByIdList != null and vo.createByIdList.size() > 0"> 161 <if test="vo.createByIdList != null and vo.createByIdList.size() > 0">
162 - AND pwt.create_by_id IN 162 + AND tb.create_by_id IN
163 <foreach collection="vo.createByIdList" open="(" separator="," close=")" item="item"> 163 <foreach collection="vo.createByIdList" open="(" separator="," close=")" item="item">
164 #{item} 164 #{item}
165 </foreach> 165 </foreach>
166 </if> 166 </if>
167 </if> 167 </if>
168 </where> 168 </where>
169 - ORDER BY pwt.create_time DESC 169 + ORDER BY tb.create_time DESC
170 </select> 170 </select>
171 171
172 <select id="findById" resultMap="ProcurementWeighingTicketResult"> 172 <select id="findById" resultMap="ProcurementWeighingTicketResult">
173 <include refid="PWT_sql"/> 173 <include refid="PWT_sql"/>
174 - WHERE pwt.id = #{id} 174 + WHERE tb.id = #{id}
175 </select> 175 </select>
176 176
177 <!-- 查询以指定前缀开头的最大编号(用于生成当日流水号),不过滤 deleted 避免与作废单据重复 --> 177 <!-- 查询以指定前缀开头的最大编号(用于生成当日流水号),不过滤 deleted 避免与作废单据重复 -->
178 <select id="findMaxCodeByPrefix" resultType="java.lang.String"> 178 <select id="findMaxCodeByPrefix" resultType="java.lang.String">
179 - SELECT MAX(pwt.code)  
180 - FROM procurement_weighing_ticket pwt  
181 - WHERE pwt.code LIKE CONCAT(#{prefix}, '%') 179 + SELECT MAX(tb.code)
  180 + FROM procurement_weighing_ticket tb
  181 + WHERE tb.code LIKE CONCAT(#{prefix}, '%')
182 </select> 182 </select>
183 183
184 <!-- 可关联过磅码单的采购计划(新增过磅码单选择计划弹窗) --> 184 <!-- 可关联过磅码单的采购计划(新增过磅码单选择计划弹窗) -->
@@ -363,9 +363,9 @@ @@ -363,9 +363,9 @@
363 pwtl.procurement_plan_id AS planId, 363 pwtl.procurement_plan_id AS planId,
364 SUM(pwtl.quantity) AS totalQuantity 364 SUM(pwtl.quantity) AS totalQuantity
365 FROM procurement_weighing_ticket_line pwtl 365 FROM procurement_weighing_ticket_line pwtl
366 - INNER JOIN procurement_weighing_ticket pwt ON pwt.id = pwtl.weighing_ticket_id  
367 - WHERE pwt.deleted = 0  
368 - AND pwt.complete_time IS NOT NULL 366 + INNER JOIN procurement_weighing_ticket tb ON tb.id = pwtl.weighing_ticket_id
  367 + WHERE tb.deleted = 0
  368 + AND tb.complete_time IS NOT NULL
369 AND pwtl.procurement_plan_id IN 369 AND pwtl.procurement_plan_id IN
370 <foreach collection="planIds" open="(" separator="," close=")" item="item"> 370 <foreach collection="planIds" open="(" separator="," close=")" item="item">
371 #{item} 371 #{item}