|
|
@ -30,9 +30,11 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.CustomerDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
|
import com.epmet.feign.OperCrmFeignClient; |
|
|
|
import com.epmet.redis.CustomerAgencyRedis; |
|
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -55,10 +57,11 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao, CustomerAgencyEntity> implements CustomerAgencyService { |
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class); |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private CustomerAgencyRedis customerAgencyRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OperCrmFeignClient operCrmFeignClient; |
|
|
|
@Override |
|
|
|
public PageData<CustomerAgencyDTO> page(Map<String, Object> params) { |
|
|
|
IPage<CustomerAgencyEntity> page = baseDao.selectPage( |
|
|
@ -117,6 +120,22 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
return new Result<>(); |
|
|
|
} |
|
|
|
List<StaffOrgsResultDTO> list = baseDao.selectStaffOrgList(staffOrgsFormDTO.getCustomerIdList()); |
|
|
|
CustomerFormDTO customerFormDTO = new CustomerFormDTO(); |
|
|
|
customerFormDTO.setCustomerIdList(staffOrgsFormDTO.getCustomerIdList()); |
|
|
|
Result<List<CustomerDTO>> customerDTOResult = operCrmFeignClient.queryCustomerList(customerFormDTO); |
|
|
|
List<CustomerDTO> customerDTOList = customerDTOResult.getData(); |
|
|
|
if (customerDTOResult.success() && customerDTOList.size() > 0) { |
|
|
|
for (CustomerDTO customer : customerDTOList) { |
|
|
|
for (StaffOrgsResultDTO staffOrgsResultDTO : list) { |
|
|
|
if (customer.getId().equals(staffOrgsResultDTO.getCustomerId())) { |
|
|
|
staffOrgsResultDTO.setCustomerName(customer.getCustomerName()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
logger.error("获取客户名称失败"); |
|
|
|
} |
|
|
|
return new Result<List<StaffOrgsResultDTO>>().ok(list); |
|
|
|
} |
|
|
|
|
|
|
@ -147,7 +166,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
} |
|
|
|
//2:保存组织信息
|
|
|
|
if (baseDao.insert(entity) < NumConstant.ONE) { |
|
|
|
log.error(CustomerAgencyConstant.SAVE_EXCEPTION); |
|
|
|
logger.error(CustomerAgencyConstant.SAVE_EXCEPTION); |
|
|
|
throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION); |
|
|
|
} |
|
|
|
//3:返回新组织Id
|
|
|
@ -169,7 +188,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
entity.setId(formDTO.getAgencyId()); |
|
|
|
entity.setOrganizationName(formDTO.getAgencyName()); |
|
|
|
if (baseDao.updateById(entity) < NumConstant.ONE) { |
|
|
|
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|
|
logger.error(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|
|
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); |
|
|
|
} |
|
|
|
return result; |
|
|
@ -194,7 +213,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
} |
|
|
|
//2:删除当前机关组织(逻辑删)
|
|
|
|
if (baseDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { |
|
|
|
log.error(CustomerAgencyConstant.DEL_EXCEPTION); |
|
|
|
logger.error(CustomerAgencyConstant.DEL_EXCEPTION); |
|
|
|
throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); |
|
|
|
} |
|
|
|
return result; |
|
|
|