Commit 43f8eea2297082140de6da69ffdd7d544e51130e
Merge branch 'master_after0506' into mater_procurement
Showing
3 changed files
with
159 additions
and
102 deletions
xingyun-sc/src/main/java/com/lframework/xingyun/sc/impl/statistics/OrderDetailReportServiceImpl.java
| @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.impl.statistics; | @@ -2,6 +2,7 @@ package com.lframework.xingyun.sc.impl.statistics; | ||
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 3 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 5 | +import com.github.pagehelper.Page; | ||
| 5 | import com.github.pagehelper.PageInfo; | 6 | import com.github.pagehelper.PageInfo; |
| 6 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | 7 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 7 | import com.lframework.starter.web.core.utils.PageResultUtil; | 8 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| @@ -40,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional; | @@ -40,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 40 | import javax.annotation.Resource; | 41 | import javax.annotation.Resource; |
| 41 | import java.math.BigDecimal; | 42 | import java.math.BigDecimal; |
| 42 | import java.math.RoundingMode; | 43 | import java.math.RoundingMode; |
| 44 | +import java.util.Collections; | ||
| 43 | import java.util.List; | 45 | import java.util.List; |
| 44 | 46 | ||
| 45 | @Service | 47 | @Service |
| @@ -68,15 +70,25 @@ public class OrderDetailReportServiceImpl extends BaseMpServiceImpl<OrderDetailR | @@ -68,15 +70,25 @@ public class OrderDetailReportServiceImpl extends BaseMpServiceImpl<OrderDetailR | ||
| 68 | Assert.greaterThanZero(pageSize); | 70 | Assert.greaterThanZero(pageSize); |
| 69 | 71 | ||
| 70 | PageHelperUtil.startPage(pageIndex, pageSize); | 72 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 71 | - List<OrderDetailReport> datas = getBaseMapper().authQuery(vo); | 73 | + List<String> ids = getBaseMapper().authQueryPageIds(vo); |
| 74 | + PageInfo<String> idPageInfo = new PageInfo<>(ids); | ||
| 75 | + List<OrderDetailReport> datas = CollectionUtils.isEmpty(ids) | ||
| 76 | + ? Collections.emptyList() | ||
| 77 | + : getBaseMapper().queryByIds(ids); | ||
| 72 | 78 | ||
| 73 | - return PageResultUtil.convert(new PageInfo<>(datas)); | 79 | + Page<OrderDetailReport> page = new Page<>(idPageInfo.getPageNum(), idPageInfo.getPageSize(), false); |
| 80 | + page.setTotal(idPageInfo.getTotal()); | ||
| 81 | + page.addAll(datas); | ||
| 82 | + return PageResultUtil.convert(new PageInfo<>(page)); | ||
| 74 | } | 83 | } |
| 75 | 84 | ||
| 76 | @Override | 85 | @Override |
| 77 | public List<OrderDetailReport> query(QueryOrderDetailReportVo vo) { | 86 | public List<OrderDetailReport> query(QueryOrderDetailReportVo vo) { |
| 78 | - | ||
| 79 | - return getBaseMapper().query(vo); | 87 | + List<String> ids = getBaseMapper().queryPageIds(vo); |
| 88 | + if (CollectionUtils.isEmpty(ids)) { | ||
| 89 | + return Collections.emptyList(); | ||
| 90 | + } | ||
| 91 | + return getBaseMapper().queryByIds(ids); | ||
| 80 | } | 92 | } |
| 81 | 93 | ||
| 82 | @Override | 94 | @Override |
| @@ -19,24 +19,32 @@ import java.util.List; | @@ -19,24 +19,32 @@ import java.util.List; | ||
| 19 | public interface OrderDetailReportMapper extends BaseMapper<OrderDetailReport> { | 19 | public interface OrderDetailReportMapper extends BaseMapper<OrderDetailReport> { |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | - * 查询列表 | 22 | + * 查询列表ID |
| 23 | * | 23 | * |
| 24 | * @param vo | 24 | * @param vo |
| 25 | * @return | 25 | * @return |
| 26 | */ | 26 | */ |
| 27 | - List<OrderDetailReport> query(@Param("vo") QueryOrderDetailReportVo vo); | 27 | + List<String> queryPageIds(@Param("vo") QueryOrderDetailReportVo vo); |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | - * 查询列表 | 30 | + * 查询列表ID |
| 31 | * 开启权限控制 | 31 | * 开启权限控制 |
| 32 | * | 32 | * |
| 33 | * @param vo 查询条件 | 33 | * @param vo 查询条件 |
| 34 | - * @return List<OrderDetailReport> | 34 | + * @return List<String> |
| 35 | */ | 35 | */ |
| 36 | @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | 36 | @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { |
| 37 | - @DataPermission(template = "order", alias = "t") | 37 | + @DataPermission(template = "order", alias = "tb") |
| 38 | }) | 38 | }) |
| 39 | - List<OrderDetailReport> authQuery(@Param("vo") QueryOrderDetailReportVo vo); | 39 | + List<String> authQueryPageIds(@Param("vo") QueryOrderDetailReportVo vo); |
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 根据ID列表查询详情 | ||
| 43 | + * | ||
| 44 | + * @param ids ID列表 | ||
| 45 | + * @return List<OrderDetailReport> | ||
| 46 | + */ | ||
| 47 | + List<OrderDetailReport> queryByIds(@Param("ids") List<String> ids); | ||
| 40 | 48 | ||
| 41 | /** | 49 | /** |
| 42 | * 查询 | 50 | * 查询 |
| @@ -141,90 +141,97 @@ | @@ -141,90 +141,97 @@ | ||
| 141 | <!-- </where>--> | 141 | <!-- </where>--> |
| 142 | <!-- </select>--> | 142 | <!-- </select>--> |
| 143 | 143 | ||
| 144 | - <select id="findById" resultType="com.lframework.xingyun.sc.entity.OrderDetailReport"> | ||
| 145 | - <include refid="OrderDetailReport_sql"/> | ||
| 146 | - <where> | ||
| 147 | - <if test="id != null and id != ''"> | ||
| 148 | - AND tb.id = #{id} | ||
| 149 | - </if> | ||
| 150 | - </where> | ||
| 151 | - </select> | ||
| 152 | - | ||
| 153 | - <sql id="OrderDetailReport_query_sql"> | ||
| 154 | - SELECT * | ||
| 155 | - FROM ( | 144 | + <sql id="OrderDetailReport_detail_select_sql"> |
| 156 | SELECT | 145 | SELECT |
| 157 | - tb.id, | ||
| 158 | - tb.purchase_order_line_id, | ||
| 159 | - tb.order_no, | ||
| 160 | - tb.order_date, | ||
| 161 | - tb.workshop_id, | ||
| 162 | - ws.name AS workshop_name, | ||
| 163 | - tb.dept_name, | ||
| 164 | - tb.region_name, | ||
| 165 | - tb.ordering_unit_name, | ||
| 166 | - tb.industry, | ||
| 167 | - tb.brand, | ||
| 168 | - tb.thickness, | ||
| 169 | - tb.thickness_tol_pos, | ||
| 170 | - tb.thickness_tol_neg, | ||
| 171 | - tb.width, | ||
| 172 | - tb.width_tol_pos, | ||
| 173 | - tb.width_tol_neg, | ||
| 174 | - tb.length, | ||
| 175 | - tb.length_tol_pos, | ||
| 176 | - tb.length_tol_neg, | ||
| 177 | - tb.status, | ||
| 178 | - tb.quantity, | ||
| 179 | - tb.suggested_price, | ||
| 180 | - tb.delivery_date, | ||
| 181 | - tb.assessment_exceeds_agreement, | ||
| 182 | - tb.sales_price, | ||
| 183 | - tb.price_list_no, | ||
| 184 | - tb.packaging_fee, | ||
| 185 | - tb.invoicing_status, | ||
| 186 | - tb.piece_weight_header, | ||
| 187 | - tb.surface, | ||
| 188 | - tb.tolerance, | ||
| 189 | - tb.performance, | ||
| 190 | - tb.packaging, | ||
| 191 | - tb.remarks, | ||
| 192 | - tb.shipping_cost, | ||
| 193 | - tb.return_shipping_cost, | ||
| 194 | - tb.customer_type, | ||
| 195 | - tb.quality, | ||
| 196 | - tb.contract_type, | ||
| 197 | - tb.stock_up_company_name, | ||
| 198 | - tb.order_type, | ||
| 199 | - tb.show_order, | ||
| 200 | - tb.type, | ||
| 201 | - tb.production_process, | ||
| 202 | - tb.create_by_id, | ||
| 203 | - tb.create_by, | ||
| 204 | - tb.update_by_id, | ||
| 205 | - tb.update_by, | ||
| 206 | - tb.create_time, | ||
| 207 | - tb.update_time, | ||
| 208 | - cs.short_name AS customer_short_name, | ||
| 209 | - poi.settlement_terms AS settlement_terms, | ||
| 210 | - poi.execution_standard AS execution_standard, | ||
| 211 | - poi.execution_standard_remarks AS execution_standard_remarks, | ||
| 212 | - CASE | ||
| 213 | - WHEN c.type = 'PROCESS_STD_AGMT' THEN pl.product_id | ||
| 214 | - ELSE cl.product_id | ||
| 215 | - END AS structure_report_used, | ||
| 216 | - c.type AS contract_type_code, | ||
| 217 | - c.special_terms AS special_requirements, | ||
| 218 | - c.create_by AS contract_create_by, | ||
| 219 | - MAX(tb.create_time) OVER (PARTITION BY tb.order_no, tb.purchase_order_line_id) AS group_latest_time | ||
| 220 | - FROM order_detail_report tb | ||
| 221 | - LEFT JOIN base_data_workshop ws ON ws.id = tb.workshop_id | ||
| 222 | - LEFT JOIN tbl_purchase_order_line pol ON pol.id = tb.purchase_order_line_id | 146 | + t.id, |
| 147 | + t.purchase_order_line_id, | ||
| 148 | + t.order_no, | ||
| 149 | + t.order_date, | ||
| 150 | + t.workshop_id, | ||
| 151 | + ws.name AS workshop_name, | ||
| 152 | + t.dept_name, | ||
| 153 | + t.region_name, | ||
| 154 | + t.ordering_unit_name, | ||
| 155 | + t.industry, | ||
| 156 | + t.brand, | ||
| 157 | + t.thickness, | ||
| 158 | + t.thickness_tol_pos, | ||
| 159 | + t.thickness_tol_neg, | ||
| 160 | + t.width, | ||
| 161 | + t.width_tol_pos, | ||
| 162 | + t.width_tol_neg, | ||
| 163 | + t.length, | ||
| 164 | + t.length_tol_pos, | ||
| 165 | + t.length_tol_neg, | ||
| 166 | + t.status, | ||
| 167 | + t.quantity, | ||
| 168 | + t.suggested_price, | ||
| 169 | + t.delivery_date, | ||
| 170 | + t.assessment_exceeds_agreement, | ||
| 171 | + t.sales_price, | ||
| 172 | + t.price_list_no, | ||
| 173 | + t.packaging_fee, | ||
| 174 | + t.invoicing_status, | ||
| 175 | + t.piece_weight_header, | ||
| 176 | + t.surface, | ||
| 177 | + t.tolerance, | ||
| 178 | + t.performance, | ||
| 179 | + t.packaging, | ||
| 180 | + t.remarks, | ||
| 181 | + t.shipping_cost, | ||
| 182 | + t.return_shipping_cost, | ||
| 183 | + t.customer_type, | ||
| 184 | + t.quality, | ||
| 185 | + t.contract_type, | ||
| 186 | + t.stock_up_company_name, | ||
| 187 | + t.order_type, | ||
| 188 | + t.show_order, | ||
| 189 | + t.type, | ||
| 190 | + t.production_process, | ||
| 191 | + t.create_by_id, | ||
| 192 | + t.create_by, | ||
| 193 | + t.update_by_id, | ||
| 194 | + t.update_by, | ||
| 195 | + t.create_time, | ||
| 196 | + t.update_time, | ||
| 197 | + cs.short_name AS customer_short_name, | ||
| 198 | + poi.settlement_terms AS settlement_terms, | ||
| 199 | + poi.execution_standard AS execution_standard, | ||
| 200 | + poi.execution_standard_remarks AS execution_standard_remarks, | ||
| 201 | + CASE | ||
| 202 | + WHEN c.type = 'PROCESS_STD_AGMT' THEN pl.product_id | ||
| 203 | + ELSE cl.product_id | ||
| 204 | + END AS structure_report_used, | ||
| 205 | + c.type AS contract_type_code, | ||
| 206 | + c.special_terms AS special_requirements, | ||
| 207 | + c.create_by AS contract_create_by | ||
| 208 | + FROM order_detail_report t | ||
| 209 | + LEFT JOIN base_data_workshop ws ON ws.id = t.workshop_id | ||
| 210 | + LEFT JOIN tbl_purchase_order_line pol ON pol.id = t.purchase_order_line_id | ||
| 223 | LEFT JOIN purchase_order_info poi ON poi.id = pol.purchase_order_id | 211 | LEFT JOIN purchase_order_info poi ON poi.id = pol.purchase_order_id |
| 224 | LEFT JOIN tbl_contract_distributor_standard c ON c.id = poi.contract_id | 212 | LEFT JOIN tbl_contract_distributor_standard c ON c.id = poi.contract_id |
| 225 | LEFT JOIN base_data_customer_short cs ON cs.customer_id = poi.ordering_unit | 213 | LEFT JOIN base_data_customer_short cs ON cs.customer_id = poi.ordering_unit |
| 226 | LEFT JOIN tbl_contract_distributor_line cl ON cl.id = pol.contract_distributor_line_id | 214 | LEFT JOIN tbl_contract_distributor_line cl ON cl.id = pol.contract_distributor_line_id |
| 227 | LEFT JOIN tbl_contract_std_processing_line pl ON pl.id = pol.contract_distributor_line_id | 215 | LEFT JOIN tbl_contract_std_processing_line pl ON pl.id = pol.contract_distributor_line_id |
| 216 | + </sql> | ||
| 217 | + | ||
| 218 | + <sql id="OrderDetailReport_page_id_from_sql"> | ||
| 219 | + FROM order_detail_report tb | ||
| 220 | + LEFT JOIN ( | ||
| 221 | + SELECT | ||
| 222 | + order_no, | ||
| 223 | + purchase_order_line_id, | ||
| 224 | + MAX(create_time) AS group_latest_time | ||
| 225 | + FROM order_detail_report | ||
| 226 | + GROUP BY order_no, purchase_order_line_id | ||
| 227 | + ) grp ON grp.order_no = tb.order_no | ||
| 228 | + AND grp.purchase_order_line_id = tb.purchase_order_line_id | ||
| 229 | + LEFT JOIN tbl_purchase_order_line pol ON pol.id = tb.purchase_order_line_id | ||
| 230 | + LEFT JOIN purchase_order_info poi ON poi.id = pol.purchase_order_id | ||
| 231 | + LEFT JOIN tbl_contract_distributor_standard c ON c.id = poi.contract_id | ||
| 232 | + </sql> | ||
| 233 | + | ||
| 234 | + <sql id="OrderDetailReport_page_id_where_sql"> | ||
| 228 | <where> | 235 | <where> |
| 229 | <if test="vo.ids != null and !vo.ids.isEmpty()"> | 236 | <if test="vo.ids != null and !vo.ids.isEmpty()"> |
| 230 | AND tb.id IN | 237 | AND tb.id IN |
| @@ -261,7 +268,7 @@ | @@ -261,7 +268,7 @@ | ||
| 261 | </if> | 268 | </if> |
| 262 | <if test="vo.orderDateEnd != null"> | 269 | <if test="vo.orderDateEnd != null"> |
| 263 | <![CDATA[ | 270 | <![CDATA[ |
| 264 | - AND tb.order_date <= #{vo.orderDateEnd} | 271 | + AND tb.order_date <= #{vo.orderDateEnd} |
| 265 | ]]> | 272 | ]]> |
| 266 | </if> | 273 | </if> |
| 267 | <if test="vo.createTimeStart != null"> | 274 | <if test="vo.createTimeStart != null"> |
| @@ -269,7 +276,7 @@ | @@ -269,7 +276,7 @@ | ||
| 269 | </if> | 276 | </if> |
| 270 | <if test="vo.createTimeEnd != null"> | 277 | <if test="vo.createTimeEnd != null"> |
| 271 | <![CDATA[ | 278 | <![CDATA[ |
| 272 | - AND tb.create_time <= #{vo.createTimeEnd} | 279 | + AND tb.create_time <= #{vo.createTimeEnd} |
| 273 | ]]> | 280 | ]]> |
| 274 | </if> | 281 | </if> |
| 275 | <if test="vo.thickness != null and vo.thickness != ''"> | 282 | <if test="vo.thickness != null and vo.thickness != ''"> |
| @@ -282,9 +289,9 @@ | @@ -282,9 +289,9 @@ | ||
| 282 | AND tb.status = #{vo.status} | 289 | AND tb.status = #{vo.status} |
| 283 | </if> | 290 | </if> |
| 284 | <if test="vo.inventoryUnlockedOnly != null and vo.inventoryUnlockedOnly"> | 291 | <if test="vo.inventoryUnlockedOnly != null and vo.inventoryUnlockedOnly"> |
| 285 | - AND c.type IN ('DIST_STOCK_CONTRACT','INTL_INVENTORY_AGMT') | ||
| 286 | - AND c.status ='FORMAL' | ||
| 287 | - AND poi.type='PRODUCTION' | 292 | + AND c.type IN ('DIST_STOCK_CONTRACT', 'INTL_INVENTORY_AGMT') |
| 293 | + AND c.status = 'FORMAL' | ||
| 294 | + AND poi.type = 'PRODUCTION' | ||
| 288 | AND (c.price_spec_locked = 0 OR c.price_spec_locked IS NULL) | 295 | AND (c.price_spec_locked = 0 OR c.price_spec_locked IS NULL) |
| 289 | </if> | 296 | </if> |
| 290 | <if test="vo.excludeInventoryUnlocked != null and vo.excludeInventoryUnlocked"> | 297 | <if test="vo.excludeInventoryUnlocked != null and vo.excludeInventoryUnlocked"> |
| @@ -325,19 +332,49 @@ | @@ -325,19 +332,49 @@ | ||
| 325 | </choose> | 332 | </choose> |
| 326 | </if> | 333 | </if> |
| 327 | </where> | 334 | </where> |
| 328 | - ) t | 335 | + </sql> |
| 336 | + | ||
| 337 | + <sql id="OrderDetailReport_page_id_order_sql"> | ||
| 329 | ORDER BY | 338 | ORDER BY |
| 330 | - t.group_latest_time DESC, | ||
| 331 | - t.order_no ASC, | ||
| 332 | - t.purchase_order_line_id ASC, | ||
| 333 | - t.show_order ASC | 339 | + grp.group_latest_time DESC, |
| 340 | + tb.order_no ASC, | ||
| 341 | + tb.purchase_order_line_id ASC, | ||
| 342 | + tb.show_order ASC | ||
| 334 | </sql> | 343 | </sql> |
| 335 | 344 | ||
| 336 | - <select id="query" resultMap="OrderDetailReport"> | ||
| 337 | - <include refid="OrderDetailReport_query_sql"/> | 345 | + <select id="findById" resultMap="OrderDetailReport"> |
| 346 | + <include refid="OrderDetailReport_detail_select_sql"/> | ||
| 347 | + <where> | ||
| 348 | + <if test="id != null and id != ''"> | ||
| 349 | + AND t.id = #{id} | ||
| 350 | + </if> | ||
| 351 | + </where> | ||
| 352 | + </select> | ||
| 353 | + | ||
| 354 | + <select id="queryPageIds" resultType="java.lang.String"> | ||
| 355 | + SELECT tb.id | ||
| 356 | + <include refid="OrderDetailReport_page_id_from_sql"/> | ||
| 357 | + <include refid="OrderDetailReport_page_id_where_sql"/> | ||
| 358 | + <include refid="OrderDetailReport_page_id_order_sql"/> | ||
| 359 | + </select> | ||
| 360 | + | ||
| 361 | + <select id="authQueryPageIds" resultType="java.lang.String"> | ||
| 362 | + SELECT tb.id | ||
| 363 | + <include refid="OrderDetailReport_page_id_from_sql"/> | ||
| 364 | + <include refid="OrderDetailReport_page_id_where_sql"/> | ||
| 365 | + <include refid="OrderDetailReport_page_id_order_sql"/> | ||
| 338 | </select> | 366 | </select> |
| 339 | 367 | ||
| 340 | - <select id="authQuery" resultMap="OrderDetailReport"> | ||
| 341 | - <include refid="OrderDetailReport_query_sql"/> | 368 | + <select id="queryByIds" resultMap="OrderDetailReport"> |
| 369 | + <include refid="OrderDetailReport_detail_select_sql"/> | ||
| 370 | + WHERE t.id IN | ||
| 371 | + <foreach collection="ids" item="id" open="(" separator="," close=")"> | ||
| 372 | + #{id} | ||
| 373 | + </foreach> | ||
| 374 | + ORDER BY FIELD(t.id, | ||
| 375 | + <foreach collection="ids" item="id" separator=","> | ||
| 376 | + #{id} | ||
| 377 | + </foreach> | ||
| 378 | + ) | ||
| 342 | </select> | 379 | </select> |
| 343 | </mapper> | 380 | </mapper> |