Andru
2023-12-22 7ee867936786bc685c26acd88c739f6eb58c32b9
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
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
package com.hx.phip.controller.deduction;
 
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hx.common.BaseController;
import com.hx.exception.TipsException;
import com.hx.mybatisTool.SqlSentence;
import com.hx.phiappt.common.DeductionSingleConstants;
import com.hx.phiappt.constants.tool.PerformanceInfoTool;
import com.hx.phiappt.constants.tool.user.UserProjectTool;
import com.hx.phiappt.dao.mapper.NotificationLogMapper;
import com.hx.phiappt.dao.mapper.ProjectMapper;
import com.hx.phiappt.model.*;
import com.hx.phiappt.model.deduction.*;
import com.hx.phiappt.model.intro.IntroProjectManual;
import com.hx.phiappt.model.performance.PerformanceInfo;
import com.hx.phip.config.CustomParameter;
import com.hx.phip.dao.mapper.ShopMapper;
import com.hx.phip.dao.mapper.UserMapper;
import com.hx.phip.service.ComparePhotoRecordPicturesService;
import com.hx.phip.service.ComparePhotoRecordService;
import com.hx.phip.service.deduction.*;
import com.hx.resultTool.Result;
import com.hx.util.HttpServletRequestUtil;
import com.hx.util.StringUtils;
import com.hx.util.thread.ExecutorServiceTool;
import com.hz.his.dto.deduction.DeductionDto;
import com.platform.constants.LoginConstant;
import com.platform.entity.ThirtApplication;
import com.platform.exception.PlatTipsException;
import com.platform.resultTool.PlatformCode;
import com.platform.resultTool.PlatformResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 执行划扣控制器
 *
 * @USER: Andru
 * @DATE: 2021/12/10
 */
@RestController
@RequestMapping("/deduction")
public class DeductionController extends BaseController {
 
    //log4j日志
    private static final Logger logger = LoggerFactory.getLogger(DeductionController.class.getName());
 
    /**固定线程池-改*/
    public static ExecutorServiceTool threadPool = new ExecutorServiceTool(10,200);
 
    @Resource
    private CustomParameter customParameter;
    @Resource
    private DeductionSingleService deductionSingleService;
    @Resource
    private DeductionProjectService deductionProjectService;
    @Resource
    private DeductionJoinService deductionJoinService;
    @Resource
    private DeductionSignService deductionSignService;
    @Resource
    private DeductionDrugsService deductionDrugsService;
    @Resource
    private DeductionDeviceParameterService deductionDeviceParameterService;
    @Resource
    private ComparePhotoRecordService comparePhotoRecordService;
    @Resource
    private ComparePhotoRecordPicturesService comparePhotoRecordPicturesService;
 
