|
@@ -16,14 +16,12 @@ import com.cloudcross.ssp.common.consts.DirectType;
|
|
|
import com.cloudcross.ssp.common.utils.AdvertiserScheduleAclsUtis;
|
|
|
import com.cloudcross.ssp.common.utils.Assert;
|
|
|
import com.cloudcross.ssp.common.utils.MapBuilder;
|
|
|
-import com.cloudcross.ssp.common.utils.OperatorScheduleAclsUtis;
|
|
|
import com.cloudcross.ssp.common.utils.Pager;
|
|
|
import com.cloudcross.ssp.common.utils.SqlHelper;
|
|
|
import com.cloudcross.ssp.model.Acls;
|
|
|
import com.cloudcross.ssp.model.AdGroup;
|
|
|
import com.cloudcross.ssp.model.AdGroupPlace;
|
|
|
import com.cloudcross.ssp.model.AdGroupSchedule;
|
|
|
-import com.cloudcross.ssp.model.AdGroupZone;
|
|
|
import com.cloudcross.ssp.model.Direct;
|
|
|
import com.cloudcross.ssp.model.Location;
|
|
|
import com.cloudcross.ssp.service.IAdGroupPlaceService;
|
|
@@ -291,32 +289,11 @@ edit(adGroup);
|
|
|
return adGroupFlag&&bannerFlag;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public int countByParamsOperator(Map<String, Object> paramMap) {
|
|
|
- //这里的搜索只是对名称进行搜索
|
|
|
- String searchValue = SqlHelper.doLike(paramMap.get("searchValue"));
|
|
|
- paramMap.put("key", paramMap.get("searchKey"));
|
|
|
- paramMap.put("value", searchValue);
|
|
|
- return myBatisDao.get("adGroupSqlMapper.countByParams", paramMap);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Map findAreasBack(Long adGroupId) {
|
|
|
return myBatisDao.get("adGroupSqlMapper.findAreasBack", adGroupId);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<AdGroup> findByParamsOperator(Map<String, Object> paramMap,
|
|
|
- Pager pager) {
|
|
|
- // 这里的搜索只是对名称进行搜索
|
|
|
- String searchValue = SqlHelper.doLike(paramMap.get("searchValue"));
|
|
|
- paramMap.put("key", paramMap.get("searchKey"));
|
|
|
- paramMap.put("value", searchValue);
|
|
|
- paramMap.put("pager", pager);
|
|
|
- return myBatisDao.getList("adGroupSqlMapper.findByParams",
|
|
|
- paramMap);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Map<String, List<? extends ISelector>> provideData(String[] parentId) {
|
|
|
Assert.isTrue(ArrayUtils.isNotEmpty(parentId));
|
|
@@ -326,124 +303,6 @@ edit(adGroup);
|
|
|
.map();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public boolean saveOperator(AdGroup adGroup,
|
|
|
- Map<String, Object> targetParamsMap) {
|
|
|
- //创建策略
|
|
|
- add(adGroup);
|
|
|
-
|
|
|
- //将广告位id插入表里
|
|
|
- Long[] zoneId = (Long[])targetParamsMap.get("zoneId");
|
|
|
- for(int i = 0; i < zoneId.length; i++) {
|
|
|
- AdGroupZone adGroupZone = new AdGroupZone();
|
|
|
- adGroupZone.setAdGroupId(adGroup.getId());
|
|
|
- adGroupZone.setZoneId(zoneId[i]);
|
|
|
- adGroupZoneService.add(adGroupZone);
|
|
|
- }
|
|
|
-
|
|
|
- //处理带定向的问题
|
|
|
- MapBuilder mapBuilder = MapBuilder.create(HashMap.class).add("adGroup", adGroup);
|
|
|
- //地域定向
|
|
|
- commonSaveDriect(targetParamsMap, mapBuilder.add("uiKey", "areas")
|
|
|
- .add("uiType",DirectType.locateType)
|
|
|
- .map());
|
|
|
- //时间定向
|
|
|
- commonSaveDriect(targetParamsMap, mapBuilder.add("uiKey","dayParting")
|
|
|
- .add("uiType",DirectType.timeType)
|
|
|
- .map());
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean editOperator(AdGroup adGroup,
|
|
|
- Map<String, Object> targetParamsMap) {
|
|
|
- edit(adGroup);
|
|
|
-
|
|
|
- /**
|
|
|
- * 广告位的更新
|
|
|
- */
|
|
|
- //先将以前存储的投放和广告位
|
|
|
- adGroupZoneService.deleteByAdGroupId(adGroup.getId());
|
|
|
- //将广告位id插入表里
|
|
|
- Long[] zoneId = (Long[])targetParamsMap.get("zoneId");
|
|
|
- for(int i = 0; i < zoneId.length; i++) {
|
|
|
- AdGroupZone adGroupZone = new AdGroupZone();
|
|
|
- adGroupZone.setAdGroupId(adGroup.getId());
|
|
|
- adGroupZone.setZoneId(zoneId[i]);
|
|
|
- adGroupZoneService.add(adGroupZone);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 时段定向的数据更新
|
|
|
- */
|
|
|
- //先删除原来的信息
|
|
|
- adGroupScheduleService.deleteByAdGroupId(adGroup.getId());
|
|
|
-// directService.deleteByadGroupId(adGroup.getId(), DirectType.timeType);
|
|
|
-
|
|
|
- //处理带定向的问题
|
|
|
-// MapBuilder mapBuilder = MapBuilder.create(HashMap.class).add("adGroup", adGroup);
|
|
|
- //时间定向
|
|
|
-
|
|
|
- //banner 表的compiledLimitation aclPlugins字段 默认值是 "true" null
|
|
|
- StringBuilder compiledLimitationStr=new StringBuilder();
|
|
|
- StringBuilder aclPluginsStr=new StringBuilder();
|
|
|
- //获取策略下的所有创意
|
|
|
-// List<Ad> adList = myBatisDao.getList("adSqlMapper.findByParams", MapBuilder.create(HashMap.class)
|
|
|
-// .add("adGroupId",adGroup.getId())
|
|
|
-// .map());
|
|
|
- List<Long> idList = null;
|
|
|
- //把创意List的id保存到idList
|
|
|
-// if(adList!=null&&adList.size()>0) {
|
|
|
-// idList = new ArrayList<Long> ();
|
|
|
-// for (Ad tempAd : adList) {
|
|
|
-// idList.add(tempAd.getId());
|
|
|
-// }
|
|
|
-// }
|
|
|
- //公共的参数
|
|
|
- MapBuilder mapBuilder = MapBuilder.create(HashMap.class).add("adGroup", adGroup)
|
|
|
- .add("idList", idList)
|
|
|
- .add("compiledLimitationStr", compiledLimitationStr)
|
|
|
- .add("aclPluginsStr",aclPluginsStr);
|
|
|
- //添加策略通用处理方法
|
|
|
- //地域定向
|
|
|
- commonEditDirect(targetParamsMap, mapBuilder.add("uiKey", "areas")
|
|
|
- .add("uiType",DirectType.locateType)
|
|
|
- .add("logical","and")
|
|
|
- .add("comparison","=x")
|
|
|
- .add("suffix", new String[] { "MAX_checkGeo_City('","', '=x')"})
|
|
|
- .map());
|
|
|
- commonEditDirect(targetParamsMap, mapBuilder.add("uiKey", "dayParting")
|
|
|
- .add("uiType",DirectType.timeType)
|
|
|
- .add("logical","and")
|
|
|
- .add("comparison","=~")
|
|
|
- .add("suffix", new String[] { "MAX_checkTime_Day('","', '=~')"})
|
|
|
- .map());
|
|
|
-
|
|
|
- //修改创意的字段
|
|
|
- //修改创意的compiledLimitation aclPluginsStr的字段
|
|
|
- if(idList!=null){
|
|
|
- if(compiledLimitationStr.length()<=0){
|
|
|
- myBatisDao.save("adSqlMapper.editBatch", MapBuilder.create(HashMap.class)
|
|
|
- .add("compiledLimitation","true")
|
|
|
- .add("aclPlugins",null)
|
|
|
- .add("idList",idList)
|
|
|
- .map());
|
|
|
- }else {
|
|
|
- myBatisDao.save("adSqlMapper.editBatch", MapBuilder.create(HashMap.class)
|
|
|
- .add("compiledLimitation", compiledLimitationStr.toString())
|
|
|
- .add("aclPlugins",aclPluginsStr.toString())
|
|
|
- .add("idList",idList)
|
|
|
- .map());
|
|
|
- }
|
|
|
-
|
|
|
- }else {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
public void commonSaveDriect(Map<String,Object> targetParamsMap,Map<String,Object> map){
|
|
|
|
|
@@ -611,222 +470,6 @@ public void commonSaveDriect(Map<String,Object> targetParamsMap,Map<String,Objec
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-public void commonSaveDriectOperator(Map<String,Object> targetParamsMap,Map<String,Object> map){
|
|
|
-
|
|
|
- String uiKey = (String)map.get("uiKey");
|
|
|
- String uiType = (String) map.get("uiType");
|
|
|
- AdGroup adGroup= (AdGroup)map.get("adGroup");
|
|
|
- Long adGroupId = adGroup.getId();
|
|
|
-
|
|
|
- if (targetParamsMap != null && targetParamsMap.containsKey(uiKey)
|
|
|
- && !targetParamsMap.get(uiKey).equals("")) {
|
|
|
- // 添加地域 rv_traget_show
|
|
|
- Direct direct = new Direct();
|
|
|
- direct.setAdGroupId(adGroup.getId());
|
|
|
- direct.setBackShow((String) targetParamsMap.get(uiKey));
|
|
|
- // 把前台数据转化为后台需要的数据格式
|
|
|
- direct.setData(front2dbOperator((String) targetParamsMap.get(uiKey),uiType));
|
|
|
-
|
|
|
- if(uiType.equalsIgnoreCase(DirectType.timeType)) {
|
|
|
- // 将数据批量存入排期表
|
|
|
- List<AdGroupSchedule> scheduleList = OperatorScheduleAclsUtis.getScheduleList(
|
|
|
- adGroupId, (String) targetParamsMap.get(uiKey));
|
|
|
-
|
|
|
- //调用接口batchschedule
|
|
|
- adGroupScheduleService.batchAdd(scheduleList);
|
|
|
- String data = OperatorScheduleAclsUtis.scheduleRoleStr(scheduleList);
|
|
|
- if(data != null && data.trim() != ""){
|
|
|
- data = data.concat("@Asia/Shanghai");
|
|
|
- }
|
|
|
- direct.setData(data);
|
|
|
- try {
|
|
|
- JSONArray sdayParting = new JSONArray(targetParamsMap.get("sdayParting").toString());
|
|
|
- JSONArray result = new JSONArray();
|
|
|
- for (int i = 0; i < sdayParting.length(); i++) {
|
|
|
- JSONObject obj = (JSONObject) sdayParting.get(i);
|
|
|
- result.put(obj);
|
|
|
- }
|
|
|
- direct.setBackShow(result.toString());
|
|
|
- } catch (JSONException e) {
|
|
|
- direct.setBackShow(targetParamsMap.get("sdayParting").toString());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- direct.setDirectType(Integer.parseInt(uiType));
|
|
|
- myBatisDao.save("directSqlMapper.addDirect", direct);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // uiKey地域: "areas" uiType地域: DirectType.locateType
|
|
|
- //targetParamsMap 前台UI传入的表单
|
|
|
- public void commonEditDirectOperator(Map<String,Object> targetParamsMap,Map<String,Object> map){
|
|
|
-
|
|
|
- String uiKey = (String)map.get("uiKey");
|
|
|
- String uiType = (String)map.get("uiType");
|
|
|
- AdGroup adGroup= (AdGroup)map.get("adGroup");
|
|
|
- System.out.println((String)map.get(uiKey)+">>>>");
|
|
|
- List<Long> idList = (List<Long>) map.get("idList");
|
|
|
- String logical = (String) map.get("logical");
|
|
|
- String comparison = (String)map.get("comparison");
|
|
|
- StringBuilder compiledLimitationStr=(StringBuilder) map.get("compiledLimitationStr");
|
|
|
- String [] suffix=(String[]) map.get("suffix");
|
|
|
- StringBuilder aclPluginsStr=(StringBuilder) map.get("aclPluginsStr");
|
|
|
- //处理策略 地域定向的情况
|
|
|
- if(targetParamsMap.containsKey(uiKey)){
|
|
|
- System.out.println("HelloWorld!");
|
|
|
- //删除数据库对应的历史数据
|
|
|
- myBatisDao.delete("directSqlMapper.deleteDirect", MapBuilder.create(HashMap.class)
|
|
|
- .add("adGroupId", adGroup.getId())
|
|
|
- .add("directType",uiType)
|
|
|
- .map());
|
|
|
- if(idList!=null){
|
|
|
- myBatisDao.delete("aclsSqlMapper.deleteAclsBatch", MapBuilder.create(HashMap.class)
|
|
|
- .add("idList", idList)
|
|
|
- .add("type",uiType)
|
|
|
- .map());
|
|
|
- }
|
|
|
-
|
|
|
- if(!((String)targetParamsMap.get(uiKey)).equalsIgnoreCase("")){
|
|
|
- //添加对应的定向数据
|
|
|
- Direct direct = new Direct();
|
|
|
- direct.setAdGroupId(adGroup.getId());
|
|
|
- direct.setBackShow((String) targetParamsMap.get(uiKey));
|
|
|
- System.out.println(front2dbOperator((String) targetParamsMap.get(uiKey),uiType)+"mmmmmm");
|
|
|
- // 把前台数据转化为后台需要的数据格式
|
|
|
- direct.setData(front2dbOperator((String) targetParamsMap.get(uiKey),uiType));
|
|
|
-
|
|
|
- //注释掉排期注释代码
|
|
|
- if(uiType.equalsIgnoreCase(DirectType.timeType)) {
|
|
|
- // 将数据批量存入排期表
|
|
|
- List<AdGroupSchedule> scheduleList = OperatorScheduleAclsUtis.getScheduleList(
|
|
|
- adGroup.getId(), (String) targetParamsMap.get(uiKey));
|
|
|
-
|
|
|
- //调用接口batchschedule
|
|
|
- adGroupScheduleService.batchAdd(scheduleList);
|
|
|
- String data = OperatorScheduleAclsUtis.scheduleRoleStr(scheduleList);
|
|
|
- if(data != null && data.trim() != ""){
|
|
|
- data = data.concat("@Asia/Shanghai");
|
|
|
- }
|
|
|
- direct.setData(data);
|
|
|
- try {
|
|
|
- JSONArray sdayParting = new JSONArray(targetParamsMap.get("sdayParting").toString());
|
|
|
- JSONArray result = new JSONArray();
|
|
|
- for (int i = 0; i < sdayParting.length(); i++) {
|
|
|
- JSONObject obj = (JSONObject) sdayParting.get(i);
|
|
|
- if(obj.has("dehours") && (obj.getString("dehours").equals("-1") || "".equals(obj.getString("dehours").trim()))){
|
|
|
- obj.remove("dailyImpression");
|
|
|
- obj.put("dailyImpression", "0");
|
|
|
- }
|
|
|
- result.put(obj);
|
|
|
- }
|
|
|
- direct.setBackShow(result.toString());
|
|
|
- } catch (JSONException e) {
|
|
|
- direct.setBackShow(targetParamsMap.get("sdayParting").toString());
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- /* data = data.concat("@Asia/Shanghai");
|
|
|
- direct.setData(data);
|
|
|
- direct.setBackShow(targetParamsMap.get("sdayParting").toString());*/
|
|
|
- }
|
|
|
-
|
|
|
- direct.setDirectType(Integer.parseInt(uiType));
|
|
|
- myBatisDao.save("directSqlMapper.addDirect", direct);
|
|
|
- //增加对应策略下的acls数据
|
|
|
- if(idList!=null) {
|
|
|
- Acls acls = new Acls();
|
|
|
- acls.setLogical(logical);
|
|
|
- acls.setType(direct.getDirectType());
|
|
|
- acls.setComparison(comparison);
|
|
|
- acls.setData(direct.getData());
|
|
|
- acls.setAdGroupId(adGroup.getId());
|
|
|
- myBatisDao.save("aclsSqlMapper.addAclsBatch",MapBuilder.create(HashMap.class)
|
|
|
- .add("idList",idList)
|
|
|
- .add("acls",acls)
|
|
|
- .add("adGroupId", adGroup.getId())
|
|
|
- .map());
|
|
|
- if(compiledLimitationStr.length()<=0){
|
|
|
- compiledLimitationStr.append(suffix[0]+ direct.getData() +suffix[1]);
|
|
|
- aclPluginsStr.append(direct.getDirectType());
|
|
|
- }else {
|
|
|
- compiledLimitationStr.append(" and "+suffix[0]+ direct.getData() +suffix[1]);
|
|
|
- aclPluginsStr.append(","+direct.getDirectType());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }else {
|
|
|
- //处理定向没有设置的情况
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private String front2dbOperator(String data ,String directType){
|
|
|
-
|
|
|
- if(DirectType.locateType.equalsIgnoreCase(directType)){
|
|
|
-
|
|
|
- return front2dblocate(data);
|
|
|
-
|
|
|
- }else if(DirectType.timeType.equalsIgnoreCase(directType)){
|
|
|
-
|
|
|
- return front2dbTimeOperator(data);
|
|
|
- }else if(DirectType.osType.equalsIgnoreCase(directType)){
|
|
|
- //目前什么也不做,直接返回数据
|
|
|
- return data;
|
|
|
- }else if(DirectType.browserType.equalsIgnoreCase(directType)){
|
|
|
- //目前什么也不做,直接返回数据
|
|
|
- return data;
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param dateTime
|
|
|
- * 页面传入JSON的日期的数据格式
|
|
|
- * {"Monday":{"display":[],"value":[]},"Tuesday":
|
|
|
- * {"display":[[2,4],[11,11]],"value":[[2],[3],[4],[11]]},
|
|
|
- * "Wednesday"
|
|
|
- * :{"display":[],"value":[]},"Thursday":{"display":[],
|
|
|
- * "value":[]},
|
|
|
- * "Friday":{"display":[],"value":[]},"Saturday":{"display"
|
|
|
- * :[],"value":[]},"Sunday":{"display":[],"value":[]}}
|
|
|
- * @return 转化成数据库需要的数据格式 0_9,0_11,1_11,1_12,2_8,2_9,3_15,3_16
|
|
|
- */
|
|
|
- private static String front2dbTimeOperator(String dateTime) {
|
|
|
-
|
|
|
- String[] days = { "Sunday", "Monday", "Tuesday", "Wednesday",
|
|
|
- "Thursday", "Friday", "Saturday" };
|
|
|
- if (dateTime != null) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- try {
|
|
|
- JSONObject jObject = new JSONObject(dateTime);
|
|
|
- for (int i = 0; i < 7; i++) {
|
|
|
- if (!jObject.getJSONObject(days[i]).getString("value")
|
|
|
- .equals("[]")) {
|
|
|
- String tmp = jObject.getJSONObject(days[i]).getString(
|
|
|
- "value");
|
|
|
- String[] strs = tmp.substring(1, tmp.length() - 1)
|
|
|
- .split(",");
|
|
|
- for (int j = 0; j < strs.length; j++) {
|
|
|
- if (sb.length() <= 0) {
|
|
|
- sb.append(i + "_" + strs[j].substring(1, strs[j].length()-1));
|
|
|
- } else {
|
|
|
- sb.append("," + i + "_" + strs[j].substring(1, strs[j].length()-1));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- sb.append("@Asia/Shanghai");
|
|
|
- return sb.toString();
|
|
|
- } catch (Exception e) {
|
|
|
- // TODO: handle exception
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 把前台获取的数据转化成后台数据库需要的数据格式 CN|/CNXAXA00|CNSHSH00|CNBJBJ00|CNAHHZ00/
|
|
|
*/
|