| | |
| | | package com.consum.base.service.impl; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.consum.base.Constants; |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.pojo.BaseWarehouseParam; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.FinSysTenantDepartmentService; |
| | | import com.consum.base.service.FinSysTenantServiceImpl; |
| | | import com.consum.base.service.FinSysTenantService; |
| | | import com.consum.base.service.SDictDataServiceImpl; |
| | | 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.model.po.SDictData; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.jdbc.service.BaseServiceImpl; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @Description 仓库管理 |
| | |
| | | @Autowired |
| | | private CodeGeneratorService codeGeneratorService; |
| | | @Autowired |
| | | private FinSysTenantServiceImpl finSysTenantService; |
| | | @Autowired |
| | | private FinSysTenantDepartmentService departmentService; |
| | | private FinSysTenantService finSysTenantService; |
| | | @Autowired |
| | | private SDictDataServiceImpl sDictDataService; |
| | | |
| | |
| | | baseWarehouse.setId(IdUtil.generateId()); |
| | | baseWarehouse.setWarehouseType(Constants.WAREHOUSE_TYPE_TENANT); |
| | | baseWarehouse.setWarehouseCode(codeGeneratorService.createWarehouseCode()); |
| | | //根据机构id查询机构 |
| | | // 根据机构id查询机构 |
| | | FinSysTenant finSysTenant = finSysTenantService.get(new FinSysTenant(baseWarehouse.getAgencyId())); |
| | | if (finSysTenant != null) { |
| | | baseWarehouse.setParentAgencyId(finSysTenant.getParentId()); |
| | | baseWarehouse.setAgencyName(finSysTenant.getName()); |
| | | } |
| | | //根据CLASSIFICATION_CODE查询CLASSIFICATION_NAME |
| | | // 根据CLASSIFICATION_CODE查询CLASSIFICATION_NAME |
| | | SDictData dictData = this.sDictDataService.get(new SDictData(Long.valueOf(param.getClassificationCode()))); |
| | | if (dictData != null) { |
| | | baseWarehouse.setClassificationName(dictData.getDict_label()); |
| | |
| | | * @Date 2023/10/26 |
| | | */ |
| | | @Override |
| | | public GenericPager<BaseWarehouse> queryList(BaseWarehouseParam param) { |
| | | public GenericPager<BaseWarehouse> queryList(BaseWarehouseParam param, FinSysTenantUser currentUser) { |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_warehouse WHERE 1 = 1 "); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //仓库名称 |
| | | // 仓库名称 |
| | | if (!StringUtils.isEmpty(param.getWarehouseName())) { |
| | | sql.append(" and WAREHOUSE_NAME like:WAREHOUSE_NAME "); |
| | | paramts.put("WAREHOUSE_NAME", StringUtils.CHAR_PERCENT + param.getWarehouseName() + StringUtils.CHAR_PERCENT); |
| | | paramts.put("WAREHOUSE_NAME", |
| | | StringUtils.CHAR_PERCENT + param.getWarehouseName() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | //类型 |
| | | // 类型 |
| | | if (!StringUtils.isEmpty(param.getClassificationCode())) { |
| | | sql.append(" and CLASSIFICATION_CODE =:CLASSIFICATION_CODE "); |
| | | paramts.put("CLASSIFICATION_CODE", param.getClassificationCode()); |
| | | } |
| | | //机构id |
| | | // 机构id |
| | | // 因为仓库是省公司统一维护的,省可以看到全部,地市和县区看自己的 |
| | | if (param.getAgencyId() != null) { |
| | | sql.append(" and AGENCY_ID =:AGENCY_ID "); |
| | | paramts.put("AGENCY_ID", param.getAgencyId()); |
| | | Integer lv = currentUser.getLv(); |
| | | if (lv != 1) { |
| | | sql.append(" and AGENCY_ID =:AGENCY_ID "); |
| | | paramts.put("AGENCY_ID", param.getAgencyId()); |
| | | } else { |
| | | sql.append(" and AGENCY_ID like :AGENCY_ID "); |
| | | paramts.put("AGENCY_ID", param.getAgencyId() + StringUtils.CHAR_PERCENT); |
| | | } |
| | | } |
| | | //状态 |
| | | // 状态 |
| | | if (param.getStates() != null) { |
| | | sql.append(" and states =:states "); |
| | | paramts.put("states", param.getStates()); |
| | |
| | | */ |
| | | @Override |
| | | public int updateBaseWarehouse(BaseWarehouse baseWarehouse) { |
| | | SDictData SDictData = this.sDictDataService.get(new SDictData(Long.valueOf(baseWarehouse.getClassificationCode()))); |
| | | SDictData SDictData = |
| | | this.sDictDataService.get(new SDictData(Long.valueOf(baseWarehouse.getClassificationCode()))); |
| | | if (SDictData != null) { |
| | | baseWarehouse.setClassificationName(SDictData.getDict_label()); |
| | | } |
| | | //根据机构id查询机构 |
| | | // 根据机构id查询机构 |
| | | FinSysTenant finSysTenant = finSysTenantService.get(new FinSysTenant(baseWarehouse.getAgencyId())); |
| | | if (finSysTenant != null) { |
| | | baseWarehouse.setParentAgencyId(finSysTenant.getParentId()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @Description 根据仓库id获取机构用户信息 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/26 |
| | | */ |
| | | @Override |
| | | public void queryUserList(Long baseWarehouseId) { |
| | | //1.根据仓库id查询仓库 |
| | | BaseWarehouse baseWarehouse = this.getById(baseWarehouseId); |
| | | if (baseWarehouse != null) { |
| | | Long agencyId = baseWarehouse.getAgencyId(); |
| | | String agencyName = baseWarehouse.getAgencyName(); |
| | | //2.根据机构id查询部门 |
| | | List<FinSysTenantDepartment> list = this.departmentService.getByTenantId(agencyId); |
| | | //获取部门id |
| | | Set<Long> deptIds = list.stream().map(dept -> dept.getId()).collect(Collectors.toSet()); |
| | | //3.根据部门id查询用户 |
| | | //this.userService.getByDeptIds(); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @return |
| | | * @Description 根据机构id查询机构仓库 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/27 |
| | | */ |
| | | @Override |
| | | public List<BaseWarehouse> getByAgencyId(Long agencyId, Short isDefault, Short states) { |
| | | public List<BaseWarehouse> getBaseWareHouseList(Long agencyId, Short states) { |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_warehouse WHERE 1 = 1 "); |
| | | HashMap<String, Object> paramts = new HashMap<>(); |
| | | |
| | | //机构id |
| | | // 机构id |
| | | if (agencyId != null) { |
| | | sql.append(" and AGENCY_ID =:AGENCY_ID "); |
| | | paramts.put("AGENCY_ID", agencyId); |
| | | } |
| | | // 是否为默认仓库 |
| | | if (isDefault != null) { |
| | | sql.append(" and IS_DEFAULT =:isDefault "); |
| | | paramts.put("isDefault", isDefault); |
| | | } |
| | | // 状态 |
| | | if (states != null) { |
| | |
| | | return select(sql.toString(), paramts, new BaseWarehouse()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据机构id查询默认仓库 |
| | | * |
| | |
| | | */ |
| | | @Override |
| | | public BaseWarehouse getDefaultWarehouseByAgencyId(Long agencyId) { |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_warehouse WHERE IS_DEFAULT = 1 and AGENCY_ID =:agencyId "); |
| | | StringBuilder sql = |
| | | new StringBuilder("SELECT * FROM base_warehouse WHERE IS_DEFAULT = 1 and AGENCY_ID =:agencyId "); |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("agencyId", agencyId); |
| | | List<BaseWarehouse> select = select(sql.toString(), param, new BaseWarehouse()); |
| | | Optional<BaseWarehouse> optional = select.stream().findFirst(); |
| | | if (optional.isPresent()) { |
| | | return optional.get(); |
| | | } |
| | | return null; |
| | | BaseWarehouse baseWarehouse = select.stream().findFirst().orElse(null); |
| | | return baseWarehouse; |
| | | } |
| | | |
| | | @Override |