zm
2024-10-09 185712d82c7fa38824bbd8735b68361c7ecb00b4
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
package com.product.contract.service;
 
import com.product.common.lang.StringUtils;
import com.product.contract.config.CmnConst;
import com.product.contract.service.ide.IAwardedService;
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.tool.flow.service.FlowService;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * Copyright LX
 *
 * @Title: AwardedService
 * @Project: product-server
 * @date: 2021-06-18 14:03
 * @author: ZhouJie
 * @Description: 中标项目任务
 */
@Component
public class AwardedService extends AbstractBaseService implements IAwardedService {
    @Autowired
    public BaseDao baseDao;
    @Autowired
    PermissionService permissionService;
    @Autowired
    QueryFilterService queryFilterService;
    @Autowired
    FlowService flowService;
 
    /**
     * 中标项目任务保存
     * @param fs
     * @return
     */
    @Override
    @Transactional
    public String saveAwarded(FieldSetEntity fs) {
        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());
            String uuid = baseDao.add(fs,true);
            FieldSetEntity fss = new FieldSetEntity();
            fss.setTableName(fs.getTableName());
            fss.setValue("flow_uuid","a561ea69-35f2-4de8-abb4-836ab8d3e99c");
            fss.setValue("type_code","db748af3-716c-4902-a901-7ad66b76919a");
            fss.setValue("~table~",fs.getTableName());
            fss.setValue("accepters",fs.getString("assignment_person"));
            fss.setValue("uuid",fs.getString("uuid"));
            fss.setValue("flow_title","中标项目任务流程");
            flowService.autoSendFlow(fss);
            return uuid;
        } 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
     * @return
     */
    public String autoLaunch(String uuid) {
        FieldSetEntity fs = baseDao.getFieldSetEntity("product_project_awarded",uuid,true);
        FieldSetEntity fsfunction = null;
        FieldSetEntity fstb = null;
        FieldSetEntity fsflow = null;
        FieldSetEntity fsOth = new FieldSetEntity();
        String uuids = "";
        FieldSetEntity fss = new FieldSetEntity();
        FieldSetEntity fsub = baseDao.getFieldSetEntityByFilter("product_project_awarded_sub","contract_awarded_uuid=?",new Object[]{uuid},false);
        if(fsub!=null){
            fsfunction = baseDao.getFieldSetEntity("product_sys_functions",fsub.getString("task_item"),false);
        }
        if(fsfunction!=null){
            fstb = baseDao.getFieldSetEntity("product_sys_datamodel_table",fsfunction.getString("table_uuid"),false);
        }
        if(fstb!=null){
            fss.setTableName(fstb.getString("table_name"));
            fss.setValue("~table~",fstb.getString("table_name"));
            fss.setValue("accepters",fsub.getString("user_name"));
            fsflow = baseDao.getFieldSetEntityByFilter("product_sys_flow_model","table_uuid=? and org_level_uuid is not null",new Object[]{fstb.getString("table_name")},false);
        }
        if(fsflow!=null){
            fss.setValue("flow_uuid",fsflow.getUUID());
            fss.setValue("type_code",fsflow.getString("type_code"));
            fss.setValue("flow_title",fsflow.getString("title"));
        }
        fsOth.setTableName(fstb.getString("table_name"));
        fsOth.setValue("org_level_uuid", fs.getString("org_level_uuid"));
        fsOth.setValue("created_by", fs.getString("created_by"));
        fsOth.setValue("created_utc_datetime",new Date());
        if("product_project_performance_bond".equals(fstb.getString("table_name"))){
            fsOth.setValue("project_uuid",fs.getString("project_name"));
            fsOth.setValue("owner",fs.getString("owner_name"));
            fsOth.setValue("business_type",fs.getString("business_type"));
            fsOth.setValue("project_nature",fs.getString("project_nature"));
        }
        if("product_project_contract_info".equals(fstb.getString("table_name"))){
            fsOth.setValue("project_uuid",fs.getString("project_name"));
            fsOth.setValue("owner",fs.getString("owner_name"));
            fsOth.setValue("business_type",fs.getString("business_type"));
        }
        uuids = baseDao.add(fsOth);
        fss.setValue("uuid",fsOth.getString("uuid"));
        flowService.autoSendFlow(fss);
        return uuids;
    }
 
 
    /**
     * 中标项目任务删除
     * @param fs
     * @return
     */
    @Override
    @Transactional
    public boolean deleteAwarded(FieldSetEntity fs) {
        String uuid = fs.getUUID();
        String[] uuids = uuid.split(",");
        return baseDao.delete(CmnConst.LX_PROJECT_AWARDED, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuids.length, true), uuids);
    }
 
    /**
     * 获取中标项目任务列表
     * @param fs
     * @return
     */
    public DataTableEntity listAwarded(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") + " AND " + queryFilter;
        DataTableEntity dt = baseDao.listTable(CmnConst.LX_PROJECT_AWARDED,filter,new Object[]{},null,null,fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
        baseDao.loadPromptData(dt);
        return dt;
    }
 
    /**
     *中标项目任务详情查询
     * @param fs
     * @return
     * @throws BaseException
     */
    public FieldSetEntity findAwaded(FieldSetEntity fs) throws BaseException {
        return baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_AWARDED,fs.getUUID(),true);
    }
 
 
 
 
}