18756
2024-07-25 bdbdf515571035f0e63f06b2300ae0745d019282
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
package com.product.contract.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.product.contract.config.CmnConst;
import com.product.contract.service.ide.IProjectInfoService;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.permission.PermissionService;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.service.support.QueryFilterService;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.core.transfer.Transactional;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.product.common.lang.StringUtils;
 
import java.util.*;
 
/**
 * Copyright LX
 *
 * @Title: ProjectInfoService
 * @Project: product-server
 * @date: 2021-07-01 13:49
 * @author: ZhouJie
 * @Description:
 */
@Component
public class ProjectInfoService extends AbstractBaseService implements IProjectInfoService {
 
    @Autowired
    public BaseDao baseDao;
    @Autowired
    PermissionService permissionService;
    @Autowired
    QueryFilterService queryFilterService;
 
    /**
     * 根据uuid获取项目详情
     * @param fs
     * @return
     * @throws BaseException
     */
    public FieldSetEntity getProjectInfo(FieldSetEntity fs) throws BaseException {
        return baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_INFO,fs.getUUID(),true);
    }
 
    /** 保存项目信息
     * @param fs
     * @return
     */
    @Transactional
    public String saveProjectInfo(FieldSetEntity fs) throws BaseException {
        String re = fs.getString("region");
 
        if(StringUtils.isEmpty(fs.getString(CmnConst.UUID))){
            fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
            fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
            fs.setValue("created_utc_datetime",new Date());
            return baseDao.add(fs);
        } else {
            fs.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
            fs.setValue("updated_utc_datetime",new Date());
            baseDao.update(fs);
            return fs.getString(CmnConst.UUID);
        }
    }
 
    /**
     * 删除项目信息
     * @param fs
     * @return
     */
    @Transactional
    public boolean deleteProjectInfo(FieldSetEntity fs) {
        String uuid = fs.getUUID();
        String[] uuids = uuid.split(",");
        return baseDao.delete(CmnConst.LX_PROJECT_INFO, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuids.length, true), uuids);
    }
 
    /**
     * 设置资料清单
     * @param fse
     * @throws BaseException
     */
    @Override
    @Transactional
    public void saveOrUpdate(FieldSetEntity fse) throws BaseException {
 
        String dic_name = fse.getValues().get("dict_name").toString();
        StringBuilder filterSb = new StringBuilder(64);;
        filterSb.append( " project_type = "+dic_name);
        DataTableEntity dataListNew = fse.getSubData().get("product_project_manager_data_list");
        for (int i = 0; i < dataListNew.getRows(); i++) {
            FieldSetEntity fs = dataListNew.getData().get(i);
 
            //此时为新增数据
            if(ObjectUtil.isNotEmpty(fs.getValues().get("~uuid~"))){
                fs.setValue("project_type",dic_name);
                fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
                fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
                fs.setValue("created_utc_datetime",new Date());
                baseDao.add(fs);
            }else if(ObjectUtil.isNotEmpty(fs.getValues().get("~type~"))&&fs.getValues().get("~type~").toString().equals("del")){
                StringBuilder filter = new StringBuilder(64);
                filter.append( "uuid  = '"+fs.getValues().get("uuid")+"'");
                filter.append(" and id = "+fs.getValues().get("id"));
                baseDao.delete("product_project_manager_data_list",filter.toString(),new Object[]{});
            }else {
                fs.setValue("updated_by",SpringMVCContextHolder.getCurrentUser().getUser_id());
                fs.setValue("updated_utc_datetime",new Date());
                baseDao.update(fs);
            }
 
 
 
        }
 
    }
 
    /**
     * 获取资料清单列表(分项目类型)
     * @param dict_value
     * @return
     * @throws BaseException
     */
    @Override
    public JSONObject getDataList(String dict_value) throws BaseException {
 
        JSONObject jsonObject=new JSONObject();
        if(!StringUtils.isEmpty(dict_value)){
            StringBuilder filterSb = new StringBuilder(64);;
            filterSb.append( " project_type = "+dict_value);
            DataTableEntity product_project_manager_data_list = baseDao.listTable("product_project_manager_data_list", filterSb.toString(), new Object[]{});
            JSONArray objects = BaseUtil.dataTableEntityToJson(product_project_manager_data_list);
            jsonObject.put("data",objects);
        }
        return  jsonObject;
    }
 
    /**
     * 获取合同列表
     * @param fs
     * @return
     */
    public DataTableEntity listProject(FieldSetEntity fs) {
        String queryFilter=permissionService.getDataFilter(CmnConst.ORG_LEVEL_UUID);
        if(StringUtils.isEmpty(queryFilter)) {
            queryFilter = CmnConst.CREATED_BY + " = " + SpringMVCContextHolder.getCurrentUser().getUser_id();
        }
        if(!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))){
            queryFilter    = queryFilter +" AND "+ queryFilterService.getQueryFilter(fs);
        }
        String filter = fs.getString("filter");
        if(BaseUtil.strIsNull(filter)){
            filter = queryFilter;
        }else {
            filter = filter  + " AND " + queryFilter;
        }
        DataTableEntity dt = baseDao.listTable(CmnConst.LX_PROJECT_INFO,filter,new Object[]{},null,null,fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
        baseDao.loadPromptData(dt);
        return dt;
    }
 
 
}