zss
2024-12-30 97bb7a8832281eafe0ef947ea095258d355e52f5
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
package com.yuanchu.mom.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.mapper.StandardMethodListMapper;
import com.yuanchu.mom.mapper.StandardProductListMapper;
import com.yuanchu.mom.pojo.StandardMethodList;
import com.yuanchu.mom.pojo.StandardProductList;
import com.yuanchu.mom.service.StandardMethodListService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.util.*;
 
/**
* @author Administrator
* @description 针对表【standard_method_list(标准树下的标准列表)】的数据库操作Service实现
* @createDate 2024-03-04 13:44:04
*/
@Service
@AllArgsConstructor
public class StandardMethodListServiceImpl extends ServiceImpl<StandardMethodListMapper, StandardMethodList>
    implements StandardMethodListService{
 
    private StandardMethodListMapper standardMethodListMapper;
 
    private StandardProductListMapper standardProductListMapper;
 
    @Override
    public int addStandardMethodList(Integer standardId, String tree) {
        String[] trees = tree.split(" - ");
        Map<String, String> map = standardMethodListMapper.selectStandardMethodById(standardId);
        StandardMethodList list = new StandardMethodList();
        list.setCode(map.get("code"));
        list.setName(map.get("name"));
        list.setRemark(map.get("remark"));
        list.setFactory(trees[0]);
        try {
            list.setLaboratory(trees[1]);
        }catch (Exception e){}
        try {
            list.setSampleType(trees[2]);
        }catch (Exception e){}
        try {
            list.setSample(trees[3]);
        }catch (Exception e){}
        try {
            list.setModel(trees[4]);
        }catch (Exception e){}
        standardMethodListMapper.insert(list);
        List<StandardProductList> standardProductLists = standardMethodListMapper.selectParameterList(list.getCode());
        for (StandardProductList standardProductList : standardProductLists) {
            standardProductList.setStandardMethodListId(list.getId());
            standardProductList.setFactory(trees[0]);
            try {
                standardProductList.setLaboratory(trees[1]);
            }catch (Exception e){}
            try {
                standardProductList.setSampleType(trees[2]);
            }catch (Exception e){}
            try {
                standardProductList.setSample(trees[3]);
            }catch (Exception e){}
            try {
                standardProductList.setModel(trees[4]);
            }catch (Exception e){}
            standardProductListMapper.insert(standardProductList);
        }
        return 1;
    }
 
    @Override
    public Map<String, List<?>> selectsStandardMethodByFLSSM(String tree) {
        String[] trees = tree.split(" - ");
        Map<String, List<?>> map = new HashMap<>();
        String str = "";
        List<StandardMethodList> standardMethodLists = new ArrayList<>();
        switch (trees.length){
            case 5:
                str += "\"" + trees[2] + "\",\"" + trees[3] + "\",\"" + trees[4] + "\"";
                standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str));
                standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[2] + "\",\"" + trees[3] + "\""));
                standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[2] + "\""));
                break;
            case 4:
                str += "\"" + trees[2] + "\",\"" + trees[3] + "\"";
                standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists(str));
                standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists("\"" + trees[2] + "\""));
                break;
            case 3:
                str += "\"" + trees[2] + "\"";
                standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodLists3(str));
                break;
            default:
                map.put("standardMethodList", null);
                return map;
        }
        standardMethodLists.addAll(standardMethodListMapper.selectStandardMethodListsByNull(str));
        map.put("standardMethodList", standardMethodLists);
        return map;
    }
 
    @Override
    public Map<String, List<?>> selectsStandardMethodByFLSSM2(String tree) {
        String[] trees = tree.split(" - ");
        List<StandardMethodList> standardMethodLists = null;
        switch (trees.length){
            case 5:
                standardMethodLists = standardMethodListMapper.selectStandardMethodLists2(trees[0],trees[1],trees[2],trees[3],trees[4]);
                break;
            case 4:
                standardMethodLists = standardMethodListMapper.selectStandardMethodLists2(trees[0],trees[1],trees[2],trees[3],null);
                break;
            case 3:
                standardMethodLists = standardMethodListMapper.selectStandardMethodLists2(trees[0],trees[1],trees[2],null,null);
                break;
            case 2:
                standardMethodLists = standardMethodListMapper.selectStandardMethodLists2(trees[0],trees[1],null,null,null);
                break;
            case 1:
                standardMethodLists = standardMethodListMapper.selectStandardMethodLists2(trees[0],null,null,null,null);
                break;
        }
        Map<String, List<?>> map = new HashMap<>();
        map.put("standardMethodList", standardMethodLists);
        return map;
    }
 
    @Override
    public int delStandardMethodByFLSSM(Integer id) {
        standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id));
        return standardMethodListMapper.deleteById(id);
    }
    @Override
    public List<StandardMethodList> selectStandardMethodEnum() {
        return standardMethodListMapper.selectListEnum();
    }
 
    @Override
    public Integer getStandardMethodId(String code) {
        return baseMapper.getStandardMethodId(code);
    }
}