多单位版国产化地质资料管理系统
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
package com.zbooksoft.gdmis.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruili.wcp.service.config.ModuleService;
import com.ruili.wcp.service.config.ViewService;
import com.zbooksoft.gdmis.dao.StudyMaterialMapper;
import com.zbooksoft.gdmis.data.entity.CatAjjxx;
import com.zbooksoft.gdmis.data.entity.StudyMaterial;
import com.zbooksoft.gdmis.service.CatAjjxxService;
import com.zbooksoft.gdmis.service.StudyMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Slf4j
@Service
public class StudyMaterialServiceImpl extends ServiceImpl<StudyMaterialMapper, StudyMaterial>
        implements StudyMaterialService {
    @Autowired
    private ModuleService moduleService;
 
    @Autowired
    private ViewService viewService;
    @Autowired
    private StudyMaterialService studyMaterialService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private CatAjjxxService catAjjxxService;
 
    @Override
    public String addByIdList(Long studyId, List<Long> idList) {
        int successCount = 0;
        int errorCount = 0;
        String errorMsg = "";
        //通过id取专题名称返回
        String sql = "SELECT TYPE_NAME FROM UTL_STUDY_TYPE WHERE ID=" + studyId;
        String typeName = jdbcTemplate.queryForObject(sql, String.class);
        for (Long id : idList) {
            QueryWrapper<StudyMaterial> wrapper = new QueryWrapper<>();
            wrapper.eq("key_id", id);
            if (studyMaterialService.count(wrapper) == 0) {
                CatAjjxx catAjjxx = catAjjxxService.getById(id);
                StudyMaterial studyMaterial = new StudyMaterial();
                studyMaterial.setKeyId(id);
                studyMaterial.setTypeId(studyId);
                studyMaterial.setTypeName(typeName);
                studyMaterial.setArchivalCode(catAjjxx.getSgdh());
                studyMaterial.setTitle(catAjjxx.getZlmc());
                studyMaterial.setSecurityClassification(catAjjxx.getMj());
                studyMaterial.setDeptName(catAjjxx.getXcdwmc());
                studyMaterial.setProjectName(catAjjxx.getXmkyqmc());
                studyMaterial.setProjectNumber(catAjjxx.getXmkyqbh());
                studyMaterial.setConfluenceNum(catAjjxx.getHjpzh());
                studyMaterial.setFormationDate(catAjjxx.getXcsj());
                studyMaterialService.saveOrUpdate(studyMaterial);
                successCount++;
            } else {
                errorCount++;
            }
        }
        if (errorCount == 0) {
            errorMsg = "成功添加" + successCount + "条!可以继续选择数据,完成后请手动关闭窗口!";
        } else {
            if (successCount == 0) {
                errorMsg = "加入失败的条数为" + errorCount + "条!可以继续选择数据,完成后请手动关闭窗口!";
            } else {
                errorMsg = "成功添加条数为" + successCount + "条," + "加入失败的条数为" + errorCount + "条!可以继续选择数据,完成后请手动关闭窗口!";
            }
        }
        return errorMsg;
    }
 
}