|
|
@ -17,23 +17,36 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.PlaceOrgDao; |
|
|
|
import com.epmet.dto.PlaceOrgDTO; |
|
|
|
import com.epmet.dto.form.AddPlaceOrgFormDTO; |
|
|
|
import com.epmet.dto.form.EditPlaceOrgFormDTO; |
|
|
|
import com.epmet.dto.form.GetListPlaceOrgFormDTO; |
|
|
|
import com.epmet.dto.form.UserIdsFormDTO; |
|
|
|
import com.epmet.dto.result.GetListPlaceOrgResultDTO; |
|
|
|
import com.epmet.dto.result.GetListSocietyOrgResultDTO; |
|
|
|
import com.epmet.dto.result.PlaceOrgDetailResultDTO; |
|
|
|
import com.epmet.dto.result.StaffSinGridResultDTO; |
|
|
|
import com.epmet.entity.PlaceOrgEntity; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.service.PlaceOrgService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 九小场所下组织管理 |
|
|
@ -43,58 +56,98 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class PlaceOrgServiceImpl extends BaseServiceImpl<PlaceOrgDao, PlaceOrgEntity> implements PlaceOrgService { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(PlaceOrgServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private EpmetAdminOpenFeignClient epmetAdminOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 新增九小场所下组织 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public PageData<PlaceOrgDTO> page(Map<String, Object> params) { |
|
|
|
IPage<PlaceOrgEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, PlaceOrgDTO.class); |
|
|
|
public void add(AddPlaceOrgFormDTO formDTO) { |
|
|
|
PlaceOrgEntity entity = ConvertUtils.sourceToTarget(formDTO, PlaceOrgEntity.class); |
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |
|
|
|
entity.setAgencyId(staffInfoCache.getAgencyId()); |
|
|
|
entity.setPids(staffInfoCache.getAgencyPIds()); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 修改九小场所下组织 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public List<PlaceOrgDTO> list(Map<String, Object> params) { |
|
|
|
List<PlaceOrgEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, PlaceOrgDTO.class); |
|
|
|
public void edit(EditPlaceOrgFormDTO formDTO) { |
|
|
|
PlaceOrgEntity entity = baseDao.selectById(formDTO.getPlaceOrgId()); |
|
|
|
if (null == entity) { |
|
|
|
throw new RenException(String.format("修改九小场所下组织信息失败,场所信息不存在,场所Id->%s", formDTO.getPlaceOrgId())); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<PlaceOrgEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<PlaceOrgEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
entity = ConvertUtils.sourceToTarget(formDTO, PlaceOrgEntity.class); |
|
|
|
baseDao.updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 删除九小场所下组织 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public PlaceOrgDTO get(String id) { |
|
|
|
PlaceOrgEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, PlaceOrgDTO.class); |
|
|
|
public void del(String placeOrgId) { |
|
|
|
if (baseDao.deleteById(placeOrgId) < NumConstant.ONE) { |
|
|
|
throw new RenException(String.format("修改九小场所下组织信息删除失败,场所Id->%s", placeOrgId)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(PlaceOrgDTO dto) { |
|
|
|
PlaceOrgEntity entity = ConvertUtils.sourceToTarget(dto, PlaceOrgEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 九小场所下组织详情 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(PlaceOrgDTO dto) { |
|
|
|
PlaceOrgEntity entity = ConvertUtils.sourceToTarget(dto, PlaceOrgEntity.class); |
|
|
|
updateById(entity); |
|
|
|
public PlaceOrgDetailResultDTO detail(String placeOrgId) { |
|
|
|
PlaceOrgDetailResultDTO resultDTO = new PlaceOrgDetailResultDTO(); |
|
|
|
//1.查询场所基础信息
|
|
|
|
GetListPlaceOrgFormDTO dto = new GetListPlaceOrgFormDTO(); |
|
|
|
dto.setPlaceOrgId(placeOrgId); |
|
|
|
List<GetListPlaceOrgResultDTO.PlaceOrgList> result = baseDao.getList(dto); |
|
|
|
if (CollectionUtils.isEmpty(result)) { |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
resultDTO = ConvertUtils.sourceToTarget(result.get(0), PlaceOrgDetailResultDTO.class); |
|
|
|
//2.查询九小场所信息
|
|
|
|
Result<List<OptionResultDTO>> result1 = epmetAdminOpenFeignClient.getNineSmallPlacesOption(); |
|
|
|
if (!result1.success()) { |
|
|
|
throw new RenException("获取九小场所基本信息失败......"); |
|
|
|
} |
|
|
|
for (OptionResultDTO d : result1.getData()) { |
|
|
|
if (d.getValue().equals(resultDTO.getNinePlaceVal())) { |
|
|
|
resultDTO.setNinePlaceName(d.getLabel()); |
|
|
|
} |
|
|
|
} |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 九小场所下组织列表查询 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
public GetListPlaceOrgResultDTO getList(GetListPlaceOrgFormDTO formDTO) { |
|
|
|
GetListPlaceOrgResultDTO resultDTO = new GetListPlaceOrgResultDTO(); |
|
|
|
//1.根据查询条件分页查询场所数据
|
|
|
|
PageInfo<GetListPlaceOrgResultDTO.PlaceOrgList> result = |
|
|
|
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()).doSelectPageInfo(() -> baseDao.getList(formDTO)); |
|
|
|
if (CollectionUtils.isEmpty(result.getList())) { |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
resultDTO.setTotal((int) result.getTotal()); |
|
|
|
//2.查询九小场所信息
|
|
|
|
Result<List<OptionResultDTO>> result1 = epmetAdminOpenFeignClient.getNineSmallPlacesOption(); |
|
|
|
if (!result1.success()) { |
|
|
|
throw new RenException("获取九小场所基本信息失败......"); |
|
|
|
} |
|
|
|
result.getList().forEach(r -> result1.getData().stream().filter(u -> r.getNinePlaceVal().equals(u.getValue())).forEach(u -> r.setNinePlaceName(u.getLabel()))); |
|
|
|
resultDTO.setList(result.getList()); |
|
|
|
|
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
} |