郑永安
2023-06-19 59e91a4e9ddaf23cebb12993c774aa899ab22d16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
package com.gk.firework.Service.ServiceImpl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.firework.Domain.*;
import com.gk.firework.Domain.Exception.BusinessException;
import com.gk.firework.Domain.Utils.PageInfo;
import com.gk.firework.Domain.Utils.StringUtils;
import com.gk.firework.Domain.Vo.*;
import com.gk.firework.Mapper.SaleOrderDetailInfoMapper;
import com.gk.firework.Service.*;
import com.spire.doc.interfaces.IField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.math.BigDecimal;
import java.util.*;
 
 
/**
 * @author : jingjy
 * @date : 2021/3/30 17:34
 */
@Service("SaleOrderDetailService")
public class SaleOrderDetailServiceImpl extends ServiceImpl<SaleOrderDetailInfoMapper, SaleOrderDetailInfo> implements SaleOrderDetailService {
    @Autowired
    SaleOrderDetailInfoMapper saleOrderDetailInfoMapper;
    @Autowired
    SaleOrderService saleOrderService;
    @Autowired
    EnterpriseService enterpriseService;
    @Autowired
    ProductService productService;
    @Autowired
    private EntryDetailService entryDetailService;
    @Autowired
    private EntryService entryService;
    @Autowired
    private StockService stockService;
    @Autowired
    UserService userService;
    @Autowired
    DistrictService districtService;
 
    @Override
    public void selectByCustomId(PageInfo pageInfo) {
        Page<SaleDetailVo> page = new Page<>(pageInfo.getPageIndex(), pageInfo.getPageSize());
        List<OrderItem> orderItems = new ArrayList<>();
        OrderItem orderItem = new OrderItem();
        if (StringUtils.isNotBlank(pageInfo.getSort()) && StringUtils.isNotBlank(pageInfo.getOrder())) {
            orderItem.setAsc(pageInfo.getOrder().equalsIgnoreCase("ascending"));
            orderItem.setColumn(pageInfo.getSort());
        }else {
            orderItem.setAsc(false);
            orderItem.setColumn("createdat");
        }
        orderItems.add(orderItem);
        page.setOrders(orderItems);
        List<SaleDetailVo> list = saleOrderDetailInfoMapper.selectByCustomId(page,pageInfo.getCondition());
        pageInfo.setResult(list);
        pageInfo.setTotalCount(page.getTotal());
    }
 
 
    /**
     * @Description: 近n天销售数据统计
     * @date 2021/4/16 16:21
     */
    @Override
    public List<Map> getSaleDataInDays(Integer days) {
        Date startTime = moveForwardDays(days);
        int[] index = new int[days];
        for (int i = 0; i < days; i++) {
            index[i] = i + 1;
        }
        return saleOrderDetailInfoMapper.getSaleDataInDays(startTime,null,index);
    }
 
 
    /**
     * @Description: 销售数量按地区统计 n天 默认90
     * @date 2021/4/16 16:21
     */
    @Override
    public List<Map> getSaleDataAreaInDays(Integer days) {
        Date startTime = moveForwardDays(days);
        Map<String, Object> params = new HashMap<>();
        params.put("province", "新疆维吾尔自治区");
        return saleOrderDetailInfoMapper.getSaleDataAreaInDays(startTime,null,params);
    }
 
 
    /**
     * @Description: 销售数量按品种统计 n天 默认90
     * @date 2021/4/16 17:03
     */
    @Override
    public List<Map> getSaleDataProductTypeInDays(Integer days) {
        Date startTime = moveForwardDays(days);
        return saleOrderDetailInfoMapper.getSaleDataProductTypeInDays(startTime,null);
    }
 
    /**
    * @Description: 销售量同年对比
    * @date 2021/4/22 15:13
    */
    @Override
    public Map getSaleDataCompareInYear(String province, String city) {
        //今年数据
        Calendar cal = Calendar.getInstance();
        int thisYear = cal.get(Calendar.YEAR);
        List<Map> thisYearData = this.getSaleDataInYear(province, city, thisYear);
        //去年数据
        cal.add(Calendar.YEAR, -1);
        int lastYear = cal.get(Calendar.YEAR);
        List<Map> lastYearData = this.getSaleDataInYear(province, city, lastYear);
        //生成结果
        Map<Object, Object> result = new HashMap<>();
        result.put(thisYear, thisYearData);
        result.put(lastYear, lastYearData);
        return result;
    }
 
