|
@@ -1,16 +1,29 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.ProductLineDTO;
|
|
|
+import com.diagbot.dto.RenewalsInfosDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.dto.UserOrgDTO;
|
|
|
import com.diagbot.entity.UserRenewals;
|
|
|
+import com.diagbot.entity.wrapper.UserRenewalsWrapper;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.UserRenewalsServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.AddRenewalsInfoVO;
|
|
|
+import com.diagbot.vo.RenewalsInfosVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.bind.annotation.InitBinder;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -19,6 +32,10 @@ import java.util.List;
|
|
|
*/
|
|
|
@Component
|
|
|
public class UserRenewalsFacade extends UserRenewalsServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ private UserServiceClient userServiceClient;
|
|
|
+ @Autowired
|
|
|
+ private LantoneProductFacade lantoneProductFacade;
|
|
|
|
|
|
public RespDTO<Boolean> addRenewalsInfos(AddRenewalsInfoVO addRenewalsInfoVO){
|
|
|
UserRenewals userRenewals =new UserRenewals();
|
|
@@ -37,4 +54,52 @@ public class UserRenewalsFacade extends UserRenewalsServiceImpl {
|
|
|
userRenewals.setProductId(addRenewalsInfoVO.getProductId());
|
|
|
return RespDTO.onSuc(this.save(userRenewals));
|
|
|
}
|
|
|
+
|
|
|
+ @InitBinder
|
|
|
+ public IPage renewalsInfo(RenewalsInfosVO renewalsInfosVO){
|
|
|
+ Page page =new Page();
|
|
|
+ if(renewalsInfosVO.getCurrent() ==null ){
|
|
|
+ renewalsInfosVO.setCurrent(1L);
|
|
|
+ }
|
|
|
+ if(renewalsInfosVO.getSize() ==null){
|
|
|
+ renewalsInfosVO.setSize(10L);
|
|
|
+ }
|
|
|
+ if(renewalsInfosVO.getCurrent() !=0 && renewalsInfosVO.getSize() != 0){
|
|
|
+ page.setCurrent(renewalsInfosVO.getCurrent());
|
|
|
+ page.setSize(renewalsInfosVO.getSize());
|
|
|
+ }
|
|
|
+ UserRenewalsWrapper userRenewalsWrapper =new UserRenewalsWrapper();
|
|
|
+ BeanUtil.copyProperties(renewalsInfosVO,userRenewalsWrapper);
|
|
|
+ if(renewalsInfosVO.getOrgName()!=null && renewalsInfosVO.getOrgName()!=""){
|
|
|
+ RespDTO<List<Long>> rlist = userServiceClient.getUserByOrgName(renewalsInfosVO.getOrgName());
|
|
|
+ userRenewalsWrapper.setUserId(rlist.data);
|
|
|
+ }
|
|
|
+ List<RenewalsInfosDTO> list = this.selectUserRenewals(page,userRenewalsWrapper).getRecords();
|
|
|
+ List<ProductLineDTO> productList =lantoneProductFacade.productLine().data;
|
|
|
+ List<Long> userIds =new ArrayList<>();
|
|
|
+ for (RenewalsInfosDTO renewalsInfosDTO:list) {
|
|
|
+ Long userId = renewalsInfosDTO.getUserId();
|
|
|
+ userIds.add(userId);
|
|
|
+ }
|
|
|
+ RespDTO<Map<Long, UserOrgDTO>> mapRespDTO = userServiceClient.getUserAndOrg(userIds);
|
|
|
+ if(mapRespDTO == null || !"0".equals(mapRespDTO.code) ) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR,
|
|
|
+ "获取用户和机构信息失败");
|
|
|
+ }
|
|
|
+ Map<Long, UserOrgDTO> dataMap = mapRespDTO.data;
|
|
|
+ for(RenewalsInfosDTO bean : list) {
|
|
|
+ UserOrgDTO uo = dataMap.get(bean.getUserId());
|
|
|
+ for (ProductLineDTO productLineDTO:productList) {
|
|
|
+ if (productLineDTO.getId()==bean.getProductId()){
|
|
|
+ bean.setProductName(productLineDTO.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(uo != null) {
|
|
|
+ bean.setUsername(uo.getUsername());
|
|
|
+ bean.setLinkman(uo.getLinkman());
|
|
|
+ bean.setOrgName(uo.getOrgName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
}
|