czt
2025-06-09 13b6ad41f0b057f8405f7976a990e9057547443a
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
package com.fzzy.igds.sys;
 
import com.fzzy.igds.dzhwk.domain.Company;
import com.fzzy.igds.sys.repository.CompanyRepository;
import com.fzzy.igds.util.ContextUtil;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
/**
 * @Description service层
 * @Author CZT
 * @Date 2024/11/28 15:03
 */
@Slf4j
@Service("sys.coreCompanyService")
public class CoreCompanyService {
 
    @Resource
    private CompanyRepository companyRepository;
 
    /**
     * jpa查询公司信息
     * @param id
     * @return
     */
    public Company getDataById(String id) {
 
        if (StringUtils.isEmpty(id)) {
            return null;
        }
        return companyRepository.getDataById(id);
    }
 
    /**
     * jpa查询公司信息
     * @param companyId
     * @return
     */
    public List<Company> getAllData(String companyId) {
 
        if (StringUtils.isEmpty(companyId)) {
 
            companyId = ContextUtil.getCompanyId();
        }
        return companyRepository.getAllData(companyId);
    }
 
    /**
     * jpa查询公司信息
     * @param sysDept
     * @return
     */
    public Company initCompanyData(SysDept sysDept) {
 
        if (null == sysDept) {
            return null;
        }
        Company company = new Company();
        company.setId(sysDept.getDeptId() + "");
        company.setDwmc(sysDept.getDeptName());
        company.setCompanyId(sysDept.getCompanyId());
        this.saveOrUpdate(company);
        return company;
    }
 
    /**
     * 保存仓房信息
     * @param data
     */
    public void saveOrUpdate(Company data) {
        if (StringUtils.isEmpty(data.getCompanyId())) {
            data.setCompanyId(ContextUtil.getCompanyId());
        }
        data.setZhgxsj(new Date());
        companyRepository.save(data);
    }
 
    /**
     * 删除仓房信息
     * @param data
     * @return
     */
    public void delData(Company data) {
        companyRepository.delete(data);
    }
}