    /**
    * @Description: 获取{xxxx}年的销售数据
    * @date 2021/4/22 15:50
    */
    @Override
    public List<Map> getSaleDataInYear(String province, String city, Integer year) {
        Map<String, Object> params = new HashMap<>();
        params.put("province", province);
        params.put("city", city);
        params.put("year", year);
        return saleOrderDetailInfoMapper.getSaleDataInYear(params);
    }
 
    /**
    * @Description: 进货量同年对比
    * @date 2021/4/23 9:28
    */
    @Override
    public Map getInboundCompareInYear(String province, String city) {
        //今年数据
        Calendar cal = Calendar.getInstance();
        int thisYear = cal.get(Calendar.YEAR);
        List<Map> thisYearData = this.getInboundInYear(province, city, thisYear);
        //去年数据
        cal.add(Calendar.YEAR, -1);
        int lastYear = cal.get(Calendar.YEAR);
        List<Map> lastYearData = this.getInboundInYear(province, city, lastYear);
        //生成结果
        Map<Object, Object> result = new HashMap<>();
        result.put(thisYear, thisYearData);
        result.put(lastYear, lastYearData);
        return result;
    }
 
    /**
    * @Description: 获取{xxxx}年的进货量
    * @date 2021/4/23 9:31
    */
    @Override
    public List<Map> getInboundInYear(String province, String city, Integer year) {
        Map<String, Object> params = new HashMap<>();
        params.put("province", province);
        params.put("city", city);
        params.put("year", year);
        return saleOrderDetailInfoMapper.getInboundInYear(params);
    }
    @Override
    public List<SaleOrderDetailInfo> selectByOrderCode(String code) {
        LambdaQueryWrapper<SaleOrderDetailInfo>wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SaleOrderDetailInfo::getOrdercode,code);
        return saleOrderDetailInfoMapper.selectList(wrapper);
    }
 
    /**
     * @Description: 标题数据 (零售店数量 今日销售数量 今年销售总量 今年购买人次)
     * @date 2021/4/25 9:44
     */
    @Override
    public Map getTitleData() {
        //1.零售店数量
        int saleShopNum = enterpriseService.getSaleNum();
        //2.今日销售数量
        int thisDaySaleNum = saleOrderDetailInfoMapper.getSaleNumThisDay();
        //3.今年销售数量
        int thisYearSaleNum = saleOrderDetailInfoMapper.getSaleNumThisYear();
        //今年购买人数
        int thisYearPurchasersNum = saleOrderDetailInfoMapper.getPurchasersNum();
        Map<String, Integer> result = new HashMap<>();
        result.put("saleShopNum", saleShopNum);
        result.put("thisDaySaleNum", thisDaySaleNum);
        result.put("thisYearSaleNum", thisYearSaleNum);
        result.put("thisYearPurchasersNum", thisYearPurchasersNum);
        return result;
    }
 
    @Override
    public IPage getCityInAndOut(Page<Map> page, Map filter) {
 
        Map<String, Object> params = new HashMap<>();
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("province", "新疆维吾尔自治区");
        params.put("safetysupervision", filter.get("safetysupervision"));
        List<Map> list = saleOrderDetailInfoMapper.selectCityInAndOut(page, params);
        page.setRecords(list);
        return page;
    }
 
    @Override
    public IPage getGenderSale(Page<Map> page, Map filter, UserInfo userInfo) {
 
        Map<String, Object> params = new HashMap<>();
        //可视权限
        UserInfo user = userService.getById(userInfo.getId());
        if (user.getCompanynumber() != null) {
            params.put("enterprisenumber", user.getCompanynumber());
        }else {
            if (StringUtils.isNotBlank(user.getProvince())) {
                params.put("province", user.getProvince());
            }
            if (StringUtils.isNotBlank(user.getCity())) {
                params.put("city", user.getCity());
            }
            if (StringUtils.isNotBlank(user.getArea())) {
                params.put("district", user.getArea());
            }
            if (StringUtils.isNotBlank(user.getTown())) {
                params.put("street", user.getTown());
            }
 
            if (StringUtils.isNotBlank(user.getCommunity())) {
                params.put("committee", user.getCommunity());
            }
        }
 
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("producttype", filter.get("producttype"));
        params.put("secondarytype", filter.get("secondarytype"));
        params.put("productname", filter.get("productname"));
        params.put("provinceFilter", filter.get("province"));
        params.put("cityFilter", filter.get("city"));
        params.put("districtFilter", filter.get("district"));
        params.put("streetFilter", filter.get("street"));
        params.put("committeeFilter", filter.get("committee"));
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        List<Map> records =  saleOrderDetailInfoMapper.getGenderSale(page,params);
        return page.setRecords(records);
    }
 
    @Override
    public IPage getRaceSale(Page<Map> page, Map filter, UserInfo userInfo) {
 
 
        Map<String, Object> params = new HashMap<>();
 
        UserInfo user = userService.getById(userInfo.getId());
        {
            params.put("enterprisenumber", user.getCompanynumber());
            params.put("province", user.getProvince());
            params.put("city", user.getCity());
            params.put("district", user.getArea());
            params.put("street", user.getTown());
            params.put("committee", user.getCommunity());
        }
 
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("producttype", filter.get("producttype"));
        params.put("secondarytype", filter.get("secondarytype"));
        params.put("productname", filter.get("productname"));
        params.put("provinceFilter", filter.get("province"));
        params.put("cityFilter", filter.get("city"));
        params.put("districtFilter", filter.get("city"));
        params.put("streetFilter", filter.get("street"));
        params.put("committeeFilter", filter.get("committee"));
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        List<Map> records =  saleOrderDetailInfoMapper.getRaceSale(page,params);
        return page.setRecords(records);
    }
 
    @Override
    public List<Map> getGenerationSale(Map filter, UserInfo userInfo) {
        UserInfo user = userService.getById(userInfo.getId());
        String[] generations = {"0-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70"};
        List<Map> table = new ArrayList<>();
        Map<String, Object> row = null;
        for (String generation : generations) {
            Integer head = null;
            Integer tail = null;
            String[] split = generation.split("-");
            head = Integer.valueOf(split[0]);
            if (split.length > 1) {
                tail = Integer.valueOf(split[1]);
            }
            int num = this.getSaleInfoByGeneration(head,tail,filter,user);
            row = new HashMap<>();
            row.put("generation", generation);
            row.put("num", num);
            table.add(row);
        }
        return table;
    }
 
 
    /**
    * @Description: 年龄段购买数量
    * @date 2021/5/15 17:05
    */
    @Override
    public int getSaleInfoByGeneration(Integer head, Integer tail, Map filter,UserInfo user) {
 
        Map<String, Object> params = new HashMap<>();
        {
            params.put("enterprisenumber", user.getCompanynumber());
            params.put("province", user.getProvince());
            params.put("city", user.getCity());
            params.put("district", user.getArea());
            params.put("street", user.getTown());
            params.put("committee", user.getCommunity());
        }
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("producttype", filter.get("producttype"));
        params.put("secondarytype", filter.get("secondarytype"));
        params.put("productname", filter.get("productname"));
        params.put("provinceFilter", filter.get("province"));
        params.put("cityFilter", filter.get("city"));
        params.put("districtFilter", filter.get("city"));
        params.put("streetFilter", filter.get("street"));
        params.put("committeeFilter", filter.get("committee"));
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        //年龄段头尾
        params.put("head", head);
        params.put("tail", tail);
        return saleOrderDetailInfoMapper.getSaleInfoByGeneration(params);
    }
 
    @Override
    public List<SaleDetailVo> getDetailList(String directionCode) {
        if (StringUtils.isBlank(directionCode)|| FireworkDeal.isNotDirectionCode(directionCode)) {
            throw new BusinessException("流向码不符合规则");
        }
        List<String>  codes= new ArrayList<>();
        //22位
        if (FireworkDeal.is22Characters(directionCode)){
            DirectionDetail directionDetail = FireworkDeal.dealDirectionCode(directionCode);
            List<ProductVo> productVos = new ArrayList<>();
            ProductVo productVo = productService.selectVoByDirection(directionCode);
            FireworkDeal.getProductVos(directionCode,directionDetail,directionDetail,productVos,productVo);
            if (productVos.size() > 0) {
                for (ProductVo product : productVos) {
                    codes.add(product.getDirectionCode());
                }
            }
        }else{
            //19位
            codes.add(directionCode);
        }
 
 
        if (codes.size() < 1) {
            throw new BusinessException("流向码有误");
        }
 
        //循环查询
        List<SaleDetailVo> details = new ArrayList<>();
        for (String code : codes) {
            SaleDetailVo saleDetailVo = saleOrderDetailInfoMapper.selectOneByDirectionCode(code);
            if (saleDetailVo != null) {
                details.add(saleDetailVo);
            }
        }
        return details;
    }
 
    @Override
    @Transactional
    public void returnAndStorage(String directionCodes, String userId, String auth) {
 
 
        if (StringUtils.isBlank(userId)) {
            throw new BusinessException("用户信息不能为空");
        }
        UserInfo userInfo = userService.getById(userId);
        if (userInfo == null) {
            throw new BusinessException("用户不存在");
        }
 
        List<String> directionCodeList = new ArrayList<>();
        if (FireworkDeal.is22Characters(directionCodes)){
            DirectionDetail directionDetail = FireworkDeal.dealDirectionCode(directionCodes);
            List<ProductVo> productVos = new ArrayList<>();
            ProductVo productVo = productService.selectVoByDirection(directionCodes);
            FireworkDeal.getProductVos(directionCodes,directionDetail,directionDetail,productVos,productVo);
            if (productVos.size() > 0) {
                for (ProductVo product : productVos) {
                    directionCodeList.add(product.getDirectionCode());
                }
            }
        }else{
            //19位
            directionCodeList.add(directionCodes);
        }
 
 
        if (directionCodeList.size() < 1) {
            throw new BusinessException("流向码有误");
        }
        for (String directionCode : directionCodeList) {
 
            if (StringUtils.isBlank(directionCode) || FireworkDeal.isNotDirectionCode(directionCode)) {
                throw new BusinessException("流向码不符合规则,退货失败!");
            }
            StockInfo stockInfo = stockService.selectStockByDirection(directionCode);
//        if (stockInfo == null || !stockInfo.getOwner().equals(customerInfo.getId().toString())) {
//            msg.setCode(ErrorCode.ERROR_CODE);
//            msg.setMessage("库存状态异常,退货失败!");
//            return msg;
//        }
            ProductInfo productInfo = productService.selectByDirection(directionCode.substring(0, 10));
 
            // 创建入库单,type为2,创建入库明细,修改stock
            EntryOrderInfo entryOrderInfo = entryService.generateEntryOrderInfo(EntryUtils.TH_ENTRY, userInfo, new Date(), "", auth);
            EntryDetailInfo entryDetailInfo = new EntryDetailInfo(entryOrderInfo.getCode(), directionCode, productInfo.getDirectionCode(),
                    productInfo.getName(), productInfo.getManufacturer(), new Date(),userInfo.getCompanynumber());
            entryOrderInfo.setNum(1);
            entryDetailInfo.setNum(1);
            //查找未退货的商品记录
            SaleOrderDetailInfo detailInfo = saleOrderService.selectOrderByDirectionReturnflag(directionCode,(byte) 0, null);
            if (detailInfo == null) {
                throw new BusinessException("条码:" + directionCode + ",已退货入库或者记录不存在");
            }
            Byte flag = 1;
            detailInfo.setReturnflag(flag);
            this.updateById(detailInfo);
 
            int i = stockService.doReturn(stockInfo,userInfo,null, new Date());
            if (i != 1){
                throw new BusinessException("更新失败");
            }else {
                entryService.save(entryOrderInfo);
                entryDetailService.save(entryDetailInfo);
            }
        }
 
 
    }
 
    @Override
    public IPage selectSaleNumInfo(Page<SaleNumVo> page, Map<String, Object> filter, UserInfo user) {
 
        List<SaleNumVo> records = saleOrderDetailInfoMapper.selectSaleNumInfo(page, filter);
        page.setRecords(records);
        return page;
    }
 
    @Override
    public IPage selectSaleNumInfoDetail(Page<SaleOrderDetailInfo> page, Map<String, Object> filter, UserInfo user) {
        List<SaleOrderDetailInfo> records = saleOrderDetailInfoMapper.selectSaleNumInfoDetail(page, filter);
        page.setRecords(records);
        return page;
    }
 
    @Override
    public IPage getCityInAndOutDetail(Page<Map> page, Map<String, Object> filter) {
 
        Map<String, Object> params = new HashMap<>();
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("province", "新疆维吾尔自治区");
        params.put("city", filter.get("city"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        List<Map> list = saleOrderDetailInfoMapper.selectCityInAndOutDetail(page, params);
        return page.setRecords(list);
    }
 
    @Override
    public List<Map> getCityInAndOutExport(Map<String, Object> filter) {
        Map<String, Object> params = new HashMap<>();
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("province", "新疆维吾尔自治区");
        params.put("safetysupervision", filter.get("safetysupervision"));
        return saleOrderDetailInfoMapper.selectCityInAndOut(params);
    }
 
    @Override
    public IPage selectCityTypeSale(Page<Map> page, Map<String, Object> filter) {
        Map<String, Object> params = new HashMap<>();
        params.put("province", "新疆维吾尔自治区");
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        List<String> list = productService.selectTypes();
        List<Map> res =  saleOrderDetailInfoMapper.selectCityTypeSale(page,params,list);
        Map totalRow = saleOrderDetailInfoMapper.selectAllType(list, params);
        ArrayList<Map> result = new ArrayList<>(res);
        result.add(totalRow);
        return page.setRecords(result);
    }
 
    @Override
    public List<Map> selectCityTypeSaleExport(Map<String, Object> filter) {
        Map<String, Object> params = new HashMap<>();
        params.put("province", "新疆维吾尔自治区");
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        List<String> list = productService.selectTypes();
        List<Map> res = saleOrderDetailInfoMapper.selectCityTypeSale(params, list);
        Map totalRow = saleOrderDetailInfoMapper.selectAllType(list, params);
        ArrayList<Map> result = new ArrayList<>(res);
        result.add(totalRow);
        return result;
    }
 
    @Override
    public IPage selectEnterpriseTypeSale(Page<Map> page, Map<String, Object> filter, UserInfo user) {
        Map<String, Object> params = new HashMap<>();
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        params.put("province", filter.get("province"));
        params.put("city", filter.get("city"));
        params.put("district", filter.get("district"));
        List<String> list = productService.selectTypes();
        List<Map> res =  saleOrderDetailInfoMapper.selectEnterpriseTypeSale(page,params,list);
        //合计行
        Map totalRow = saleOrderDetailInfoMapper.selectAllType(list, params);
        ArrayList<Map> result = new ArrayList<>(res);
        result.add(totalRow);
        return page.setRecords(result);
    }
 
    @Override
    public List<Map> selectExportEnterpriseTypeSale(Map<String, Object> filter, UserInfo user) {
        Map<String, Object> params = new HashMap<>();
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        params.put("province", filter.get("province"));
        params.put("city", filter.get("city"));
        params.put("district", filter.get("district"));
        List<String> list = productService.selectTypes();
        List<Map> res =  saleOrderDetailInfoMapper.selectEnterpriseTypeSale(params,list);
        //合计行
        Map totalRow = saleOrderDetailInfoMapper.selectAllType(list, params);
        ArrayList<Map> result = new ArrayList<>(res);
        result.add(totalRow);
        return result;
    }
 
 
    private Date moveForwardDays(Integer days) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(new Date());
        //当前日期往前推days天
        calendar.add(Calendar.DATE, -days);
        return calendar.getTime();
    }
 
    @Override
    public IPage selectDistrictTypeSale(Page<Map> page, Map<String, Object> filter) {
        Map<String, Object> params = new HashMap<>();
        params.put("province", "新疆维吾尔自治区");
        params.put("city", filter.get("city"));
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        List<String> list = productService.selectTypes();
        List<Map> res =  saleOrderDetailInfoMapper.selectDistrictTypeSale(page,params,list);
        Map totalRow = saleOrderDetailInfoMapper.selectAllDistrictType(list, params);
        ArrayList<Map> result = new ArrayList<>(res);
        result.add(totalRow);
        return page.setRecords(result);
    }
 
    @Override
    public List<Map> selectDistrictTypeSaleExport(Map<String, Object> filter) {
        Map<String, Object> params = new HashMap<>();
        params.put("province", "新疆维吾尔自治区");
        params.put("city", filter.get("city"));
        params.put("starttime", filter.get("starttime"));
        params.put("endtime", filter.get("endtime"));
        params.put("enterprisename", filter.get("enterprisename"));
        params.put("safetysupervision", filter.get("safetysupervision"));
        List<String> list = productService.selectTypes();
        List<Map> res = saleOrderDetailInfoMapper.selectDistrictTypeSale(params, list);
        Map totalRow = saleOrderDetailInfoMapper.selectAllDistrictType(list, params);
        ArrayList<Map> result = new ArrayList<>(res);
        result.add(totalRow);
        return result;
    }
 
    @Override
    public void saveBatchOrderDetailInfo(List<SaleOrderDetailInfo> detailInfoList) {
        if (detailInfoList == null || detailInfoList.size() == 0) {
            throw new BusinessException("系统参数为空");
        }
        int i = saleOrderDetailInfoMapper.saveBatchOrderDetailInfo(detailInfoList);
    }
}