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
package com.product.org.admin.service;
 
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.FieldMetaEntity;
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.org.admin.config.CmnConst;
 
/**
 * Copyright LX-BASE
 * 
 * @Title: CostCenterService
 * @Project: LX-BASE-SERVER
 * @Date: 2020年10月09日 下午14:59:26
 * @Author: 
 * @Description:成本中心
 */
@Component
public class CostCenterService extends AbstractBaseService {
    
    @Autowired
    public BaseDao baseDao;
    
    @Autowired
    PermissionService permissionService;
    
    @Autowired
    QueryFilterService queryFilterService;
 
    /**
     *     成本中心详情
     * @param fs
     * @return
     * @throws BaseException
     */
    public FieldSetEntity findCenter(FieldSetEntity fs) throws BaseException {
        FieldSetEntity fss = baseDao.getFieldSetEntity(CmnConst.PRODUCT_SYS_COST_CENTER, fs.getString("uuid"), false);
        return baseDao.listInternationDataTable(fss, null);
    }
 
    /**
     * 成本中心列表
     * @param fs
     * @return
     * @throws BaseException
     */
    public DataTableEntity listCenter(FieldSetEntity fs) throws BaseException {
        String dataFilter=permissionService.getDataFilter(CmnConst.ORG_LEVEL_UUID) ;
        if(StringUtils.isEmpty(dataFilter)) {    //杜洪波  2020-12-28 10:09:00 BUG更改(列表加载错误)
            dataFilter="";
        }
        // 高级搜索
        String filter = queryFilterService.getQueryFilter(fs);    //杜洪波  2021-01-13 10:09:00 添加高级搜索
        if (!StringUtils.isEmpty(filter)) {
            if (dataFilter.length() > 0) {
                dataFilter += " and " + filter;
            } else {
                dataFilter = " where  " + filter;
            }
        }
        
        DataTableEntity dt=baseDao.listTable(CmnConst.PRODUCT_SYS_COST_CENTER, dataFilter, new String[] {}, null, null, fs.getInteger("pagesize"), fs.getInteger("cpage"));
        return baseDao.listInternationDataTable(dt, null);
    }
 
    /**
     * 成本中心删除
     * @param fs
     * @return
     * @throws BaseException
     */
    public boolean deleteCenter(FieldSetEntity fs) throws BaseException {
        return baseDao.delete(CmnConst.PRODUCT_SYS_COST_CENTER, "uuid=?", new String[] { fs.getString("uuid") });
    }
 
    /**
     * 新增人员成本中心(一般在新建人员时调用)
     */
    public String addStaffCostCenter(String staff_uuid, String cost_center_uuid, Object effective_start_date)
            throws BaseException {
        FieldSetEntity fs = new FieldSetEntity();
        FieldMetaEntity fm = new FieldMetaEntity();
        fm.setTableName(new Object[] { CmnConst.PRODUCT_SYS_STAFF_COST_CENTER });
        fs.setMeta(fm);
        fs.setValue("staff_uuid", staff_uuid);
        fs.setValue("cost_center_uuid", cost_center_uuid);
        fs.setValue("effective_start_date", effective_start_date);
        fs.setValue(CmnConst.CREATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
        fs.setValue(CmnConst.CREATED_UTC_DATETIME, new Date());
        return baseDao.add(fs);
    }
 
    /**
     * 修改人员成本中心
     */
    public boolean updateStaffCostCenter(String staff_uuid, String cost_center_uuid, Object effective_start_date)throws BaseException {
        FieldSetEntity fs = baseDao.getFieldSetEntityByFilter(CmnConst.PRODUCT_SYS_STAFF_COST_CENTER, "staff_uuid=?",new String[] { staff_uuid }, false);
        if (fs==null) {
            return true;
        }
        fs.setValue("cost_center_uuid", cost_center_uuid);
        fs.setValue(CmnConst.UPDATED_BY, SpringMVCContextHolder.getCurrentUser().getUser_id());
        fs.setValue(CmnConst.UPDATED_UTC_DATETIME, effective_start_date);
        return baseDao.update(fs);
    }
    
    /**
     *     删除成本中心
     * @param staff_uuid
     * @return
     * @throws BaseException
     */
    public boolean deleteStaffCostCenter(String staff_uuid)throws BaseException{
        return baseDao.delete("product_sys_staff_cost_center", "staff_uuid=?", new Object[] {staff_uuid});
    }
}