futian.liu
2023-11-13 31692354e8191b583250c213152bfd0068ffe0fc
consum-base/src/main/java/com/consum/base/service/BaseWarehouseServiceImpl.java
@@ -3,13 +3,9 @@
import com.consum.base.Constants;
import com.consum.base.core.CodeGeneratorService;
import com.consum.base.pojo.BaseWarehouseParam;
import com.consum.base.util.IdUtil;
import com.consum.model.po.BaseWarehouse;
import com.consum.model.po.FinSysTenant;
import com.consum.model.po.FinSysTenantDepartment;
import com.consum.model.po.FinSysTenantUser;
import com.consum.base.core.utils.IdUtil;
import com.consum.model.po.*;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.utils.DateUtils;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.jdbc.service.BaseServiceImpl;
import org.springframework.beans.BeanUtils;
@@ -37,6 +33,8 @@
    private FinSysTenantDepartmentServiceImpl departmentService;
    @Autowired
    private FinSysTenantUserServiceImpl userService;
    @Autowired
    private SDictDataServiceImpl sDictDataService;
    /**
     * @Description 新增
@@ -55,6 +53,11 @@
            baseWarehouse.setParentAgencyId(finSysTenant.getParentId());
            baseWarehouse.setAgencyName(finSysTenant.getName());
        }
        //根据CLASSIFICATION_CODE查询CLASSIFICATION_NAME
        SDictData dictData = this.sDictDataService.get(new SDictData(Long.valueOf(param.getClassificationCode())));
        if (dictData != null) {
            baseWarehouse.setClassificationName(dictData.getDict_label());
        }
        baseWarehouse.setIsDefault(Constants.IS_DEFAULT_YES);
        return this.insert(baseWarehouse);
@@ -65,7 +68,8 @@
     * @Author 卢庆阳
     * @Date 2023/10/26
     */
    public GenericPager<BaseWarehouse> queryList(BaseWarehouseParam param, FinSysTenantUser sysInfo) {
//    public GenericPager<BaseWarehouse> queryList(BaseWarehouseParam param, FinSysTenantUser sysInfo) {
    public GenericPager<BaseWarehouse> queryList(BaseWarehouseParam param) {
        StringBuilder sql = new StringBuilder("SELECT * FROM base_warehouse WHERE 1 = 1 ");
        HashMap<String, Object> paramts = new HashMap<>();
@@ -80,12 +84,12 @@
            paramts.put("CLASSIFICATION_CODE", param.getClassificationCode());
        }
        //机构id
        sql.append(" and AGENCY_ID =:AGENCY_ID ");
        if (param.getAgencyId() != null) {
            paramts.put("AGENCY_ID", param.getAgencyId());
        } else {
            paramts.put("AGENCY_ID", Long.valueOf(sysInfo.getTenantId()));
        }
//        sql.append(" and AGENCY_ID =:AGENCY_ID ");
//        if (param.getAgencyId() != null) {
//            paramts.put("AGENCY_ID", param.getAgencyId());
//        } else {
//            paramts.put("AGENCY_ID", Long.valueOf(sysInfo.getTenantId()));
//        }
        //状态
        if (param.getStates() != null) {
            sql.append(" and states =:states ");
@@ -104,6 +108,16 @@
     * @Date 2023/10/26
     */
    public int updateBaseWarehouse(BaseWarehouse baseWarehouse) {
        SDictData SDictData = this.sDictDataService.get(new SDictData(Long.valueOf(baseWarehouse.getClassificationCode())));
        if (SDictData != null) {
            baseWarehouse.setClassificationName(SDictData.getDict_label());
        }
        //根据机构id查询机构
        FinSysTenant finSysTenant = finSysTenantService.get(new FinSysTenant(baseWarehouse.getAgencyId()));
        if (finSysTenant != null) {
            baseWarehouse.setParentAgencyId(finSysTenant.getParentId());
            baseWarehouse.setAgencyName(finSysTenant.getName());
        }
        return this.update(baseWarehouse);
    }
@@ -148,4 +162,22 @@
    }
    /**
     * @Description  根据机构id查询机构仓库
     * @Author 卢庆阳
     * @Date 2023/10/27
     * @return
     */
    public List<BaseWarehouse> getByAgencyId(Long agencyId) {
        StringBuilder sql = new StringBuilder("SELECT * FROM base_warehouse WHERE 1 = 1 ");
        HashMap<String, Object> paramts = new HashMap<>();
        //机构id
        if (agencyId != null) {
            sql.append(" and AGENCY_ID =:AGENCY_ID ");
            paramts.put("AGENCY_ID", agencyId);
        }
        return select(sql.toString(), paramts, new BaseWarehouse());
    }
}