Commit ff1957ce authored by 廖旭伟's avatar 廖旭伟

修改页面访问路径存储逻辑

parent 98358c45
......@@ -29,5 +29,5 @@ public class BuryPointPdu {
/** 产品页面访问深度 **/
private PageRouteEntity routeInfo;
/** 场景深度 **/
private List<AccessPdu> depthArr;
private List<PageRouteEntity> depthArr;
}
......@@ -42,19 +42,27 @@ public class PageAccessServiceImpl extends AbstractCRUDServiceImpl<PageAccessDao
entity.setDeviceNum(pdu.getDeviceNum());
entity.setProductId(pdu.getProductId());
entity.setProductName(pdu.getProductName());
entity.setFirstCode(pdu.getDepthArr().get(0).getPageCode());
entity.setFirstName(pdu.getDepthArr().get(0).getPageName());
if(pdu.getDepthArr().size()>1){
entity.setSecondCode(pdu.getDepthArr().get(1).getPageCode());
entity.setSecondName(pdu.getDepthArr().get(1).getPageName());
if(pdu.getDepthArr().size()==1) {
entity.setFirstCode(pdu.getDepthArr().get(0).getSourceCode());
entity.setFirstName(pdu.getDepthArr().get(0).getSourceName());
entity.setSecondCode(pdu.getDepthArr().get(0).getTargetCode());
entity.setSecondName(pdu.getDepthArr().get(0).getTargetName());
}
if(pdu.getDepthArr().size()>2){
entity.setThirdCode(pdu.getDepthArr().get(2).getPageCode());
entity.setThirdName(pdu.getDepthArr().get(2).getPageName());
if(pdu.getDepthArr().size()==2){
entity.setSecondCode(pdu.getDepthArr().get(1).getSourceCode());
entity.setSecondName(pdu.getDepthArr().get(1).getSourceCode());
entity.setThirdCode(pdu.getDepthArr().get(1).getTargetCode());
entity.setThirdName(pdu.getDepthArr().get(1).getTargetName());
}
if(pdu.getDepthArr().size()>3){
entity.setFourthCode(pdu.getDepthArr().get(3).getPageCode());
entity.setFourthName(pdu.getDepthArr().get(3).getPageName());
if(pdu.getDepthArr().size()==3){
entity.setThirdCode(pdu.getDepthArr().get(2).getSourceCode());
entity.setThirdName(pdu.getDepthArr().get(2).getSourceCode());
entity.setFourthCode(pdu.getDepthArr().get(2).getTargetCode());
entity.setFourthName(pdu.getDepthArr().get(2).getTargetName());
}
if(pdu.getDepthArr().size()==4){
entity.setFourthCode(pdu.getDepthArr().get(3).getSourceCode());
entity.setFourthName(pdu.getDepthArr().get(3).getSourceCode());
}
entity.setPageDepth(pdu.getDepthArr().size());
entity.setAccessContent(JSONObject.toJSONString(pdu.getDepthArr()));
......
......@@ -3,6 +3,7 @@ import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.module.page.model.pdu.BuryPointPdu;
import com.mortals.xhx.module.page.model.pdu.PageCensusPdu;
import com.mortals.xhx.module.page.model.vo.PageWayCensusVo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
......@@ -11,10 +12,7 @@ import com.mortals.xhx.module.page.dao.PageRouteDao;
import com.mortals.xhx.module.page.model.PageRouteEntity;
import com.mortals.xhx.module.page.service.PageRouteService;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* PageRouteService
......@@ -44,19 +42,24 @@ public class PageRouteServiceImpl extends AbstractCRUDServiceImpl<PageRouteDao,
@Override
public PageRouteEntity saveByPdu(BuryPointPdu pdu) {
if(pdu.getRouteInfo()==null){
return null;
if(CollectionUtils.isNotEmpty(pdu.getDepthArr())){
List<PageRouteEntity> list = new ArrayList<>();
for(PageRouteEntity item:pdu.getDepthArr()) {
PageRouteEntity entity = new PageRouteEntity();
entity.setDeviceNum(pdu.getDeviceNum());
entity.setProductId(pdu.getProductId());
entity.setProductName(pdu.getProductName());
entity.setSourceCode(item.getSourceCode());
entity.setSourceName(item.getSourceName());
entity.setTargetCode(item.getTargetCode());
entity.setTargetName(item.getTargetName());
entity.setCreateTime(new Date());
list.add(entity);
}
this.save(list);
}
PageRouteEntity entity = new PageRouteEntity();
entity.setDeviceNum(pdu.getDeviceNum());
entity.setProductId(pdu.getProductId());
entity.setProductName(pdu.getProductName());
entity.setSourceCode(pdu.getRouteInfo().getSourceCode());
entity.setSourceName(pdu.getRouteInfo().getSourceName());
entity.setTargetCode(pdu.getRouteInfo().getTargetCode());
entity.setTargetName(pdu.getRouteInfo().getTargetName());
entity.setCreateTime(new Date());
return this.save(entity);
return null;
}
@Override
......
......@@ -9,17 +9,18 @@ import com.mortals.framework.service.IUser;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.module.page.model.PageInfoEntity;
import com.mortals.xhx.module.page.model.PageRouteEntity;
import com.mortals.xhx.module.page.model.pdu.AccessPdu;
import com.mortals.xhx.module.page.model.pdu.BuryPointPdu;
import com.mortals.xhx.module.page.service.*;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* 页面埋点
......@@ -73,6 +74,17 @@ public class BuryPointController extends BaseJsonBodyController {
if(StringUtils.isEmpty(pdu.getProductName())){
throw new AppException("产品名称不能为空");
}
if(CollectionUtils.isNotEmpty(pdu.getDepthArr())){
List<PageRouteEntity> list = new ArrayList<>();
Map<String,String> source = new HashMap<>();
for(PageRouteEntity item:pdu.getDepthArr()){
source.put(item.getSourceCode(),item.getSourceName());
if(!source.containsKey(item.getTargetCode())){
list.add(item);
}
}
pdu.setDepthArr(list);
}
}
@PostMapping({"screen/save"})
......@@ -99,4 +111,51 @@ public class BuryPointController extends BaseJsonBodyController {
return ret.toJSONString();
}
// public static void main(String[] args){
// List<PageRouteEntity> arrayList = new ArrayList<>();
// PageRouteEntity r1 = new PageRouteEntity();
// r1.setSourceCode("1111");
// r1.setSourceName("1111");
// r1.setTargetCode("2222");
// r1.setTargetName("2222");
// arrayList.add(r1);
// PageRouteEntity r2 = new PageRouteEntity();
// r2.setSourceCode("2222");
// r2.setSourceName("2222");
// r2.setTargetCode("1111");
// r2.setTargetName("1111");
// arrayList.add(r2);
// PageRouteEntity r3 = new PageRouteEntity();
// r3.setSourceCode("1111");
// r3.setSourceName("1111");
// r3.setTargetCode("3333");
// r3.setTargetName("3333");
// arrayList.add(r3);
// PageRouteEntity r4 = new PageRouteEntity();
// r4.setSourceCode("3333");
// r4.setSourceName("3333");
// r4.setTargetCode("2222");
// r4.setTargetName("2222");
// arrayList.add(r4);
// PageRouteEntity r5 = new PageRouteEntity();
// r5.setSourceCode("2222");
// r5.setSourceName("2222");
// r5.setTargetCode("4444");
// r5.setTargetName("4444");
// arrayList.add(r5);
// List<PageRouteEntity> list = new ArrayList<>();
// Map<String,String> source = new HashMap<>();
// for(PageRouteEntity item:arrayList){
// System.out.println(item.getSourceCode()+"-->"+item.getTargetCode());
// source.put(item.getSourceCode(),item.getSourceName());
// if(!source.containsKey(item.getTargetCode())){
// list.add(item);
// }
// }
// System.out.println("---------------------------------------");
// for(PageRouteEntity item:list){
// System.out.println(item.getSourceCode()+"-->"+item.getTargetCode());
// }
//
// }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment