jiangping
2023-09-14 352d337c355f60909d9dd24bd613c12ea92f8015
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
package doumeemes.service.ext.impl;
 
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import doumeemes.core.model.LoginUserInfo;
import doumeemes.core.model.PageData;
import doumeemes.core.model.PageWrap;
import doumeemes.dao.business.model.Appliances;
import doumeemes.dao.business.model.WorkorderCheck;
import doumeemes.dao.ext.CategoryUnionExtMapper;
import doumeemes.dao.ext.dto.QueryCategoryUnionExtDTO;
import doumeemes.dao.ext.vo.CategoryUnionExtListVO;
import doumeemes.service.business.impl.AppliancesServiceImpl;
import doumeemes.service.business.impl.WorkorderCheckServiceImpl;
import doumeemes.service.ext.CategoryUnionExtService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 分类组合信息Service实现
 *
 * @author 江蹄蹄
 * @date 2022/04/27 16:15
 */
@Service
public class CategoryUnionExtServiceImpl implements CategoryUnionExtService {
 
    @Autowired
    private CategoryUnionExtMapper categoryUnionExtMapper;
 
    @Autowired
    private AppliancesServiceImpl appliancesServiceimpl;
    @Autowired
    private WorkorderCheckServiceImpl workorderCheckServiceimpl;
 
 
    @Override
    public PageData<CategoryUnionExtListVO> findPage(PageWrap<QueryCategoryUnionExtDTO> pageWrap) {
        PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity());
        List<CategoryUnionExtListVO> result = categoryUnionExtMapper.selectList(pageWrap.getModel());
        if (result.size() > 0) {
            for (int i = 0; i < result.size(); i++) {
                CategoryUnionExtListVO ca = result.get(i);
                String bname = ca.getBmodel() != null ? ca.getBmodel().getName() : "";
                String mname = ca.getMmodel() != null ? "-" + ca.getMmodel().getName() : "";
                String cname = ca.getCmodel() != null ? "-" + ca.getCmodel().getName() : "";
                ca.setCombinationName(bname + mname + cname);
                String catetype = ca.getBmodel() != null ? ca.getBmodel().getCateType() : "";
                ca.setUnionCateType(catetype);
            }
        }
        return PageData.from(new PageInfo<>(result));
    }
 
    @Override
    public List<CategoryUnionExtListVO> getCategoryUnionListByOrg(QueryCategoryUnionExtDTO qcu) {
        List<CategoryUnionExtListVO> result = categoryUnionExtMapper.selectList(qcu);
        if (result.size() > 0) {
            for (int i = 0; i < result.size(); i++) {
                CategoryUnionExtListVO ca = result.get(i);
                String bname = ca.getBmodel() != null ? ca.getBmodel().getName() : "";
                String mname = ca.getMmodel() != null ? "-" + ca.getMmodel().getName() : "";
                String cname = ca.getCmodel() != null ? "-" + ca.getCmodel().getName() : "";
                ca.setCombinationName(bname + mname + cname);
                String catetype = ca.getBmodel() != null ? ca.getBmodel().getCateType() : "";
                ca.setUnionCateType(catetype);
            }
        }
        return result;
    }
 
 
    @Override
    public List<CategoryUnionExtListVO> checkAllList(QueryCategoryUnionExtDTO pageWrap) {
        List<CategoryUnionExtListVO> result = categoryUnionExtMapper.selectList(pageWrap);
        if (result.size() > 0) {
            for (int i = 0; i < result.size(); i++) {
                CategoryUnionExtListVO ca = result.get(i);
                String bname = ca.getBmodel() != null ? ca.getBmodel().getName() : "";
                String mname = ca.getMmodel() != null ? "-" + ca.getMmodel().getName() : "";
                String cname = ca.getCmodel() != null ? "-" + ca.getCmodel().getName() : "";
                ca.setCombinationName(bname + mname + cname);
                String catetype = ca.getBmodel() != null ? ca.getBmodel().getCateType() : "";
                ca.setUnionCateType(catetype);
            }
        }
        return result;
    }
 
 
    @Override
    public List<CategoryUnionExtListVO> checkFGFXList(String applianceid) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if (StringUtils.isNotEmpty(applianceid)) {
            String[] ids = applianceid.split(",");
            List<CategoryUnionExtListVO> alllist = new ArrayList<>();
            for (String id : ids) {
                Appliances appliances = appliancesServiceimpl.findById(Integer.valueOf(id));
                WorkorderCheck workorderCheck = new WorkorderCheck();
                workorderCheck.setWorkorderId(appliances.getWorkorderId());
                workorderCheck.setRootDepartId(user.getRootDepartment().getId());
 
                List<WorkorderCheck> workorderCheckslist = workorderCheckServiceimpl.findList(workorderCheck);
                if (workorderCheckslist.size() > 0) {
                    for (int j = 0; j < workorderCheckslist.size(); j++) {
                        WorkorderCheck wc = workorderCheckslist.get(j);
 
                        if (StringUtils.isNotEmpty(wc.getCheckInfo())) {
                            QueryCategoryUnionExtDTO pageWrap = new QueryCategoryUnionExtDTO();
                            pageWrap.setId(Integer.valueOf(wc.getCheckInfo().trim()));
                            List<CategoryUnionExtListVO> result = categoryUnionExtMapper.selectList(pageWrap);
                            if (result.size() > 0) {
                                for (int i = 0; i < result.size(); i++) {
                                    CategoryUnionExtListVO ca = result.get(i);
                                    String bname = ca.getBmodel() != null ? ca.getBmodel().getName() : "";
                                    String mname = ca.getMmodel() != null ? "-" + ca.getMmodel().getName() : "";
                                    String cname = ca.getCmodel() != null ? "-" + ca.getCmodel().getName() : "";
                                    ca.setCombinationName(bname + mname + cname);
                                    String catetype = ca.getBmodel() != null ? ca.getBmodel().getCateType() : "";
                                    ca.setUnionCateType(catetype);
                                }
                                alllist.addAll(result);
                            }
 
                        }
 
                    }
 
                }
 
            }
            return alllist;
        }
        return null;
    }
}