|
|
@ -1,6 +1,8 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.OperCustomizeConstant; |
|
|
|
import com.epmet.constant.ReginConstant; |
|
|
|
import com.epmet.dao.CustomerHomeDao; |
|
|
|
import com.epmet.dao.CustomerHomeDetailDao; |
|
|
@ -11,18 +13,23 @@ import com.epmet.dto.result.ComponentListByCustomerResultDTO; |
|
|
|
import com.epmet.dto.result.HomeDesignByCustomerResultDTO; |
|
|
|
import com.epmet.entity.CustomerHomeDetailEntity; |
|
|
|
import com.epmet.entity.CustomerHomeEntity; |
|
|
|
import com.epmet.service.CustomerHomeDetailService; |
|
|
|
import com.epmet.service.HomeService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 客户定制化服务-首页 |
|
|
|
* @Author yinzuomei |
|
|
|
* @Date 2020/3/11 13:14 |
|
|
|
* 客户定制化服务-首页 |
|
|
|
* |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2020/3/11 13:14 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class HomeServiceImpl implements HomeService { |
|
|
|
@Autowired |
|
|
@ -31,6 +38,8 @@ public class HomeServiceImpl implements HomeService { |
|
|
|
private CustomerHomeDetailDao customerHomeDetailDao; |
|
|
|
@Autowired |
|
|
|
private CustomerHomeDao customerHomeDao; |
|
|
|
@Autowired |
|
|
|
private CustomerHomeDetailService customerHomeDetailService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<ComponentListByCustomerResultDTO> getComponentListByCustomer(ComponentListByCustomerFormDTO formDTO) { |
|
|
@ -41,106 +50,78 @@ public class HomeServiceImpl implements HomeService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getHomeDesignByCustomer(HomeDesignByCustomerFormDTO formDTO) { |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getHomeDesignByCustomer(CustomerHomeFormDTO formDTO) { |
|
|
|
HomeDesignByCustomerResultDTO resultDTO = new HomeDesignByCustomerResultDTO(); |
|
|
|
//根据客户id,所属端获取客户首页配置的设计稿
|
|
|
|
List<CommonComponentDesignResultDTO> list = customerHomeDetailDao.getCustomerHomeDetailComponent(formDTO); |
|
|
|
List<CommonComponentDesignResultDTO> titlelist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<CommonComponentDesignResultDTO> toplist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<CommonComponentDesignResultDTO> functionlist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<CommonComponentDesignResultDTO> floatlist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<String> usedComponent=new ArrayList<>();//使用过的组件集合
|
|
|
|
for(CommonComponentDesignResultDTO c:list){ |
|
|
|
List<CommonComponentDesignResultDTO> list = customerHomeDetailDao.selectCustomerHomeDetail(formDTO); |
|
|
|
List<CommonComponentDesignResultDTO> titleList = new ArrayList<>(); |
|
|
|
List<CommonComponentDesignResultDTO> topList = new ArrayList<>(); |
|
|
|
List<CommonComponentDesignResultDTO> functionList = new ArrayList<>(); |
|
|
|
List<CommonComponentDesignResultDTO> floatingList = new ArrayList<>(); |
|
|
|
//使用过的组件集合
|
|
|
|
List<String> usedComponent = new ArrayList<>(); |
|
|
|
for (CommonComponentDesignResultDTO c : list) { |
|
|
|
usedComponent.add(c.getComponentId()); |
|
|
|
//所属区域:0.标题区、1.置顶区、2.功能区、3.悬浮区
|
|
|
|
if(ReginConstant.titleList.equals(c.getRegion())){ |
|
|
|
titlelist.add(c); |
|
|
|
}else if(ReginConstant.topList.equals(c.getRegion())){ |
|
|
|
toplist.add(c); |
|
|
|
}else if(ReginConstant.functionList.equals(c.getRegion())){ |
|
|
|
functionlist.add(c); |
|
|
|
}else if(ReginConstant.floatingList.equals(c.getRegion())){ |
|
|
|
floatlist.add(c); |
|
|
|
if (ReginConstant.TITLE_LIST.equals(c.getRegion())) { |
|
|
|
titleList.add(c); |
|
|
|
} else if (ReginConstant.TOP_LIST.equals(c.getRegion())) { |
|
|
|
topList.add(c); |
|
|
|
} else if (ReginConstant.FUNCTION_LIST.equals(c.getRegion())) { |
|
|
|
functionList.add(c); |
|
|
|
} else if (ReginConstant.FLOATING_LIST.equals(c.getRegion())) { |
|
|
|
floatingList.add(c); |
|
|
|
} |
|
|
|
} |
|
|
|
resultDTO.setTitleList(titlelist); |
|
|
|
resultDTO.setTopList(toplist); |
|
|
|
resultDTO.setFloatingList(floatlist); |
|
|
|
resultDTO.setFunctionList(functionlist); |
|
|
|
resultDTO.setTitleList(titleList); |
|
|
|
resultDTO.setTopList(topList); |
|
|
|
resultDTO.setFloatingList(floatingList); |
|
|
|
resultDTO.setFunctionList(functionList); |
|
|
|
if (OperCustomizeConstant.STATUS_DRAFT.equals(formDTO.getStatus())) { |
|
|
|
resultDTO.setUsedComponentIdList(usedComponent); |
|
|
|
} |
|
|
|
return new Result<HomeDesignByCustomerResultDTO>().ok(resultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveHomeDesign(HomeDesignFormDTO formDTO) { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result saveHomeDesign(HomeDesignFormDTO formDTO) { |
|
|
|
//根据客户ID和所属端类型从客户首页表找到对应的已发布和草稿
|
|
|
|
List<CustomerHomeEntity> customerHomeList = customerHomeDao.selectCustomerHomeList(formDTO); |
|
|
|
|
|
|
|
//只处理草稿的数据
|
|
|
|
for(CustomerHomeEntity entity : customerHomeList) { |
|
|
|
if (entity.getStatus() == 1) { |
|
|
|
for (CustomerHomeEntity entity : customerHomeList) { |
|
|
|
if (OperCustomizeConstant.STATUS_IS_DRAFT.equals(entity.getStatus())) { |
|
|
|
saveCustomerHomeDetail(formDTO, entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void distributeHomeDesign(HomeDesignFormDTO formDTO) { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result distributeHomeDesign(HomeDesignFormDTO formDTO) { |
|
|
|
//根据客户ID和所属端类型从客户首页表找到对应的已发布和草稿
|
|
|
|
List<CustomerHomeEntity> customerHomeList = customerHomeDao.selectCustomerHomeList(formDTO); |
|
|
|
|
|
|
|
//草稿和模板数据都要处理
|
|
|
|
for(CustomerHomeEntity entity : customerHomeList) { |
|
|
|
for (CustomerHomeEntity entity : customerHomeList) { |
|
|
|
saveCustomerHomeDetail(formDTO, entity); |
|
|
|
} |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
private void saveCustomerHomeDetail(HomeDesignFormDTO formDTO, CustomerHomeEntity entity) { |
|
|
|
private void saveCustomerHomeDetail(HomeDesignFormDTO formDTO, CustomerHomeEntity customerHomeEntity) { |
|
|
|
//根据homeID清空客户首页详情表中的数据
|
|
|
|
customerHomeDetailDao.updateCustomerHomeDetailByHomeId(entity.getId()); |
|
|
|
customerHomeDetailDao.deleteCustomerHomeDetailByHomeId(customerHomeEntity.getId()); |
|
|
|
|
|
|
|
List<CustomerHomeDetailEntity> list = ConvertUtils.sourceToTarget(formDTO.getComponentList(), CustomerHomeDetailEntity.class); |
|
|
|
|
|
|
|
//将数据存入客户首页详情表
|
|
|
|
for (HomeComponentFormDTO homeComponentForm : formDTO.getComponentList()) { |
|
|
|
CustomerHomeDetailEntity customerHomeDetailEntity = new CustomerHomeDetailEntity(); |
|
|
|
customerHomeDetailEntity.setHomeId(entity.getId()); |
|
|
|
customerHomeDetailEntity.setComponentId(homeComponentForm.getComponentId()); |
|
|
|
customerHomeDetailEntity.setRegion(homeComponentForm.getRegion()); |
|
|
|
customerHomeDetailEntity.setConfiguration(homeComponentForm.getConfiguration()); |
|
|
|
customerHomeDetailEntity.setDemoData(homeComponentForm.getDemoData()); |
|
|
|
customerHomeDetailEntity.setDisplayOrder(homeComponentForm.getDisplayOrder()); |
|
|
|
customerHomeDetailDao.insert(customerHomeDetailEntity); |
|
|
|
customerHomeDetailService.insertBatch(list); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getHomeReleaseByCustomer(CustomerHomeFormDTO formDTO) { |
|
|
|
HomeDesignByCustomerResultDTO resultDTO = new HomeDesignByCustomerResultDTO(); |
|
|
|
//根据客户id,所属端获取客户首页配置的设计稿
|
|
|
|
List<CommonComponentDesignResultDTO> list = customerHomeDetailDao.getHomeReleaseByCustomer(formDTO); |
|
|
|
List<CommonComponentDesignResultDTO> titlelist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<CommonComponentDesignResultDTO> toplist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<CommonComponentDesignResultDTO> functionlist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
List<CommonComponentDesignResultDTO> floatlist=new ArrayList<CommonComponentDesignResultDTO>(); |
|
|
|
//List<String> usedComponent=new ArrayList<>();//使用过的组件集合
|
|
|
|
for(CommonComponentDesignResultDTO c:list){ |
|
|
|
//usedComponent.add(c.getComponentId());
|
|
|
|
//所属区域:0.标题区、1.置顶区、2.功能区、3.悬浮区
|
|
|
|
if(ReginConstant.titleList.equals(c.getRegion())){ |
|
|
|
titlelist.add(c); |
|
|
|
}else if(ReginConstant.topList.equals(c.getRegion())){ |
|
|
|
toplist.add(c); |
|
|
|
}else if(ReginConstant.functionList.equals(c.getRegion())){ |
|
|
|
functionlist.add(c); |
|
|
|
}else if(ReginConstant.floatingList.equals(c.getRegion())){ |
|
|
|
floatlist.add(c); |
|
|
|
} |
|
|
|
} |
|
|
|
resultDTO.setTitleList(titlelist); |
|
|
|
resultDTO.setTopList(toplist); |
|
|
|
resultDTO.setFloatingList(floatlist); |
|
|
|
resultDTO.setFunctionList(functionlist); |
|
|
|
//resultDTO.setUsedComponentIdList(usedComponent);
|
|
|
|
return new Result<HomeDesignByCustomerResultDTO>().ok(resultDTO); |
|
|
|
} |
|
|
|
} |
|
|
|