shichongfu
2023-04-25 ce0b49552668d3331055e2b1a1447a743dc54939
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
package com.product.org.admin.service;
 
import com.product.org.admin.config.CmnConst;
import com.product.org.admin.config.SystemCode;
import java.util.Date;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.alibaba.druid.util.StringUtils;
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.org.admin.service.idel.IProxyApprovalService;
import com.product.util.BaseUtil;
 
/**
 * 
 * Copyright LX-BASE
 * 
 * @Title: ProxyApprovalService
 * @Project: LX-BASE-SERVER
 * @Date: 2020年5月29日 上午10:59:54
 * @Author: 郑盟
 * @Description:流程代理配置,对应流程代理表
 */
@Component
public class ProxyApprovalService extends AbstractBaseService implements IProxyApprovalService {
    @Autowired
    public BaseDao baseDao;
    @Autowired
    PermissionService permissionService;
    @Autowired
    public QueryFilterService queryFilterService;
 
    /**
     * 流程审批代理列表查询 @param cpage @param pagesize @return @throws BaseException
     * DataTableEntity @throws
     */
    public DataTableEntity listApproval(FieldSetEntity fs) throws BaseException {
        //郑盟   2020年12月22日   下午18:34
        String dataFilter = permissionService.getDataFilter(CmnConst.ORG_LEVEL_UUID);
        String queryFilter="";
        if (!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))) {
            if (!StringUtils.isEmpty(dataFilter)) {
                queryFilter =" and"+queryFilterService.getQueryFilter(fs);
            }else {
                queryFilter =queryFilterService.getQueryFilter(fs);
            }
        } 
        return baseDao.listTable(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL, dataFilter+queryFilter, new Object[] {},new Object[] {}, null, fs.getInteger("pagesize"), fs.getInteger("cpage"));
 
 
    }
 
    public FieldSetEntity findApproval(FieldSetEntity fs) throws BaseException {
        return baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL, "uuid=?  ",
                new String[] { fs.getString("uuid") }, false);
 
    }
 
    /**
     * 根据UUID删除流程审批代理
     * 
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean deleteApprovalList(FieldSetEntity fs) throws BaseException {
        return baseDao.delete(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL, "  uuid=?", new String[] { fs.getString("uuid") });
    }
 
    @Transactional
    public String addApprovalList(FieldSetEntity fs) throws BaseException {
        // 设置时区值
        String Org_level_code = SpringMVCContextHolder.getCurrentUser().getOrg_level_code();
        FieldSetEntity org_levels = baseDao.getFieldSetEntityByFilter("product_sys_org_levels", "org_level_code=?",
                new String[] { Org_level_code }, false);
        FieldSetEntity company_time_zone = baseDao.getFieldSetEntityByFilter("product_sys_company_time_zone",
                "org_level_uuid=?", new String[] { org_levels.getString("uuid") }, false);
        if (company_time_zone == null) {
            throw new BaseException(SystemCode.SYSTEM_TIME_ZONE_ERROR.getValue(),
                    SystemCode.SYSTEM_TIME_ZONE_ERROR.getText());
        }
        FieldSetEntity zone = baseDao.getFieldSetEntityByFilter("product_common_time_zone", "   uuid=?",
                new String[] { company_time_zone.getString("zone_uuid") }, false);
        fs.setValue("effective_end_zone", zone.getString("utc_time_zone"));
        fs.setValue("effective_start_zone", zone.getString("utc_time_zone"));
        String org_level_uuid = fs.getString("org_level_uuid");
        //郑盟   2020年12月17日   下午16:05
        if (StringUtils.isEmpty(org_level_uuid)) {
            fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
        }
        fs.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
        fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
        return baseDao.add(fs);
    }
 
    @Transactional
    public boolean updateApprovalList(FieldSetEntity fs) throws BaseException {
        fs.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
        fs.setValue(CmnConst.UPDATED_UTC_DATETIME, new Date());
        return baseDao.update(fs);
    }
 
    public FieldSetEntity findApprovalType(FieldSetEntity fs) throws BaseException {
        FieldSetEntity fieldSetEntity = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL_TYPE,
                fs.getString("uuid"), false);
        return baseDao.listInternationDataTable(fieldSetEntity, null);
 
    }
 
    @Transactional
    public String addApprovalType(FieldSetEntity fs) throws BaseException {
        fs.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
        fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
        return baseDao.add(fs);
 
    }
    public DataTableEntity listApprovalType(FieldSetEntity fs) throws BaseException {
        DataTableEntity listTable = baseDao.listTable(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL_TYPE);
        baseDao.listTable(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL_TYPE, null, null, null, null, fs.getInteger("cpage"),
                fs.getInteger("pagesize"));
        if (null != listTable) {
            return baseDao.listInternationDataTable(listTable, null);
        }
        return null;
    }
 
    /**
     * 根据UUID删除流程审批类型代理
     * 
     * @return
     * @throws BaseException
     */
    @Transactional
    public boolean deleteApprovalType(FieldSetEntity fs) throws BaseException {
        return baseDao.delete(CmnConst.PRODUCT_SYS_FLOW_PROXY_APPROVAL_TYPE, "uuid=?",
                new String[] { fs.getString("uuid") });
    }
 
}