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
package com.product.org.admin.service;
 
import com.alibaba.druid.util.StringUtils;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.org.admin.config.CmnConst;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
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.service.support.AbstractBaseService;
 
 
/**
 * Copyright LX-BASE
 *
 * @Title: CompanyService
 * @Project: LX-BASE-SERVER
 * @Date: 2020年5月29日 上午11:00:39
 * @Author: 郑盟
 * @Description:单位基本信息配置,对应单位表
 */
@Component
public class CompanyService extends AbstractBaseService {
    @Autowired
    public BaseDao baseDao;
 
    /**
     * 单位详情
     *
     * @param : fs 详情参数org_level_uuid
     * @return :FieldSetEntity
     */
    public FieldSetEntity findCompany(FieldSetEntity fs) throws BaseException {
        FieldSetEntity fieldSetEntity = baseDao.listInternationDataTable(baseDao.getFieldSetEntityByFilter("product_sys_company", "org_level_uuid=?", new String[]{fs.getString("org_level_uuid")}, false), null);
        if (fieldSetEntity == null) {
            return null;
        }
        return fieldSetEntity;
    }
 
    public Boolean updateCompany(FieldSetEntity fse) throws BaseException {
        if (!StringUtils.isEmpty(fse.getString("del"))) {
            String[] dels = fse.getString("del").split(",");
            for (int i = 0; i < dels.length; i++) {
                baseDao.delete("product_sys_attachments", "uuid=?", new String[]{dels[i]});
            }
        }
        return baseDao.update(fse);
    }
 
 
    /**
     * levels单位详情
     *
     * @param : fs 详情参数uuid
     * @return :FieldSetEntity
     */
    public FieldSetEntity findLevelAll(FieldSetEntity fs) throws BaseException {
        return baseDao.getFieldSetEntity("product_sys_org_levels", fs.getString("uuid"), false);
    }
 
    /**
     * 删除单位详情
     *
     * @param : fs 详情参数org_level_uuid
     * @return :FieldSetEntity
     */
    public boolean deleteCompanyList(FieldSetEntity fs) throws BaseException {
        return baseDao.delete("product_sys_company", "org_level_uuid=?",
                new String[]{fs.getString("org_level_uuid")});
    }
 
    /**
     * 获取当前用户的关联公司
     *
     * @param filter
     * @return
     */
    public DataTableEntity relationCompany(String filter) throws BaseException {
        if (filter == null) {
            return null;
        }
        DataTableEntity dataTableEntity = baseDao.listTable("product_sys_org_levels", filter,CmnConst.ORG_LEVEL_CODE);
        if (dataTableEntity == null) {
            return null;
        }
        return BaseUtil.dataTableToTreeTable(dataTableEntity, CmnConst.ORG_LEVEL_CODE, CmnConst.ORG_LEVEL_CODE_PARENT, null);
    }
 
}