From 51a4ff5d777028d52a19c314a99f796334cb7b51 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 十一月 2019 18:30:01 +0800 Subject: [PATCH] 配置文件修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java | 137 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 104 insertions(+), 33 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java index d3ec032..5a7ce9c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java @@ -1,6 +1,7 @@ package com.yeshi.fanli.service.impl.homemodule; import java.io.InputStream; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -18,10 +19,10 @@ import com.yeshi.fanli.dao.mybatis.homemodule.SpecialMapper; import com.yeshi.fanli.dto.common.CommonContentTypeEnum; -import com.yeshi.fanli.entity.AppVersionInfo; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.homemodule.Special; import com.yeshi.fanli.entity.common.JumpDetailV2; +import com.yeshi.fanli.exception.homemodule.HomeNavbarException; import com.yeshi.fanli.exception.homemodule.SpecialException; import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; import com.yeshi.fanli.service.inter.config.AppVersionService; @@ -52,10 +53,9 @@ @Resource private ConfigService configService; - + @Resource private AppVersionService appVersionService; - @Override public Special selectByPrimaryKey(Long id) { @@ -81,31 +81,16 @@ throw new SpecialException(1, "鎬у埆涓嶈兘涓虹┖"); } - String version = record.getVersion(); - Integer platformCode = record.getPlatform(); - if (!StringUtil.isNullOrEmpty(version) && platformCode != null) { - String platform = "android"; - if (platformCode == 2) - platform = "ios"; - AppVersionInfo versionInfo = appVersionService.getByPlatformAndVersion(platform, version); - if (versionInfo == null) - throw new SpecialException(1, "鐗堟湰鍙蜂俊鎭己澶�"); - - record.setVersionCode(versionInfo.getVersionCode()); - record.setPlatform(platformCode); - } else { - if (!StringUtil.isNullOrEmpty(version)) - throw new SpecialException(1, "骞冲彴绫诲瀷涓嶈兘涓虹┖"); - - if (platformCode != null) - throw new SpecialException(1, "鐗堟湰鍙蜂笉鑳戒负绌�"); - } - String params = record.getParams(); if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) { record.setParams(null); } else if (!StringUtil.isJson(params)) { throw new SpecialException(1, "璺宠浆鍙傛暟闈濲SON鏍煎紡"); + } + + String startTime_str = record.getStartTime_str(); + if (record.isTimeTask() && (startTime_str == null || startTime_str.length() == 0)) { + throw new SpecialException(1, "鎺у埗鏃堕棿涓嶈兘涓虹┖"); } if (!StringUtil.isNullOrEmpty(jumpType)) { @@ -114,6 +99,9 @@ record.setJumpDetail(listByType.get(0)); } } + + // 鏃堕棿杞崲 + conversionTime(record); Long state = record.getState(); if (state == null) { @@ -220,6 +208,37 @@ } } + /** + * web娈垫椂闂磋浆鎹� + * @param record + */ + public void conversionTime(Special record) throws SpecialException, Exception { + // 鏄惁鏃堕棿鎺у埗 + if(!record.isTimeTask()) { + record.setStartTime(null); + record.setEndTime(null); + } else { + String startTime_str = record.getStartTime_str(); + String endTime_str = record.getEndTime_str(); + + if ((startTime_str == null|| startTime_str.trim().length() == 0) + && (endTime_str == null || endTime_str.trim().length() == 0)) { + throw new HomeNavbarException(1, "璇疯緭鍏ユ帶鍒舵椂闂�"); + } else { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + if (startTime_str != null && startTime_str.trim().length() > 0) { + startTime_str = startTime_str.replaceAll("T", " "); + record.setStartTime(format.parse(startTime_str)); + } + + if (endTime_str != null && endTime_str.trim().length() > 0) { + endTime_str = endTime_str.replaceAll("T", " "); + record.setEndTime(format.parse(endTime_str)); + } + } + } + } + /** * 涓婁紶鍥剧墖 * @@ -352,6 +371,32 @@ // 璺宠浆閾炬帴 for (Special special : list) { + + Date startTime = special.getStartTime(); + Date endTime = special.getEndTime(); + + if (startTime == null && endTime == null) { + special.setTimeTask(false); + special.setStartTime_str(""); + special.setEndTime_str(""); + } else { + special.setTimeTask(true); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); + if (startTime == null) { + special.setStartTime_str(""); + } else { + special.setStartTime_str(sdf.format(startTime)); + } + + if (endTime == null) { + special.setEndTime_str(""); + } else { + special.setEndTime_str(sdf.format(endTime)); + } + } + + String params = special.getParams(); if (StringUtil.isNullOrEmpty(params)) { special.setParams(""); @@ -396,8 +441,7 @@ public List<Special> listByVersion(long start, int count, String card, Integer platform, Integer versionCode) { return specialMapper.listByVersion(start, count, card, platform, versionCode); } - - + @Override @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex") public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception { @@ -406,14 +450,19 @@ JSONObject arcMap = new JSONObject(); String indexArc = "index_arc"; - if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) + if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) + indexArc = "index_arc_1.6.5"; + else if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) indexArc = "index_arc_1.6.0"; else if (VersionUtil.greaterThan_1_5_70(acceptData.getPlatform(), acceptData.getVersion())) indexArc = "index_arc_1.5.7"; else if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion())) indexArc = "index_arc_1.5.6"; - List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex); + int platformCode = Constant.getPlatformCode(acceptData.getPlatform()); + int version = Integer.parseInt(acceptData.getVersion()); + + List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version); if (listArc == null) { listArc = new ArrayList<Special>(); } else if (listArc.size() > 0) { @@ -442,8 +491,10 @@ params.put("url", configService.get("tlj_own_buy_nogoods")); s.setParams(params.toString()); } else { - s.setJumpDetail(jumpDetailV2Service.getByTypeCache("tlj_own_buy")); - s.setParams(null); + // 鏌ヨ涓撻璇︽儏 + Special special = specialMapper.selectByPrimaryKey(s.getId()); + s.setJumpDetail(special.getJumpDetail()); + s.setParams(special.getParams()); } } } @@ -459,7 +510,7 @@ && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) { // 濡傛灉IOS褰撳墠鐗堟湰澶勪簬瀹℃牳鐘舵�佸氨涓嶈繑鍥� } else { - listActivity = specialMapper.listByPlaceKey("index_activity", null); + listActivity = specialMapper.listByPlaceKey("index_activity", null, platformCode, version); } if (listActivity == null) { @@ -482,7 +533,7 @@ indexBlock = "index_block_1.5.6"; JSONObject blockJsonMap = new JSONObject(); - List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex); + List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex, platformCode, version); if (listBlock == null) { listBlock = new ArrayList<Special>(); } else if (listBlock.size() > 0) { @@ -516,9 +567,29 @@ } @Override - public List<Special> listByPlaceKey(String placeKey) { - return specialMapper.listByPlaceKey(placeKey, null); + public List<Special> listByPlaceKey(String placeKey, Integer platform, Integer versionCode) { + return specialMapper.listByPlaceKey(placeKey, null, platform, versionCode); } + + + @Override + public List<Special> listByPlaceKeyList(long start, int count, List<String> list, Integer platform, Integer versionCode) { + return specialMapper.listByPlaceKeyList(start, count, list, null, platform, versionCode); + } + + + @Override + public long countByPlaceKeyList(List<String> list, Integer platform, Integer versionCode) { + return specialMapper.countByPlaceKeyList(list, null, platform, versionCode); + } + + + @Override + @Cacheable(value = "specialCache", key = "'listByPlaceKeyHasLabel'+#start+'-'+#platform+'-'+#versionCode+'-'+#list") + public List<Special> listByPlaceKeyHasLabel(long start, int count, List<String> list, Integer platform, Integer versionCode) { + return specialMapper.listByPlaceKeyHasLabel(start, count, list, null, platform, versionCode); + } + /** * 澶勭悊 鏁版嵁 -- Gitblit v1.8.0