    /**
     * 获取划扣清单id
     * @param param 参数值
     * @return id
     */
    private String getId(String param) {
        JSONObject jsonObject = JSONObject.parseObject(param);
        if (jsonObject == null || !jsonObject.containsKey("deductionSingleId")) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "参数不能为空不能为空");
        }
        // 获取接收的对象
        return jsonObject.getString("deductionSingleId");
    }
 
    /**
     * 校验参数
     * @param deductionDto 参数对象
     */
    private void checkParam(DeductionDto deductionDto) {
        if (StringUtils.isEmpty(deductionDto.getUserProjectId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空");
        }
 
        if (deductionDto.getDeductionNum() <= 0) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "数量/划扣次数需要大于0");
        }
 
        /* if (deductionDto.getExecuteStartTime() == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "执行开始时间不内为空!");
        }
 
        if (deductionDto.getExecuteEndTime() == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "执行结束时间不内为空!");
        } */
    }
 
    /**
     * 查看记录
     */
    @RequestMapping(value = "/see", method = RequestMethod.POST)
    public Result seeData(HttpServletRequest request, @RequestBody String param) {
        // 获取接收的参数里面的id
        String deductionSingleId = getId(param);
 
        // 获取用户信息
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
 
        Map<String, Object> mapData = new HashMap<>();
        DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId);
        if (deductionSingle != null) {
            // 划扣记录
            mapData.put("deductionSingle", deductionSingle);
            // 项目划扣
            DeductionProject deductionProject = deductionProjectService.selectOneByDeductionSingleId(deductionSingle.getId());
            mapData.put("deductionProject", deductionProject);
            if (deductionProject != null) {
                // 参与人员信息
                List<DeductionJoin> deductionJoinList = deductionJoinService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
                mapData.put("deductionJoinList", deductionJoinList);
                // 消耗物品信息
                List<DeductionDrugs> deductionDrugsList = deductionDrugsService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
                mapData.put("deductionDrugsList", deductionDrugsList);
                // 治疗参数(设备)信息
                List<DeductionDeviceParameter> deductionDeviceParameterList = deductionDeviceParameterService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
                mapData.put("deductionDeviceParameterList", deductionDeviceParameterList);
                // 客户签名信息
                List<DeductionSign> deductionSignList = deductionSignService.selectListByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
                mapData.put("deductionSignList", deductionSignList);
                // 治疗图片
                ComparePhotoRecord comparePhotoRecord = comparePhotoRecordService.selectOneByDeductionSingleId(deductionSingle.getId(), deductionProject.getId());
                if (comparePhotoRecord != null) {
                    List<ComparePhotoRecordPictures> comparePhotoRecordPicturesList = comparePhotoRecordPicturesService.selectListByComparePhotoRecordId(comparePhotoRecord.getId());
                    mapData.put("comparePhotoRecordPicturesList", comparePhotoRecordPicturesList);
                } else {
                    mapData.put("comparePhotoRecordPicturesList", null);
                }
            }
        }
        return Result.success(mapData);
    }
 
    /**
     * 新增划扣记录
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result addData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        logger.info("新增划扣记录打印入参数据:"+ JSONObject.toJSONString(deductionDto));
        // 校验参数
        checkParam(deductionDto);
        // 获取用户信息
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 填充接口登入信息
        deductionDto.setAppId(thirtApplication.getAppId());
        deductionDto.setAppIdCode(thirtApplication.getAppIdCode());
        deductionDto.setSourceCode(thirtApplication.getAppId());
        deductionDto.setSourceName(thirtApplication.getName());
 
        // 添加数据
        String id = deductionSingleService.editInfo(deductionDto, BaseEntity.YES);
 
        logger.info("多线程队列数DeductionController-1:{}", threadPool.getThreadPool().getQueue().size());
 
        // 判断是否发送消息
        if (BaseEntity.YES == deductionDto.getIsSentNotice()) {
            // 发送公众号确认消息
            threadPool.getThreadPool().execute(() -> deductionSingleService.sendConfirmNotice(id));
            // 发送划扣成功调查问卷
            threadPool.getThreadPool().execute(() -> deductionSingleService.sendGZHQuestionnaire(id));
        }
        // 计算新增划扣业绩信息
        threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(id, BaseEntity.YES));
        // 划扣自动打标签处理
        threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(id));
        // 处理保妥适俱乐部权益
        threadPool.getThreadPool().execute(() -> deductionSingleService.handleBotoxClub(id));
        // 返回id
        return Result.success(id);
    }
 
    /**
     * 新增划扣记录(Phitab数据划扣)
     */
    //@RequestMapping(value = "/add/phitab", method = RequestMethod.POST)
    public Result addPhitabData(@RequestBody DeductionDto deductionDto) {
        logger.info("新增划扣记录(Phitab)打印入参数据:"+ JSONObject.toJSONString(deductionDto));
        // 校验参数
        checkParam(deductionDto);
        // 填充接口登入信息
        deductionDto.setAppId("phitab");
        deductionDto.setAppIdCode("phitab");
        deductionDto.setSourceCode("phitab");
        deductionDto.setSourceName("phitab");
        // 添加数据
        String id = deductionSingleService.addInfoPhitab(deductionDto);
        // 返回id
        return Result.success(id);
    }
 
    /**
     * 新增划扣记录 直接划扣his系统
     */
    //@RequestMapping(value = "/add", method = RequestMethod.POST)
    public Result addHisData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        // 获取用户信息
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 填充接口登入信息
        deductionDto.setAppId(thirtApplication.getAppId());
        deductionDto.setAppIdCode(thirtApplication.getAppIdCode());
        deductionDto.setSourceCode(thirtApplication.getAppId());
        deductionDto.setSourceName(thirtApplication.getName());
 
        // 校验参数
        if (StringUtils.isEmpty(deductionDto.getUserProjectId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空");
        }
 
        if (StringUtils.isEmpty(deductionDto.getShopId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "userProjectId不能为空");
        }
 
        if (deductionDto.getDeductionNum() <= 0) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "数量/划扣次数需要大于0");
        }
 
        // 划扣成功返回hisId
        //String id = deductionSingleService.hisDeduction(deductionDto);
        String id = "";
        return Result.success(id);
    }
 
    /**
     * 批量新增划扣记录
     */
    @RequestMapping(value = "/batch/add", method = RequestMethod.POST)
    public Result batchAddData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        logger.info("批量新增划扣记录打印入参数据:"+ JSONObject.toJSONString(deductionDto));
        // 获取用户信息
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 填充接口登入信息
        deductionDto.setAppId(thirtApplication.getAppId());
        deductionDto.setAppIdCode(thirtApplication.getAppIdCode());
        deductionDto.setSourceCode(thirtApplication.getAppId());
        deductionDto.setSourceName(thirtApplication.getName());
 
        // 判断 批量添加项目id列表 是否为空
        if (StringUtils.isEmpty(deductionDto.getUserProjectIds())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "批量添加项目id列表不能为空");
        }
 
        // 解析批量id
        List<String> userProjectIdList = JSONArray.parseArray(deductionDto.getUserProjectIds(), String.class);
 
        // 判断是否传值
        if (userProjectIdList == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户项目id列表不能为空!");
        }
 
        // 批量划扣
        for (String userProjectId : userProjectIdList) {
            deductionDto.setUserProjectId(userProjectId);
            // 添加数据
            String id = deductionSingleService.editInfo(deductionDto, BaseEntity.YES);
            // 切换领建屏蔽代码 date:20230108
            /*// 参数构造
            DeductionDto paramDeductionDto = new DeductionDto();
            paramDeductionDto.setDeductionSingleId(id);
            // 同步划扣记录到his系统
            String returnData;
            try {
                returnData = ApiPlatformUtil.syncHisDeduction(customParameter, id);
            } catch (Exception ex) {
                logger.error("同步划扣数据到his系统失败!", ex);
                // his操作失败删除记录
                deductionSingleService.deleteOne(paramDeductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL);
                throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + ex.getMessage());
            }
            // 处理返回消息
            if (!StringUtils.isEmpty(returnData)) {
                JSONObject jsonObject = JSONObject.parseObject(returnData);
                String code = jsonObject.getString("code");
                if (!"100".equals(code)) {
                    String error = jsonObject.getString("msg");
                    // his操作失败删除记录
                    deductionSingleService.deleteOne(paramDeductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL);
                    throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + error);
                } else {
                    String hisId = jsonObject.getString("data");
                    if (!StringUtils.isEmpty(hisId)) {
                        SqlSentence sqlSentence = new SqlSentence();
                        String sql = String.format(" hisId='%s' WHERE isDel = 0 AND id ='%s'", hisId, id);
                        sqlSentence.setSqlSentence(sql);
                        deductionSingleService.updateWhere(sqlSentence);
                    }
                }
            } else {
                deductionSingleService.deleteOne(paramDeductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL);
                throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回空消息!");
            }*/
        }
        return Result.success();
    }
 
    /**
     * 修改划扣记录 注释划扣没有编辑功能
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Result updateData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        logger.info("修改划扣记录打印入参数据:"+ JSONObject.toJSONString(deductionDto));
        // 判断deductionSingleId 是否为空
        if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空");
        }
        // 校验参数
        checkParam(deductionDto);
        // 获取用户信息
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 填充接口登入信息
        deductionDto.setAppId(thirtApplication.getAppId());
        deductionDto.setAppIdCode(thirtApplication.getAppIdCode());
        deductionDto.setSourceCode(thirtApplication.getAppId());
        deductionDto.setSourceName(thirtApplication.getName());
 
        // 添加数据
        deductionSingleService.editInfo(deductionDto, BaseEntity.NO);
 
        return Result.success();
    }
 
    /**
     * 删除记录
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Result deleteData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        logger.info("删除划扣记录接口打印入参数据:"+ JSONObject.toJSONString(deductionDto));
        // 判断deductionSingleId 是否为空
        if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空");
        }
        // 判断操作人id 是否为空
        if (StringUtils.isEmpty(deductionDto.getOperatorId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "operatorId不能为空");
        }
        // 验签数据
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 删除数据
        deductionSingleService.deleteOne(deductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_CANCEL, BaseEntity.NO);
 
        logger.info("多线程队列数DeductionController-2:{}", threadPool.getThreadPool().getQueue().size());
        // 计算撤销或删除划扣业绩信息
        threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(deductionDto.getDeductionSingleId(), BaseEntity.NO));
        // 划扣自动打标签处理
        threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(deductionDto.getDeductionSingleId()));
        // 返回
        return Result.success();
    }
 
    /**
     * 作废记录
     */
    @RequestMapping(value = "/rescinded", method = RequestMethod.POST)
    public Result rescindedData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        logger.info("撤销划扣记录接口打印入参数据:"+ JSONObject.toJSONString(deductionDto));
        // 判断deductionSingleId 是否为空
        if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空");
        }
        // 判断操作人id 是否为空
        if (StringUtils.isEmpty(deductionDto.getOperatorId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "operatorId不能为空");
        }
        // 验签数据
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 删除数据
        deductionSingleService.deleteOne(deductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED, BaseEntity.NO);
        logger.info("多线程队列数DeductionController-3:{}", threadPool.getThreadPool().getQueue().size());
        // 计算撤销或删除划扣业绩信息
        threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(deductionDto.getDeductionSingleId(), BaseEntity.NO));
        // 划扣自动打标签处理
        threadPool.getThreadPool().execute(() -> deductionSingleService.autoTag(deductionDto.getDeductionSingleId()));
        // 保妥适俱乐部撤回赠送优惠券
        threadPool.getThreadPool().execute(() -> deductionSingleService.cancelDeductionSingleCoupon(deductionDto.getDeductionSingleId()));
        // 作废划扣发通知给护士长
        threadPool.getThreadPool().execute(() -> deductionSingleService.cancelDeductionSingleSentNotice(deductionDto.getDeductionSingleId()));
        // 返回
        return Result.success();
    }
 
    /**
     * 作废记录(不退回库存)
     */
    @RequestMapping(value = "/rescinded/not/stock", method = RequestMethod.POST)
    public Result rescindedNotStockData(HttpServletRequest request, @RequestBody DeductionDto deductionDto) {
        logger.info("撤销划扣记录(不退回库存)接口打印入参数据:" + JSONObject.toJSONString(deductionDto));
        // 判断deductionSingleId 是否为空
        if (StringUtils.isEmpty(deductionDto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "deductionSingleId不能为空");
        }
        // 判断操作人id 是否为空
        if (StringUtils.isEmpty(deductionDto.getOperatorId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "operatorId不能为空");
        }
        // 验签数据
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        // 删除数据
        deductionSingleService.deleteOne(deductionDto, thirtApplication.getAppId(), thirtApplication.getName(), DeductionSingleConstants.STATUS_RESCINDED, BaseEntity.YES);
        logger.info("多线程队列数DeductionController-4:{}", threadPool.getThreadPool().getQueue().size());
 
        // 计算撤销或删除划扣业绩信息
        threadPool.getThreadPool().execute(() -> this.handlerPerformanceInfoDeduction(deductionDto.getDeductionSingleId(), BaseEntity.NO));
        return Result.success();
    }
 
    /**
     * 同步划扣到his系统
     */
    @RequestMapping(value = "/sync/deduction/his", method = RequestMethod.POST)
    public PlatformResult syncToHis(HttpServletRequest request) {
        // 获取返回参数
        String bodyData = HttpServletRequestUtil.getBody(request);
        if (StringUtils.isEmpty(bodyData)) {
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误");
        }
 
        // 获取传参
        JSONObject jsonObject = JSONObject.parseObject(bodyData);
        if (jsonObject == null || !jsonObject.containsKey("deductionSingleId")) {
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "参数错误!");
        }
 
        String deductionSingleId = jsonObject.getString("deductionSingleId");
 
        if (StringUtils.isEmpty(deductionSingleId)) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "划扣记录id不能为空!");
        }
 
        DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId);
        if (deductionSingle == null) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到划扣记录!");
        } else {
            if (!StringUtils.isEmpty(deductionSingle.getHisId())) {
                throw new PlatTipsException(PlatformCode.ERROR_TIPS, "您的记录已同步,请不要重复同步划扣记录!");
            }
        }
 
        // 切换领建屏蔽代码 date:20230108
        /*// 同步划扣记录到his系统
        String returnHisData;
        try {
            returnHisData = ApiPlatformUtil.syncHisDeduction(customParameter, deductionSingleId);
        } catch (Exception ex) {
            logger.error("同步划扣数据到his系统失败!", ex);
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + ex.getMessage());
        }
        if (!StringUtils.isEmpty(returnHisData)) {
            JSONObject jsonHisObject = JSONObject.parseObject(returnHisData);
            String code = jsonHisObject.getString("code");
            if (!"100".equals(code)) {
                String error = jsonHisObject.getString("msg");
                throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回错误消息:" + error);
            } else {
                String hisId = jsonHisObject.getString("data");
                if (!StringUtils.isEmpty(hisId)) {
                    SqlSentence sqlSentence = new SqlSentence();
                    String sql = String.format(" hisId='%s' WHERE isDel = 0 AND id ='%s'", hisId, deductionSingleId);
                    sqlSentence.setSqlSentence(sql);
                    deductionSingleService.updateWhere(sqlSentence);
                }
            }
        } else {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "同步划扣到his系统失败! 返回空消息!");
        }*/
        return PlatformResult.success();
    }
 
    /**
     * 同步修改划扣到his系统
     */
    @RequestMapping(value = "/sync/edit/deduction/his", method = RequestMethod.POST)
    public PlatformResult syncEditHis(HttpServletRequest request) {
        // 获取返回参数
        String bodyData = HttpServletRequestUtil.getBody(request);
        if (StringUtils.isEmpty(bodyData)) {
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误");
        }
 
        // 获取传参
        JSONObject jsonObject = JSONObject.parseObject(bodyData);
        if (jsonObject == null || !jsonObject.containsKey("deductionSingleId")) {
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "参数错误!");
        }
 
        String deductionSingleId = jsonObject.getString("deductionSingleId");
 
        if (StringUtils.isEmpty(deductionSingleId)) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "划扣记录id不能为空!");
        }
 
        DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(deductionSingleId);
        if (deductionSingle == null) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "未找到划扣记录!");
        }
        // 切换领建屏蔽代码 date:20230108
        /*// 同步操作到领建
        deductionSingleService.syncEditHisDeduction(deductionSingle.getId());*/
        // 返回
        return PlatformResult.success();
    }
 
    /**
     * 查看his划扣接口
     */
    @RequestMapping(value = "/sync/executionRecord/get/obtain", method = RequestMethod.POST)
    public PlatformResult syncToHis(HttpServletRequest request,@RequestBody(required = false) DeductionDto dto) {
        if (dto==null) {
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式异常");
        }
 
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "验签失败!");
        }
        if(StringUtils.isEmpty(dto.getUserId())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户标识未空");
        }
        if(StringUtils.isEmpty(dto.getShopId())){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "门店标识未空");
        }
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> map=new HashMap<>();
        sqlSentence.setM(map);
        map.put("isDel",BaseEntity.NO);
        map.put("userId",dto.getUserId());
        map.put("shopId",dto.getShopId());
        User user=commonService.selectOneByKey(UserMapper.class,dto.getUserId());
        if(user==null){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "该用户不存在");
        }
        Shop shop=commonService.selectOneByKey(ShopMapper.class,dto.getShopId());
        if(shop==null){
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "该门店不存在");
        }
        // 切换领建屏蔽代码 date:20230108
        /*JSONObject param =new JSONObject();
        param.put("clinicId",shop.getApiId());
        param.put("customerId",user.getApiId());
        param.put("page",dto.getPage()==null?0:dto.getPage());
        param.put("size",dto.getSize()==null?20:dto.getSize());
        param.put("start",dto.getLogStartTime());
        param.put("end",dto.getLogEndTime());
        String returnData = ApiPlatformUtil.executionRecordLog(customParameter, param);
        if(StringUtils.noNull(returnData)){
            JSONObject jsonObject = JSONObject.parseObject(returnData);
            String code = jsonObject.getString("code");
            if("100".equals(code)){
                String data = jsonObject.getString("data");
                if(StringUtils.isEmpty(data)){
                    throw new PlatTipsException(PlatformCode.ERROR_TIPS,"同步中心-查看划扣日志操作:返回data没有数据");
                }
                JSONObject contentsObject = JSONObject.parseObject(data);
                JSONObject object;
                JSONArray jsonArray=new JSONArray();
                if(contentsObject!=null){
                    JSONArray contentList = contentsObject.getJSONArray("content");
                    if(contentList!=null || contentList.size()>0){
                        for(int i=0;i<contentList.size();i++){
                            object=new JSONObject();
                            JSONObject datas = contentList.getJSONObject(i);
 
                            JSONObject creator = datas.getJSONObject("creator");//创建人
                            JSONObject service = datas.getJSONObject("service");//项目
                            Long executedDate = datas.getLong("executedDate");//执行时间
 
                            Project project=null;
                            if(service != null){
                                map.clear();
                                map.put("apiId",service.getString("id"));
                                sqlSentence.setSqlSentence("select * from project where apiId =#{m.apiId} and  isDel=0 ");
                                project=commonService.selectOne(ProjectMapper.class,sqlSentence);
                            }
                            Employee employee=null;
                            if(creator!=null){
                                map.clear();
                                map.put("apiId",creator.getString("id"));
                                sqlSentence.setSqlSentence("select * from employee where apiId =#{m.apiId} and  isDel=0 ");
                                employee=commonService.selectOne(EmployeeMapper.class,sqlSentence);
                            }
 
                            //执行时间
                            object.put("executedDate",executedDate==null?"": DateUtil.timestampToDate(executedDate,"yyyy-MM-dd HH:mm:ss"));
                            object.put("executedDate",executedDate==null?"": executedDate);
                            //划扣项目
                            object.put("projectName",project==null ?"":project.getName());
                            object.put("projectId",project==null ?"":project.getId());
                            object.put("projectHisId",project==null ?"":project.getApiId());
                            //执行次数
                            object.put("quantity",datas.getInteger("quantity")==null ?0:datas.getInteger("quantity"));
                            //创建人
                            object.put("projectName",employee==null ?"":employee.getCnName());
                            object.put("projectId",employee==null ?"":employee.getId());
                            object.put("projectHisId",employee==null ?"":employee.getApiId());
 
                            jsonArray.add(object);
                        }
                    }
                }
                return PlatformResult.success(jsonArray);
            }else{
                //旭爷说除了100 都是失败
                throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"同步中心-查看划扣日志:同步中心返回的状态:"+code);
            }
        }else{
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"同步中心-查看划扣日志操作解析第三方参数为空");
        }*/
        return PlatformResult.success();
    }
 
    /**
     * 发送单条公众号消息
     */
    @RequestMapping(value = "/send/gzh/notice", method = RequestMethod.POST)
    public PlatformResult sendGZHNotice(HttpServletRequest request, @RequestBody DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣参数");
        }
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!");
        }
        if (StringUtils.isEmpty(dto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣id参数");
        }
        logger.info("打印发送单条公众号消息接口参数:{}", JSONObject.toJSONString(dto));
        // 校验参数
        DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(dto.getDeductionSingleId());
        if (deductionSingle == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "划扣记录不存在");
        }
        // 发送单条公众号消息
        deductionSingleService.sendGZHNotice(dto.getDeductionSingleId());
        // 返回
        return PlatformResult.success();
    }
 
    /**
     * 划扣客户确认
     */
    @RequestMapping(value = "/customer/confirm", method = RequestMethod.POST)
    public PlatformResult customerConfirm(HttpServletRequest request, @RequestBody DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣参数");
        }
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!");
        }
        if (StringUtils.isEmpty(dto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣id参数");
        }
        if (dto.getIsCustomerConfirm() == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传是否客户确认参数");
        } else {
            if (!BaseEntity.YES.equals(dto.getIsCustomerConfirm())) {
                throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传正确的客户确认值");
            }
        }
        logger.info("打印客户确认划扣参数:{}", JSONObject.toJSONString(dto));
        // 校验参数
        DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(dto.getDeductionSingleId());
        if (deductionSingle == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "划扣记录不存在");
        }
        if (deductionSingle.getIsCustomerConfirm() != null) {
            if (BaseEntity.YES.equals(deductionSingle.getIsCustomerConfirm())) {
                throw new PlatTipsException(PlatformCode.ERROR_TIPS, "划扣记录已确认,请勿重复确认!");
            }
        }
        // 处理状态
        deductionSingleService.customerConfirm(dto.getDeductionSingleId(), dto.getIsCustomerConfirm());
        // 返回
        return PlatformResult.success();
    }
 
    /**
     * 划扣客户确认所有
     */
    @RequestMapping(value = "/customer/confirm/all", method = RequestMethod.POST)
    public PlatformResult customerConfirmAll(HttpServletRequest request, @RequestBody DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣参数");
        }
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!");
        }
        if (StringUtils.isEmpty(dto.getUserId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传用户id参数");
        }
        if (dto.getIsCustomerConfirm() == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传是否客户确认参数");
        } else {
            if (!BaseEntity.YES.equals(dto.getIsCustomerConfirm())) {
                throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传正确的客户确认值");
            }
        }
        logger.info("打印客户确认所有划扣参数:{}", JSONObject.toJSONString(dto));
        // 校验参数
        User user = commonService.selectOneByKey(UserMapper.class, dto.getUserId());
        if (user == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "划用户不存在");
        }
        // 处理状态
        deductionSingleService.customerConfirmAll(dto.getUserId(), dto.getIsCustomerConfirm());
        // 返回
        return PlatformResult.success();
    }
 
    /**
     * 划扣客户确认之前页面
     */
    @RequestMapping(value = "/customer/confirm/before", method = RequestMethod.POST)
    public PlatformResult customerConfirmBefore(HttpServletRequest request, @RequestBody DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣参数");
        }
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!");
        }
        if (StringUtils.isEmpty(dto.getDeductionSingleId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣id参数");
        }
        logger.info("打印客户确认划扣之前页面接口参数:{}", JSONObject.toJSONString(dto));
        // 校验参数
        DeductionSingle deductionSingle = deductionSingleService.selectOneByKey(dto.getDeductionSingleId());
        if (deductionSingle == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "划扣记录不存在");
        }
        // 数据查询
        Map<String, Object> data = deductionSingleService.customerConfirmBefore(dto, deductionSingle);
        // 返回
        return PlatformResult.success(data);
    }
 
    /**
     * 划扣客户确认之前页面所有未确认数据
     */
    @RequestMapping(value = "/customer/confirm/all/before", method = RequestMethod.POST)
    public PlatformResult customerConfirmAllBefore(HttpServletRequest request, @RequestBody DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传划扣参数");
        }
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!");
        }
        if (StringUtils.isEmpty(dto.getUserId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传用户id参数");
        }
        logger.info("打印客户确认划扣之前页面所有数据接口参数:{}", JSONObject.toJSONString(dto));
        // 校验参数
        User user = commonService.selectOneByKey(UserMapper.class, dto.getUserId());
        if (user == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "划用户不存在");
        }
        // 返回数据处理
        List<Map<String, Object>> list = new ArrayList<>();
        // 获取数据处理
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> sqlValues = new HashMap<>();
        sqlValues.put("isDel", BaseEntity.NO);
        sqlValues.put("userId", dto.getUserId());
        sqlValues.put("isCustomerConfirm", BaseEntity.NO);
        sqlValues.put("status", DeductionSingleConstants.STATUS_DONE_EXECUTE);
        String sql = "SELECT * FROM deduction_single WHERE userId=#{m.userId} AND status=#{m.status} " +
                "AND isCustomerConfirm=#{m.isCustomerConfirm} AND isDel=#{m.isDel} ORDER BY createTime DESC";
        sqlSentence.sqlSentence(sql, sqlValues);
        List<DeductionSingle> deductionSingleList = deductionSingleService.selectList(sqlSentence);
        if (deductionSingleList != null && deductionSingleList.size() > 0) {
            for (DeductionSingle deductionSingle : deductionSingleList) {
                // 数据查询
                Map<String, Object> data = deductionSingleService.customerConfirmBefore(dto, deductionSingle);
                if (data != null && data.size() > 0) {
                    list.add(data);
                }
            }
        }
        // 返回
        return PlatformResult.success(list);
    }
 
    /**
     * 划扣计算业绩信息
     * @param deductionSingleId 划扣id
     * @param type 是否 新增划扣 0 否(撤销划扣) 1 是(新增划扣)
     */
    private synchronized void handlerPerformanceInfoDeduction(String deductionSingleId, Integer type) {
        try {
            deductionSingleService.handlerPerformanceInfoDeduction(deductionSingleId, type);
        } catch (Exception ex) {
            // 打印日志
            logger.error("划扣计算业绩信息出现错误,划扣id:{},错误信息:{}", deductionSingleId, ex);
            // 添加错误日志
            PerformanceInfoTool.addErrorLog(commonService, deductionSingleId, PerformanceInfo.ASSOCIATION_TYPE_DEDUCTION, ex.getMessage());
            // 企业微信错误提示
            deductionSingleService.performanceInfoErrorTips(deductionSingleId, ex.getMessage());
        }
    }
 
    /**
     * 获取用户划扣信息之前医生信息
     */
    @RequestMapping(value = "/project/before/doctor/info", method = RequestMethod.POST)
    public Result projectBeforeDoctorInfo(@RequestBody(required = false) DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA, "数据格式错误");
        }
        if (StringUtils.isEmpty(dto.getUserId())) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传用户id!");
        }
        // 判断用户信息
        User user = commonService.selectOneByKey(UserMapper.class, dto.getUserId());
        if (user == null) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "找不到用户!");
        }
        // 项目id数据
        if (dto.getProjectIds() == null || dto.getProjectIds().size() < 1) {
            throw new PlatTipsException(PlatformCode.ERROR_TIPS, "请传项目id数据!");
        }
        // 获取数据并返回处理
        List<Map<String, Object>> list = new ArrayList<>();
        for (String projectId : dto.getProjectIds()) {
            // 获取数据处理
            SqlSentence sqlSentence = new SqlSentence();
            Map<String, Object> sqlValues = new HashMap<>();
            sqlValues.put("isDel", BaseEntity.NO);
            sqlValues.put("userId", dto.getUserId());
            sqlValues.put("projectId", projectId);
            sqlValues.put("status", DeductionSingleConstants.STATUS_DONE_EXECUTE);
            String sql = "SELECT dp.projectId,dp.projectName,dp.departmentId,dp.departmentCode,dp.departmentName,dp.primaryDoctorId,dp.primaryDoctorName," +
                    "dp.treatmentDoctorId,dp.treatmentDoctorName FROM deduction_single AS ds LEFT JOIN deduction_project AS dp " +
                    "ON dp.deductionSingleId=ds.id WHERE ds.userId=#{m.userId} AND ds.status=#{m.status} AND dp.projectId=#{m.projectId} " +
                    "AND ds.isDel=#{m.isDel} ORDER BY ds.createTime DESC LIMIT 1";
            sqlSentence.sqlSentence(sql, sqlValues);
            Map<String, Object> map = deductionProjectService.selectOneMap(sqlSentence);
            if (map != null) {
                list.add(map);
            }
        }
        // 返回数据
        return Result.success(list);
    }
 
    /**
     * 划扣术后提示卡通知获取数据
     */
    @RequestMapping(value = "/postoperative/card/info", method = RequestMethod.POST)
    public PlatformResult postoperativeCardInfo(HttpServletRequest request, @RequestBody DeductionDto dto) {
        if (dto == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传参数");
        }
        ThirtApplication thirtApplication = (ThirtApplication) request.getSession().getAttribute(LoginConstant.LOGIN_APPLY);
        if (thirtApplication == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "签名失败,请检查签名!");
        }
        if (StringUtils.isEmpty(dto.getCommonId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "请传id参数");
        }
        logger.info("打印划扣术后提示卡通知获取数据接口参数:{}", JSONObject.toJSONString(dto));
        // 校验参数
        NotificationLog notificationLog = commonService.selectOneByKey(NotificationLogMapper.class, dto.getCommonId());
        if (notificationLog == null) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "数据不存在");
        }
        // 获取项目信息
        JSONArray projectIdList;
        try {
            projectIdList = JSONArray.parseArray(notificationLog.getOtherInfo());
        } catch (Exception ex) {
            throw new TipsException("解析项目信息列表出现异常!");
        }
        // 判断是否有项目信息
        if (projectIdList.size() <= 0) {
            throw new TipsException("解析项目信息列表不能为空!");
        }
        // 获取数据并返回处理
        List<Map<String, Object>> list = new ArrayList<>();
        // 查询数据
        SqlSentence sqlSentence = new SqlSentence();
        Map<String, Object> sqlValues = new HashMap<>();
        sqlValues.put("isDel", BaseEntity.NO);
        StringBuilder sql = new StringBuilder();
        // 获取查询数据
        StringBuilder sqlIn = new StringBuilder();
        for (int i = 0; i < projectIdList.size(); i++) {
            // 拼接数据
            String projectId = projectIdList.getString(i);
            if (!StringUtils.isEmpty(projectId)) {
                sqlIn.append("'").append(projectId).append("'");
                // 添加逗号符号分隔
                if (i != projectIdList.size() - 1) {
                    sqlIn.append(",");
                }
            }
        }
        sql.append(" SELECT * FROM project WHERE id IN (").append(sqlIn).append(") AND isDel=#{m.isDel} ORDER BY createTime ASC");
        sqlSentence.sqlSentence(sql.toString(), sqlValues);
        List<Project> projectList = commonService.selectList(ProjectMapper.class, sqlSentence);
        if (projectList != null && projectList.size() > 0) {
            for (Project project : projectList) {
                // 返回数据
                Map<String, Object> data = new HashMap<>();
                data.put("projectId", project.getId());
                data.put("projectName", project.getName());
                data.put("postoperativeCardUrl", "");
                // 获取术后提示卡信息
                IntroProjectManual introProjectManual = UserProjectTool.getIntroProjectManualByProject(commonService, project);
                if (introProjectManual != null && !StringUtils.isEmpty(introProjectManual.getContent())) {
                    data.put("postoperativeCardUrl", introProjectManual.getContent());
                }
                list.add(data);
            }
        }
        // 返回
        return PlatformResult.success(list);
    }
}