Commit 7d98d1288db027988790bbeea236d5bc10e542a8
1 parent
acdf9f10
1.
Showing
21 changed files
with
4073 additions
and
4184 deletions
src/main/java/com/bsth/XDApplication.java
| @@ -194,7 +194,7 @@ public class XDApplication implements CommandLineRunner { | @@ -194,7 +194,7 @@ public class XDApplication implements CommandLineRunner { | ||
| 194 | ScheduledExecutorService sexec = Application.mainServices; | 194 | ScheduledExecutorService sexec = Application.mainServices; |
| 195 | //安全驾驶 | 195 | //安全驾驶 |
| 196 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); | 196 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 197 | - sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | 197 | + //sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 198 | 198 | ||
| 199 | GpsDataLoaderThread.setFlag(-1); | 199 | GpsDataLoaderThread.setFlag(-1); |
| 200 | /** 线调业务 */ | 200 | /** 线调业务 */ |
src/main/java/com/bsth/data/directive/GatewayHttpUtils.java
| 1 | -package com.bsth.data.directive; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSONObject; | ||
| 4 | -import com.bsth.util.ConfigUtil; | ||
| 5 | -import org.apache.http.client.config.RequestConfig; | ||
| 6 | -import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 7 | -import org.apache.http.client.methods.HttpPost; | ||
| 8 | -import org.apache.http.entity.StringEntity; | ||
| 9 | -import org.apache.http.impl.client.CloseableHttpClient; | ||
| 10 | -import org.apache.http.impl.client.HttpClients; | ||
| 11 | -import org.apache.http.util.EntityUtils; | ||
| 12 | -import org.slf4j.Logger; | ||
| 13 | -import org.slf4j.LoggerFactory; | ||
| 14 | - | ||
| 15 | -/** | ||
| 16 | - * @author PanZhao | ||
| 17 | - * @ClassName: GatewayHttpUtils | ||
| 18 | - * @Description: TODO(和网关HTTP通讯工具类) | ||
| 19 | - * @date 2016年8月14日 下午9:50:46 | ||
| 20 | - */ | ||
| 21 | -public class GatewayHttpUtils { | ||
| 22 | - static Logger logger = LoggerFactory.getLogger(GatewayHttpUtils.class); | ||
| 23 | - | ||
| 24 | - static String url; | ||
| 25 | - static CloseableHttpClient httpClient = null; | ||
| 26 | - static HttpPost post; | ||
| 27 | - static RequestConfig requestConfig; | ||
| 28 | - static CloseableHttpResponse response; | ||
| 29 | - | ||
| 30 | - static { | ||
| 31 | - url = ConfigUtil.get("http.send.directive"); | ||
| 32 | - httpClient = HttpClients.createDefault(); | ||
| 33 | - post = new HttpPost(url); | ||
| 34 | - requestConfig = RequestConfig.custom() | ||
| 35 | - .setConnectTimeout(3000).setConnectionRequestTimeout(2000) | ||
| 36 | - .setSocketTimeout(3000).build(); | ||
| 37 | - post.setConfig(requestConfig); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - public static int postJson(String jsonStr) { | ||
| 41 | - logger.info("send : " + jsonStr); | ||
| 42 | - | ||
| 43 | - int code = -1; | ||
| 44 | - try { | ||
| 45 | - post.setEntity(new StringEntity(jsonStr, "utf-8")); | ||
| 46 | - | ||
| 47 | - response = httpClient.execute(post); | ||
| 48 | - | ||
| 49 | - int statusCode = response.getStatusLine().getStatusCode(); | ||
| 50 | - if(statusCode != 200){ | ||
| 51 | - logger.error("http client status code: " + statusCode); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); | ||
| 55 | - if (null != json && json.getInteger("errCode") == 0) | ||
| 56 | - code = 0; | ||
| 57 | - else | ||
| 58 | - logger.error("和网关http通讯失败,rs: " + json); | ||
| 59 | - | ||
| 60 | - if (null != response) | ||
| 61 | - response.close(); | ||
| 62 | - } catch (Exception e) { | ||
| 63 | - logger.error("", e); | ||
| 64 | - } | ||
| 65 | - return code; | ||
| 66 | - } | ||
| 67 | -} | 1 | +package com.bsth.data.directive; |
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import org.apache.http.client.config.RequestConfig; | ||
| 5 | +import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 6 | +import org.apache.http.client.methods.HttpPost; | ||
| 7 | +import org.apache.http.entity.StringEntity; | ||
| 8 | +import org.apache.http.impl.client.CloseableHttpClient; | ||
| 9 | +import org.apache.http.impl.client.HttpClients; | ||
| 10 | +import org.apache.http.util.EntityUtils; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | +import org.springframework.beans.factory.InitializingBean; | ||
| 14 | +import org.springframework.beans.factory.annotation.Value; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * @author PanZhao | ||
| 19 | + * @ClassName: GatewayHttpUtils | ||
| 20 | + * @Description: TODO(和网关HTTP通讯工具类) | ||
| 21 | + * @date 2016年8月14日 下午9:50:46 | ||
| 22 | + */ | ||
| 23 | +@Component | ||
| 24 | +public class GatewayHttpUtils implements InitializingBean { | ||
| 25 | + static Logger logger = LoggerFactory.getLogger(GatewayHttpUtils.class); | ||
| 26 | + | ||
| 27 | + static String url; | ||
| 28 | + static CloseableHttpClient httpClient = null; | ||
| 29 | + static HttpPost post; | ||
| 30 | + static RequestConfig requestConfig; | ||
| 31 | + static CloseableHttpResponse response; | ||
| 32 | + | ||
| 33 | + public static int postJson(String jsonStr) { | ||
| 34 | + logger.info("send : " + jsonStr); | ||
| 35 | + | ||
| 36 | + int code = -1; | ||
| 37 | + try { | ||
| 38 | + post.setEntity(new StringEntity(jsonStr, "utf-8")); | ||
| 39 | + | ||
| 40 | + response = httpClient.execute(post); | ||
| 41 | + | ||
| 42 | + int statusCode = response.getStatusLine().getStatusCode(); | ||
| 43 | + if(statusCode != 200){ | ||
| 44 | + logger.error("http client status code: " + statusCode); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + JSONObject json = JSONObject.parseObject(EntityUtils.toString(response.getEntity())); | ||
| 48 | + if (null != json && json.getInteger("errCode") == 0) | ||
| 49 | + code = 0; | ||
| 50 | + else | ||
| 51 | + logger.error("和网关http通讯失败,rs: " + json); | ||
| 52 | + | ||
| 53 | + if (null != response) | ||
| 54 | + response.close(); | ||
| 55 | + } catch (Exception e) { | ||
| 56 | + logger.error("", e); | ||
| 57 | + } | ||
| 58 | + return code; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Value("${http.send.directive}") | ||
| 62 | + public void setUrl(String url) { | ||
| 63 | + GatewayHttpUtils.url = url; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public void afterPropertiesSet() throws Exception { | ||
| 68 | + httpClient = HttpClients.createDefault(); | ||
| 69 | + post = new HttpPost(url); | ||
| 70 | + requestConfig = RequestConfig.custom() | ||
| 71 | + .setConnectTimeout(3000).setConnectionRequestTimeout(2000) | ||
| 72 | + .setSocketTimeout(3000).build(); | ||
| 73 | + post.setConfig(requestConfig); | ||
| 74 | + } | ||
| 75 | +} |
src/main/java/com/bsth/data/gpsdata_v2/load/GatewayHttpLoader.java
| @@ -5,7 +5,6 @@ import com.bsth.data.BasicData; | @@ -5,7 +5,6 @@ import com.bsth.data.BasicData; | ||
| 5 | import com.bsth.data.gpsdata_v2.GpsRealData; | 5 | import com.bsth.data.gpsdata_v2.GpsRealData; |
| 6 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; | 6 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 7 | import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; | 7 | import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; |
| 8 | -import com.bsth.util.ConfigUtil; | ||
| 9 | import org.apache.commons.lang3.StringUtils; | 8 | import org.apache.commons.lang3.StringUtils; |
| 10 | import org.apache.http.HttpEntity; | 9 | import org.apache.http.HttpEntity; |
| 11 | import org.apache.http.client.config.RequestConfig; | 10 | import org.apache.http.client.config.RequestConfig; |
src/main/java/com/bsth/data/gpsdata_v2/load/SocketClientLoader.java
| @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; | @@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; | ||
| 4 | import com.bsth.data.BasicData; | 4 | import com.bsth.data.BasicData; |
| 5 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; | 5 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 6 | import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; | 6 | import com.bsth.data.gpsdata_v2.utils.GpsDataUtils; |
| 7 | -import com.bsth.util.ConfigUtil; | ||
| 8 | import org.apache.http.HttpEntity; | 7 | import org.apache.http.HttpEntity; |
| 9 | import org.apache.http.client.config.RequestConfig; | 8 | import org.apache.http.client.config.RequestConfig; |
| 10 | import org.apache.http.client.methods.CloseableHttpResponse; | 9 | import org.apache.http.client.methods.CloseableHttpResponse; |
src/main/java/com/bsth/data/gpsdata_v2/rfid/RfidHttpLoader.java
| 1 | package com.bsth.data.gpsdata_v2.rfid; | 1 | package com.bsth.data.gpsdata_v2.rfid; |
| 2 | 2 | ||
| 3 | import com.bsth.data.gpsdata_v2.rfid.entity.RfidInfo; | 3 | import com.bsth.data.gpsdata_v2.rfid.entity.RfidInfo; |
| 4 | -import com.bsth.util.ConfigUtil; | ||
| 5 | import com.fasterxml.jackson.databind.ObjectMapper; | 4 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 6 | import org.apache.commons.io.IOUtils; | 5 | import org.apache.commons.io.IOUtils; |
| 7 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 8 | +import org.springframework.beans.factory.annotation.Value; | ||
| 9 | +import org.springframework.stereotype.Component; | ||
| 9 | 10 | ||
| 10 | import java.io.ByteArrayOutputStream; | 11 | import java.io.ByteArrayOutputStream; |
| 11 | import java.io.IOException; | 12 | import java.io.IOException; |
| @@ -20,11 +21,12 @@ import java.util.List; | @@ -20,11 +21,12 @@ import java.util.List; | ||
| 20 | * @author hill | 21 | * @author hill |
| 21 | * @date | 22 | * @date |
| 22 | */ | 23 | */ |
| 24 | +@Component | ||
| 23 | public class RfidHttpLoader { | 25 | public class RfidHttpLoader { |
| 24 | 26 | ||
| 25 | private final static Logger log = LoggerFactory.getLogger(RfidHttpLoader.class); | 27 | private final static Logger log = LoggerFactory.getLogger(RfidHttpLoader.class); |
| 26 | 28 | ||
| 27 | - private static String RFID_URL = ConfigUtil.get("http.rfid.url"); | 29 | + private static String RFID_URL; |
| 28 | 30 | ||
| 29 | public static List<RfidInfo> load() { | 31 | public static List<RfidInfo> load() { |
| 30 | List<RfidInfo> result = new ArrayList<>(); | 32 | List<RfidInfo> result = new ArrayList<>(); |
| @@ -75,4 +77,9 @@ public class RfidHttpLoader { | @@ -75,4 +77,9 @@ public class RfidHttpLoader { | ||
| 75 | 77 | ||
| 76 | return result; | 78 | return result; |
| 77 | } | 79 | } |
| 80 | + | ||
| 81 | + @Value("${http.rfid.url}") | ||
| 82 | + public void setRfidUrl(String rfidUrl) { | ||
| 83 | + RFID_URL = rfidUrl; | ||
| 84 | + } | ||
| 78 | } | 85 | } |
src/main/java/com/bsth/service/forms/impl/BudgetServiceImpl.java
| 1 | -package com.bsth.service.forms.impl; | ||
| 2 | - | ||
| 3 | -import java.io.File; | ||
| 4 | -import java.io.FileInputStream; | ||
| 5 | -import java.math.BigDecimal; | ||
| 6 | -import java.text.DecimalFormat; | ||
| 7 | -import java.text.ParseException; | ||
| 8 | -import java.text.SimpleDateFormat; | ||
| 9 | -import java.util.ArrayList; | ||
| 10 | -import java.util.Date; | ||
| 11 | -import java.util.HashMap; | ||
| 12 | -import java.util.HashSet; | ||
| 13 | -import java.util.Iterator; | ||
| 14 | -import java.util.List; | ||
| 15 | -import java.util.Map; | ||
| 16 | -import java.util.Set; | ||
| 17 | - | ||
| 18 | -import javax.transaction.Transactional; | ||
| 19 | - | ||
| 20 | -import org.apache.commons.lang3.StringEscapeUtils; | ||
| 21 | -import org.apache.poi.hssf.usermodel.HSSFCell; | ||
| 22 | -import org.apache.poi.hssf.usermodel.HSSFRow; | ||
| 23 | -import org.apache.poi.hssf.usermodel.HSSFSheet; | ||
| 24 | -import org.apache.poi.hssf.usermodel.HSSFWorkbook; | ||
| 25 | -import org.apache.poi.poifs.filesystem.POIFSFileSystem; | ||
| 26 | -import org.slf4j.Logger; | ||
| 27 | -import org.slf4j.LoggerFactory; | ||
| 28 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 29 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 30 | -import org.springframework.stereotype.Service; | ||
| 31 | - | ||
| 32 | -import com.alibaba.fastjson.JSONArray; | ||
| 33 | -import com.alibaba.fastjson.JSONObject; | ||
| 34 | -import com.bsth.common.ResponseCode; | ||
| 35 | -import com.bsth.data.BasicData; | ||
| 36 | -import com.bsth.entity.Line; | ||
| 37 | -import com.bsth.entity.calc.CalcStatistics; | ||
| 38 | -import com.bsth.entity.forms.Budget; | ||
| 39 | -import com.bsth.entity.forms.Revenue; | ||
| 40 | -import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 41 | -import com.bsth.entity.schedule.TTInfoBxDetail; | ||
| 42 | -import com.bsth.entity.sys.Dictionary; | ||
| 43 | -import com.bsth.repository.calc.CalcStatisticsRepository; | ||
| 44 | -import com.bsth.repository.form.BudgetRepository; | ||
| 45 | -import com.bsth.repository.form.RevenueRepository; | ||
| 46 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 47 | -import com.bsth.repository.schedule.CarConfigInfoRepository; | ||
| 48 | -import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | ||
| 49 | -import com.bsth.repository.schedule.SchedulePlanInfoRepository; | ||
| 50 | -import com.bsth.repository.schedule.TTInfoBxDetailRepository; | ||
| 51 | -import com.bsth.service.LineService; | ||
| 52 | -import com.bsth.service.forms.BudgetService; | ||
| 53 | -import com.bsth.service.impl.BaseServiceImpl; | ||
| 54 | -import com.bsth.service.sys.DictionaryService; | ||
| 55 | -import com.bsth.util.ReportUtils; | ||
| 56 | - | ||
| 57 | -@Service | ||
| 58 | -public class BudgetServiceImpl extends BaseServiceImpl<Budget, Integer> implements BudgetService{ | ||
| 59 | - | ||
| 60 | - @Autowired | ||
| 61 | - private BudgetRepository repository; | ||
| 62 | - | ||
| 63 | - @Autowired | ||
| 64 | - private RevenueRepository revenueRepository; | ||
| 65 | - | ||
| 66 | - @Autowired | ||
| 67 | - private LineService lineService; | ||
| 68 | - | ||
| 69 | - @Autowired | ||
| 70 | - private CarConfigInfoRepository ccRepository; | ||
| 71 | - | ||
| 72 | - @Autowired | ||
| 73 | - private EmployeeConfigInfoRepository ecRepository; | ||
| 74 | - | ||
| 75 | - @Autowired | ||
| 76 | - private CalcStatisticsRepository calcStatisticsRepository; | ||
| 77 | - | ||
| 78 | - @Autowired | ||
| 79 | - private SchedulePlanInfoRepository schedulePlanRepository; | ||
| 80 | - | ||
| 81 | - @Autowired | ||
| 82 | - private ScheduleRealInfoRepository scheduleRealRepository; | ||
| 83 | - | ||
| 84 | - @Autowired | ||
| 85 | - private TTInfoBxDetailRepository ttInfoBxDetailRepository; | ||
| 86 | - | ||
| 87 | - @Autowired | ||
| 88 | - private DictionaryService dictionaryService; | ||
| 89 | - | ||
| 90 | - @Autowired | ||
| 91 | - JdbcTemplate jdbcTemplate; | ||
| 92 | - | ||
| 93 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 94 | - | ||
| 95 | - @Override | ||
| 96 | - public String importExcel(File file) { | ||
| 97 | - SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); | ||
| 98 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 99 | - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 100 | - DecimalFormat df = new DecimalFormat("######0.000"); | ||
| 101 | - List<String> textList = new ArrayList<String>(); | ||
| 102 | - List<Budget> list = new ArrayList<Budget>(); | ||
| 103 | - String msg = "", tempMsg = ""; | ||
| 104 | - try { | ||
| 105 | - POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); | ||
| 106 | - HSSFWorkbook wb = new HSSFWorkbook(fs); | ||
| 107 | - HSSFSheet sheet = wb.getSheetAt(0); | ||
| 108 | - // 取得总行数 | ||
| 109 | - int rowNum = sheet.getLastRowNum() + 1; | ||
| 110 | - // 取得总列数 | ||
| 111 | - int cellNum = sheet.getRow(0).getLastCellNum(); | ||
| 112 | - HSSFRow row = null; | ||
| 113 | - HSSFCell cell = null; | ||
| 114 | - for(int i = 3; i < rowNum; i++){ | ||
| 115 | - row = sheet.getRow(i); | ||
| 116 | - if (row == null){ | ||
| 117 | - continue; | ||
| 118 | - } | ||
| 119 | - String text = ""; | ||
| 120 | - for(int j = 0; j < cellNum; j++){ | ||
| 121 | - cell = row.getCell(j); | ||
| 122 | - if(cell == null){ | ||
| 123 | - text += ","; | ||
| 124 | - continue; | ||
| 125 | - } | ||
| 126 | - text += String.valueOf(cell) + ","; | ||
| 127 | - } | ||
| 128 | - String[] split = (text+";").split(","); | ||
| 129 | - String str = ""; | ||
| 130 | - for(int j = 0; j < split.length && j < 5; j++){ | ||
| 131 | - str += split[j]; | ||
| 132 | - } | ||
| 133 | - if(str.trim().length() == 0){ | ||
| 134 | - continue; | ||
| 135 | - } | ||
| 136 | - textList.add(i + "," + text + ";"); | ||
| 137 | - } | ||
| 138 | - | ||
| 139 | - Map<String, Line> lineMap = new HashMap<String, Line>(); | ||
| 140 | - Iterable<Line> findAllLine = lineService.findAll(); | ||
| 141 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 142 | - for(Line l : findAllLine){ | ||
| 143 | - if(BasicData.businessCodeNameMap.containsKey(l.getCompany())){ | ||
| 144 | -// String gsName = BasicData.businessCodeNameMap.get(l.getCompany()); | ||
| 145 | -// gsName = gsName.replaceAll("公司", ""); | ||
| 146 | -// lineMap.put(gsName + "_" + l.getName(), l); | ||
| 147 | - lineMap.put(l.getName(), l); | ||
| 148 | - } | ||
| 149 | - } | ||
| 150 | - | ||
| 151 | - for(int i = 0; i < textList.size(); i++){ | ||
| 152 | - String text = textList.get(i); | ||
| 153 | - String[] split = text.split(","); | ||
| 154 | - int rowNo = Integer.valueOf(split[0].trim()); | ||
| 155 | - String year = split[1].trim(); | ||
| 156 | - String gsName = split[2].trim().replaceAll("公司", ""); | ||
| 157 | - String xlName = split[3].trim(); | ||
| 158 | - Line line = null; | ||
| 159 | - String gsBm = ""; | ||
| 160 | - for(String key : BasicData.businessCodeNameMap.keySet()){ | ||
| 161 | - String name = BasicData.businessCodeNameMap.get(key).replaceAll("公司", ""); | ||
| 162 | - if(name.equals(gsName)){ | ||
| 163 | - gsBm = key; | ||
| 164 | - } | ||
| 165 | - } | ||
| 166 | - boolean sfyy = false; | ||
| 167 | - if(year.length() == 0){ | ||
| 168 | - msg += "第"+(rowNo+1)+"行,没有年份;\\n"; | ||
| 169 | - } else { | ||
| 170 | - try { | ||
| 171 | - yearFormat.parse(year); | ||
| 172 | - } catch (ParseException pe) { | ||
| 173 | - // TODO: handle exception | ||
| 174 | - pe.printStackTrace(); | ||
| 175 | - msg += "第"+(rowNo+1)+"行,年份书写错误;\\n"; | ||
| 176 | - } | ||
| 177 | - } | ||
| 178 | - if(xlName.length() == 0){ | ||
| 179 | - msg += "第"+(rowNo+1)+"行,没有线路名;\\n"; | ||
| 180 | - } else { | ||
| 181 | - if(lineMap.containsKey(xlName)){ | ||
| 182 | - line = lineMap.get(xlName); | ||
| 183 | - sfyy = lineNature.containsKey(line.getLineCode())?lineNature.get(line.getLineCode()):false; | ||
| 184 | - } else { | ||
| 185 | - msg += "第"+(rowNo+1)+"行,线路基础信息无此线路;\\n"; | ||
| 186 | - } | ||
| 187 | - } | ||
| 188 | - int left = 3; | ||
| 189 | - for(int mon = 1; mon <= 12; mon++){ | ||
| 190 | - String mileage = split[left+(mon-1)*3+1].trim(); | ||
| 191 | - String person = split[left+(mon-1)*3+2].trim(); | ||
| 192 | - String amounts = split[left+(mon-1)*3+3].trim(); | ||
| 193 | - Double formalMileage = null, formalPerson = null, formalAmounts = null; | ||
| 194 | - try { | ||
| 195 | - if(mileage.length() > 0){ | ||
| 196 | - formalMileage = Double.valueOf(df.format(Double.valueOf(mileage))); | ||
| 197 | - } | ||
| 198 | - if(person.length() > 0){ | ||
| 199 | - formalPerson = Double.valueOf(df.format(Double.valueOf(person))); | ||
| 200 | - } | ||
| 201 | - if(amounts.length() > 0){ | ||
| 202 | - formalAmounts = Double.valueOf(df.format(Double.valueOf(amounts))); | ||
| 203 | - } | ||
| 204 | - Budget b = new Budget(); | ||
| 205 | - b.setYear(year + "-" + (mon>9?mon:("0"+mon))); | ||
| 206 | - b.setGsBm(gsBm); | ||
| 207 | - b.setGsName(BasicData.businessCodeNameMap.get(gsBm)); | ||
| 208 | - b.setXlBm(line!=null?line.getLineCode():""); | ||
| 209 | - b.setXlName(line!=null?line.getName():""); | ||
| 210 | - b.setSfyy(sfyy); | ||
| 211 | - b.setFormalMileage(formalMileage); | ||
| 212 | - b.setFormalPerson(formalPerson); | ||
| 213 | - b.setFormalAmounts(formalAmounts); | ||
| 214 | - list.add(b); | ||
| 215 | - } catch (NumberFormatException nfe) { | ||
| 216 | - // TODO: handle exception | ||
| 217 | - nfe.printStackTrace(); | ||
| 218 | - msg += "第"+(rowNo+1)+"行,数字格式异常;\\n"; | ||
| 219 | - } | ||
| 220 | - } | ||
| 221 | - } | ||
| 222 | - | ||
| 223 | - List<Budget> insertList = new ArrayList<Budget>(); | ||
| 224 | - if(msg.length() == 0){ | ||
| 225 | - for(Budget b : list){ | ||
| 226 | - List<Budget> budgets = repository.import_queryBySame(b.getYear(), b.getGsBm(), b.getXlBm()); | ||
| 227 | - if(budgets.size() > 0) { | ||
| 228 | - Budget bud = budgets.get(0); | ||
| 229 | - if(b.getFormalPerson() != null){ | ||
| 230 | - if(bud.getBudgetMileage() != null){ | ||
| 231 | - bud.setChangeMileage(b.getFormalMileage()); | ||
| 232 | - } else { | ||
| 233 | - bud.setBudgetMileage(b.getFormalMileage()); | ||
| 234 | - } | ||
| 235 | - bud.setFormalMileage(b.getFormalMileage()); | ||
| 236 | - } | ||
| 237 | - if(b.getFormalPerson() != null){ | ||
| 238 | - if(bud.getBudgetPerson() != null){ | ||
| 239 | - bud.setChangePerson(b.getFormalPerson()); | ||
| 240 | - } else { | ||
| 241 | - bud.setBudgetPerson(b.getFormalPerson()); | ||
| 242 | - } | ||
| 243 | - bud.setFormalPerson(b.getFormalPerson()); | ||
| 244 | - } | ||
| 245 | - if(b.getFormalAmounts() != null){ | ||
| 246 | - if(bud.getBudgetAmounts() != null){ | ||
| 247 | - bud.setChangeAmounts(b.getFormalAmounts()); | ||
| 248 | - } else { | ||
| 249 | - bud.setBudgetAmounts(b.getFormalAmounts()); | ||
| 250 | - } | ||
| 251 | - bud.setFormalAmounts(b.getFormalAmounts()); | ||
| 252 | - } | ||
| 253 | - repository.update(bud.getBudgetMileage(), bud.getChangeMileage(), bud.getFormalMileage(), | ||
| 254 | - bud.getBudgetPerson(), bud.getChangePerson(), bud.getFormalPerson(), | ||
| 255 | - bud.getBudgetAmounts(), bud.getChangeAmounts(), bud.getFormalAmounts(), bud.getId()); | ||
| 256 | - } else { | ||
| 257 | - b.setBudgetMileage(b.getFormalMileage()); | ||
| 258 | - b.setBudgetPerson(b.getFormalPerson()); | ||
| 259 | - b.setBudgetAmounts(b.getFormalAmounts()); | ||
| 260 | - insertList.add(b); | ||
| 261 | - } | ||
| 262 | - } | ||
| 263 | - repository.saveAll(insertList); | ||
| 264 | - | ||
| 265 | - } | ||
| 266 | - | ||
| 267 | - wb.close(); | ||
| 268 | - fs.close(); | ||
| 269 | - }catch (Exception e) { | ||
| 270 | - // TODO Auto-generated catch block | ||
| 271 | - e.printStackTrace(); | ||
| 272 | - return msg.length()>0?msg:"文件导入失败"; | ||
| 273 | - } finally { | ||
| 274 | - file.delete(); | ||
| 275 | - } | ||
| 276 | - return msg.length()>0?msg:"文件导入成功"; | ||
| 277 | - } | ||
| 278 | - | ||
| 279 | - @Transactional | ||
| 280 | - @Override | ||
| 281 | - public Map<String, Object> deleteIds(Map<String, Object> map) throws Exception{ | ||
| 282 | - // TODO Auto-generated method stub | ||
| 283 | - Map<String, Object> maps = new HashMap<>(); | ||
| 284 | - try{ | ||
| 285 | - String json =StringEscapeUtils.unescapeHtml4(map.get("ids").toString()); | ||
| 286 | - JSONArray jsonArray=JSONArray.parseArray(json); | ||
| 287 | - JSONObject jsonObject; | ||
| 288 | - for (int x = 0; x < jsonArray.size(); x++) { | ||
| 289 | - jsonObject=jsonArray.getJSONObject(x); | ||
| 290 | - Long id = jsonObject.getLong("id"); | ||
| 291 | - Budget b = new Budget(); | ||
| 292 | - b.setId(id); | ||
| 293 | - repository.delete(b); | ||
| 294 | -// repository.deleteById(id); | ||
| 295 | - } | ||
| 296 | - | ||
| 297 | -// SysUser user = SecurityUtils.getCurrentUser(); | ||
| 298 | - maps.put("status", ResponseCode.SUCCESS); | ||
| 299 | - } catch (Exception e) { | ||
| 300 | - maps.put("status", ResponseCode.ERROR); | ||
| 301 | - logger.error("save erro.", e); | ||
| 302 | - throw e; | ||
| 303 | - } | ||
| 304 | - return maps; | ||
| 305 | - } | ||
| 306 | - | ||
| 307 | - @Override | ||
| 308 | - public void updateRevenueRange(String date1, String date2) { | ||
| 309 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 310 | - try { | ||
| 311 | - if(date1 == null || date2 == null | ||
| 312 | - || date1.trim().length() == 0 | ||
| 313 | - || date2.trim().length() == 0){ | ||
| 314 | - Date d = new Date(); | ||
| 315 | - d.setTime(d.getTime() - (1l * 1000 * 60 * 60 * 24)); | ||
| 316 | - date2 = sdf.format(d); | ||
| 317 | - d.setTime(d.getTime() - (8l * 1000 * 60 * 60 * 24)); | ||
| 318 | - date1 = sdf.format(d); | ||
| 319 | - } | ||
| 320 | - Date parse1 = sdf.parse(date1); | ||
| 321 | - Date parse2 = sdf.parse(date2); | ||
| 322 | - for(Date parse = new Date(parse1.getTime()); | ||
| 323 | - parse.getTime() <= parse2.getTime(); | ||
| 324 | - parse.setTime(parse.getTime() + 1l*1000*60*60*24)){ | ||
| 325 | - try { | ||
| 326 | - updateRevenue(sdf.format(parse)); | ||
| 327 | - } catch (Exception e) { | ||
| 328 | - // TODO: handle exception | ||
| 329 | - e.printStackTrace(); | ||
| 330 | - } | ||
| 331 | - } | ||
| 332 | - } catch (ParseException e) { | ||
| 333 | - // TODO: handle exception | ||
| 334 | - e.printStackTrace(); | ||
| 335 | - } | ||
| 336 | - } | ||
| 337 | - | ||
| 338 | - @Override | ||
| 339 | - public Map<String, Object> updateRevenue(String date) throws Exception { | ||
| 340 | - // TODO Auto-generated method stub | ||
| 341 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 342 | - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd"); | ||
| 343 | - Map<String, Object> resMap=new HashMap<String, Object>(); | ||
| 344 | - Set<String> strSet = new HashSet<String>(); // 去重 | ||
| 345 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 346 | - Map<String, Map<String, Line>> lineMap = new HashMap<String, Map<String, Line>>(); | ||
| 347 | - Map<String, Line> lineAllMap = new HashMap<String, Line>(); | ||
| 348 | - Iterable<Line> findAllLine = lineService.findAll(); | ||
| 349 | - for(Line l : findAllLine){ | ||
| 350 | - if(!(lineMap.containsKey(l.getCompany()))){ | ||
| 351 | - lineMap.put(l.getCompany(), new HashMap<String, Line>()); | ||
| 352 | - } | ||
| 353 | - lineMap.get(l.getCompany()).put(l.getName(), l); | ||
| 354 | - lineAllMap.put(l.getName(), l); | ||
| 355 | - } | ||
| 356 | - Map<String, String> dictionMap = new HashMap<String, String>(); | ||
| 357 | - List<Map<String, String>> revenueDiction = revenueRepository.findRevenueDictionAll(); | ||
| 358 | - for(Map<String, String> m : revenueDiction){ | ||
| 359 | - dictionMap.put(m.get("ticket_line_name").toString(), m.get("local_line_name").toString()); | ||
| 360 | - } | ||
| 361 | - List<Revenue> list = new ArrayList<Revenue>(); | ||
| 362 | - Date parse = sdf.parse(date); | ||
| 363 | - String ymd = sdf2.format(parse); | ||
| 364 | - for(String gsBm : BasicData.businessCodeNameMap.keySet()){ | ||
| 365 | - List<Map<String, Object>> load = RevenueLoader.load(ymd, gsBm); | ||
| 366 | - if(load != null && load.size() > 0){ | ||
| 367 | - for(Map<String, Object> m : load){ | ||
| 368 | - if(m.containsKey("lineName")){ | ||
| 369 | - String fgsBm = m.get("branchCompanyCode") != null ? m.get("branchCompanyCode").toString() : ""; | ||
| 370 | - String lineName = m.get("lineName").toString().split("空调")[0].split("电车")[0]; | ||
| 371 | - Revenue r = new Revenue(); | ||
| 372 | - if(lineMap.get(gsBm) != null && lineMap.get(gsBm).containsKey(lineName)){ | ||
| 373 | - r.setXlBm(lineMap.get(gsBm).get(lineName).getLineCode()); | ||
| 374 | - r.setXlName(lineMap.get(gsBm).get(lineName).getName()); | ||
| 375 | - }if(dictionMap.containsKey(lineName)){ | ||
| 376 | - String name = dictionMap.get(lineName); | ||
| 377 | - if(lineAllMap.containsKey(name)){ | ||
| 378 | - r.setXlBm(lineAllMap.get(name).getLineCode()); | ||
| 379 | - r.setXlName(lineAllMap.get(name).getName()); | ||
| 380 | - } | ||
| 381 | - } else { | ||
| 382 | - for(String key : lineAllMap.keySet()){ | ||
| 383 | - Line l = lineAllMap.get(key); | ||
| 384 | - String name = l.getName(); | ||
| 385 | - if(l.getStartStationName() != null & l.getStartStationName().length() > 0){ | ||
| 386 | - name = name.replaceAll("区间", "") + l.getStartStationName().substring(0, 1); | ||
| 387 | - } | ||
| 388 | - if(l.getName().equals(lineName) || name.equals(lineName)){ | ||
| 389 | - r.setXlBm(l.getLineCode()); | ||
| 390 | - r.setXlName(l.getName()); | ||
| 391 | - break; | ||
| 392 | - } | ||
| 393 | - } | ||
| 394 | - } | ||
| 395 | - | ||
| 396 | - if(r.getXlBm() != null){ | ||
| 397 | - r.setScheduleDate(parse); | ||
| 398 | - r.setScheduleDateStr(date); | ||
| 399 | - r.setGsBm(gsBm); | ||
| 400 | - r.setGsName(BasicData.businessCodeNameMap.get(gsBm)); | ||
| 401 | - r.setFgsBm(fgsBm); | ||
| 402 | - r.setFgsName(BasicData.businessFgsCodeNameMap.get(fgsBm + "_" + gsBm)); | ||
| 403 | - r.setSfyy(lineNature.containsKey(r.getXlBm())?lineNature.get(r.getXlBm()):false); | ||
| 404 | - r.setNum(Long.valueOf(m.get("num").toString().split("[.]")[0])); | ||
| 405 | - r.setAmount(Double.valueOf(m.get("amount").toString())); | ||
| 406 | - String str = r.getGsBm() + "/" + r.getFgsBm() + "/" + r.getXlBm(); | ||
| 407 | - if(strSet.add(str)){ | ||
| 408 | - list.add(r); | ||
| 409 | - } | ||
| 410 | - } | ||
| 411 | - } | ||
| 412 | - } | ||
| 413 | - } | ||
| 414 | - } | ||
| 415 | - if(list.size() > 0){ | ||
| 416 | - revenueRepository.deleteByScheduleDate(date); | ||
| 417 | - revenueRepository.saveAll(list); | ||
| 418 | - } | ||
| 419 | - | ||
| 420 | - resMap.put("status", ResponseCode.SUCCESS); | ||
| 421 | - return resMap; | ||
| 422 | - } | ||
| 423 | - | ||
| 424 | - @Override | ||
| 425 | - public List<Map<String, Object>> budgetMileage(String year, String tttt, String kkk) { | ||
| 426 | - // TODO Auto-generated method stub | ||
| 427 | - SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 428 | - SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 429 | - DecimalFormat df = new DecimalFormat("0.###"); | ||
| 430 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 431 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 432 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 433 | - List<Budget> findByYear = repository.findByYear(year); | ||
| 434 | - List<CalcStatistics> list = calcStatisticsRepository.selectByDateAndLineTj3(year+"-01-01", year+"-12-31"); | ||
| 435 | - | ||
| 436 | - String year_1 = ""; | ||
| 437 | - try { | ||
| 438 | - year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 439 | - } catch (ParseException e) { | ||
| 440 | - // TODO Auto-generated catch block | ||
| 441 | - e.printStackTrace(); | ||
| 442 | - } | ||
| 443 | - List<CalcStatistics> scheduleList_1 = calcStatisticsRepository.selectByDateAndLineTj3(year_1+"-01-01", year_1+"-12-31"); | ||
| 444 | - | ||
| 445 | - Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 446 | - List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 447 | - | ||
| 448 | - String[] strs = createBudgetMap(resList, keyMap); | ||
| 449 | - | ||
| 450 | - for(Budget b : findByYear){ | ||
| 451 | - if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 452 | - continue; | ||
| 453 | - } | ||
| 454 | - if(b.getFormalMileage()==null || b.getFormalMileage() < 0d){ | ||
| 455 | - continue; | ||
| 456 | - } | ||
| 457 | - String gsBm = b.getGsBm(); | ||
| 458 | - String xlBm = b.getXlBm(); | ||
| 459 | - String xlName = b.getXlName(); | ||
| 460 | - int sfyy = b.getSfyy()?1:0; | ||
| 461 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 462 | - | ||
| 463 | - String key = gsBm + "_" + xlBm; | ||
| 464 | - if(!(xlMap.containsKey(key))){ | ||
| 465 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 466 | - m.put("gsBm", gsBm); | ||
| 467 | - m.put("gsName", b.getGsName()); | ||
| 468 | - m.put("xlBm", xlBm); | ||
| 469 | - m.put("xlName", xlName); | ||
| 470 | - m.put("sfyy", sfyy); | ||
| 471 | - m.put("sfjc", sfjc); | ||
| 472 | - m.put("budget", b.getBudgetMileage()!=null?df.format(b.getBudgetMileage()):""); | ||
| 473 | - m.put("change", b.getChangeMileage()!=null?df.format(b.getChangeMileage()):""); | ||
| 474 | - m.put("formal", b.getFormalMileage()!=null?df.format(b.getFormalMileage()):""); | ||
| 475 | - for(int i = 1; i <= 12; i++){ | ||
| 476 | - m.put("mon"+i, ""); | ||
| 477 | - m.put("bud"+i, ""); | ||
| 478 | - m.put("pre"+i, ""); | ||
| 479 | - } | ||
| 480 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 481 | - if(b.getFormalMileage()!=null){ | ||
| 482 | - m.put(bud, b.getFormalMileage()); | ||
| 483 | - } | ||
| 484 | - m.put("monAll", "0"); | ||
| 485 | - xlMap.put(key, m); | ||
| 486 | - xlList.add(m); | ||
| 487 | - } else { | ||
| 488 | - Map<String, Object> m = xlMap.get(key); | ||
| 489 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 490 | - if(b.getBudgetMileage()!=null){ | ||
| 491 | - if(m.get("budget").toString().length() > 0){ | ||
| 492 | - m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 493 | - new BigDecimal(b.getBudgetMileage())).doubleValue())); | ||
| 494 | - } else { | ||
| 495 | - m.put("budget", df.format(b.getBudgetMileage())); | ||
| 496 | - } | ||
| 497 | - } | ||
| 498 | - if(b.getChangeMileage()!=null){ | ||
| 499 | - if(m.get("change").toString().length() > 0){ | ||
| 500 | - m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 501 | - new BigDecimal(b.getChangeMileage())).doubleValue())); | ||
| 502 | - } else { | ||
| 503 | - m.put("change", df.format(b.getChangeMileage())); | ||
| 504 | - } | ||
| 505 | - } | ||
| 506 | - if(b.getFormalMileage()!=null){ | ||
| 507 | - if(m.get("formal").toString().length() > 0){ | ||
| 508 | - m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 509 | - new BigDecimal(b.getFormalMileage())).doubleValue())); | ||
| 510 | - } else { | ||
| 511 | - m.put("formal", df.format(b.getFormalMileage())); | ||
| 512 | - } | ||
| 513 | - m.put(bud, df.format(b.getFormalMileage())); | ||
| 514 | - } | ||
| 515 | - } | ||
| 516 | - } | ||
| 517 | - | ||
| 518 | - for(CalcStatistics cs : list){ | ||
| 519 | - String gsBm = cs.getGsdm(); | ||
| 520 | - String xlBm = cs.getXl(); | ||
| 521 | - String xlName = cs.getXlName(); | ||
| 522 | - int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 523 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 524 | - | ||
| 525 | - String key = gsBm + "_" + xlBm; | ||
| 526 | - if(!(xlMap.containsKey(key))){ | ||
| 527 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 528 | - m.put("gsBm", gsBm); | ||
| 529 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 530 | - m.put("xlBm", xlBm); | ||
| 531 | - m.put("xlName", xlName); | ||
| 532 | - m.put("sfyy", sfyy); | ||
| 533 | - m.put("sfjc", sfjc); | ||
| 534 | - m.put("budget", ""); | ||
| 535 | - m.put("change", ""); | ||
| 536 | - m.put("formal", ""); | ||
| 537 | - for(int i = 1; i <= 12; i++){ | ||
| 538 | - m.put("mon"+i, ""); | ||
| 539 | - m.put("bud"+i, ""); | ||
| 540 | - m.put("pre"+i, ""); | ||
| 541 | - } | ||
| 542 | - m.put("monAll", "0"); | ||
| 543 | - xlMap.put(key, m); | ||
| 544 | - xlList.add(m); | ||
| 545 | - } | ||
| 546 | - Map<String, Object> map = xlMap.get(key); | ||
| 547 | - String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getDate())); | ||
| 548 | - String val = map.get(mon).toString(); | ||
| 549 | - BigDecimal sjzlc = new BigDecimal(cs.getSjzlc().toString()); | ||
| 550 | - if(val.length() == 0){ | ||
| 551 | - map.put(mon, sjzlc.doubleValue()); | ||
| 552 | - } else { | ||
| 553 | - map.put(mon, new BigDecimal(val).add(sjzlc).doubleValue()); | ||
| 554 | - } | ||
| 555 | - } | ||
| 556 | - | ||
| 557 | - for(CalcStatistics cs1 : scheduleList_1){ // 去年公里 | ||
| 558 | - String gsdm = cs1.getGsdm(); | ||
| 559 | - String xlBm = cs1.getXl(); | ||
| 560 | - String xlName = cs1.getXlName(); | ||
| 561 | - int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 562 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 563 | - | ||
| 564 | - String key = gsdm + "_" + xlBm; | ||
| 565 | - if(!(xlMap.containsKey(key))){ | ||
| 566 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 567 | - m.put("gsBm", gsdm); | ||
| 568 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsdm)); | ||
| 569 | - m.put("xlBm", xlBm); | ||
| 570 | - m.put("xlName", xlName); | ||
| 571 | - m.put("sfyy", sfyy); | ||
| 572 | - m.put("sfjc", sfjc); | ||
| 573 | - m.put("budget", ""); | ||
| 574 | - m.put("change", ""); | ||
| 575 | - m.put("formal", ""); | ||
| 576 | - for(int i = 1; i <= 12; i++){ | ||
| 577 | - m.put("mon"+i, ""); | ||
| 578 | - m.put("bud"+i, ""); | ||
| 579 | - m.put("pre"+i, ""); | ||
| 580 | - } | ||
| 581 | - m.put("monAll", "0"); | ||
| 582 | - xlMap.put(key, m); | ||
| 583 | - xlList.add(m); | ||
| 584 | - } | ||
| 585 | - Map<String, Object> map = xlMap.get(key); | ||
| 586 | - String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getDate())); | ||
| 587 | - String val = map.get(pre).toString(); | ||
| 588 | - BigDecimal num = new BigDecimal(cs1.getSjzlc().toString()); | ||
| 589 | - if(val.length() == 0){ | ||
| 590 | - map.put(pre, num.doubleValue()); | ||
| 591 | - } else { | ||
| 592 | - map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 593 | - } | ||
| 594 | - } | ||
| 595 | - | ||
| 596 | - for(Map<String, Object> m : xlList){ | ||
| 597 | - String gsBm = m.get("gsBm").toString(); | ||
| 598 | - int type = Integer.valueOf(m.get("sfyy").toString()); | ||
| 599 | - int item = Integer.valueOf(m.get("sfjc").toString()) == 1 ? 0 : 1; | ||
| 600 | - List<String> strList = new ArrayList<String>(); | ||
| 601 | - if(1 == type){ | ||
| 602 | - strList.add(gsBm + "_" + type + "_" + item); | ||
| 603 | - strList.add(gsBm + "_" + type + "_all"); | ||
| 604 | - } else { | ||
| 605 | - strList.add(gsBm + "_" + type); | ||
| 606 | - } | ||
| 607 | - strList.add(gsBm + "_all"); | ||
| 608 | - | ||
| 609 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 610 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 611 | - for(int i = 1; i <= 12; i++){ | ||
| 612 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 613 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 614 | - monAll = monAll.add(val); | ||
| 615 | - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 616 | - m.put("mon"+i, val.doubleValue()); | ||
| 617 | - } | ||
| 618 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 619 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 620 | - preAll = preAll.add(val); | ||
| 621 | - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 622 | - m.put("pre"+i, val.doubleValue()); | ||
| 623 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 624 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 625 | - BigDecimal sub = monVal.subtract(val); | ||
| 626 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 627 | - } else { | ||
| 628 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 629 | - } | ||
| 630 | - } | ||
| 631 | - } | ||
| 632 | - monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 633 | - preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 634 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 635 | - m.put("monAll", monAll.doubleValue()); | ||
| 636 | - m.put("preAll", preAll.doubleValue()); | ||
| 637 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 638 | - | ||
| 639 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 640 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 641 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 642 | - m.put("complete", monAll.divide( | ||
| 643 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 644 | - new BigDecimal(100)).divide( | ||
| 645 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 646 | - BigDecimal diff = monAll.subtract(formal); | ||
| 647 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 648 | - } else { | ||
| 649 | - m.put("complete", ""); | ||
| 650 | - m.put("diff", ""); | ||
| 651 | - } | ||
| 652 | - | ||
| 653 | - for(String str : strList){ | ||
| 654 | - if(!keyMap.containsKey(str)){ | ||
| 655 | - continue; | ||
| 656 | - } | ||
| 657 | - Map<String, Object> map = keyMap.get(str); | ||
| 658 | - if(m.get("budget").toString().length() > 0){ | ||
| 659 | - if(map.get("budget").toString().length() > 0){ | ||
| 660 | - map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 661 | - new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 662 | - } else { | ||
| 663 | - map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 664 | - } | ||
| 665 | - } | ||
| 666 | - if(m.get("change").toString().length() > 0){ | ||
| 667 | - if(map.get("change").toString().length() > 0){ | ||
| 668 | - map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 669 | - new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 670 | - } else { | ||
| 671 | - map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 672 | - } | ||
| 673 | - } | ||
| 674 | - if(m.get("formal").toString().length() > 0){ | ||
| 675 | - if(map.get("formal").toString().length() > 0){ | ||
| 676 | - map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 677 | - new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 678 | - } else { | ||
| 679 | - map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 680 | - } | ||
| 681 | - } | ||
| 682 | - for(int i = 1; i <= 12; i++){ | ||
| 683 | - String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 684 | - if(m.get(mon).toString().length() > 0){ | ||
| 685 | - if(map.get(mon).toString().length() > 0){ | ||
| 686 | - map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 687 | - new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 688 | - } else { | ||
| 689 | - map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 690 | - } | ||
| 691 | - } | ||
| 692 | - if(m.get(bud).toString().length() > 0){ | ||
| 693 | - if(map.get(bud).toString().length() > 0){ | ||
| 694 | - map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 695 | - new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 696 | - } else { | ||
| 697 | - map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 698 | - } | ||
| 699 | - } | ||
| 700 | - if(m.get(pre).toString().length() > 0){ | ||
| 701 | - if(map.get(pre).toString().length() > 0){ | ||
| 702 | - map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 703 | - new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 704 | - } else { | ||
| 705 | - map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 706 | - } | ||
| 707 | - } | ||
| 708 | - } | ||
| 709 | - List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 710 | - dataList.add(m); | ||
| 711 | - } | ||
| 712 | - } | ||
| 713 | - | ||
| 714 | - for(String key : strs){ | ||
| 715 | - if(!(key.contains("all_"))){ | ||
| 716 | - String[] sp = key.split("_"); | ||
| 717 | - String allKey = "all"; | ||
| 718 | - for(int i = 1; i < sp.length; i++){ | ||
| 719 | - allKey += "_" + sp[i]; | ||
| 720 | - } | ||
| 721 | - Map<String, Object> map = keyMap.get(key); | ||
| 722 | - Map<String, Object> allMap = keyMap.get(allKey); | ||
| 723 | - for(String k : map.keySet()){ | ||
| 724 | - if("year".equals(k)){ // 不想被计算的数字型字段 | ||
| 725 | - continue; | ||
| 726 | - } | ||
| 727 | - try { | ||
| 728 | - allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 729 | - new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 730 | - } catch (Exception e) { | ||
| 731 | - // TODO: handle exception | ||
| 732 | - } | ||
| 733 | - } | ||
| 734 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 735 | - dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 736 | - allMap.put("dataList", dataList); | ||
| 737 | - | ||
| 738 | - for(Map<String, Object> m : dataList){ | ||
| 739 | - for(int i = 1; i <= 12; i++){ | ||
| 740 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 741 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 742 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 743 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 744 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 745 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 746 | - } else { | ||
| 747 | - m.put("com" + i, ""); | ||
| 748 | - } | ||
| 749 | - } | ||
| 750 | - } | ||
| 751 | - } | ||
| 752 | - } | ||
| 753 | - | ||
| 754 | - for(String key : strs){ | ||
| 755 | - Map<String, Object> m = keyMap.get(key); | ||
| 756 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 757 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 758 | - for(int i = 1; i <= 12; i++){ | ||
| 759 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 760 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 761 | - monAll = monAll.add(val); | ||
| 762 | - } | ||
| 763 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 764 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 765 | - preAll = preAll.add(val); | ||
| 766 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 767 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 768 | - BigDecimal sub = monVal.subtract(val); | ||
| 769 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 770 | - } else { | ||
| 771 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 772 | - } | ||
| 773 | - } | ||
| 774 | - } | ||
| 775 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 776 | - m.put("monAll", monAll.doubleValue()); | ||
| 777 | - m.put("preAll", preAll.doubleValue()); | ||
| 778 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 779 | - | ||
| 780 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 781 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 782 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 783 | - m.put("complete", monAll.divide( | ||
| 784 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 785 | - new BigDecimal(100)).divide( | ||
| 786 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 787 | - BigDecimal diff = monAll.subtract(formal); | ||
| 788 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 789 | - } else { | ||
| 790 | - m.put("complete", ""); | ||
| 791 | - m.put("diff", ""); | ||
| 792 | - } | ||
| 793 | - m.put("year", year); | ||
| 794 | - | ||
| 795 | - for(int i = 1; i <= 12; i++){ | ||
| 796 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 797 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 798 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 799 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 800 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 801 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 802 | - } else { | ||
| 803 | - m.put("com" + i, ""); | ||
| 804 | - } | ||
| 805 | - } | ||
| 806 | - } | ||
| 807 | - | ||
| 808 | - if(tttt.equals("export")){ | ||
| 809 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 810 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 811 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 812 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 813 | - String xls="budgetMileage.xls"; | ||
| 814 | - ReportUtils ee = new ReportUtils(); | ||
| 815 | - try { | ||
| 816 | - String dateTime = ""; | ||
| 817 | - m.put("date", year); | ||
| 818 | - dateTime = year; | ||
| 819 | - listI.add(resList.iterator()); | ||
| 820 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 821 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 822 | - path + "export/"+dateTime+"-预算公里明细表.xls"); | ||
| 823 | - } catch (Exception e) { | ||
| 824 | - // TODO: handle exception | ||
| 825 | - e.printStackTrace(); | ||
| 826 | - } | ||
| 827 | - } | ||
| 828 | - | ||
| 829 | - if(tttt.equals("exportData")){ | ||
| 830 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 831 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 832 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 833 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 834 | - m.put("date", year); | ||
| 835 | - ReportUtils ee = new ReportUtils(); | ||
| 836 | - try { | ||
| 837 | - for(Map<String, Object> map : resList){ | ||
| 838 | - if(kkk.equals(map.get("key").toString())){ | ||
| 839 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 840 | - listI.add(dataList.iterator()); | ||
| 841 | - } | ||
| 842 | - } | ||
| 843 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 844 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetMileage_data.xls", | ||
| 845 | - path + "export/" + year + "-预算公里明细表-线路明细.xls"); | ||
| 846 | - } catch (Exception e) { | ||
| 847 | - // TODO: handle exception | ||
| 848 | - e.printStackTrace(); | ||
| 849 | - logger.info("", e); | ||
| 850 | - } | ||
| 851 | - } | ||
| 852 | - | ||
| 853 | - return resList; | ||
| 854 | - } | ||
| 855 | - | ||
| 856 | - @Override | ||
| 857 | - public List<Map<String, Object>> budgetPerson(String year, String tttt, String kkk) { | ||
| 858 | - // TODO Auto-generated method stub | ||
| 859 | - SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 860 | - SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 861 | - DecimalFormat df = new DecimalFormat("0.###"); | ||
| 862 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 863 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 864 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 865 | - List<Budget> findByYear = repository.findByYear(year); | ||
| 866 | - List<Revenue> list = revenueRepository.findByDates(year+"-01-01", year+"-12-31"); | ||
| 867 | - | ||
| 868 | - String year_1 = ""; | ||
| 869 | - try { | ||
| 870 | - year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 871 | - } catch (ParseException e) { | ||
| 872 | - // TODO Auto-generated catch block | ||
| 873 | - e.printStackTrace(); | ||
| 874 | - } | ||
| 875 | - List<Revenue> revenueList_1 = revenueRepository.findByDates(year_1+"-01-01", year_1+"-12-31"); | ||
| 876 | - | ||
| 877 | - Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 878 | - List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 879 | - | ||
| 880 | - String[] strs = createBudgetMap(resList, keyMap); | ||
| 881 | - | ||
| 882 | - for(Budget b : findByYear){ | ||
| 883 | - if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 884 | - continue; | ||
| 885 | - } | ||
| 886 | - if(b.getFormalPerson()==null || b.getFormalPerson() < 0d){ | ||
| 887 | - continue; | ||
| 888 | - } | ||
| 889 | - String gsBm = b.getGsBm(); | ||
| 890 | - String xlBm = b.getXlBm(); | ||
| 891 | - String xlName = b.getXlName(); | ||
| 892 | - int sfyy = b.getSfyy()?1:0; | ||
| 893 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 894 | - | ||
| 895 | - String key = gsBm + "_" + xlBm; | ||
| 896 | - if(!(xlMap.containsKey(key))){ | ||
| 897 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 898 | - m.put("gsBm", gsBm); | ||
| 899 | - m.put("gsName", b.getGsName()); | ||
| 900 | - m.put("xlBm", xlBm); | ||
| 901 | - m.put("xlName", xlName); | ||
| 902 | - m.put("sfyy", sfyy); | ||
| 903 | - m.put("sfjc", sfjc); | ||
| 904 | - m.put("budget", b.getBudgetPerson()!=null?df.format(b.getBudgetPerson()):""); | ||
| 905 | - m.put("change", b.getChangePerson()!=null?df.format(b.getChangePerson()):""); | ||
| 906 | - m.put("formal", b.getFormalPerson()!=null?df.format(b.getFormalPerson()):""); | ||
| 907 | - for(int i = 1; i <= 12; i++){ | ||
| 908 | - m.put("mon"+i, ""); | ||
| 909 | - m.put("bud"+i, ""); | ||
| 910 | - m.put("pre"+i, ""); | ||
| 911 | - } | ||
| 912 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 913 | - if(b.getFormalPerson()!=null){ | ||
| 914 | - m.put(bud, b.getFormalPerson()); | ||
| 915 | - } | ||
| 916 | - m.put("monAll", "0"); | ||
| 917 | - xlMap.put(key, m); | ||
| 918 | - xlList.add(m); | ||
| 919 | - } else { | ||
| 920 | - Map<String, Object> m = xlMap.get(key); | ||
| 921 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 922 | - if(b.getBudgetPerson()!=null){ | ||
| 923 | - if(m.get("budget").toString().length() > 0){ | ||
| 924 | - m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 925 | - new BigDecimal(b.getBudgetPerson())).doubleValue())); | ||
| 926 | - } else { | ||
| 927 | - m.put("budget", df.format(b.getBudgetPerson())); | ||
| 928 | - } | ||
| 929 | - } | ||
| 930 | - if(b.getChangePerson()!=null){ | ||
| 931 | - if(m.get("change").toString().length() > 0){ | ||
| 932 | - m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 933 | - new BigDecimal(b.getChangePerson())).doubleValue())); | ||
| 934 | - } else { | ||
| 935 | - m.put("change", df.format(b.getChangePerson())); | ||
| 936 | - } | ||
| 937 | - } | ||
| 938 | - if(b.getFormalPerson()!=null){ | ||
| 939 | - if(m.get("formal").toString().length() > 0){ | ||
| 940 | - m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 941 | - new BigDecimal(b.getFormalPerson())).doubleValue())); | ||
| 942 | - } else { | ||
| 943 | - m.put("formal", df.format(b.getFormalPerson())); | ||
| 944 | - } | ||
| 945 | - m.put(bud, df.format(b.getFormalPerson())); | ||
| 946 | - } | ||
| 947 | - } | ||
| 948 | - } | ||
| 949 | - | ||
| 950 | - for(Revenue cs : list){ | ||
| 951 | - String gsBm = cs.getGsBm(); | ||
| 952 | - String xlBm = cs.getXlBm(); | ||
| 953 | - String xlName = cs.getXlName(); | ||
| 954 | - int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 955 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 956 | - | ||
| 957 | - String key = gsBm + "_" + xlBm; | ||
| 958 | - if(!(xlMap.containsKey(key))){ | ||
| 959 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 960 | - m.put("gsBm", gsBm); | ||
| 961 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 962 | - m.put("xlBm", xlBm); | ||
| 963 | - m.put("xlName", xlName); | ||
| 964 | - m.put("sfyy", sfyy); | ||
| 965 | - m.put("sfjc", sfjc); | ||
| 966 | - m.put("budget", ""); | ||
| 967 | - m.put("change", ""); | ||
| 968 | - m.put("formal", ""); | ||
| 969 | - for(int i = 1; i <= 12; i++){ | ||
| 970 | - m.put("mon"+i, ""); | ||
| 971 | - m.put("bud"+i, ""); | ||
| 972 | - m.put("pre"+i, ""); | ||
| 973 | - } | ||
| 974 | - m.put("monAll", "0"); | ||
| 975 | - xlMap.put(key, m); | ||
| 976 | - xlList.add(m); | ||
| 977 | - } | ||
| 978 | - Map<String, Object> map = xlMap.get(key); | ||
| 979 | - String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 980 | - String val = map.get(mon).toString(); | ||
| 981 | - BigDecimal num = new BigDecimal(cs.getNum().toString()); | ||
| 982 | - if(val.length() == 0){ | ||
| 983 | - map.put(mon, num.doubleValue()); | ||
| 984 | - } else { | ||
| 985 | - map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 986 | - } | ||
| 987 | - } | ||
| 988 | - | ||
| 989 | - for(Revenue cs1 : revenueList_1){ // 去年人次与营收 | ||
| 990 | - String gsBm = cs1.getGsBm(); | ||
| 991 | - String xlBm = cs1.getXlBm(); | ||
| 992 | - String xlName = cs1.getXlName(); | ||
| 993 | - int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 994 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 995 | - | ||
| 996 | - { // 去年人次 | ||
| 997 | - String key = gsBm + "_" + xlBm; | ||
| 998 | - if(!(xlMap.containsKey(key))){ | ||
| 999 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1000 | - m.put("gsBm", gsBm); | ||
| 1001 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 1002 | - m.put("xlBm", xlBm); | ||
| 1003 | - m.put("xlName", xlName); | ||
| 1004 | - m.put("sfyy", sfyy); | ||
| 1005 | - m.put("sfjc", sfjc); | ||
| 1006 | - m.put("budget", ""); | ||
| 1007 | - m.put("change", ""); | ||
| 1008 | - m.put("formal", ""); | ||
| 1009 | - for(int i = 1; i <= 12; i++){ | ||
| 1010 | - m.put("mon"+i, ""); | ||
| 1011 | - m.put("bud"+i, ""); | ||
| 1012 | - m.put("pre"+i, ""); | ||
| 1013 | - } | ||
| 1014 | - m.put("monAll", "0"); | ||
| 1015 | - xlMap.put(key, m); | ||
| 1016 | - xlList.add(m); | ||
| 1017 | - } | ||
| 1018 | - Map<String, Object> map = xlMap.get(key); | ||
| 1019 | - String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 1020 | - String val = map.get(pre).toString(); | ||
| 1021 | - BigDecimal num = new BigDecimal(cs1.getNum().toString()); | ||
| 1022 | - if(val.length() == 0){ | ||
| 1023 | - map.put(pre, num.doubleValue()); | ||
| 1024 | - } else { | ||
| 1025 | - map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 1026 | - } | ||
| 1027 | - } | ||
| 1028 | - } | ||
| 1029 | - | ||
| 1030 | - for(Map<String, Object> m : xlList){ | ||
| 1031 | - String gsBm = m.get("gsBm").toString(); | ||
| 1032 | - int type = Integer.valueOf(m.get("sfyy").toString()); | ||
| 1033 | - int item = Integer.valueOf(m.get("sfjc").toString()) == 1 ? 0 : 1; | ||
| 1034 | - List<String> strList = new ArrayList<String>(); | ||
| 1035 | - if(1 == type){ | ||
| 1036 | - strList.add(gsBm + "_" + type + "_" + item); | ||
| 1037 | - strList.add(gsBm + "_" + type + "_all"); | ||
| 1038 | - } else { | ||
| 1039 | - strList.add(gsBm + "_" + type); | ||
| 1040 | - } | ||
| 1041 | - strList.add(gsBm + "_all"); | ||
| 1042 | - | ||
| 1043 | - for(String str : strList){ | ||
| 1044 | - if(!keyMap.containsKey(str)){ | ||
| 1045 | - continue; | ||
| 1046 | - } | ||
| 1047 | - Map<String, Object> map = keyMap.get(str); | ||
| 1048 | - if(m.get("budget").toString().length() > 0){ | ||
| 1049 | - if(map.get("budget").toString().length() > 0){ | ||
| 1050 | - map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 1051 | - new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 1052 | - } else { | ||
| 1053 | - map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 1054 | - } | ||
| 1055 | - } | ||
| 1056 | - if(m.get("change").toString().length() > 0){ | ||
| 1057 | - if(map.get("change").toString().length() > 0){ | ||
| 1058 | - map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 1059 | - new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 1060 | - } else { | ||
| 1061 | - map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 1062 | - } | ||
| 1063 | - } | ||
| 1064 | - if(m.get("formal").toString().length() > 0){ | ||
| 1065 | - if(map.get("formal").toString().length() > 0){ | ||
| 1066 | - map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 1067 | - new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 1068 | - } else { | ||
| 1069 | - map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 1070 | - } | ||
| 1071 | - } | ||
| 1072 | - for(int i = 1; i <= 12; i++){ | ||
| 1073 | - String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 1074 | - if(m.get(mon).toString().length() > 0){ | ||
| 1075 | - if(map.get(mon).toString().length() > 0){ | ||
| 1076 | - map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 1077 | - new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 1078 | - } else { | ||
| 1079 | - map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 1080 | - } | ||
| 1081 | - } | ||
| 1082 | - if(m.get(bud).toString().length() > 0){ | ||
| 1083 | - if(map.get(bud).toString().length() > 0){ | ||
| 1084 | - map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 1085 | - new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 1086 | - } else { | ||
| 1087 | - map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 1088 | - } | ||
| 1089 | - } | ||
| 1090 | - if(m.get(pre).toString().length() > 0){ | ||
| 1091 | - if(map.get(pre).toString().length() > 0){ | ||
| 1092 | - map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 1093 | - new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 1094 | - } else { | ||
| 1095 | - map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 1096 | - } | ||
| 1097 | - } | ||
| 1098 | - } | ||
| 1099 | - List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1100 | - dataList.add(m); | ||
| 1101 | - } | ||
| 1102 | - | ||
| 1103 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 1104 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 1105 | - for(int i = 1; i <= 12; i++){ | ||
| 1106 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1107 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1108 | - monAll = monAll.add(val); | ||
| 1109 | - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1110 | - m.put("mon"+i, val.doubleValue()); | ||
| 1111 | - } | ||
| 1112 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 1113 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1114 | - preAll = preAll.add(val); | ||
| 1115 | - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1116 | - m.put("pre"+i, val.doubleValue()); | ||
| 1117 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1118 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1119 | - BigDecimal sub = monVal.subtract(val); | ||
| 1120 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1121 | - } else { | ||
| 1122 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1123 | - } | ||
| 1124 | - } | ||
| 1125 | - } | ||
| 1126 | - monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1127 | - preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1128 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1129 | - m.put("monAll", monAll.doubleValue()); | ||
| 1130 | - m.put("preAll", preAll.doubleValue()); | ||
| 1131 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1132 | - | ||
| 1133 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1134 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1135 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1136 | - m.put("complete", monAll.divide( | ||
| 1137 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1138 | - new BigDecimal(100)).divide( | ||
| 1139 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1140 | - BigDecimal diff = monAll.subtract(formal); | ||
| 1141 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1142 | - } else { | ||
| 1143 | - m.put("complete", ""); | ||
| 1144 | - m.put("diff", ""); | ||
| 1145 | - } | ||
| 1146 | - } | ||
| 1147 | - | ||
| 1148 | - for(String key : strs){ | ||
| 1149 | - if(!(key.contains("all_"))){ | ||
| 1150 | - String[] sp = key.split("_"); | ||
| 1151 | - String allKey = "all"; | ||
| 1152 | - for(int i = 1; i < sp.length; i++){ | ||
| 1153 | - allKey += "_" + sp[i]; | ||
| 1154 | - } | ||
| 1155 | - Map<String, Object> map = keyMap.get(key); | ||
| 1156 | - Map<String, Object> allMap = keyMap.get(allKey); | ||
| 1157 | - for(String k : map.keySet()){ | ||
| 1158 | - if("year".equals(k)){ // 不想被计算的数字型字段 | ||
| 1159 | - continue; | ||
| 1160 | - } | ||
| 1161 | - try { | ||
| 1162 | - allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 1163 | - new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 1164 | - } catch (Exception e) { | ||
| 1165 | - // TODO: handle exception | ||
| 1166 | - } | ||
| 1167 | - } | ||
| 1168 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 1169 | - dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 1170 | - allMap.put("dataList", dataList); | ||
| 1171 | - | ||
| 1172 | - for(Map<String, Object> m : dataList){ | ||
| 1173 | - for(int i = 1; i <= 12; i++){ | ||
| 1174 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 1175 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1176 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1177 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1178 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1179 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1180 | - } else { | ||
| 1181 | - m.put("com" + i, ""); | ||
| 1182 | - } | ||
| 1183 | - } | ||
| 1184 | - } | ||
| 1185 | - } | ||
| 1186 | - } | ||
| 1187 | - | ||
| 1188 | - for(String key : strs){ | ||
| 1189 | - Map<String, Object> m = keyMap.get(key); | ||
| 1190 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 1191 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 1192 | - for(int i = 1; i <= 12; i++){ | ||
| 1193 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1194 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1195 | - monAll = monAll.add(val); | ||
| 1196 | - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1197 | - m.put("mon"+i, val.doubleValue()); | ||
| 1198 | - } | ||
| 1199 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 1200 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1201 | - preAll = preAll.add(val); | ||
| 1202 | - val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1203 | - m.put("pre"+i, val.doubleValue()); | ||
| 1204 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1205 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1206 | - BigDecimal sub = monVal.subtract(val); | ||
| 1207 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1208 | - } else { | ||
| 1209 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1210 | - } | ||
| 1211 | - } | ||
| 1212 | - } | ||
| 1213 | - monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1214 | - preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1215 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1216 | - m.put("monAll", monAll.doubleValue()); | ||
| 1217 | - m.put("preAll", preAll.doubleValue()); | ||
| 1218 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1219 | - | ||
| 1220 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1221 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1222 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1223 | - m.put("complete", monAll.divide( | ||
| 1224 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1225 | - new BigDecimal(100)).divide( | ||
| 1226 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1227 | - BigDecimal diff = monAll.subtract(formal); | ||
| 1228 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1229 | - } else { | ||
| 1230 | - m.put("complete", ""); | ||
| 1231 | - m.put("diff", ""); | ||
| 1232 | - } | ||
| 1233 | - m.put("year", year); | ||
| 1234 | - | ||
| 1235 | - for(int i = 1; i <= 12; i++){ | ||
| 1236 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 1237 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1238 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1239 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1240 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1241 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1242 | - } else { | ||
| 1243 | - m.put("com" + i, ""); | ||
| 1244 | - } | ||
| 1245 | - } | ||
| 1246 | - } | ||
| 1247 | - | ||
| 1248 | - if(tttt.equals("export")){ | ||
| 1249 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1250 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1251 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1252 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1253 | - String xls="budgetPerson.xls"; | ||
| 1254 | - ReportUtils ee = new ReportUtils(); | ||
| 1255 | - try { | ||
| 1256 | - String dateTime = ""; | ||
| 1257 | - m.put("date", year); | ||
| 1258 | - dateTime = year; | ||
| 1259 | - listI.add(resList.iterator()); | ||
| 1260 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1261 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 1262 | - path + "export/"+dateTime+"-预算人次明细表.xls"); | ||
| 1263 | - } catch (Exception e) { | ||
| 1264 | - // TODO: handle exception | ||
| 1265 | - e.printStackTrace(); | ||
| 1266 | - } | ||
| 1267 | - } | ||
| 1268 | - | ||
| 1269 | - if(tttt.equals("exportData")){ | ||
| 1270 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1271 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1272 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1273 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1274 | - m.put("date", year); | ||
| 1275 | - ReportUtils ee = new ReportUtils(); | ||
| 1276 | - try { | ||
| 1277 | - for(Map<String, Object> map : resList){ | ||
| 1278 | - if(kkk.equals(map.get("key").toString())){ | ||
| 1279 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1280 | - listI.add(dataList.iterator()); | ||
| 1281 | - } | ||
| 1282 | - } | ||
| 1283 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1284 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetPerson_data.xls", | ||
| 1285 | - path + "export/" + year + "-预算人次明细表-线路明细.xls"); | ||
| 1286 | - } catch (Exception e) { | ||
| 1287 | - // TODO: handle exception | ||
| 1288 | - e.printStackTrace(); | ||
| 1289 | - logger.info("", e); | ||
| 1290 | - } | ||
| 1291 | - } | ||
| 1292 | - | ||
| 1293 | - return resList; | ||
| 1294 | - } | ||
| 1295 | - | ||
| 1296 | - @Override | ||
| 1297 | - public List<Map<String, Object>> budgetAmounts(String year, String tttt, String kkk) { | ||
| 1298 | - // TODO Auto-generated method stub | ||
| 1299 | - SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 1300 | - SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 1301 | - DecimalFormat df = new DecimalFormat("0.###"); | ||
| 1302 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 1303 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 1304 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 1305 | - List<Budget> findByYear = repository.findByYear(year); | ||
| 1306 | - List<Revenue> list = revenueRepository.findByDates(year+"-01-01", year+"-12-31"); | ||
| 1307 | - | ||
| 1308 | - String year_1 = ""; | ||
| 1309 | - try { | ||
| 1310 | - year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 1311 | - } catch (ParseException e) { | ||
| 1312 | - // TODO Auto-generated catch block | ||
| 1313 | - e.printStackTrace(); | ||
| 1314 | - } | ||
| 1315 | - List<CalcStatistics> scheduleList_1 = calcStatisticsRepository.selectByDateAndLineTj3(year_1+"-01-01", year_1+"-12-31"); | ||
| 1316 | - List<Revenue> revenueList_1 = revenueRepository.findByDates(year_1+"-01-01", year_1+"-12-31"); | ||
| 1317 | - | ||
| 1318 | - Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 1319 | - List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 1320 | - | ||
| 1321 | - String[] strs = createBudgetMap(resList, keyMap); | ||
| 1322 | - | ||
| 1323 | - for(Budget b : findByYear){ | ||
| 1324 | - if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 1325 | - continue; | ||
| 1326 | - } | ||
| 1327 | - if(b.getFormalAmounts()==null || b.getFormalAmounts() < 0d){ | ||
| 1328 | - continue; | ||
| 1329 | - } | ||
| 1330 | - String gsBm = b.getGsBm(); | ||
| 1331 | - String xlBm = b.getXlBm(); | ||
| 1332 | - String xlName = b.getXlName(); | ||
| 1333 | - int sfyy = b.getSfyy()?1:0; | ||
| 1334 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 1335 | - | ||
| 1336 | - String key = gsBm + "_" + xlBm; | ||
| 1337 | - if(!(xlMap.containsKey(key))){ | ||
| 1338 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1339 | - m.put("gsBm", gsBm); | ||
| 1340 | - m.put("gsName", b.getGsName()); | ||
| 1341 | - m.put("xlBm", xlBm); | ||
| 1342 | - m.put("xlName", xlName); | ||
| 1343 | - m.put("sfyy", sfyy); | ||
| 1344 | - m.put("sfjc", sfjc); | ||
| 1345 | - m.put("budget", b.getBudgetAmounts()!=null?df.format(b.getBudgetAmounts()):""); | ||
| 1346 | - m.put("change", b.getChangeAmounts()!=null?df.format(b.getChangeAmounts()):""); | ||
| 1347 | - m.put("formal", b.getFormalAmounts()!=null?df.format(b.getFormalAmounts()):""); | ||
| 1348 | - for(int i = 1; i <= 12; i++){ | ||
| 1349 | - m.put("mon"+i, ""); | ||
| 1350 | - m.put("bud"+i, ""); | ||
| 1351 | - m.put("pre"+i, ""); | ||
| 1352 | - } | ||
| 1353 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1354 | - if(b.getFormalAmounts()!=null){ | ||
| 1355 | - m.put(bud, b.getFormalAmounts()); | ||
| 1356 | - } | ||
| 1357 | - m.put("monAll", "0"); | ||
| 1358 | - m.put("num", "0"); | ||
| 1359 | - xlMap.put(key, m); | ||
| 1360 | - xlList.add(m); | ||
| 1361 | - } else { | ||
| 1362 | - Map<String, Object> m = xlMap.get(key); | ||
| 1363 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1364 | - if(b.getBudgetAmounts()!=null){ | ||
| 1365 | - if(m.get("budget").toString().length() > 0){ | ||
| 1366 | - m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1367 | - new BigDecimal(b.getBudgetAmounts())).doubleValue())); | ||
| 1368 | - } else { | ||
| 1369 | - m.put("budget", df.format(b.getBudgetAmounts())); | ||
| 1370 | - } | ||
| 1371 | - } | ||
| 1372 | - if(b.getChangeAmounts()!=null){ | ||
| 1373 | - if(m.get("change").toString().length() > 0){ | ||
| 1374 | - m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1375 | - new BigDecimal(b.getChangeAmounts())).doubleValue())); | ||
| 1376 | - } else { | ||
| 1377 | - m.put("change", df.format(b.getChangeAmounts())); | ||
| 1378 | - } | ||
| 1379 | - } | ||
| 1380 | - if(b.getFormalAmounts()!=null){ | ||
| 1381 | - if(m.get("formal").toString().length() > 0){ | ||
| 1382 | - m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1383 | - new BigDecimal(b.getFormalAmounts())).doubleValue())); | ||
| 1384 | - } else { | ||
| 1385 | - m.put("formal", df.format(b.getFormalAmounts())); | ||
| 1386 | - } | ||
| 1387 | - m.put(bud, df.format(b.getFormalAmounts())); | ||
| 1388 | - } | ||
| 1389 | - } | ||
| 1390 | - } | ||
| 1391 | - | ||
| 1392 | - for(Revenue cs : list){ | ||
| 1393 | - String gsBm = cs.getGsBm(); | ||
| 1394 | - String xlBm = cs.getXlBm(); | ||
| 1395 | - String xlName = cs.getXlName(); | ||
| 1396 | - int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 1397 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 1398 | - | ||
| 1399 | - String key = gsBm + "_" + xlBm; | ||
| 1400 | - if(!(xlMap.containsKey(key))){ | ||
| 1401 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1402 | - m.put("gsBm", gsBm); | ||
| 1403 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 1404 | - m.put("xlBm", xlBm); | ||
| 1405 | - m.put("xlName", xlName); | ||
| 1406 | - m.put("sfyy", sfyy); | ||
| 1407 | - m.put("sfjc", sfjc); | ||
| 1408 | - m.put("budget", ""); | ||
| 1409 | - m.put("change", ""); | ||
| 1410 | - m.put("formal", ""); | ||
| 1411 | - for(int i = 1; i <= 12; i++){ | ||
| 1412 | - m.put("mon"+i, ""); | ||
| 1413 | - m.put("bud"+i, ""); | ||
| 1414 | - m.put("pre"+i, ""); | ||
| 1415 | - } | ||
| 1416 | - m.put("monAll", "0"); | ||
| 1417 | - m.put("num", "0"); | ||
| 1418 | - xlMap.put(key, m); | ||
| 1419 | - xlList.add(m); | ||
| 1420 | - } | ||
| 1421 | - Map<String, Object> map = xlMap.get(key); | ||
| 1422 | - String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 1423 | - String val = map.get(mon).toString(); | ||
| 1424 | - BigDecimal amount = new BigDecimal(cs.getAmount().toString()); | ||
| 1425 | - if(val.length() == 0){ | ||
| 1426 | - map.put(mon, amount.doubleValue()); | ||
| 1427 | - } else { | ||
| 1428 | - map.put(mon, new BigDecimal(val).add(amount).doubleValue()); | ||
| 1429 | - } | ||
| 1430 | - | ||
| 1431 | - BigDecimal num = new BigDecimal(cs.getNum().toString()); | ||
| 1432 | - if(map.containsKey("num")){ | ||
| 1433 | - map.put("num", new BigDecimal(map.get("num").toString()).add(num).doubleValue()); | ||
| 1434 | - } else { | ||
| 1435 | - map.put("num", num.doubleValue()); | ||
| 1436 | - } | ||
| 1437 | - } | ||
| 1438 | - | ||
| 1439 | - for(Revenue cs1 : revenueList_1){ // 去年人次与营收 | ||
| 1440 | - String gsBm = cs1.getGsBm(); | ||
| 1441 | - String xlBm = cs1.getXlBm(); | ||
| 1442 | - String xlName = cs1.getXlName(); | ||
| 1443 | - int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 1444 | - int sfjc = xlName.contains("机场")?1:0; | ||
| 1445 | - | ||
| 1446 | - { // 去年营收 | ||
| 1447 | - String key = gsBm + "_" + xlBm; | ||
| 1448 | - if(!(xlMap.containsKey(key))){ | ||
| 1449 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1450 | - m.put("gsBm", gsBm); | ||
| 1451 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 1452 | - m.put("xlBm", xlBm); | ||
| 1453 | - m.put("xlName", xlName); | ||
| 1454 | - m.put("sfyy", sfyy); | ||
| 1455 | - m.put("sfjc", sfjc); | ||
| 1456 | - m.put("budget", ""); | ||
| 1457 | - m.put("change", ""); | ||
| 1458 | - m.put("formal", ""); | ||
| 1459 | - for(int i = 1; i <= 12; i++){ | ||
| 1460 | - m.put("mon"+i, ""); | ||
| 1461 | - m.put("bud"+i, ""); | ||
| 1462 | - m.put("pre"+i, ""); | ||
| 1463 | - } | ||
| 1464 | - m.put("monAll", "0"); | ||
| 1465 | - xlMap.put(key, m); | ||
| 1466 | - xlList.add(m); | ||
| 1467 | - } | ||
| 1468 | - Map<String, Object> map = xlMap.get(key); | ||
| 1469 | - String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 1470 | - String val = map.get(pre).toString(); | ||
| 1471 | - BigDecimal num = new BigDecimal(cs1.getAmount().toString()); | ||
| 1472 | - if(val.length() == 0){ | ||
| 1473 | - map.put(pre, num.doubleValue()); | ||
| 1474 | - } else { | ||
| 1475 | - map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 1476 | - } | ||
| 1477 | - } | ||
| 1478 | - } | ||
| 1479 | - | ||
| 1480 | - for(Map<String, Object> m : xlList){ | ||
| 1481 | - String gsBm = m.get("gsBm").toString(); | ||
| 1482 | - int type = Integer.valueOf(m.get("sfyy").toString()); | ||
| 1483 | - int item = Integer.valueOf(m.get("sfjc").toString()) == 1 ? 0 : 1; | ||
| 1484 | - List<String> strList = new ArrayList<String>(); | ||
| 1485 | - if(1 == type){ | ||
| 1486 | - strList.add(gsBm + "_" + type + "_" + item); | ||
| 1487 | - strList.add(gsBm + "_" + type + "_all"); | ||
| 1488 | - } else { | ||
| 1489 | - strList.add(gsBm + "_" + type); | ||
| 1490 | - } | ||
| 1491 | - strList.add(gsBm + "_all"); | ||
| 1492 | - | ||
| 1493 | - for(String str : strList){ | ||
| 1494 | - if(!keyMap.containsKey(str)){ | ||
| 1495 | - continue; | ||
| 1496 | - } | ||
| 1497 | - Map<String, Object> map = keyMap.get(str); | ||
| 1498 | - if(m.get("budget").toString().length() > 0){ | ||
| 1499 | - if(map.get("budget").toString().length() > 0){ | ||
| 1500 | - map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 1501 | - new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 1502 | - } else { | ||
| 1503 | - map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 1504 | - } | ||
| 1505 | - } | ||
| 1506 | - if(m.get("change").toString().length() > 0){ | ||
| 1507 | - if(map.get("change").toString().length() > 0){ | ||
| 1508 | - map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 1509 | - new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 1510 | - } else { | ||
| 1511 | - map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 1512 | - } | ||
| 1513 | - } | ||
| 1514 | - if(m.get("formal").toString().length() > 0){ | ||
| 1515 | - if(map.get("formal").toString().length() > 0){ | ||
| 1516 | - map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 1517 | - new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 1518 | - } else { | ||
| 1519 | - map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 1520 | - } | ||
| 1521 | - } | ||
| 1522 | - for(int i = 1; i <= 12; i++){ | ||
| 1523 | - String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 1524 | - if(m.get(mon).toString().length() > 0){ | ||
| 1525 | - if(map.get(mon).toString().length() > 0){ | ||
| 1526 | - map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 1527 | - new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 1528 | - } else { | ||
| 1529 | - map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 1530 | - } | ||
| 1531 | - } | ||
| 1532 | - if(m.get(bud).toString().length() > 0){ | ||
| 1533 | - if(map.get(bud).toString().length() > 0){ | ||
| 1534 | - map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 1535 | - new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 1536 | - } else { | ||
| 1537 | - map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 1538 | - } | ||
| 1539 | - } | ||
| 1540 | - if(m.get(pre).toString().length() > 0){ | ||
| 1541 | - if(map.get(pre).toString().length() > 0){ | ||
| 1542 | - map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 1543 | - new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 1544 | - } else { | ||
| 1545 | - map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 1546 | - } | ||
| 1547 | - } | ||
| 1548 | - } | ||
| 1549 | - if(m.containsKey("num") && m.get("num").toString().length() > 0){ | ||
| 1550 | - if(map.containsKey("num") && map.get("num").toString().length() > 0){ | ||
| 1551 | - map.put("num", new BigDecimal(m.get("num").toString()).add( | ||
| 1552 | - new BigDecimal(map.get("num").toString())).doubleValue()); | ||
| 1553 | - } else { | ||
| 1554 | - map.put("num", new BigDecimal(m.get("num").toString()).doubleValue()); | ||
| 1555 | - } | ||
| 1556 | - } | ||
| 1557 | - List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1558 | - dataList.add(m); | ||
| 1559 | - } | ||
| 1560 | - | ||
| 1561 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 1562 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 1563 | - for(int i = 1; i <= 12; i++){ | ||
| 1564 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1565 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1566 | - monAll = monAll.add(val); | ||
| 1567 | - val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1568 | - m.put("mon"+i, val.doubleValue()); | ||
| 1569 | - } | ||
| 1570 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 1571 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1572 | - preAll = preAll.add(val); | ||
| 1573 | - val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1574 | - m.put("pre"+i, val.doubleValue()); | ||
| 1575 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1576 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1577 | - BigDecimal sub = monVal.subtract(val); | ||
| 1578 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1579 | - } else { | ||
| 1580 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1581 | - } | ||
| 1582 | - } | ||
| 1583 | - } | ||
| 1584 | - monAll = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1585 | - preAll = preAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1586 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1587 | - m.put("monAll", monAll.doubleValue()); | ||
| 1588 | - m.put("preAll", preAll.doubleValue()); | ||
| 1589 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1590 | - | ||
| 1591 | - if(m.containsKey("num") && m.get("num").toString().length() > 0 | ||
| 1592 | - && Double.valueOf(m.get("num").toString()) > 0){ | ||
| 1593 | - m.put("average", monAll.divide( | ||
| 1594 | - new BigDecimal(m.get("num").toString()).multiply(new BigDecimal("100")), | ||
| 1595 | - 2, BigDecimal.ROUND_HALF_UP).doubleValue()); | ||
| 1596 | - } else { | ||
| 1597 | - m.put("average", ""); | ||
| 1598 | - } | ||
| 1599 | - | ||
| 1600 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1601 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1602 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1603 | - m.put("complete", monAll.divide( | ||
| 1604 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1605 | - new BigDecimal(100)).divide( | ||
| 1606 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1607 | - BigDecimal diff = monAll.subtract(formal); | ||
| 1608 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1609 | - } else { | ||
| 1610 | - m.put("complete", ""); | ||
| 1611 | - m.put("diff", ""); | ||
| 1612 | - } | ||
| 1613 | - } | ||
| 1614 | - | ||
| 1615 | - for(String key : strs){ | ||
| 1616 | - if(!(key.contains("all_"))){ | ||
| 1617 | - String[] sp = key.split("_"); | ||
| 1618 | - String allKey = "all"; | ||
| 1619 | - for(int i = 1; i < sp.length; i++){ | ||
| 1620 | - allKey += "_" + sp[i]; | ||
| 1621 | - } | ||
| 1622 | - Map<String, Object> map = keyMap.get(key); | ||
| 1623 | - Map<String, Object> allMap = keyMap.get(allKey); | ||
| 1624 | - for(String k : map.keySet()){ | ||
| 1625 | - if("year".equals(k) || "num".equals(k)){ // 不想被计算的数字型字段 | ||
| 1626 | - continue; | ||
| 1627 | - } | ||
| 1628 | - try { | ||
| 1629 | - allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 1630 | - new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 1631 | - } catch (Exception e) { | ||
| 1632 | - // TODO: handle exception | ||
| 1633 | - } | ||
| 1634 | - } | ||
| 1635 | - if(map.containsKey("num") && map.get("num").toString().length() > 0){ | ||
| 1636 | - if(allMap.containsKey("num") && allMap.get("num").toString().length() > 0){ | ||
| 1637 | - allMap.put("num", new BigDecimal(map.get("num").toString()).add( | ||
| 1638 | - new BigDecimal(allMap.get("num").toString())).doubleValue()); | ||
| 1639 | - } else { | ||
| 1640 | - allMap.put("num", new BigDecimal(map.get("num").toString()).doubleValue()); | ||
| 1641 | - } | ||
| 1642 | - } | ||
| 1643 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 1644 | - dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 1645 | - allMap.put("dataList", dataList); | ||
| 1646 | - | ||
| 1647 | - for(Map<String, Object> m : dataList){ | ||
| 1648 | - for(int i = 1; i <= 12; i++){ | ||
| 1649 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 1650 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1651 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1652 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1653 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1654 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1655 | - } else { | ||
| 1656 | - m.put("com" + i, ""); | ||
| 1657 | - } | ||
| 1658 | - } | ||
| 1659 | - } | ||
| 1660 | - } | ||
| 1661 | - } | ||
| 1662 | - | ||
| 1663 | - for(String key : strs){ | ||
| 1664 | - Map<String, Object> m = keyMap.get(key); | ||
| 1665 | - | ||
| 1666 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 1667 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 1668 | - for(int i = 1; i <= 12; i++){ | ||
| 1669 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1670 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1671 | - monAll = monAll.add(val); | ||
| 1672 | - val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1673 | - m.put("mon"+i, val.doubleValue()); | ||
| 1674 | - } | ||
| 1675 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 1676 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1677 | - preAll = preAll.add(val); | ||
| 1678 | - val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1679 | - m.put("pre"+i, val.doubleValue()); | ||
| 1680 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 1681 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1682 | - BigDecimal sub = monVal.subtract(val); | ||
| 1683 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1684 | - } else { | ||
| 1685 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1686 | - } | ||
| 1687 | - } | ||
| 1688 | - } | ||
| 1689 | - monAll = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1690 | - preAll = preAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1691 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1692 | - m.put("monAll", monAll.doubleValue()); | ||
| 1693 | - m.put("preAll", preAll.doubleValue()); | ||
| 1694 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1695 | - | ||
| 1696 | - if(m.containsKey("num") && m.get("num").toString().length() > 0 | ||
| 1697 | - && Double.valueOf(m.get("num").toString()) > 0){ | ||
| 1698 | - m.put("average", monAll.divide( | ||
| 1699 | - new BigDecimal(m.get("num").toString()).multiply(new BigDecimal("100")), | ||
| 1700 | - 2, BigDecimal.ROUND_HALF_UP).doubleValue()); | ||
| 1701 | - } else { | ||
| 1702 | - m.put("average", ""); | ||
| 1703 | - } | ||
| 1704 | - | ||
| 1705 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1706 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1707 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1708 | - m.put("complete", monAll.divide( | ||
| 1709 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1710 | - new BigDecimal(100)).divide( | ||
| 1711 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1712 | - BigDecimal diff = monAll.subtract(formal); | ||
| 1713 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1714 | - } else { | ||
| 1715 | - m.put("complete", ""); | ||
| 1716 | - m.put("diff", ""); | ||
| 1717 | - } | ||
| 1718 | - m.put("year", year); | ||
| 1719 | - | ||
| 1720 | - for(int i = 1; i <= 12; i++){ | ||
| 1721 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 1722 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1723 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1724 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1725 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1726 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1727 | - } else { | ||
| 1728 | - m.put("com" + i, ""); | ||
| 1729 | - } | ||
| 1730 | - } | ||
| 1731 | - } | ||
| 1732 | - | ||
| 1733 | - if(tttt.equals("export")){ | ||
| 1734 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1735 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1736 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1737 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1738 | - String xls="budgetAmounts.xls"; | ||
| 1739 | - ReportUtils ee = new ReportUtils(); | ||
| 1740 | - try { | ||
| 1741 | - String dateTime = ""; | ||
| 1742 | - m.put("date", year); | ||
| 1743 | - dateTime = year; | ||
| 1744 | - listI.add(resList.iterator()); | ||
| 1745 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1746 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 1747 | - path + "export/"+dateTime+"-预算营收明细表.xls"); | ||
| 1748 | - } catch (Exception e) { | ||
| 1749 | - // TODO: handle exception | ||
| 1750 | - e.printStackTrace(); | ||
| 1751 | - } | ||
| 1752 | - } | ||
| 1753 | - | ||
| 1754 | - if(tttt.equals("exportData")){ | ||
| 1755 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1756 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1757 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1758 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1759 | - m.put("date", year); | ||
| 1760 | - ReportUtils ee = new ReportUtils(); | ||
| 1761 | - try { | ||
| 1762 | - for(Map<String, Object> map : resList){ | ||
| 1763 | - if(kkk.equals(map.get("key").toString())){ | ||
| 1764 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1765 | - listI.add(dataList.iterator()); | ||
| 1766 | - } | ||
| 1767 | - } | ||
| 1768 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1769 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetAmounts_data.xls", | ||
| 1770 | - path + "export/" + year + "-预算营收明细表-线路明细.xls"); | ||
| 1771 | - } catch (Exception e) { | ||
| 1772 | - // TODO: handle exception | ||
| 1773 | - e.printStackTrace(); | ||
| 1774 | - logger.info("", e); | ||
| 1775 | - } | ||
| 1776 | - } | ||
| 1777 | - | ||
| 1778 | - return resList; | ||
| 1779 | - } | ||
| 1780 | - | ||
| 1781 | - @Override | ||
| 1782 | - public List<Map<String, Object>> budgetSum(String year, String nature, String tttt, String kkk) { | ||
| 1783 | - // TODO Auto-generated method stub | ||
| 1784 | - SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 1785 | - SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 1786 | - DecimalFormat df = new DecimalFormat("0.###"); | ||
| 1787 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 1788 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 1789 | - List<Budget> findByYear = repository.findByYear(year); | ||
| 1790 | - List<CalcStatistics> scheduleList = calcStatisticsRepository.selectByDateAndLineTj3(year+"-01-01", year+"-12-31"); | ||
| 1791 | - List<Revenue> revenueList = revenueRepository.findByDates(year+"-01-01", year+"-12-31"); | ||
| 1792 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 1793 | - | ||
| 1794 | - String year_1 = ""; | ||
| 1795 | - try { | ||
| 1796 | - year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 1797 | - } catch (ParseException e) { | ||
| 1798 | - // TODO Auto-generated catch block | ||
| 1799 | - e.printStackTrace(); | ||
| 1800 | - } | ||
| 1801 | - List<CalcStatistics> scheduleList_1 = calcStatisticsRepository.selectByDateAndLineTj3(year_1+"-01-01", year_1+"-12-31"); | ||
| 1802 | - List<Revenue> revenueList_1 = revenueRepository.findByDates(year_1+"-01-01", year_1+"-12-31"); | ||
| 1803 | - | ||
| 1804 | - Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 1805 | - List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 1806 | - | ||
| 1807 | - String[] strs = createBudgetMap_sum(resList, keyMap); | ||
| 1808 | - | ||
| 1809 | - for(Budget b : findByYear){ | ||
| 1810 | - if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 1811 | - continue; | ||
| 1812 | - } | ||
| 1813 | - Boolean flag = true; | ||
| 1814 | - if("0".equals(nature)){ | ||
| 1815 | - flag = false; | ||
| 1816 | - } else if("1".equals(nature) && b.getSfyy()){ | ||
| 1817 | - flag = false; | ||
| 1818 | - } else if("2".equals(nature) && !(b.getSfyy())){ | ||
| 1819 | - flag = false; | ||
| 1820 | - } | ||
| 1821 | - if(flag){ | ||
| 1822 | - continue; | ||
| 1823 | - } | ||
| 1824 | - String gsBm = b.getGsBm(); | ||
| 1825 | - String xlBm = b.getXlBm(); | ||
| 1826 | - String xlName = b.getXlName(); | ||
| 1827 | - String key = gsBm + "_" + xlBm; | ||
| 1828 | - if(b.getFormalMileage()!=null && b.getFormalMileage() >= 0d){ | ||
| 1829 | - String key1 = key + "_1"; | ||
| 1830 | - if(!(xlMap.containsKey(key1))){ | ||
| 1831 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1832 | - m.put("gsBm", gsBm); | ||
| 1833 | - m.put("gsName", b.getGsName()); | ||
| 1834 | - m.put("xlBm", xlBm); | ||
| 1835 | - m.put("xlName", xlName); | ||
| 1836 | - m.put("type", "公里"); | ||
| 1837 | - m.put("budget", b.getBudgetMileage()!=null?df.format(b.getBudgetMileage()):""); | ||
| 1838 | - m.put("change", b.getChangeMileage()!=null?df.format(b.getChangeMileage()):""); | ||
| 1839 | - m.put("formal", b.getFormalMileage()!=null?df.format(b.getFormalMileage()):""); | ||
| 1840 | - for(int i = 1; i <= 12; i++){ | ||
| 1841 | - m.put("mon"+i, ""); | ||
| 1842 | - m.put("bud"+i, ""); | ||
| 1843 | - m.put("pre"+i, ""); | ||
| 1844 | - } | ||
| 1845 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1846 | - if(b.getFormalMileage()!=null){ | ||
| 1847 | - m.put(bud, df.format(b.getFormalMileage())); | ||
| 1848 | - } | ||
| 1849 | - m.put("monAll", "0"); | ||
| 1850 | - xlMap.put(key1, m); | ||
| 1851 | - xlList.add(m); | ||
| 1852 | - } else { | ||
| 1853 | - Map<String, Object> m = xlMap.get(key1); | ||
| 1854 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1855 | - if(b.getBudgetMileage()!=null){ | ||
| 1856 | - if(m.get("budget").toString().length() > 0){ | ||
| 1857 | - m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1858 | - new BigDecimal(b.getBudgetMileage())).doubleValue())); | ||
| 1859 | - } else { | ||
| 1860 | - m.put("budget", df.format(b.getBudgetMileage())); | ||
| 1861 | - } | ||
| 1862 | - } | ||
| 1863 | - if(b.getChangeMileage()!=null){ | ||
| 1864 | - if(m.get("change").toString().length() > 0){ | ||
| 1865 | - m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1866 | - new BigDecimal(b.getChangeMileage())).doubleValue())); | ||
| 1867 | - } else { | ||
| 1868 | - m.put("change", df.format(b.getChangeMileage())); | ||
| 1869 | - } | ||
| 1870 | - } | ||
| 1871 | - if(b.getFormalMileage()!=null){ | ||
| 1872 | - if(m.get("formal").toString().length() > 0){ | ||
| 1873 | - m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1874 | - new BigDecimal(b.getFormalMileage())).doubleValue())); | ||
| 1875 | - } else { | ||
| 1876 | - m.put("formal", df.format(b.getFormalMileage())); | ||
| 1877 | - } | ||
| 1878 | - m.put(bud, df.format(b.getFormalMileage())); | ||
| 1879 | - } | ||
| 1880 | - } | ||
| 1881 | - } | ||
| 1882 | - if(b.getFormalPerson()!=null && b.getFormalPerson() >= 0d){ | ||
| 1883 | - String key2 = key + "_2"; | ||
| 1884 | - if(!(xlMap.containsKey(key2))){ | ||
| 1885 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1886 | - m.put("gsBm", gsBm); | ||
| 1887 | - m.put("gsName", b.getGsName()); | ||
| 1888 | - m.put("xlBm", xlBm); | ||
| 1889 | - m.put("xlName", xlName); | ||
| 1890 | - m.put("type", "人次"); | ||
| 1891 | - m.put("budget", b.getBudgetPerson()!=null?df.format(b.getBudgetPerson()):""); | ||
| 1892 | - m.put("change", b.getChangePerson()!=null?df.format(b.getChangePerson()):""); | ||
| 1893 | - m.put("formal", b.getFormalPerson()!=null?df.format(b.getFormalPerson()):""); | ||
| 1894 | - for(int i = 1; i <= 12; i++){ | ||
| 1895 | - m.put("mon"+i, ""); | ||
| 1896 | - m.put("bud"+i, ""); | ||
| 1897 | - m.put("pre"+i, ""); | ||
| 1898 | - } | ||
| 1899 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1900 | - if(b.getFormalPerson()!=null){ | ||
| 1901 | - m.put(bud, df.format(b.getFormalPerson())); | ||
| 1902 | - } | ||
| 1903 | - m.put("monAll", "0"); | ||
| 1904 | - xlMap.put(key2, m); | ||
| 1905 | - xlList.add(m); | ||
| 1906 | - } else { | ||
| 1907 | - Map<String, Object> m = xlMap.get(key2); | ||
| 1908 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1909 | - if(b.getBudgetPerson()!=null){ | ||
| 1910 | - if(m.get("budget").toString().length() > 0){ | ||
| 1911 | - m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1912 | - new BigDecimal(b.getBudgetPerson())).doubleValue())); | ||
| 1913 | - } else { | ||
| 1914 | - m.put("budget", df.format(b.getBudgetPerson())); | ||
| 1915 | - } | ||
| 1916 | - } | ||
| 1917 | - if(b.getChangePerson()!=null){ | ||
| 1918 | - if(m.get("change").toString().length() > 0){ | ||
| 1919 | - m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1920 | - new BigDecimal(b.getChangePerson())).doubleValue())); | ||
| 1921 | - } else { | ||
| 1922 | - m.put("change", df.format(b.getChangePerson())); | ||
| 1923 | - } | ||
| 1924 | - } | ||
| 1925 | - if(b.getFormalPerson()!=null){ | ||
| 1926 | - if(m.get("formal").toString().length() > 0){ | ||
| 1927 | - m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1928 | - new BigDecimal(b.getFormalPerson())).doubleValue())); | ||
| 1929 | - } else { | ||
| 1930 | - m.put("formal", df.format(b.getFormalPerson())); | ||
| 1931 | - } | ||
| 1932 | - m.put(bud, df.format(b.getFormalPerson())); | ||
| 1933 | - } | ||
| 1934 | - } | ||
| 1935 | - } | ||
| 1936 | - if(b.getFormalAmounts()!=null && b.getFormalAmounts() >= 0d){ | ||
| 1937 | - String key3 = key + "_3"; | ||
| 1938 | - if(!(xlMap.containsKey(key3))){ | ||
| 1939 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1940 | - m.put("gsBm", gsBm); | ||
| 1941 | - m.put("gsName", b.getGsName()); | ||
| 1942 | - m.put("xlBm", xlBm); | ||
| 1943 | - m.put("xlName", xlName); | ||
| 1944 | - m.put("type", "营收"); | ||
| 1945 | - m.put("budget", b.getBudgetAmounts()!=null?df.format(b.getBudgetAmounts()):""); | ||
| 1946 | - m.put("change", b.getChangeAmounts()!=null?df.format(b.getChangeAmounts()):""); | ||
| 1947 | - m.put("formal", b.getFormalAmounts()!=null?df.format(b.getFormalAmounts()):""); | ||
| 1948 | - for(int i = 1; i <= 12; i++){ | ||
| 1949 | - m.put("mon"+i, ""); | ||
| 1950 | - m.put("bud"+i, ""); | ||
| 1951 | - m.put("pre"+i, ""); | ||
| 1952 | - } | ||
| 1953 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1954 | - if(b.getFormalAmounts()!=null){ | ||
| 1955 | - m.put(bud, df.format(b.getFormalAmounts())); | ||
| 1956 | - } | ||
| 1957 | - m.put("monAll", "0"); | ||
| 1958 | - xlMap.put(key3, m); | ||
| 1959 | - xlList.add(m); | ||
| 1960 | - } else { | ||
| 1961 | - Map<String, Object> m = xlMap.get(key3); | ||
| 1962 | - String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1963 | - if(b.getBudgetAmounts()!=null){ | ||
| 1964 | - if(m.get("budget").toString().length() > 0){ | ||
| 1965 | - m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1966 | - new BigDecimal(b.getBudgetAmounts())).doubleValue())); | ||
| 1967 | - } else { | ||
| 1968 | - m.put("budget", df.format(b.getBudgetAmounts())); | ||
| 1969 | - } | ||
| 1970 | - } | ||
| 1971 | - if(b.getChangeAmounts()!=null){ | ||
| 1972 | - if(m.get("change").toString().length() > 0){ | ||
| 1973 | - m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1974 | - new BigDecimal(b.getChangeAmounts())).doubleValue())); | ||
| 1975 | - } else { | ||
| 1976 | - m.put("change", df.format(b.getChangeAmounts())); | ||
| 1977 | - } | ||
| 1978 | - } | ||
| 1979 | - if(b.getFormalAmounts()!=null){ | ||
| 1980 | - if(m.get("formal").toString().length() > 0){ | ||
| 1981 | - m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1982 | - new BigDecimal(b.getFormalAmounts())).doubleValue())); | ||
| 1983 | - } else { | ||
| 1984 | - m.put("formal", df.format(b.getFormalAmounts())); | ||
| 1985 | - } | ||
| 1986 | - m.put(bud, df.format(b.getFormalAmounts())); | ||
| 1987 | - } | ||
| 1988 | - } | ||
| 1989 | - } | ||
| 1990 | - } | ||
| 1991 | - | ||
| 1992 | - for(CalcStatistics cs : scheduleList){ // 公里 | ||
| 1993 | - Boolean flag = true; | ||
| 1994 | - if("0".equals(nature)){ | ||
| 1995 | - flag = false; | ||
| 1996 | - } else if("1".equals(nature) && lineNature.containsKey(cs.getXl()) && lineNature.get(cs.getXl())){ | ||
| 1997 | - flag = false; | ||
| 1998 | - } else if("2".equals(nature) && !(lineNature.containsKey(cs.getXl()) && lineNature.get(cs.getXl()))){ | ||
| 1999 | - flag = false; | ||
| 2000 | - } | ||
| 2001 | - if(flag){ | ||
| 2002 | - continue; | ||
| 2003 | - } | ||
| 2004 | - String gsBm = cs.getGsdm(); | ||
| 2005 | - String xlBm = cs.getXl(); | ||
| 2006 | - String xlName = cs.getXlName(); | ||
| 2007 | - | ||
| 2008 | - String key = gsBm + "_" + xlBm + "_1"; | ||
| 2009 | - if(!(xlMap.containsKey(key))){ | ||
| 2010 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2011 | - m.put("gsBm", gsBm); | ||
| 2012 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2013 | - m.put("xlBm", xlBm); | ||
| 2014 | - m.put("xlName", xlName); | ||
| 2015 | - m.put("type", "公里"); | ||
| 2016 | - m.put("budget", ""); | ||
| 2017 | - m.put("change", ""); | ||
| 2018 | - m.put("formal", ""); | ||
| 2019 | - for(int i = 1; i <= 12; i++){ | ||
| 2020 | - m.put("mon"+i, ""); | ||
| 2021 | - m.put("bud"+i, ""); | ||
| 2022 | - m.put("pre"+i, ""); | ||
| 2023 | - } | ||
| 2024 | - m.put("monAll", "0"); | ||
| 2025 | - xlMap.put(key, m); | ||
| 2026 | - xlList.add(m); | ||
| 2027 | - } | ||
| 2028 | - Map<String, Object> map = xlMap.get(key); | ||
| 2029 | - String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getDate())); | ||
| 2030 | - String val = map.get(mon).toString(); | ||
| 2031 | - BigDecimal num = new BigDecimal(cs.getSjzlc().toString()); | ||
| 2032 | - if(val.length() == 0){ | ||
| 2033 | - map.put(mon, num.doubleValue()); | ||
| 2034 | - } else { | ||
| 2035 | - map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 2036 | - } | ||
| 2037 | - } | ||
| 2038 | - | ||
| 2039 | - for(Revenue cs : revenueList){ // 人次与营收 | ||
| 2040 | - Boolean flag = true; | ||
| 2041 | - if("0".equals(nature)){ | ||
| 2042 | - flag = false; | ||
| 2043 | - } else if("1".equals(nature) && cs.getSfyy()){ | ||
| 2044 | - flag = false; | ||
| 2045 | - } else if("2".equals(nature) && !(cs.getSfyy())){ | ||
| 2046 | - flag = false; | ||
| 2047 | - } | ||
| 2048 | - if(flag){ | ||
| 2049 | - continue; | ||
| 2050 | - } | ||
| 2051 | - String gsBm = cs.getGsBm(); | ||
| 2052 | - String xlBm = cs.getXlBm(); | ||
| 2053 | - String xlName = cs.getXlName(); | ||
| 2054 | - | ||
| 2055 | - { // 人次 | ||
| 2056 | - String key2 = gsBm + "_" + xlBm + "_2"; | ||
| 2057 | - if(!(xlMap.containsKey(key2))){ | ||
| 2058 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2059 | - m.put("gsBm", gsBm); | ||
| 2060 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2061 | - m.put("xlBm", xlBm); | ||
| 2062 | - m.put("xlName", xlName); | ||
| 2063 | - m.put("type", "人次"); | ||
| 2064 | - m.put("budget", ""); | ||
| 2065 | - m.put("change", ""); | ||
| 2066 | - m.put("formal", ""); | ||
| 2067 | - for(int i = 1; i <= 12; i++){ | ||
| 2068 | - m.put("mon"+i, ""); | ||
| 2069 | - m.put("bud"+i, ""); | ||
| 2070 | - m.put("pre"+i, ""); | ||
| 2071 | - } | ||
| 2072 | - m.put("monAll", "0"); | ||
| 2073 | - xlMap.put(key2, m); | ||
| 2074 | - xlList.add(m); | ||
| 2075 | - } | ||
| 2076 | - Map<String, Object> map = xlMap.get(key2); | ||
| 2077 | - String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 2078 | - String val = map.get(mon).toString(); | ||
| 2079 | - BigDecimal num = new BigDecimal(cs.getNum().toString()); | ||
| 2080 | - if(val.length() == 0){ | ||
| 2081 | - map.put(mon, num.doubleValue()); | ||
| 2082 | - } else { | ||
| 2083 | - map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 2084 | - } | ||
| 2085 | - } | ||
| 2086 | - { // 营收 | ||
| 2087 | - String key3 = gsBm + "_" + xlBm + "_3"; | ||
| 2088 | - if(!(xlMap.containsKey(key3))){ | ||
| 2089 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2090 | - m.put("gsBm", gsBm); | ||
| 2091 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2092 | - m.put("xlBm", xlBm); | ||
| 2093 | - m.put("xlName", xlName); | ||
| 2094 | - m.put("type", "营收"); | ||
| 2095 | - m.put("budget", ""); | ||
| 2096 | - m.put("change", ""); | ||
| 2097 | - m.put("formal", ""); | ||
| 2098 | - for(int i = 1; i <= 12; i++){ | ||
| 2099 | - m.put("mon"+i, ""); | ||
| 2100 | - m.put("bud"+i, ""); | ||
| 2101 | - m.put("pre"+i, ""); | ||
| 2102 | - } | ||
| 2103 | - m.put("monAll", "0"); | ||
| 2104 | - xlMap.put(key3, m); | ||
| 2105 | - xlList.add(m); | ||
| 2106 | - } | ||
| 2107 | - Map<String, Object> map = xlMap.get(key3); | ||
| 2108 | - String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 2109 | - String val = map.get(mon).toString(); | ||
| 2110 | - BigDecimal num = new BigDecimal(cs.getAmount().toString()); | ||
| 2111 | - if(val.length() == 0){ | ||
| 2112 | - map.put(mon, num.doubleValue()); | ||
| 2113 | - } else { | ||
| 2114 | - map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 2115 | - } | ||
| 2116 | - } | ||
| 2117 | - } | ||
| 2118 | - | ||
| 2119 | - for(CalcStatistics cs1 : scheduleList_1){ // 去年公里 | ||
| 2120 | - Boolean flag = true; | ||
| 2121 | - if("0".equals(nature)){ | ||
| 2122 | - flag = false; | ||
| 2123 | - } else if("1".equals(nature) && lineNature.containsKey(cs1.getXl()) && lineNature.get(cs1.getXl())){ | ||
| 2124 | - flag = false; | ||
| 2125 | - } else if("2".equals(nature) && !(lineNature.containsKey(cs1.getXl()) && lineNature.get(cs1.getXl()))){ | ||
| 2126 | - flag = false; | ||
| 2127 | - } | ||
| 2128 | - if(flag){ | ||
| 2129 | - continue; | ||
| 2130 | - } | ||
| 2131 | - String gsdm = cs1.getGsdm(); | ||
| 2132 | - String xlBm = cs1.getXl(); | ||
| 2133 | - String xlName = cs1.getXlName(); | ||
| 2134 | - String key = gsdm + "_" + xlBm; | ||
| 2135 | - String key1 = key + "_1"; | ||
| 2136 | - if(!(xlMap.containsKey(key1))){ | ||
| 2137 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2138 | - m.put("gsBm", gsdm); | ||
| 2139 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsdm)); | ||
| 2140 | - m.put("xlBm", xlBm); | ||
| 2141 | - m.put("xlName", xlName); | ||
| 2142 | - m.put("type", "公里"); | ||
| 2143 | - m.put("budget", ""); | ||
| 2144 | - m.put("change", ""); | ||
| 2145 | - m.put("formal", ""); | ||
| 2146 | - for(int i = 1; i <= 12; i++){ | ||
| 2147 | - m.put("mon"+i, ""); | ||
| 2148 | - m.put("bud"+i, ""); | ||
| 2149 | - m.put("pre"+i, ""); | ||
| 2150 | - } | ||
| 2151 | - m.put("monAll", "0"); | ||
| 2152 | - xlMap.put(key1, m); | ||
| 2153 | - xlList.add(m); | ||
| 2154 | - } | ||
| 2155 | - Map<String, Object> map = xlMap.get(key1); | ||
| 2156 | - String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getDate())); | ||
| 2157 | - String val = map.get(pre).toString(); | ||
| 2158 | - BigDecimal num = new BigDecimal(cs1.getSjzlc().toString()); | ||
| 2159 | - if(val.length() == 0){ | ||
| 2160 | - map.put(pre, num.doubleValue()); | ||
| 2161 | - } else { | ||
| 2162 | - map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 2163 | - } | ||
| 2164 | - } | ||
| 2165 | - | ||
| 2166 | - for(Revenue cs1 : revenueList_1){ // 去年人次与营收 | ||
| 2167 | - Boolean flag = true; | ||
| 2168 | - if("0".equals(nature)){ | ||
| 2169 | - flag = false; | ||
| 2170 | - } else if("1".equals(nature) && cs1.getSfyy()){ | ||
| 2171 | - flag = false; | ||
| 2172 | - } else if("2".equals(nature) && !(cs1.getSfyy())){ | ||
| 2173 | - flag = false; | ||
| 2174 | - } | ||
| 2175 | - if(flag){ | ||
| 2176 | - continue; | ||
| 2177 | - } | ||
| 2178 | - String gsBm = cs1.getGsBm(); | ||
| 2179 | - String xlBm = cs1.getXlBm(); | ||
| 2180 | - String xlName = cs1.getXlName(); | ||
| 2181 | - | ||
| 2182 | - { // 去年人次 | ||
| 2183 | - String key2 = gsBm + "_" + xlBm + "_2"; | ||
| 2184 | - if(!(xlMap.containsKey(key2))){ | ||
| 2185 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2186 | - m.put("gsBm", gsBm); | ||
| 2187 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2188 | - m.put("xlBm", xlBm); | ||
| 2189 | - m.put("xlName", xlName); | ||
| 2190 | - m.put("type", "人次"); | ||
| 2191 | - m.put("budget", ""); | ||
| 2192 | - m.put("change", ""); | ||
| 2193 | - m.put("formal", ""); | ||
| 2194 | - for(int i = 1; i <= 12; i++){ | ||
| 2195 | - m.put("mon"+i, ""); | ||
| 2196 | - m.put("bud"+i, ""); | ||
| 2197 | - m.put("pre"+i, ""); | ||
| 2198 | - } | ||
| 2199 | - m.put("monAll", "0"); | ||
| 2200 | - xlMap.put(key2, m); | ||
| 2201 | - xlList.add(m); | ||
| 2202 | - } | ||
| 2203 | - Map<String, Object> map = xlMap.get(key2); | ||
| 2204 | - String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 2205 | - String val = map.get(pre).toString(); | ||
| 2206 | - BigDecimal num = new BigDecimal(cs1.getNum().toString()); | ||
| 2207 | - if(val.length() == 0){ | ||
| 2208 | - map.put(pre, num.doubleValue()); | ||
| 2209 | - } else { | ||
| 2210 | - map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 2211 | - } | ||
| 2212 | - } | ||
| 2213 | - { // 去年营收 | ||
| 2214 | - String key3 = gsBm + "_" + xlBm + "_3"; | ||
| 2215 | - if(!(xlMap.containsKey(key3))){ | ||
| 2216 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2217 | - m.put("gsBm", gsBm); | ||
| 2218 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2219 | - m.put("xlBm", xlBm); | ||
| 2220 | - m.put("xlName", xlName); | ||
| 2221 | - m.put("type", "营收"); | ||
| 2222 | - m.put("budget", ""); | ||
| 2223 | - m.put("change", ""); | ||
| 2224 | - m.put("formal", ""); | ||
| 2225 | - for(int i = 1; i <= 12; i++){ | ||
| 2226 | - m.put("mon"+i, ""); | ||
| 2227 | - m.put("bud"+i, ""); | ||
| 2228 | - m.put("pre"+i, ""); | ||
| 2229 | - } | ||
| 2230 | - m.put("monAll", "0"); | ||
| 2231 | - xlMap.put(key3, m); | ||
| 2232 | - xlList.add(m); | ||
| 2233 | - } | ||
| 2234 | - Map<String, Object> map = xlMap.get(key3); | ||
| 2235 | - String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 2236 | - String val = map.get(pre).toString(); | ||
| 2237 | - BigDecimal num = new BigDecimal(cs1.getAmount().toString()); | ||
| 2238 | - if(val.length() == 0){ | ||
| 2239 | - map.put(pre, num.doubleValue()); | ||
| 2240 | - } else { | ||
| 2241 | - map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 2242 | - } | ||
| 2243 | - } | ||
| 2244 | - } | ||
| 2245 | - | ||
| 2246 | - for(Map<String, Object> m : xlList){ | ||
| 2247 | - | ||
| 2248 | - String gsBm = m.get("gsBm").toString(); | ||
| 2249 | - String type = m.get("type").toString(); | ||
| 2250 | - if("公里".equals(type)){ | ||
| 2251 | - type = "1"; | ||
| 2252 | - } else if("人次".equals(type)){ | ||
| 2253 | - type = "2"; | ||
| 2254 | - } else if("营收".equals(type)){ | ||
| 2255 | - type = "3"; | ||
| 2256 | - } | ||
| 2257 | - List<String> strList = new ArrayList<String>(); | ||
| 2258 | - strList.add(gsBm + "_" + type); | ||
| 2259 | - | ||
| 2260 | - for(String str : strList){ | ||
| 2261 | - if(!keyMap.containsKey(str)){ | ||
| 2262 | - continue; | ||
| 2263 | - } | ||
| 2264 | - Map<String, Object> map = keyMap.get(str); | ||
| 2265 | - if(m.get("budget").toString().length() > 0){ | ||
| 2266 | - if(map.get("budget").toString().length() > 0){ | ||
| 2267 | - map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 2268 | - new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 2269 | - } else { | ||
| 2270 | - map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 2271 | - } | ||
| 2272 | - } | ||
| 2273 | - if(m.get("change").toString().length() > 0){ | ||
| 2274 | - if(map.get("change").toString().length() > 0){ | ||
| 2275 | - map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 2276 | - new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 2277 | - } else { | ||
| 2278 | - map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 2279 | - } | ||
| 2280 | - } | ||
| 2281 | - if(m.get("formal").toString().length() > 0){ | ||
| 2282 | - if(map.get("formal").toString().length() > 0){ | ||
| 2283 | - map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 2284 | - new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 2285 | - } else { | ||
| 2286 | - map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 2287 | - } | ||
| 2288 | - } | ||
| 2289 | - for(int i = 1; i <= 12; i++){ | ||
| 2290 | - String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 2291 | - if(m.get(mon).toString().length() > 0){ | ||
| 2292 | - if(map.get(mon).toString().length() > 0){ | ||
| 2293 | - map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 2294 | - new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 2295 | - } else { | ||
| 2296 | - map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 2297 | - } | ||
| 2298 | - } | ||
| 2299 | - if(m.get(bud).toString().length() > 0){ | ||
| 2300 | - if(map.get(bud).toString().length() > 0){ | ||
| 2301 | - map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 2302 | - new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 2303 | - } else { | ||
| 2304 | - map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 2305 | - } | ||
| 2306 | - } | ||
| 2307 | - if(m.get(pre).toString().length() > 0){ | ||
| 2308 | - if(map.get(pre).toString().length() > 0){ | ||
| 2309 | - map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 2310 | - new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 2311 | - } else { | ||
| 2312 | - map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 2313 | - } | ||
| 2314 | - } | ||
| 2315 | - } | ||
| 2316 | - List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 2317 | - dataList.add(m); | ||
| 2318 | - } | ||
| 2319 | - | ||
| 2320 | - String digit = "10000"; | ||
| 2321 | - if("营收".equals(m.get("type").toString())){ | ||
| 2322 | - digit = "1000000"; | ||
| 2323 | - } | ||
| 2324 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 2325 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 2326 | - for(int i = 1; i <= 12; i++){ | ||
| 2327 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 2328 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2329 | - monAll = monAll.add(val); | ||
| 2330 | - val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2331 | - m.put("mon"+i, val.doubleValue()); | ||
| 2332 | - } | ||
| 2333 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 2334 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 2335 | - preAll = preAll.add(val); | ||
| 2336 | - val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2337 | - m.put("pre"+i, val.doubleValue()); | ||
| 2338 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 2339 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2340 | - BigDecimal sub = monVal.subtract(val); | ||
| 2341 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 2342 | - } else { | ||
| 2343 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 2344 | - } | ||
| 2345 | - } | ||
| 2346 | - } | ||
| 2347 | - monAll = monAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2348 | - preAll = preAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2349 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 2350 | - m.put("monAll", monAll.doubleValue()); | ||
| 2351 | - m.put("preAll", preAll.doubleValue()); | ||
| 2352 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 2353 | - | ||
| 2354 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 2355 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 2356 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 2357 | - m.put("complete", monAll.divide( | ||
| 2358 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 2359 | - new BigDecimal(100)).divide( | ||
| 2360 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2361 | - BigDecimal diff = monAll.subtract(formal); | ||
| 2362 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 2363 | - } else { | ||
| 2364 | - m.put("complete", ""); | ||
| 2365 | - m.put("diff", ""); | ||
| 2366 | - } | ||
| 2367 | - } | ||
| 2368 | - | ||
| 2369 | - for(String key : strs){ | ||
| 2370 | - if(!(key.contains("all_"))){ | ||
| 2371 | - String[] sp = key.split("_"); | ||
| 2372 | - String allKey = "all"; | ||
| 2373 | - for(int i = 1; i < sp.length; i++){ | ||
| 2374 | - allKey += "_" + sp[i]; | ||
| 2375 | - } | ||
| 2376 | - Map<String, Object> map = keyMap.get(key); | ||
| 2377 | - Map<String, Object> allMap = keyMap.get(allKey); | ||
| 2378 | - for(String k : map.keySet()){ | ||
| 2379 | - if("year".equals(k)){ // 不想被计算的数字型字段 | ||
| 2380 | - continue; | ||
| 2381 | - } | ||
| 2382 | - try { | ||
| 2383 | - allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 2384 | - new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 2385 | - } catch (Exception e) { | ||
| 2386 | - // TODO: handle exception | ||
| 2387 | - } | ||
| 2388 | - } | ||
| 2389 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 2390 | - dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 2391 | - allMap.put("dataList", dataList); | ||
| 2392 | - | ||
| 2393 | - for(Map<String, Object> m : dataList){ | ||
| 2394 | - for(int i = 1; i <= 12; i++){ | ||
| 2395 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 2396 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 2397 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 2398 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 2399 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 2400 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2401 | - } else { | ||
| 2402 | - m.put("com" + i, ""); | ||
| 2403 | - } | ||
| 2404 | - } | ||
| 2405 | - } | ||
| 2406 | - } | ||
| 2407 | - } | ||
| 2408 | - | ||
| 2409 | - for(String key : strs){ | ||
| 2410 | - Map<String, Object> m = keyMap.get(key); | ||
| 2411 | - BigDecimal monAll = new BigDecimal("0"); | ||
| 2412 | - BigDecimal preAll = new BigDecimal("0"); | ||
| 2413 | - String digit = "10000"; | ||
| 2414 | - if("营收".equals(m.get("type").toString())){ | ||
| 2415 | - digit = "1000000"; | ||
| 2416 | - } | ||
| 2417 | - for(int i = 1; i <= 12; i++){ | ||
| 2418 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 2419 | - BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2420 | - monAll = monAll.add(val); | ||
| 2421 | - val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2422 | - m.put("mon"+i, val.doubleValue()); | ||
| 2423 | - } | ||
| 2424 | - if(m.get("pre"+i).toString().length() > 0){ | ||
| 2425 | - BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 2426 | - preAll = preAll.add(val); | ||
| 2427 | - val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2428 | - m.put("pre"+i, val.doubleValue()); | ||
| 2429 | - if(m.get("mon"+i).toString().length() > 0){ | ||
| 2430 | - BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2431 | - BigDecimal sub = monVal.subtract(val); | ||
| 2432 | - m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 2433 | - } else { | ||
| 2434 | - m.put("sub"+i, "-" + val.doubleValue()); | ||
| 2435 | - } | ||
| 2436 | - } | ||
| 2437 | - } | ||
| 2438 | - monAll = monAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2439 | - preAll = preAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2440 | - Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 2441 | - m.put("monAll", monAll.doubleValue()); | ||
| 2442 | - m.put("preAll", preAll.doubleValue()); | ||
| 2443 | - m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 2444 | - | ||
| 2445 | - if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 2446 | - && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 2447 | - BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 2448 | - m.put("complete", monAll.divide( | ||
| 2449 | - formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 2450 | - new BigDecimal(100)).divide( | ||
| 2451 | - new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2452 | - BigDecimal diff = monAll.subtract(formal); | ||
| 2453 | - m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 2454 | - } else { | ||
| 2455 | - m.put("complete", ""); | ||
| 2456 | - m.put("diff", ""); | ||
| 2457 | - } | ||
| 2458 | - m.put("year", year); | ||
| 2459 | - | ||
| 2460 | - for(int i = 1; i <= 12; i++){ | ||
| 2461 | - String mon = "mon" + i, bud = "bud" + i; | ||
| 2462 | - if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 2463 | - && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 2464 | - BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 2465 | - BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 2466 | - m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2467 | - } else { | ||
| 2468 | - m.put("com" + i, ""); | ||
| 2469 | - } | ||
| 2470 | - } | ||
| 2471 | - } | ||
| 2472 | - | ||
| 2473 | - if(tttt.equals("export")){ | ||
| 2474 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2475 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2476 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2477 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2478 | - String xls="budgetSum.xls"; | ||
| 2479 | - ReportUtils ee = new ReportUtils(); | ||
| 2480 | - try { | ||
| 2481 | - String dateTime = ""; | ||
| 2482 | - m.put("date", year); | ||
| 2483 | - dateTime = year; | ||
| 2484 | - listI.add(resList.iterator()); | ||
| 2485 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2486 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 2487 | - path + "export/"+dateTime+"-预算汇总表.xls"); | ||
| 2488 | - } catch (Exception e) { | ||
| 2489 | - // TODO: handle exception | ||
| 2490 | - e.printStackTrace(); | ||
| 2491 | - } | ||
| 2492 | - } | ||
| 2493 | - | ||
| 2494 | - if(tttt.equals("exportData")){ | ||
| 2495 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2496 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2497 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2498 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2499 | - m.put("date", year); | ||
| 2500 | - ReportUtils ee = new ReportUtils(); | ||
| 2501 | - try { | ||
| 2502 | - if("allData".equals(kkk)){ | ||
| 2503 | - List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | ||
| 2504 | - Map<String, List<Map<String, Object>>> tempMap = new HashMap<String, List<Map<String, Object>>>(); | ||
| 2505 | - List<String> tempList = new ArrayList<String>(); | ||
| 2506 | - for(Map<String, Object> m1 : (List<Map<String, Object>>)resList.get(resList.size() - 3).get("dataList")){ | ||
| 2507 | - String xlName = m1.get("xlName")!=null?m1.get("xlName").toString():""; | ||
| 2508 | - if(!tempMap.containsKey(xlName)){ | ||
| 2509 | - tempMap.put(xlName, new ArrayList<Map<String, Object>>()); | ||
| 2510 | - tempList.add(xlName); | ||
| 2511 | - } | ||
| 2512 | - tempMap.get(xlName).add(m1); | ||
| 2513 | - } | ||
| 2514 | - for(Map<String, Object> m2 : (List<Map<String, Object>>)resList.get(resList.size() - 2).get("dataList")){ | ||
| 2515 | - String xlName = m2.get("xlName")!=null?m2.get("xlName").toString():""; | ||
| 2516 | - if(!tempMap.containsKey(xlName)){ | ||
| 2517 | - tempMap.put(xlName, new ArrayList<Map<String, Object>>()); | ||
| 2518 | - tempList.add(xlName); | ||
| 2519 | - } | ||
| 2520 | - tempMap.get(xlName).add(m2); | ||
| 2521 | - } | ||
| 2522 | - for(Map<String, Object> m3 : (List<Map<String, Object>>)resList.get(resList.size() - 1).get("dataList")){ | ||
| 2523 | - String xlName = m3.get("xlName")!=null?m3.get("xlName").toString():""; | ||
| 2524 | - if(!tempMap.containsKey(xlName)){ | ||
| 2525 | - tempMap.put(xlName, new ArrayList<Map<String, Object>>()); | ||
| 2526 | - tempList.add(xlName); | ||
| 2527 | - } | ||
| 2528 | - tempMap.get(xlName).add(m3); | ||
| 2529 | - } | ||
| 2530 | - for(String xlName : tempList){ | ||
| 2531 | - dataList.addAll(tempMap.get(xlName)); | ||
| 2532 | - } | ||
| 2533 | - listI.add(dataList.iterator()); | ||
| 2534 | - } else { | ||
| 2535 | - for(Map<String, Object> map : resList){ | ||
| 2536 | - if(kkk.equals(map.get("key").toString())){ | ||
| 2537 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 2538 | - listI.add(dataList.iterator()); | ||
| 2539 | - } | ||
| 2540 | - } | ||
| 2541 | - } | ||
| 2542 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2543 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetSum_data.xls", | ||
| 2544 | - path + "export/" + year + "-预算汇总表-线路明细.xls"); | ||
| 2545 | - } catch (Exception e) { | ||
| 2546 | - // TODO: handle exception | ||
| 2547 | - e.printStackTrace(); | ||
| 2548 | - logger.info("", e); | ||
| 2549 | - } | ||
| 2550 | - } | ||
| 2551 | - | ||
| 2552 | - return resList; | ||
| 2553 | - } | ||
| 2554 | - | ||
| 2555 | - @Override | ||
| 2556 | - public List<Map<String, Object>> timeSum(String date1, String date2, String tttt, String k) throws Exception { | ||
| 2557 | - // TODO Auto-generated method stub | ||
| 2558 | - List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 2559 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 2560 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 2561 | - Map<String, Map<String, Map<String, Long>>> timeMap = new HashMap<String, Map<String, Map<String, Long>>>(); | ||
| 2562 | - Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 2563 | - | ||
| 2564 | - Date d1 = sdf.parse(date1); | ||
| 2565 | - Date d2 = sdf.parse(date2); | ||
| 2566 | - | ||
| 2567 | - List<SchedulePlanInfo> findByDates = schedulePlanRepository.findByDates(d1, d2); | ||
| 2568 | - Iterable<Line> findAll = lineService.findAll(); | ||
| 2569 | - Map<String, Line> lineMap = new HashMap<String, Line>(); | ||
| 2570 | - for(Line line : findAll){ | ||
| 2571 | - lineMap.put(line.getLineCode(), line); | ||
| 2572 | - } | ||
| 2573 | - | ||
| 2574 | - List<Object[]> findPersonnelSchedule = schedulePlanRepository.findPersonnelSchedule(d1, d2); | ||
| 2575 | - List<Object[]> findCancelSchedule = scheduleRealRepository.findCancelSchedule(date1, date2, "缺人"); | ||
| 2576 | - Map<String, Long> psMap = new HashMap<String, Long>(), | ||
| 2577 | - csMap = new HashMap<String, Long>(); | ||
| 2578 | - for(Object[] objects : findPersonnelSchedule){ | ||
| 2579 | - if(!psMap.containsKey(objects[1])){ | ||
| 2580 | - psMap.put(objects[1].toString(), 1l); | ||
| 2581 | - } else { | ||
| 2582 | - psMap.put(objects[1].toString(), 1l + psMap.get(objects[1].toString())); | ||
| 2583 | - } | ||
| 2584 | - } | ||
| 2585 | - for(Object[] objects : findCancelSchedule){ | ||
| 2586 | - if(!csMap.containsKey(objects[1])){ | ||
| 2587 | - csMap.put(objects[1].toString(), 1l); | ||
| 2588 | - } else { | ||
| 2589 | - csMap.put(objects[1].toString(), 1l + csMap.get(objects[1].toString())); | ||
| 2590 | - } | ||
| 2591 | - } | ||
| 2592 | - | ||
| 2593 | - List<Object[]> findLineConfigCar = ccRepository.findLineConfigCar(d1); | ||
| 2594 | - List<Object[]> findLineConfigEmp = ecRepository.findLineConfigEmp(d1); | ||
| 2595 | - List<Object[]> findPlanGroupCar = schedulePlanRepository.findPlanGroupCar(d1, d2); | ||
| 2596 | - List<Object[]> findPlanGroupDriver = schedulePlanRepository.findPlanGroupDriver(d1, d2); | ||
| 2597 | - List<Object[]> findPlanGroupBusConductor = schedulePlanRepository.findPlanGroupBusConductor(d1, d2); | ||
| 2598 | - Map<String, Map<String, Object>> carMap = new HashMap<String, Map<String, Object>>(), | ||
| 2599 | - driverMap = new HashMap<String, Map<String, Object>>(), | ||
| 2600 | - busConductorMap = new HashMap<String, Map<String, Object>>(); | ||
| 2601 | - for(Object[] objects : findPlanGroupCar){ | ||
| 2602 | - String key = objects[0].toString(); | ||
| 2603 | - if(!carMap.containsKey(key)){ | ||
| 2604 | - carMap.put(key, new HashMap<String, Object>()); | ||
| 2605 | - } | ||
| 2606 | - carMap.get(key).put(objects[1].toString(), objects[2]); | ||
| 2607 | - } | ||
| 2608 | - for(Object[] objects : findPlanGroupDriver){ | ||
| 2609 | - String key = objects[0].toString(); | ||
| 2610 | - if(!driverMap.containsKey(key)){ | ||
| 2611 | - driverMap.put(key, new HashMap<String, Object>()); | ||
| 2612 | - } | ||
| 2613 | - driverMap.get(key).put(objects[1].toString(), objects[2]); | ||
| 2614 | - } | ||
| 2615 | - for(Object[] objects : findPlanGroupBusConductor){ | ||
| 2616 | - String key = objects[0].toString(); | ||
| 2617 | - if(!busConductorMap.containsKey(key)){ | ||
| 2618 | - busConductorMap.put(key, new HashMap<String, Object>()); | ||
| 2619 | - } | ||
| 2620 | - busConductorMap.get(key).put(objects[1].toString(), objects[2]); | ||
| 2621 | - } | ||
| 2622 | - | ||
| 2623 | - Map<String, Long> ccMap = new HashMap<String, Long>(); | ||
| 2624 | - Map<String, Long> ecMap = new HashMap<String, Long>(); | ||
| 2625 | - for(Object[] objects : findLineConfigCar){ | ||
| 2626 | - if(!ccMap.containsKey(objects[0].toString())){ | ||
| 2627 | - ccMap.put(objects[0].toString(), 1l); | ||
| 2628 | - } else { | ||
| 2629 | - ccMap.put(objects[0].toString(), 1l + ccMap.get(objects[0].toString())); | ||
| 2630 | - } | ||
| 2631 | - } | ||
| 2632 | - for(Object[] objects : findLineConfigEmp){ | ||
| 2633 | - if(!ecMap.containsKey(objects[0].toString())){ | ||
| 2634 | - ecMap.put(objects[0].toString(), 1l); | ||
| 2635 | - } else { | ||
| 2636 | - ecMap.put(objects[0].toString(), 1l + ecMap.get(objects[0].toString())); | ||
| 2637 | - } | ||
| 2638 | - } | ||
| 2639 | - | ||
| 2640 | - String temp = ""; | ||
| 2641 | - Long tempLong = 0l; | ||
| 2642 | - Long l = 0l; | ||
| 2643 | - SchedulePlanInfo tempSchedule = new SchedulePlanInfo(); | ||
| 2644 | - for(SchedulePlanInfo s : findByDates){ | ||
| 2645 | - String scheduleDate = sdf.format(s.getScheduleDate()); | ||
| 2646 | - String gs = s.getGsBm(); | ||
| 2647 | - String xlBm = s.getXlBm(); | ||
| 2648 | - String lpName = s.getLpName(); | ||
| 2649 | - String jGh = s.getjGh(); | ||
| 2650 | - String temp1 = gs + "/" + scheduleDate + "/" + xlBm + "/" + lpName + "/" + jGh; | ||
| 2651 | - String fcsj = s.getFcsj(); | ||
| 2652 | - String[] split = fcsj.split(":"); | ||
| 2653 | - Long tempLong1 = Long.valueOf(split[0])*60l + Long.valueOf(split[1]); | ||
| 2654 | - if(!(temp1.equals(temp)) || temp.length() == 0){ | ||
| 2655 | - if(l > 0l){ | ||
| 2656 | - String gsFgs = tempSchedule.getGsBm(); | ||
| 2657 | - String xl = tempSchedule.getXlBm(); | ||
| 2658 | - String jj = sdf.format(tempSchedule.getScheduleDate()) + "/" + tempSchedule.getjGh(); | ||
| 2659 | - if(!timeMap.containsKey(gsFgs)){ | ||
| 2660 | - timeMap.put(gsFgs, new HashMap<String, Map<String, Long>>()); | ||
| 2661 | - } | ||
| 2662 | - if(!timeMap.get(gsFgs).containsKey(xl)){ | ||
| 2663 | - timeMap.get(gsFgs).put(xl, new HashMap<String, Long>()); | ||
| 2664 | - } | ||
| 2665 | - if(timeMap.get(gsFgs).get(xl).containsKey(jj)){ | ||
| 2666 | - timeMap.get(gsFgs).get(xl).put(jj, timeMap.get(gsFgs).get(xl).get(jj) + l); | ||
| 2667 | - } else { | ||
| 2668 | - timeMap.get(gsFgs).get(xl).put(jj, l); | ||
| 2669 | - } | ||
| 2670 | - } | ||
| 2671 | - l = 0l; | ||
| 2672 | - tempLong = tempLong1; | ||
| 2673 | - temp = temp1; | ||
| 2674 | - tempSchedule = s; | ||
| 2675 | - } else { | ||
| 2676 | - tempLong1 += s.getBcsj(); | ||
| 2677 | - if(tempLong1 < tempLong){ | ||
| 2678 | - tempLong1 += (1l*60*24); | ||
| 2679 | - } | ||
| 2680 | - l += tempLong1 - tempLong; | ||
| 2681 | - tempLong = tempLong1; | ||
| 2682 | - } | ||
| 2683 | - } | ||
| 2684 | - | ||
| 2685 | - String[] strs = createBudgetMap_sum2(resList, keyMap); | ||
| 2686 | - | ||
| 2687 | - for(String key : strs){ | ||
| 2688 | - Map<String, Object> map = keyMap.get(key); | ||
| 2689 | - String[] split = key.split("_"); | ||
| 2690 | - String gs = split[0]; | ||
| 2691 | - String nature = split[1]; | ||
| 2692 | - List<Long> lList = new ArrayList<Long>(); | ||
| 2693 | - List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | ||
| 2694 | - Long warrantCar = 0l, ccNum = 0l, ecNum = 0l, | ||
| 2695 | - carNum = 0l, driverNum = 0l, busConductorNum = 0l, | ||
| 2696 | - psNum = 0l, csNum = 0l; | ||
| 2697 | - for(String gsFgs : timeMap.keySet()){ | ||
| 2698 | - if("all".equals(gs) || gsFgs.equals(gs)){ | ||
| 2699 | - Map<String, Map<String, Long>> xlMap = timeMap.get(gsFgs); | ||
| 2700 | - for(String xl : xlMap.keySet()){ | ||
| 2701 | - Boolean b = false; | ||
| 2702 | - if("1".equals(nature) && lineNature.containsKey(xl) && lineNature.get(xl)){ | ||
| 2703 | - b = true; | ||
| 2704 | - } | ||
| 2705 | - if("2".equals(nature) && !(lineNature.containsKey(xl) && lineNature.get(xl))){ | ||
| 2706 | - b = true; | ||
| 2707 | - } | ||
| 2708 | - if("0".equals(nature)){ | ||
| 2709 | - b = true; | ||
| 2710 | - } | ||
| 2711 | - if(b){ | ||
| 2712 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2713 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsFgs)); | ||
| 2714 | - m.put("xlName", lineMap.containsKey(xl)?lineMap.get(xl).getName():""); | ||
| 2715 | - List<Long> xl_lList = new ArrayList<Long>(); | ||
| 2716 | - | ||
| 2717 | - Map<String, Long> jjMap = xlMap.get(xl); | ||
| 2718 | - for(String jj : jjMap.keySet()){ //营运工时 | ||
| 2719 | - lList.add(jjMap.get(jj)); | ||
| 2720 | - xl_lList.add(jjMap.get(jj)); | ||
| 2721 | - } | ||
| 2722 | - Long sum = 0l; | ||
| 2723 | - for(Long ll : xl_lList){ | ||
| 2724 | - sum += ll; | ||
| 2725 | - } | ||
| 2726 | - m.put("time", xl_lList.size()>0?new BigDecimal(sum).divide( | ||
| 2727 | - new BigDecimal(xl_lList.size()*60l), 2, BigDecimal.ROUND_HALF_UP):""); | ||
| 2728 | - | ||
| 2729 | - if(lineMap.containsKey(xl)){ //权证配车数 | ||
| 2730 | - warrantCar += lineMap.get(xl).getWarrantCar()!=null?lineMap.get(xl).getWarrantCar():0l; | ||
| 2731 | - m.put("warrantCar", lineMap.get(xl).getWarrantCar()); | ||
| 2732 | - } else { | ||
| 2733 | - m.put("warrantCar", ""); | ||
| 2734 | - } | ||
| 2735 | - if(ccMap.containsKey(xl)){ //机务保管数 | ||
| 2736 | - ccNum += ccMap.get(xl); | ||
| 2737 | - m.put("ccNum", ccMap.get(xl)); | ||
| 2738 | - } else { | ||
| 2739 | - m.put("ccNum", ""); | ||
| 2740 | - } | ||
| 2741 | - if(ecMap.containsKey(xl)){ //人事配档数 | ||
| 2742 | - ecNum += ecMap.get(xl); | ||
| 2743 | - m.put("ecNum", ecMap.get(xl)); | ||
| 2744 | - } else { | ||
| 2745 | - m.put("ecNum", ""); | ||
| 2746 | - } | ||
| 2747 | - if(carMap.containsKey(gsFgs) && carMap.get(gsFgs).containsKey(xl)){ //最高配车数 | ||
| 2748 | - carNum += Long.valueOf(carMap.get(gsFgs).get(xl).toString()); | ||
| 2749 | - m.put("carNum", Long.valueOf(carMap.get(gsFgs).get(xl).toString())); | ||
| 2750 | - } else { | ||
| 2751 | - m.put("carNum", ""); | ||
| 2752 | - } | ||
| 2753 | - if(driverMap.containsKey(gsFgs) && driverMap.get(gsFgs).containsKey(xl)){ //司最高陪人数 | ||
| 2754 | - driverNum += Long.valueOf(driverMap.get(gsFgs).get(xl).toString()); | ||
| 2755 | - m.put("driverNum", Long.valueOf(driverMap.get(gsFgs).get(xl).toString())); | ||
| 2756 | - } else { | ||
| 2757 | - m.put("driverNum", ""); | ||
| 2758 | - } | ||
| 2759 | - if(busConductorMap.containsKey(gsFgs) && busConductorMap.get(gsFgs).containsKey(xl)){ //售最高陪人数 | ||
| 2760 | - busConductorNum += Long.valueOf(busConductorMap.get(gsFgs).get(xl).toString()); | ||
| 2761 | - m.put("busConductorNum", Long.valueOf(busConductorMap.get(gsFgs).get(xl).toString())); | ||
| 2762 | - } else { | ||
| 2763 | - m.put("busConductorNum", ""); | ||
| 2764 | - } | ||
| 2765 | - if(psMap.containsKey(xl)){ //总排挡数 | ||
| 2766 | - psNum += psMap.get(xl); | ||
| 2767 | - m.put("psNum", psMap.get(xl)); | ||
| 2768 | - } else { | ||
| 2769 | - m.put("psNum", ""); | ||
| 2770 | - } | ||
| 2771 | - if(csMap.containsKey(xl)){ //总病缺勤数(缺人烂班) | ||
| 2772 | - csNum += csMap.get(xl); | ||
| 2773 | - m.put("csNum", csMap.get(xl)); | ||
| 2774 | - } else { | ||
| 2775 | - m.put("csNum", ""); | ||
| 2776 | - } | ||
| 2777 | - | ||
| 2778 | - if(m.containsKey("carNum") && m.get("carNum").toString().length() > 0 | ||
| 2779 | - && m.containsKey("ccNum") && m.get("ccNum").toString().length() > 0){ | ||
| 2780 | - Long car = Long.valueOf(m.get("carNum").toString()); | ||
| 2781 | - Long cc = Long.valueOf(m.get("ccNum").toString()); | ||
| 2782 | - m.put("bcl", cc>0l?new BigDecimal((cc>car?cc-car:0)*100l).divide( | ||
| 2783 | - new BigDecimal(cc), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2784 | - } else { | ||
| 2785 | - m.put("bcl", "%"); | ||
| 2786 | - } | ||
| 2787 | - if(m.containsKey("csNum") && m.get("csNum").toString().length() > 0 | ||
| 2788 | - && m.containsKey("psNum") && m.get("psNum").toString().length() > 0){ | ||
| 2789 | - Long cs = Long.valueOf(m.get("csNum").toString()); | ||
| 2790 | - Long ps = Long.valueOf(m.get("psNum").toString()); | ||
| 2791 | - m.put("cspsNum", ps>0l?new BigDecimal((cs<ps?cs:ps)*100l).divide( | ||
| 2792 | - new BigDecimal(ps), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2793 | - } else { | ||
| 2794 | - m.put("cspsNum", "%"); | ||
| 2795 | - } | ||
| 2796 | - dataList.add(m); | ||
| 2797 | - } | ||
| 2798 | - } | ||
| 2799 | - } | ||
| 2800 | - } | ||
| 2801 | - map.put("warrantCar", warrantCar); | ||
| 2802 | - map.put("ccNum", ccNum); | ||
| 2803 | - map.put("carNum", carNum); | ||
| 2804 | - map.put("bcl", ccNum>0l?new BigDecimal((ccNum>carNum?ccNum-carNum:0)*100l).divide( | ||
| 2805 | - new BigDecimal(ccNum), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2806 | - map.put("ecNum", ecNum); | ||
| 2807 | - map.put("driverNum", driverNum); | ||
| 2808 | - map.put("busConductorNum", busConductorNum); | ||
| 2809 | - map.put("cspsNum", psNum>0l?new BigDecimal((csNum<psNum?csNum:psNum)*100l).divide( | ||
| 2810 | - new BigDecimal(psNum), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2811 | - Long sum = 0l; | ||
| 2812 | - for(Long ll : lList){ | ||
| 2813 | - sum += ll; | ||
| 2814 | - } | ||
| 2815 | - map.put("time", lList.size()>0?new BigDecimal(sum).divide( | ||
| 2816 | - new BigDecimal(lList.size()*60l), 2, BigDecimal.ROUND_HALF_UP):""); | ||
| 2817 | - map.put("dataList", dataList); | ||
| 2818 | - } | ||
| 2819 | - | ||
| 2820 | - if(tttt.equals("export")){ | ||
| 2821 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2822 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2823 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2824 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2825 | - m.put("date", date1 + "至" + date2); | ||
| 2826 | - m.put("typeName", "线路性质"); | ||
| 2827 | - ReportUtils ee = new ReportUtils(); | ||
| 2828 | - try { | ||
| 2829 | - String dateTime = ""; | ||
| 2830 | - if (date1.equals(date2)) { | ||
| 2831 | - dateTime = sdfSimple.format(sdfMonth.parse(date1)); | ||
| 2832 | - } else { | ||
| 2833 | - dateTime = sdfSimple.format(sdfMonth.parse(date1)) | ||
| 2834 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 2835 | - } | ||
| 2836 | - listI.add(resList.iterator()); | ||
| 2837 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2838 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/timeSum.xls", | ||
| 2839 | - path + "export/" + dateTime + "-时刻表汇总表.xls"); | ||
| 2840 | - } catch (Exception e) { | ||
| 2841 | - // TODO: handle exception | ||
| 2842 | - e.printStackTrace(); | ||
| 2843 | - logger.info("", e); | ||
| 2844 | - } | ||
| 2845 | - } | ||
| 2846 | - | ||
| 2847 | - if(tttt.equals("exportData")){ | ||
| 2848 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2849 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2850 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2851 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2852 | - m.put("date", date1 + "至" + date2); | ||
| 2853 | - m.put("typeName", "线路名"); | ||
| 2854 | - ReportUtils ee = new ReportUtils(); | ||
| 2855 | - try { | ||
| 2856 | - String dateTime = ""; | ||
| 2857 | - if (date1.equals(date2)) { | ||
| 2858 | - dateTime = sdfSimple.format(sdfMonth.parse(date1)); | ||
| 2859 | - } else { | ||
| 2860 | - dateTime = sdfSimple.format(sdfMonth.parse(date1)) | ||
| 2861 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 2862 | - } | ||
| 2863 | - for(Map<String, Object> map : resList){ | ||
| 2864 | - if(k.equals(map.get("key").toString())){ | ||
| 2865 | - List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 2866 | - for(Map<String, Object> mm : dataList){ | ||
| 2867 | - mm.put("type", mm.get("xlName")); | ||
| 2868 | - } | ||
| 2869 | - listI.add(dataList.iterator()); | ||
| 2870 | - } | ||
| 2871 | - } | ||
| 2872 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2873 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/timeSum.xls", | ||
| 2874 | - path + "export/" + dateTime + "-时刻表汇总表-线路明细.xls"); | ||
| 2875 | - } catch (Exception e) { | ||
| 2876 | - // TODO: handle exception | ||
| 2877 | - e.printStackTrace(); | ||
| 2878 | - logger.info("", e); | ||
| 2879 | - } | ||
| 2880 | - } | ||
| 2881 | - | ||
| 2882 | - return resList; | ||
| 2883 | - } | ||
| 2884 | - | ||
| 2885 | - @Override | ||
| 2886 | - public Map<String, Object> timeAnaly(String company, String subCompany, String date, | ||
| 2887 | - String line, String model, String tttt, String kkkk) throws Exception { | ||
| 2888 | - // TODO Auto-generated method stub | ||
| 2889 | - | ||
| 2890 | - int | ||
| 2891 | - zgf1 = 6 * 60 + 31, | ||
| 2892 | - zgf2 = 8 * 60 + 30, | ||
| 2893 | - wgf1 = 16 * 60 + 1, | ||
| 2894 | - wgf2 = 18 * 60, | ||
| 2895 | - xxsj = 90; | ||
| 2896 | - | ||
| 2897 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 2898 | - Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 2899 | - Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 2900 | - Map<String, List<SchedulePlanInfo>> keyList = new HashMap<String, List<SchedulePlanInfo>>(); | ||
| 2901 | - List<SchedulePlanInfo> planList = new ArrayList<SchedulePlanInfo>(); | ||
| 2902 | - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | ||
| 2903 | - | ||
| 2904 | - if(model.trim().length() > 0){ | ||
| 2905 | - planList = schedulePlanRepository.findPlanByTTinfo(line, Long.valueOf(model), date); | ||
| 2906 | - } else { | ||
| 2907 | - planList = schedulePlanRepository.findPlanByXlAndDate(line, date); | ||
| 2908 | - } | ||
| 2909 | - | ||
| 2910 | - Map<String, Object> dMap=new HashMap<>(); | ||
| 2911 | - dMap.put("dGroup_eq", "ScheduleBxType"); | ||
| 2912 | - Iterator<Dictionary> it= dictionaryService.list(dMap).iterator(); | ||
| 2913 | - while (it.hasNext()) { | ||
| 2914 | - Dictionary d=it.next(); | ||
| 2915 | - dMap.put(d.getdCode(), d.getdName()); | ||
| 2916 | - } | ||
| 2917 | - | ||
| 2918 | - for(SchedulePlanInfo plan : planList){ | ||
| 2919 | - String gsBm = plan.getGsBm(); | ||
| 2920 | - String fgsBm = plan.getFgsBm(); | ||
| 2921 | - String xl = plan.getXl().toString(); | ||
| 2922 | - String lp = plan.getLp().toString(); | ||
| 2923 | - String ttInfo = plan.getTtInfo().toString(); | ||
| 2924 | - String key = gsBm + "/" + fgsBm + "/" + xl + "/" + lp + "/" + ttInfo; | ||
| 2925 | - if(!keyMap.containsKey(key)){ | ||
| 2926 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2927 | - m.put("gsBm", gsBm); | ||
| 2928 | - m.put("fgsBm", fgsBm); | ||
| 2929 | - m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2930 | - m.put("fgsName", BasicData.businessFgsCodeNameMap.get(fgsBm + "_" + gsBm)); | ||
| 2931 | - m.put("xl", xl); | ||
| 2932 | - m.put("xlName", plan.getXlName()); | ||
| 2933 | - m.put("lp", lp); | ||
| 2934 | - m.put("lpName", plan.getLpName()); | ||
| 2935 | - m.put("outStation", ""); | ||
| 2936 | - m.put("qdzName0", ""); | ||
| 2937 | - m.put("zdzName0", ""); | ||
| 2938 | - m.put("qdzName1", ""); | ||
| 2939 | - m.put("zdzName1", ""); | ||
| 2940 | - m.put("inStation", ""); | ||
| 2941 | - keyMap.put(key, m); | ||
| 2942 | - keyList.put(key, new ArrayList<SchedulePlanInfo>()); | ||
| 2943 | - list.add(m); | ||
| 2944 | - } | ||
| 2945 | - keyList.get(key).add(plan); | ||
| 2946 | - } | ||
| 2947 | - | ||
| 2948 | - Set<String> ecSet = new HashSet<String>(); // 人事配档数 | ||
| 2949 | - Set<String> carSet = new HashSet<String>(); // 配车数 | ||
| 2950 | - for(String key : keyList.keySet()){ | ||
| 2951 | - String[] keys = key.split("/"); | ||
| 2952 | - Long ttInfo = Long.valueOf(keys[4]); | ||
| 2953 | - int xl = Integer.valueOf(keys[2]); | ||
| 2954 | - Long lp = Long.valueOf(keys[3]); | ||
| 2955 | - Map<String, Object> m = keyMap.get(key); | ||
| 2956 | - int p_fcsj = 0, p_dzsj = 0; | ||
| 2957 | - int yssj_bc = 0, yssj_all = 0, yssj_z = 0, yssj_w = 0, yssj_d = 0; | ||
| 2958 | - int tzsj_bc = 0, tzsj_all = 0, tzsj_z = 0, tzsj_w = 0, tzsj_d = 0; | ||
| 2959 | - int ksbc = 0, yybc = 0, zgs = 15; // 总工时:加上报到例保时间15分钟、复驶路牌10分钟 | ||
| 2960 | - BigDecimal kslc = new BigDecimal(0), yylc = new BigDecimal(0); | ||
| 2961 | - for(SchedulePlanInfo plan : keyList.get(key)){ | ||
| 2962 | - String[] split = plan.getFcsj().split(":"); | ||
| 2963 | - int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | ||
| 2964 | - int bcsj = plan.getBcsj(); | ||
| 2965 | - if(fcsj < p_fcsj){ | ||
| 2966 | - fcsj += 24*60; | ||
| 2967 | - } | ||
| 2968 | - int dzsj = fcsj + bcsj; | ||
| 2969 | - | ||
| 2970 | - String jGh = plan.getjGh() != null ? plan.getjGh().trim() : ""; | ||
| 2971 | - String sGh = plan.getsGh() != null ? plan.getsGh().trim() : ""; | ||
| 2972 | - String zbh = plan.getClZbh() != null ? plan.getClZbh().trim() : ""; | ||
| 2973 | - ecSet.add(jGh + "/" + sGh); | ||
| 2974 | - carSet.add(zbh); | ||
| 2975 | - | ||
| 2976 | - if(m.get("outStation").toString().length() == 0 && "out".equals(plan.getBcType())){ | ||
| 2977 | - m.put("outStation", plan.getQdzName()!=null?plan.getQdzName():""); | ||
| 2978 | - } | ||
| 2979 | - if(m.get("qdzName0").toString().length() == 0 && "0".equals(plan.getXlDir()) | ||
| 2980 | - && "normal".equals(plan.getBcType())){ | ||
| 2981 | - m.put("qdzName0", plan.getQdzName()!=null?plan.getQdzName():""); | ||
| 2982 | - m.put("zdzName0", plan.getZdzName()!=null?plan.getZdzName():""); | ||
| 2983 | - } | ||
| 2984 | - if(m.get("qdzName1").toString().length() == 0 && "1".equals(plan.getXlDir()) | ||
| 2985 | - && "normal".equals(plan.getBcType())){ | ||
| 2986 | - m.put("qdzName1", plan.getQdzName()!=null?plan.getQdzName():""); | ||
| 2987 | - m.put("zdzName1", plan.getZdzName()!=null?plan.getZdzName():""); | ||
| 2988 | - } | ||
| 2989 | - if(m.get("inStation").toString().length() == 0 && "in".equals(plan.getBcType())){ | ||
| 2990 | - m.put("inStation", plan.getZdzName()!=null?plan.getZdzName():""); | ||
| 2991 | - } | ||
| 2992 | - | ||
| 2993 | - if(p_dzsj > 0 && fcsj - p_dzsj < xxsj){ | ||
| 2994 | - zgs += dzsj - p_dzsj; | ||
| 2995 | - } else { | ||
| 2996 | - zgs += bcsj; | ||
| 2997 | - } | ||
| 2998 | - | ||
| 2999 | - if("in/out/ldks".contains(plan.getBcType())){ | ||
| 3000 | - ksbc += 1; | ||
| 3001 | - kslc = kslc.add(BigDecimal.valueOf(plan.getJhlc())); | ||
| 3002 | - } else { | ||
| 3003 | - yybc += 1; | ||
| 3004 | - yylc = yylc.add(BigDecimal.valueOf(plan.getJhlc())); | ||
| 3005 | - } | ||
| 3006 | - | ||
| 3007 | - if(!("in/out/ldks".contains(plan.getBcType()))){ | ||
| 3008 | - yssj_bc += 1; | ||
| 3009 | - yssj_all += bcsj; | ||
| 3010 | - if(fcsj <= zgf2 && dzsj >= zgf1){ | ||
| 3011 | - int a = fcsj >= zgf1 ? fcsj : zgf1; | ||
| 3012 | - int b = dzsj >= zgf2 ? zgf2 : dzsj; | ||
| 3013 | - yssj_z += b - a; | ||
| 3014 | - } | ||
| 3015 | - if(fcsj <= wgf2 && dzsj >= wgf1){ | ||
| 3016 | - int a = fcsj >= wgf1 ? fcsj : wgf1; | ||
| 3017 | - int b = dzsj >= wgf2 ? wgf2 : dzsj; | ||
| 3018 | - yssj_w += b - a; | ||
| 3019 | - } | ||
| 3020 | - yssj_d += bcsj; // 低谷运送时间,下面减去高峰时段的时间就是低谷时间 | ||
| 3021 | - if(fcsj >= zgf1 && fcsj <= zgf2){ | ||
| 3022 | - if(dzsj < zgf2){ | ||
| 3023 | - yssj_d -= dzsj - fcsj; | ||
| 3024 | - } else { | ||
| 3025 | - yssj_d -= zgf2 - fcsj; | ||
| 3026 | - } | ||
| 3027 | - } else if(dzsj >= zgf1 && dzsj <= zgf2){ | ||
| 3028 | - yssj_d -= dzsj - zgf1; | ||
| 3029 | - } else if(fcsj < zgf1 && dzsj > zgf2){ | ||
| 3030 | - yssj_d -= zgf2 - zgf1; | ||
| 3031 | - } | ||
| 3032 | - if(fcsj >= wgf1 && fcsj <= wgf2){ | ||
| 3033 | - if(dzsj < wgf2){ | ||
| 3034 | - yssj_d -= dzsj - fcsj; | ||
| 3035 | - } else { | ||
| 3036 | - yssj_d -= wgf2 - fcsj; | ||
| 3037 | - } | ||
| 3038 | - } else if(dzsj >= wgf1 && dzsj <= wgf2){ | ||
| 3039 | - yssj_d -= dzsj - wgf1; | ||
| 3040 | - } else if(fcsj < wgf1 && dzsj > wgf2){ | ||
| 3041 | - yssj_d -= wgf2 - wgf1; | ||
| 3042 | - } | ||
| 3043 | - } | ||
| 3044 | - | ||
| 3045 | - if(!("in/out".contains(plan.getBcType()))){ | ||
| 3046 | - int tzsj = fcsj - p_dzsj; // 停站时间,1、前个计划运送后到这个计划发车前;2、超过2小时或者下个班次为进出场时为空。 | ||
| 3047 | - if(tzsj < 0){ | ||
| 3048 | - tzsj = 0; | ||
| 3049 | - } | ||
| 3050 | - if(tzsj < xxsj){ | ||
| 3051 | - tzsj_bc += 1; | ||
| 3052 | - tzsj_all += tzsj; | ||
| 3053 | - } | ||
| 3054 | - if(tzsj > 0 && tzsj < xxsj){ | ||
| 3055 | - if(p_dzsj <= zgf2 && fcsj >= zgf1){ | ||
| 3056 | - int a = p_dzsj >= zgf1 ? p_dzsj : zgf1; | ||
| 3057 | - int b = fcsj >= zgf2 ? zgf2 : fcsj; | ||
| 3058 | - tzsj_z += b - a; | ||
| 3059 | - } | ||
| 3060 | - if(p_dzsj <= wgf2 && fcsj >= wgf1){ | ||
| 3061 | - int a = p_dzsj >= wgf1 ? p_dzsj : wgf1; | ||
| 3062 | - int b = fcsj >= wgf2 ? wgf2 : fcsj; | ||
| 3063 | - tzsj_w += b - a; | ||
| 3064 | - } | ||
| 3065 | - tzsj_d += tzsj; // 低谷停站时间,下面减去高峰时段的时间就是低谷时间 | ||
| 3066 | - if(p_dzsj >= zgf1 && p_dzsj <= zgf2){ | ||
| 3067 | - if(fcsj < zgf2){ | ||
| 3068 | - tzsj_d -= fcsj - p_dzsj; | ||
| 3069 | - } else { | ||
| 3070 | - tzsj_d -= zgf2 - p_dzsj; | ||
| 3071 | - } | ||
| 3072 | - } else if(fcsj >= zgf1 && fcsj <= zgf2){ | ||
| 3073 | - tzsj_d -= fcsj - zgf1; | ||
| 3074 | - } else if(p_dzsj < zgf1 && fcsj > zgf2){ | ||
| 3075 | - tzsj_d -= zgf2 - zgf1; | ||
| 3076 | - } | ||
| 3077 | - if(p_dzsj >= wgf1 && p_dzsj <= wgf2){ | ||
| 3078 | - if(fcsj < wgf2){ | ||
| 3079 | - tzsj_d -= fcsj - p_dzsj; | ||
| 3080 | - } else { | ||
| 3081 | - tzsj_d -= wgf2 - p_dzsj; | ||
| 3082 | - } | ||
| 3083 | - } else if(fcsj >= wgf1 && fcsj <= wgf2){ | ||
| 3084 | - tzsj_d -= fcsj - wgf1; | ||
| 3085 | - } else if(p_dzsj < wgf1 && fcsj > wgf2){ | ||
| 3086 | - tzsj_d -= wgf2 - wgf1; | ||
| 3087 | - } | ||
| 3088 | - } | ||
| 3089 | - } | ||
| 3090 | - | ||
| 3091 | - p_fcsj = fcsj; | ||
| 3092 | - p_dzsj = dzsj; | ||
| 3093 | - } | ||
| 3094 | - | ||
| 3095 | - m.put("yssj_z", yssj_z); | ||
| 3096 | - m.put("yssj_w", yssj_w); | ||
| 3097 | - m.put("yssj_d", yssj_d); | ||
| 3098 | - m.put("yssj_average", yssj_bc > 0 ? new BigDecimal(yssj_all).divide( | ||
| 3099 | - new BigDecimal(yssj_bc), 2, BigDecimal.ROUND_HALF_UP) : ""); | ||
| 3100 | - m.put("tzsj_z", tzsj_z); | ||
| 3101 | - m.put("tzsj_w", tzsj_w); | ||
| 3102 | - m.put("tzsj_d", tzsj_d); | ||
| 3103 | - m.put("tzsj_average", tzsj_bc > 0 ? new BigDecimal(tzsj_all).divide( | ||
| 3104 | - new BigDecimal(tzsj_bc), 2, BigDecimal.ROUND_HALF_UP) : ""); | ||
| 3105 | - m.put("ksbc", ksbc); | ||
| 3106 | - m.put("kslc", kslc); | ||
| 3107 | - m.put("ks", ksbc + "/" + kslc); | ||
| 3108 | - m.put("yybc", yybc); | ||
| 3109 | - m.put("yylc", yylc); | ||
| 3110 | - m.put("yy", yybc + "/" + yylc); | ||
| 3111 | - m.put("yygs", yssj_all/60 + "." + (yssj_all%60>9?"":"0") + yssj_all%60); | ||
| 3112 | - m.put("zgs", zgs/60 + "." + (zgs%60>9?"":"0") + zgs%60); | ||
| 3113 | - | ||
| 3114 | - String bx = ""; | ||
| 3115 | - List<TTInfoBxDetail> findBxDetail = ttInfoBxDetailRepository.findBxDetail(ttInfo, xl, lp); | ||
| 3116 | - if(findBxDetail.size() > 0){ | ||
| 3117 | - for(TTInfoBxDetail b : findBxDetail){ | ||
| 3118 | - if(b.getBxType1() != null && b.getBxType1().getDicDesc() != null | ||
| 3119 | - && !("null".equals(b.getBxType1().getDicDesc()))){ | ||
| 3120 | - String dic = b.getBxType1().getDicDesc(); | ||
| 3121 | - if(dMap.containsKey(dic)){ | ||
| 3122 | - dic = dMap.get(dic).toString(); | ||
| 3123 | - } | ||
| 3124 | - bx += bx.length() > 0 ? "/" + dic : dic; | ||
| 3125 | - } | ||
| 3126 | - if(b.getBxType2() != null && b.getBxType2().getDicDesc() != null | ||
| 3127 | - && !("null".equals(b.getBxType2().getDicDesc()))){ | ||
| 3128 | - String dic = b.getBxType2().getDicDesc(); | ||
| 3129 | - if(dMap.containsKey(dic)){ | ||
| 3130 | - dic = dMap.get(dic).toString(); | ||
| 3131 | - } | ||
| 3132 | - bx += bx.length() > 0 ? "/" + dic : dic; | ||
| 3133 | - } | ||
| 3134 | - } | ||
| 3135 | - } | ||
| 3136 | - m.put("bx", bx); | ||
| 3137 | - } | ||
| 3138 | - | ||
| 3139 | - resMap.put("ecNum", ecSet.size()); | ||
| 3140 | - resMap.put("carNum", carSet.size()); | ||
| 3141 | - resMap.put("dataList", list); | ||
| 3142 | - | ||
| 3143 | - if(tttt.equals("export")){ | ||
| 3144 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3145 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3146 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3147 | - Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3148 | - m.put("date", date); | ||
| 3149 | - m.put("ecNum", ecSet.size()); | ||
| 3150 | - m.put("carNum", carSet.size()); | ||
| 3151 | - m.put("lineName", BasicData.lineCodeAllNameMap.get(line)); | ||
| 3152 | - ReportUtils ee = new ReportUtils(); | ||
| 3153 | - try { | ||
| 3154 | - listI.add(list.iterator()); | ||
| 3155 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3156 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/timeAnaly.xls", | ||
| 3157 | - path + "export/" + date + "-" + BasicData.lineCodeAllNameMap.get(line) + "-线路时刻表分析明细.xls"); | ||
| 3158 | - } catch (Exception e) { | ||
| 3159 | - // TODO: handle exception | ||
| 3160 | - e.printStackTrace(); | ||
| 3161 | - logger.info("", e); | ||
| 3162 | - } | ||
| 3163 | - } | ||
| 3164 | - | ||
| 3165 | - return resMap; | ||
| 3166 | - } | ||
| 3167 | - | ||
| 3168 | - public String[] createBudgetMap(List<Map<String, Object>> list, Map<String, Map<String, Object>> keyMap){ | ||
| 3169 | - | ||
| 3170 | - String[] strs = {"05_1_1", "05_1_0", "05_1_all", "05_0", "05_all" | ||
| 3171 | - ,"55_1_1", "55_1_0", "55_1_all", "55_0", "55_all" | ||
| 3172 | - ,"22_1_1", "22_1_0", "22_1_all", "22_0", "22_all" | ||
| 3173 | - ,"26_1_1", "26_1_0", "26_1_all", "26_0", "26_all" | ||
| 3174 | - ,"all_1_1", "all_1_0", "all_1_all", "all_0", "all_all"}; | ||
| 3175 | - for(String s : strs){ | ||
| 3176 | - String[] sp = s.split("_"); | ||
| 3177 | - Map<String, Object> m1 = new HashMap<String, Object>(); | ||
| 3178 | - String gs = "", type = "", item = "", num = ""; | ||
| 3179 | - if("05".equals(sp[0])){ | ||
| 3180 | - gs = "杨高公司"; | ||
| 3181 | - } else if("55".equals(sp[0])){ | ||
| 3182 | - gs = "上南公司"; | ||
| 3183 | - } else if("22".equals(sp[0])){ | ||
| 3184 | - gs = "金高公司"; | ||
| 3185 | - } else if("26".equals(sp[0])){ | ||
| 3186 | - gs = "南汇公司"; | ||
| 3187 | - } else if("all".equals(sp[0])){ | ||
| 3188 | - gs = "浦东公交合计"; | ||
| 3189 | - num = "0"; | ||
| 3190 | - } | ||
| 3191 | - if("1".equals(sp[1])){ | ||
| 3192 | - type = "营运线路"; | ||
| 3193 | - } else if("0".equals(sp[1])){ | ||
| 3194 | - type = "非营运线路"; | ||
| 3195 | - } else if("all".equals(sp[1])){ | ||
| 3196 | - type = "全部线路"; | ||
| 3197 | - } | ||
| 3198 | - if(sp.length > 2){ | ||
| 3199 | - if("1".equals(sp[2])){ | ||
| 3200 | - item = "营运线路"; | ||
| 3201 | - } else if("0".equals(sp[2])){ | ||
| 3202 | - item = "机场线路"; | ||
| 3203 | - } else if("all".equals(sp[2])){ | ||
| 3204 | - item = "小计"; | ||
| 3205 | - } | ||
| 3206 | - } | ||
| 3207 | - m1.put("gsName", gs);m1.put("type", type);m1.put("item", item); | ||
| 3208 | - m1.put("budget", num);m1.put("change", num);m1.put("formal", num); | ||
| 3209 | - for(int i = 1; i <= 12; i++){ | ||
| 3210 | - m1.put("mon"+i, num); | ||
| 3211 | - m1.put("bud"+i, num); | ||
| 3212 | - m1.put("pre"+i, num); | ||
| 3213 | - m1.put("sub"+i, ""); | ||
| 3214 | - } | ||
| 3215 | - m1.put("monAll", "0"); | ||
| 3216 | - m1.put("subAll", "0"); | ||
| 3217 | - m1.put("key", s); | ||
| 3218 | - m1.put("dataList", new ArrayList<Map<String, Object>>()); | ||
| 3219 | - list.add(m1); | ||
| 3220 | - keyMap.put(s, m1); | ||
| 3221 | - } | ||
| 3222 | - return strs; | ||
| 3223 | - } | ||
| 3224 | - | ||
| 3225 | - public String[] createBudgetMap_sum(List<Map<String, Object>> list, Map<String, Map<String, Object>> keyMap){ | ||
| 3226 | - | ||
| 3227 | - String[] strs = {"05_1", "05_2", "05_3" | ||
| 3228 | - ,"55_1", "55_2", "55_3" | ||
| 3229 | - ,"22_1", "22_2", "22_3" | ||
| 3230 | - ,"26_1", "26_2", "26_3" | ||
| 3231 | - ,"all_1", "all_2", "all_3"}; | ||
| 3232 | - for(String s : strs){ | ||
| 3233 | - String[] sp = s.split("_"); | ||
| 3234 | - Map<String, Object> m1 = new HashMap<String, Object>(); | ||
| 3235 | - String gs = "", type = "", num = ""; | ||
| 3236 | - if("05".equals(sp[0])){ | ||
| 3237 | - gs = "杨高公司"; | ||
| 3238 | - } else if("55".equals(sp[0])){ | ||
| 3239 | - gs = "上南公司"; | ||
| 3240 | - } else if("22".equals(sp[0])){ | ||
| 3241 | - gs = "金高公司"; | ||
| 3242 | - } else if("26".equals(sp[0])){ | ||
| 3243 | - gs = "南汇公司"; | ||
| 3244 | - } else if("all".equals(sp[0])){ | ||
| 3245 | - gs = "浦东公交合计"; | ||
| 3246 | - num = "0"; | ||
| 3247 | - } | ||
| 3248 | - if("1".equals(sp[1])){ | ||
| 3249 | - type = "公里"; | ||
| 3250 | - } else if("2".equals(sp[1])){ | ||
| 3251 | - type = "人次"; | ||
| 3252 | - } else if("3".equals(sp[1])){ | ||
| 3253 | - type = "营收"; | ||
| 3254 | - } | ||
| 3255 | - m1.put("gsName", gs);m1.put("type", type); | ||
| 3256 | - m1.put("budget", num);m1.put("change", num);m1.put("formal", num); | ||
| 3257 | - for(int i = 1; i <= 12; i++){ | ||
| 3258 | - m1.put("mon"+i, num); | ||
| 3259 | - m1.put("bud"+i, num); | ||
| 3260 | - m1.put("pre"+i, num); | ||
| 3261 | - m1.put("sub"+i, ""); | ||
| 3262 | - } | ||
| 3263 | - m1.put("monAll", "0"); | ||
| 3264 | - m1.put("subAll", "0"); | ||
| 3265 | - m1.put("key", s); | ||
| 3266 | - m1.put("dataList", new ArrayList<Map<String, Object>>()); | ||
| 3267 | - list.add(m1); | ||
| 3268 | - keyMap.put(s, m1); | ||
| 3269 | - } | ||
| 3270 | - return strs; | ||
| 3271 | - } | ||
| 3272 | - | ||
| 3273 | -public String[] createBudgetMap_sum2(List<Map<String, Object>> list, Map<String, Map<String, Object>> keyMap){ | ||
| 3274 | - | ||
| 3275 | - String[] strs = {"05_1", "05_2", "05_0" | ||
| 3276 | - ,"55_1", "55_2", "55_0" | ||
| 3277 | - ,"22_1", "22_2", "22_0" | ||
| 3278 | - ,"26_1", "26_2", "26_0" | ||
| 3279 | - ,"all_1", "all_2", "all_0"}; | ||
| 3280 | - for(String s : strs){ | ||
| 3281 | - String[] sp = s.split("_"); | ||
| 3282 | - Map<String, Object> m1 = new HashMap<String, Object>(); | ||
| 3283 | - String gs = "", type = "", num = ""; | ||
| 3284 | - if("05".equals(sp[0])){ | ||
| 3285 | - gs = "杨高公司"; | ||
| 3286 | - } else if("55".equals(sp[0])){ | ||
| 3287 | - gs = "上南公司"; | ||
| 3288 | - } else if("22".equals(sp[0])){ | ||
| 3289 | - gs = "金高公司"; | ||
| 3290 | - } else if("26".equals(sp[0])){ | ||
| 3291 | - gs = "南汇公司"; | ||
| 3292 | - } else if("all".equals(sp[0])){ | ||
| 3293 | - gs = "浦交合计"; | ||
| 3294 | - num = "0"; | ||
| 3295 | - } | ||
| 3296 | - if("1".equals(sp[1])){ | ||
| 3297 | - type = "营运线路"; | ||
| 3298 | - } else if("2".equals(sp[1])){ | ||
| 3299 | - type = "非营运线路"; | ||
| 3300 | - } else if("0".equals(sp[1])){ | ||
| 3301 | - type = "小计"; | ||
| 3302 | - } | ||
| 3303 | - m1.put("gsName", gs); | ||
| 3304 | - m1.put("type", type); | ||
| 3305 | - m1.put("key", s); | ||
| 3306 | - m1.put("dataList", new ArrayList<Map<String, Object>>()); | ||
| 3307 | - list.add(m1); | ||
| 3308 | - keyMap.put(s, m1); | ||
| 3309 | - } | ||
| 3310 | - return strs; | ||
| 3311 | - } | ||
| 3312 | - | ||
| 3313 | -} | 1 | +package com.bsth.service.forms.impl; |
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.io.FileInputStream; | ||
| 5 | +import java.math.BigDecimal; | ||
| 6 | +import java.text.DecimalFormat; | ||
| 7 | +import java.text.ParseException; | ||
| 8 | +import java.text.SimpleDateFormat; | ||
| 9 | +import java.util.ArrayList; | ||
| 10 | +import java.util.Date; | ||
| 11 | +import java.util.HashMap; | ||
| 12 | +import java.util.HashSet; | ||
| 13 | +import java.util.Iterator; | ||
| 14 | +import java.util.List; | ||
| 15 | +import java.util.Map; | ||
| 16 | +import java.util.Set; | ||
| 17 | + | ||
| 18 | +import javax.transaction.Transactional; | ||
| 19 | + | ||
| 20 | +import org.apache.commons.lang3.StringEscapeUtils; | ||
| 21 | +import org.apache.poi.hssf.usermodel.HSSFCell; | ||
| 22 | +import org.apache.poi.hssf.usermodel.HSSFRow; | ||
| 23 | +import org.apache.poi.hssf.usermodel.HSSFSheet; | ||
| 24 | +import org.apache.poi.hssf.usermodel.HSSFWorkbook; | ||
| 25 | +import org.apache.poi.poifs.filesystem.POIFSFileSystem; | ||
| 26 | +import org.slf4j.Logger; | ||
| 27 | +import org.slf4j.LoggerFactory; | ||
| 28 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 29 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 30 | +import org.springframework.stereotype.Service; | ||
| 31 | + | ||
| 32 | +import com.alibaba.fastjson.JSONArray; | ||
| 33 | +import com.alibaba.fastjson.JSONObject; | ||
| 34 | +import com.bsth.common.ResponseCode; | ||
| 35 | +import com.bsth.data.BasicData; | ||
| 36 | +import com.bsth.entity.Line; | ||
| 37 | +import com.bsth.entity.calc.CalcStatistics; | ||
| 38 | +import com.bsth.entity.forms.Budget; | ||
| 39 | +import com.bsth.entity.forms.Revenue; | ||
| 40 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 41 | +import com.bsth.entity.schedule.TTInfoBxDetail; | ||
| 42 | +import com.bsth.entity.sys.Dictionary; | ||
| 43 | +import com.bsth.repository.calc.CalcStatisticsRepository; | ||
| 44 | +import com.bsth.repository.form.BudgetRepository; | ||
| 45 | +import com.bsth.repository.form.RevenueRepository; | ||
| 46 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | ||
| 47 | +import com.bsth.repository.schedule.CarConfigInfoRepository; | ||
| 48 | +import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | ||
| 49 | +import com.bsth.repository.schedule.SchedulePlanInfoRepository; | ||
| 50 | +import com.bsth.repository.schedule.TTInfoBxDetailRepository; | ||
| 51 | +import com.bsth.service.LineService; | ||
| 52 | +import com.bsth.service.forms.BudgetService; | ||
| 53 | +import com.bsth.service.impl.BaseServiceImpl; | ||
| 54 | +import com.bsth.service.sys.DictionaryService; | ||
| 55 | +import com.bsth.util.ReportUtils; | ||
| 56 | + | ||
| 57 | +@Service | ||
| 58 | +public class BudgetServiceImpl extends BaseServiceImpl<Budget, Integer> implements BudgetService{ | ||
| 59 | + | ||
| 60 | + @Autowired | ||
| 61 | + private BudgetRepository repository; | ||
| 62 | + | ||
| 63 | + @Autowired | ||
| 64 | + private RevenueRepository revenueRepository; | ||
| 65 | + | ||
| 66 | + @Autowired | ||
| 67 | + private LineService lineService; | ||
| 68 | + | ||
| 69 | + @Autowired | ||
| 70 | + private CarConfigInfoRepository ccRepository; | ||
| 71 | + | ||
| 72 | + @Autowired | ||
| 73 | + private EmployeeConfigInfoRepository ecRepository; | ||
| 74 | + | ||
| 75 | + @Autowired | ||
| 76 | + private CalcStatisticsRepository calcStatisticsRepository; | ||
| 77 | + | ||
| 78 | + @Autowired | ||
| 79 | + private SchedulePlanInfoRepository schedulePlanRepository; | ||
| 80 | + | ||
| 81 | + @Autowired | ||
| 82 | + private ScheduleRealInfoRepository scheduleRealRepository; | ||
| 83 | + | ||
| 84 | + @Autowired | ||
| 85 | + private TTInfoBxDetailRepository ttInfoBxDetailRepository; | ||
| 86 | + | ||
| 87 | + @Autowired | ||
| 88 | + private DictionaryService dictionaryService; | ||
| 89 | + | ||
| 90 | + @Autowired | ||
| 91 | + JdbcTemplate jdbcTemplate; | ||
| 92 | + | ||
| 93 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public String importExcel(File file) { | ||
| 97 | + SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); | ||
| 98 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 99 | + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 100 | + DecimalFormat df = new DecimalFormat("######0.000"); | ||
| 101 | + List<String> textList = new ArrayList<String>(); | ||
| 102 | + List<Budget> list = new ArrayList<Budget>(); | ||
| 103 | + String msg = "", tempMsg = ""; | ||
| 104 | + try { | ||
| 105 | + POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); | ||
| 106 | + HSSFWorkbook wb = new HSSFWorkbook(fs); | ||
| 107 | + HSSFSheet sheet = wb.getSheetAt(0); | ||
| 108 | + // 取得总行数 | ||
| 109 | + int rowNum = sheet.getLastRowNum() + 1; | ||
| 110 | + // 取得总列数 | ||
| 111 | + int cellNum = sheet.getRow(0).getLastCellNum(); | ||
| 112 | + HSSFRow row = null; | ||
| 113 | + HSSFCell cell = null; | ||
| 114 | + for(int i = 3; i < rowNum; i++){ | ||
| 115 | + row = sheet.getRow(i); | ||
| 116 | + if (row == null){ | ||
| 117 | + continue; | ||
| 118 | + } | ||
| 119 | + String text = ""; | ||
| 120 | + for(int j = 0; j < cellNum; j++){ | ||
| 121 | + cell = row.getCell(j); | ||
| 122 | + if(cell == null){ | ||
| 123 | + text += ","; | ||
| 124 | + continue; | ||
| 125 | + } | ||
| 126 | + text += String.valueOf(cell) + ","; | ||
| 127 | + } | ||
| 128 | + String[] split = (text+";").split(","); | ||
| 129 | + String str = ""; | ||
| 130 | + for(int j = 0; j < split.length && j < 5; j++){ | ||
| 131 | + str += split[j]; | ||
| 132 | + } | ||
| 133 | + if(str.trim().length() == 0){ | ||
| 134 | + continue; | ||
| 135 | + } | ||
| 136 | + textList.add(i + "," + text + ";"); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + Map<String, Line> lineMap = new HashMap<String, Line>(); | ||
| 140 | + Iterable<Line> findAllLine = lineService.findAll(); | ||
| 141 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 142 | + for(Line l : findAllLine){ | ||
| 143 | + if(BasicData.businessCodeNameMap.containsKey(l.getCompany())){ | ||
| 144 | +// String gsName = BasicData.businessCodeNameMap.get(l.getCompany()); | ||
| 145 | +// gsName = gsName.replaceAll("公司", ""); | ||
| 146 | +// lineMap.put(gsName + "_" + l.getName(), l); | ||
| 147 | + lineMap.put(l.getName(), l); | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + for(int i = 0; i < textList.size(); i++){ | ||
| 152 | + String text = textList.get(i); | ||
| 153 | + String[] split = text.split(","); | ||
| 154 | + int rowNo = Integer.valueOf(split[0].trim()); | ||
| 155 | + String year = split[1].trim(); | ||
| 156 | + String gsName = split[2].trim().replaceAll("公司", ""); | ||
| 157 | + String xlName = split[3].trim(); | ||
| 158 | + Line line = null; | ||
| 159 | + String gsBm = ""; | ||
| 160 | + for(String key : BasicData.businessCodeNameMap.keySet()){ | ||
| 161 | + String name = BasicData.businessCodeNameMap.get(key).replaceAll("公司", ""); | ||
| 162 | + if(name.equals(gsName)){ | ||
| 163 | + gsBm = key; | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + boolean sfyy = false; | ||
| 167 | + if(year.length() == 0){ | ||
| 168 | + msg += "第"+(rowNo+1)+"行,没有年份;\\n"; | ||
| 169 | + } else { | ||
| 170 | + try { | ||
| 171 | + yearFormat.parse(year); | ||
| 172 | + } catch (ParseException pe) { | ||
| 173 | + // TODO: handle exception | ||
| 174 | + pe.printStackTrace(); | ||
| 175 | + msg += "第"+(rowNo+1)+"行,年份书写错误;\\n"; | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + if(xlName.length() == 0){ | ||
| 179 | + msg += "第"+(rowNo+1)+"行,没有线路名;\\n"; | ||
| 180 | + } else { | ||
| 181 | + if(lineMap.containsKey(xlName)){ | ||
| 182 | + line = lineMap.get(xlName); | ||
| 183 | + sfyy = lineNature.containsKey(line.getLineCode())?lineNature.get(line.getLineCode()):false; | ||
| 184 | + } else { | ||
| 185 | + msg += "第"+(rowNo+1)+"行,线路基础信息无此线路;\\n"; | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + int left = 3; | ||
| 189 | + for(int mon = 1; mon <= 12; mon++){ | ||
| 190 | + String mileage = split[left+(mon-1)*3+1].trim(); | ||
| 191 | + String person = split[left+(mon-1)*3+2].trim(); | ||
| 192 | + String amounts = split[left+(mon-1)*3+3].trim(); | ||
| 193 | + Double formalMileage = null, formalPerson = null, formalAmounts = null; | ||
| 194 | + try { | ||
| 195 | + if(mileage.length() > 0){ | ||
| 196 | + formalMileage = Double.valueOf(df.format(Double.valueOf(mileage))); | ||
| 197 | + } | ||
| 198 | + if(person.length() > 0){ | ||
| 199 | + formalPerson = Double.valueOf(df.format(Double.valueOf(person))); | ||
| 200 | + } | ||
| 201 | + if(amounts.length() > 0){ | ||
| 202 | + formalAmounts = Double.valueOf(df.format(Double.valueOf(amounts))); | ||
| 203 | + } | ||
| 204 | + Budget b = new Budget(); | ||
| 205 | + b.setYear(year + "-" + (mon>9?mon:("0"+mon))); | ||
| 206 | + b.setGsBm(gsBm); | ||
| 207 | + b.setGsName(BasicData.businessCodeNameMap.get(gsBm)); | ||
| 208 | + b.setXlBm(line!=null?line.getLineCode():""); | ||
| 209 | + b.setXlName(line!=null?line.getName():""); | ||
| 210 | + b.setSfyy(sfyy); | ||
| 211 | + b.setFormalMileage(formalMileage); | ||
| 212 | + b.setFormalPerson(formalPerson); | ||
| 213 | + b.setFormalAmounts(formalAmounts); | ||
| 214 | + list.add(b); | ||
| 215 | + } catch (NumberFormatException nfe) { | ||
| 216 | + // TODO: handle exception | ||
| 217 | + nfe.printStackTrace(); | ||
| 218 | + msg += "第"+(rowNo+1)+"行,数字格式异常;\\n"; | ||
| 219 | + } | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + List<Budget> insertList = new ArrayList<Budget>(); | ||
| 224 | + if(msg.length() == 0){ | ||
| 225 | + for(Budget b : list){ | ||
| 226 | + List<Budget> budgets = repository.import_queryBySame(b.getYear(), b.getGsBm(), b.getXlBm()); | ||
| 227 | + if(budgets.size() > 0) { | ||
| 228 | + Budget bud = budgets.get(0); | ||
| 229 | + if(b.getFormalPerson() != null){ | ||
| 230 | + if(bud.getBudgetMileage() != null){ | ||
| 231 | + bud.setChangeMileage(b.getFormalMileage()); | ||
| 232 | + } else { | ||
| 233 | + bud.setBudgetMileage(b.getFormalMileage()); | ||
| 234 | + } | ||
| 235 | + bud.setFormalMileage(b.getFormalMileage()); | ||
| 236 | + } | ||
| 237 | + if(b.getFormalPerson() != null){ | ||
| 238 | + if(bud.getBudgetPerson() != null){ | ||
| 239 | + bud.setChangePerson(b.getFormalPerson()); | ||
| 240 | + } else { | ||
| 241 | + bud.setBudgetPerson(b.getFormalPerson()); | ||
| 242 | + } | ||
| 243 | + bud.setFormalPerson(b.getFormalPerson()); | ||
| 244 | + } | ||
| 245 | + if(b.getFormalAmounts() != null){ | ||
| 246 | + if(bud.getBudgetAmounts() != null){ | ||
| 247 | + bud.setChangeAmounts(b.getFormalAmounts()); | ||
| 248 | + } else { | ||
| 249 | + bud.setBudgetAmounts(b.getFormalAmounts()); | ||
| 250 | + } | ||
| 251 | + bud.setFormalAmounts(b.getFormalAmounts()); | ||
| 252 | + } | ||
| 253 | + repository.update(bud.getBudgetMileage(), bud.getChangeMileage(), bud.getFormalMileage(), | ||
| 254 | + bud.getBudgetPerson(), bud.getChangePerson(), bud.getFormalPerson(), | ||
| 255 | + bud.getBudgetAmounts(), bud.getChangeAmounts(), bud.getFormalAmounts(), bud.getId()); | ||
| 256 | + } else { | ||
| 257 | + b.setBudgetMileage(b.getFormalMileage()); | ||
| 258 | + b.setBudgetPerson(b.getFormalPerson()); | ||
| 259 | + b.setBudgetAmounts(b.getFormalAmounts()); | ||
| 260 | + insertList.add(b); | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + repository.saveAll(insertList); | ||
| 264 | + | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + wb.close(); | ||
| 268 | + fs.close(); | ||
| 269 | + }catch (Exception e) { | ||
| 270 | + // TODO Auto-generated catch block | ||
| 271 | + e.printStackTrace(); | ||
| 272 | + return msg.length()>0?msg:"文件导入失败"; | ||
| 273 | + } finally { | ||
| 274 | + file.delete(); | ||
| 275 | + } | ||
| 276 | + return msg.length()>0?msg:"文件导入成功"; | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + @Transactional | ||
| 280 | + @Override | ||
| 281 | + public Map<String, Object> deleteIds(Map<String, Object> map) throws Exception{ | ||
| 282 | + // TODO Auto-generated method stub | ||
| 283 | + Map<String, Object> maps = new HashMap<>(); | ||
| 284 | + try{ | ||
| 285 | + String json =StringEscapeUtils.unescapeHtml4(map.get("ids").toString()); | ||
| 286 | + JSONArray jsonArray=JSONArray.parseArray(json); | ||
| 287 | + JSONObject jsonObject; | ||
| 288 | + for (int x = 0; x < jsonArray.size(); x++) { | ||
| 289 | + jsonObject=jsonArray.getJSONObject(x); | ||
| 290 | + Long id = jsonObject.getLong("id"); | ||
| 291 | + Budget b = new Budget(); | ||
| 292 | + b.setId(id); | ||
| 293 | + repository.delete(b); | ||
| 294 | +// repository.deleteById(id); | ||
| 295 | + } | ||
| 296 | + | ||
| 297 | +// SysUser user = SecurityUtils.getCurrentUser(); | ||
| 298 | + maps.put("status", ResponseCode.SUCCESS); | ||
| 299 | + } catch (Exception e) { | ||
| 300 | + maps.put("status", ResponseCode.ERROR); | ||
| 301 | + logger.error("save erro.", e); | ||
| 302 | + throw e; | ||
| 303 | + } | ||
| 304 | + return maps; | ||
| 305 | + } | ||
| 306 | + | ||
| 307 | + @Override | ||
| 308 | + public void updateRevenueRange(String date1, String date2) { | ||
| 309 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 310 | + try { | ||
| 311 | + if(date1 == null || date2 == null | ||
| 312 | + || date1.trim().length() == 0 | ||
| 313 | + || date2.trim().length() == 0){ | ||
| 314 | + Date d = new Date(); | ||
| 315 | + d.setTime(d.getTime() - (1l * 1000 * 60 * 60 * 24)); | ||
| 316 | + date2 = sdf.format(d); | ||
| 317 | + d.setTime(d.getTime() - (8l * 1000 * 60 * 60 * 24)); | ||
| 318 | + date1 = sdf.format(d); | ||
| 319 | + } | ||
| 320 | + Date parse1 = sdf.parse(date1); | ||
| 321 | + Date parse2 = sdf.parse(date2); | ||
| 322 | + for(Date parse = new Date(parse1.getTime()); | ||
| 323 | + parse.getTime() <= parse2.getTime(); | ||
| 324 | + parse.setTime(parse.getTime() + 1l*1000*60*60*24)){ | ||
| 325 | + try { | ||
| 326 | + updateRevenue(sdf.format(parse)); | ||
| 327 | + } catch (Exception e) { | ||
| 328 | + // TODO: handle exception | ||
| 329 | + e.printStackTrace(); | ||
| 330 | + } | ||
| 331 | + } | ||
| 332 | + } catch (ParseException e) { | ||
| 333 | + // TODO: handle exception | ||
| 334 | + e.printStackTrace(); | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + @Override | ||
| 339 | + public Map<String, Object> updateRevenue(String date) throws Exception { | ||
| 340 | + // TODO Auto-generated method stub | ||
| 341 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 342 | + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMdd"); | ||
| 343 | + Map<String, Object> resMap=new HashMap<String, Object>(); | ||
| 344 | + Set<String> strSet = new HashSet<String>(); // 去重 | ||
| 345 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 346 | + Map<String, Map<String, Line>> lineMap = new HashMap<String, Map<String, Line>>(); | ||
| 347 | + Map<String, Line> lineAllMap = new HashMap<String, Line>(); | ||
| 348 | + Iterable<Line> findAllLine = lineService.findAll(); | ||
| 349 | + for(Line l : findAllLine){ | ||
| 350 | + if(!(lineMap.containsKey(l.getCompany()))){ | ||
| 351 | + lineMap.put(l.getCompany(), new HashMap<String, Line>()); | ||
| 352 | + } | ||
| 353 | + lineMap.get(l.getCompany()).put(l.getName(), l); | ||
| 354 | + lineAllMap.put(l.getName(), l); | ||
| 355 | + } | ||
| 356 | + Map<String, String> dictionMap = new HashMap<String, String>(); | ||
| 357 | + List<Map<String, String>> revenueDiction = revenueRepository.findRevenueDictionAll(); | ||
| 358 | + for(Map<String, String> m : revenueDiction){ | ||
| 359 | + dictionMap.put(m.get("ticket_line_name").toString(), m.get("local_line_name").toString()); | ||
| 360 | + } | ||
| 361 | + List<Revenue> list = new ArrayList<Revenue>(); | ||
| 362 | + Date parse = sdf.parse(date); | ||
| 363 | + String ymd = sdf2.format(parse); | ||
| 364 | + for(String gsBm : BasicData.businessCodeNameMap.keySet()){ | ||
| 365 | + List<Map<String, Object>> load = RevenueLoader.load(ymd, gsBm); | ||
| 366 | + if(load != null && load.size() > 0){ | ||
| 367 | + for(Map<String, Object> m : load){ | ||
| 368 | + if(m.containsKey("lineName")){ | ||
| 369 | + String fgsBm = m.get("branchCompanyCode") != null ? m.get("branchCompanyCode").toString() : ""; | ||
| 370 | + String lineName = m.get("lineName").toString().split("空调")[0].split("电车")[0]; | ||
| 371 | + Revenue r = new Revenue(); | ||
| 372 | + if(lineMap.get(gsBm) != null && lineMap.get(gsBm).containsKey(lineName)){ | ||
| 373 | + r.setXlBm(lineMap.get(gsBm).get(lineName).getLineCode()); | ||
| 374 | + r.setXlName(lineMap.get(gsBm).get(lineName).getName()); | ||
| 375 | + }if(dictionMap.containsKey(lineName)){ | ||
| 376 | + String name = dictionMap.get(lineName); | ||
| 377 | + if(lineAllMap.containsKey(name)){ | ||
| 378 | + r.setXlBm(lineAllMap.get(name).getLineCode()); | ||
| 379 | + r.setXlName(lineAllMap.get(name).getName()); | ||
| 380 | + } | ||
| 381 | + } else { | ||
| 382 | + for(String key : lineAllMap.keySet()){ | ||
| 383 | + Line l = lineAllMap.get(key); | ||
| 384 | + String name = l.getName(); | ||
| 385 | + if(l.getStartStationName() != null & l.getStartStationName().length() > 0){ | ||
| 386 | + name = name.replaceAll("区间", "") + l.getStartStationName().substring(0, 1); | ||
| 387 | + } | ||
| 388 | + if(l.getName().equals(lineName) || name.equals(lineName)){ | ||
| 389 | + r.setXlBm(l.getLineCode()); | ||
| 390 | + r.setXlName(l.getName()); | ||
| 391 | + break; | ||
| 392 | + } | ||
| 393 | + } | ||
| 394 | + } | ||
| 395 | + | ||
| 396 | + if(r.getXlBm() != null){ | ||
| 397 | + r.setScheduleDate(parse); | ||
| 398 | + r.setScheduleDateStr(date); | ||
| 399 | + r.setGsBm(gsBm); | ||
| 400 | + r.setGsName(BasicData.businessCodeNameMap.get(gsBm)); | ||
| 401 | + r.setFgsBm(fgsBm); | ||
| 402 | + r.setFgsName(BasicData.businessFgsCodeNameMap.get(fgsBm + "_" + gsBm)); | ||
| 403 | + r.setSfyy(lineNature.containsKey(r.getXlBm())?lineNature.get(r.getXlBm()):false); | ||
| 404 | + r.setNum(Long.valueOf(m.get("num").toString().split("[.]")[0])); | ||
| 405 | + r.setAmount(Double.valueOf(m.get("amount").toString())); | ||
| 406 | + String str = r.getGsBm() + "/" + r.getFgsBm() + "/" + r.getXlBm(); | ||
| 407 | + if(strSet.add(str)){ | ||
| 408 | + list.add(r); | ||
| 409 | + } | ||
| 410 | + } | ||
| 411 | + } | ||
| 412 | + } | ||
| 413 | + } | ||
| 414 | + } | ||
| 415 | + if(list.size() > 0){ | ||
| 416 | + revenueRepository.deleteByScheduleDate(date); | ||
| 417 | + revenueRepository.saveAll(list); | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + resMap.put("status", ResponseCode.SUCCESS); | ||
| 421 | + return resMap; | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + @Override | ||
| 425 | + public List<Map<String, Object>> budgetMileage(String year, String tttt, String kkk) { | ||
| 426 | + // TODO Auto-generated method stub | ||
| 427 | + SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 428 | + SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 429 | + DecimalFormat df = new DecimalFormat("0.###"); | ||
| 430 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 431 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 432 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 433 | + List<Budget> findByYear = repository.findByYear(year); | ||
| 434 | + List<CalcStatistics> list = calcStatisticsRepository.selectByDateAndLineTj3(year+"-01-01", year+"-12-31"); | ||
| 435 | + | ||
| 436 | + String year_1 = ""; | ||
| 437 | + try { | ||
| 438 | + year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 439 | + } catch (ParseException e) { | ||
| 440 | + // TODO Auto-generated catch block | ||
| 441 | + e.printStackTrace(); | ||
| 442 | + } | ||
| 443 | + List<CalcStatistics> scheduleList_1 = calcStatisticsRepository.selectByDateAndLineTj3(year_1+"-01-01", year_1+"-12-31"); | ||
| 444 | + | ||
| 445 | + Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 446 | + List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 447 | + | ||
| 448 | + String[] strs = createBudgetMap(resList, keyMap); | ||
| 449 | + | ||
| 450 | + for(Budget b : findByYear){ | ||
| 451 | + if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 452 | + continue; | ||
| 453 | + } | ||
| 454 | + if(b.getFormalMileage()==null || b.getFormalMileage() < 0d){ | ||
| 455 | + continue; | ||
| 456 | + } | ||
| 457 | + String gsBm = b.getGsBm(); | ||
| 458 | + String xlBm = b.getXlBm(); | ||
| 459 | + String xlName = b.getXlName(); | ||
| 460 | + int sfyy = b.getSfyy()?1:0; | ||
| 461 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 462 | + | ||
| 463 | + String key = gsBm + "_" + xlBm; | ||
| 464 | + if(!(xlMap.containsKey(key))){ | ||
| 465 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 466 | + m.put("gsBm", gsBm); | ||
| 467 | + m.put("gsName", b.getGsName()); | ||
| 468 | + m.put("xlBm", xlBm); | ||
| 469 | + m.put("xlName", xlName); | ||
| 470 | + m.put("sfyy", sfyy); | ||
| 471 | + m.put("sfjc", sfjc); | ||
| 472 | + m.put("budget", b.getBudgetMileage()!=null?df.format(b.getBudgetMileage()):""); | ||
| 473 | + m.put("change", b.getChangeMileage()!=null?df.format(b.getChangeMileage()):""); | ||
| 474 | + m.put("formal", b.getFormalMileage()!=null?df.format(b.getFormalMileage()):""); | ||
| 475 | + for(int i = 1; i <= 12; i++){ | ||
| 476 | + m.put("mon"+i, ""); | ||
| 477 | + m.put("bud"+i, ""); | ||
| 478 | + m.put("pre"+i, ""); | ||
| 479 | + } | ||
| 480 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 481 | + if(b.getFormalMileage()!=null){ | ||
| 482 | + m.put(bud, b.getFormalMileage()); | ||
| 483 | + } | ||
| 484 | + m.put("monAll", "0"); | ||
| 485 | + xlMap.put(key, m); | ||
| 486 | + xlList.add(m); | ||
| 487 | + } else { | ||
| 488 | + Map<String, Object> m = xlMap.get(key); | ||
| 489 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 490 | + if(b.getBudgetMileage()!=null){ | ||
| 491 | + if(m.get("budget").toString().length() > 0){ | ||
| 492 | + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 493 | + new BigDecimal(b.getBudgetMileage())).doubleValue())); | ||
| 494 | + } else { | ||
| 495 | + m.put("budget", df.format(b.getBudgetMileage())); | ||
| 496 | + } | ||
| 497 | + } | ||
| 498 | + if(b.getChangeMileage()!=null){ | ||
| 499 | + if(m.get("change").toString().length() > 0){ | ||
| 500 | + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 501 | + new BigDecimal(b.getChangeMileage())).doubleValue())); | ||
| 502 | + } else { | ||
| 503 | + m.put("change", df.format(b.getChangeMileage())); | ||
| 504 | + } | ||
| 505 | + } | ||
| 506 | + if(b.getFormalMileage()!=null){ | ||
| 507 | + if(m.get("formal").toString().length() > 0){ | ||
| 508 | + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 509 | + new BigDecimal(b.getFormalMileage())).doubleValue())); | ||
| 510 | + } else { | ||
| 511 | + m.put("formal", df.format(b.getFormalMileage())); | ||
| 512 | + } | ||
| 513 | + m.put(bud, df.format(b.getFormalMileage())); | ||
| 514 | + } | ||
| 515 | + } | ||
| 516 | + } | ||
| 517 | + | ||
| 518 | + for(CalcStatistics cs : list){ | ||
| 519 | + String gsBm = cs.getGsdm(); | ||
| 520 | + String xlBm = cs.getXl(); | ||
| 521 | + String xlName = cs.getXlName(); | ||
| 522 | + int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 523 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 524 | + | ||
| 525 | + String key = gsBm + "_" + xlBm; | ||
| 526 | + if(!(xlMap.containsKey(key))){ | ||
| 527 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 528 | + m.put("gsBm", gsBm); | ||
| 529 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 530 | + m.put("xlBm", xlBm); | ||
| 531 | + m.put("xlName", xlName); | ||
| 532 | + m.put("sfyy", sfyy); | ||
| 533 | + m.put("sfjc", sfjc); | ||
| 534 | + m.put("budget", ""); | ||
| 535 | + m.put("change", ""); | ||
| 536 | + m.put("formal", ""); | ||
| 537 | + for(int i = 1; i <= 12; i++){ | ||
| 538 | + m.put("mon"+i, ""); | ||
| 539 | + m.put("bud"+i, ""); | ||
| 540 | + m.put("pre"+i, ""); | ||
| 541 | + } | ||
| 542 | + m.put("monAll", "0"); | ||
| 543 | + xlMap.put(key, m); | ||
| 544 | + xlList.add(m); | ||
| 545 | + } | ||
| 546 | + Map<String, Object> map = xlMap.get(key); | ||
| 547 | + String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getDate())); | ||
| 548 | + String val = map.get(mon).toString(); | ||
| 549 | + BigDecimal sjzlc = new BigDecimal(cs.getSjzlc().toString()); | ||
| 550 | + if(val.length() == 0){ | ||
| 551 | + map.put(mon, sjzlc.doubleValue()); | ||
| 552 | + } else { | ||
| 553 | + map.put(mon, new BigDecimal(val).add(sjzlc).doubleValue()); | ||
| 554 | + } | ||
| 555 | + } | ||
| 556 | + | ||
| 557 | + for(CalcStatistics cs1 : scheduleList_1){ // 去年公里 | ||
| 558 | + String gsdm = cs1.getGsdm(); | ||
| 559 | + String xlBm = cs1.getXl(); | ||
| 560 | + String xlName = cs1.getXlName(); | ||
| 561 | + int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 562 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 563 | + | ||
| 564 | + String key = gsdm + "_" + xlBm; | ||
| 565 | + if(!(xlMap.containsKey(key))){ | ||
| 566 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 567 | + m.put("gsBm", gsdm); | ||
| 568 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsdm)); | ||
| 569 | + m.put("xlBm", xlBm); | ||
| 570 | + m.put("xlName", xlName); | ||
| 571 | + m.put("sfyy", sfyy); | ||
| 572 | + m.put("sfjc", sfjc); | ||
| 573 | + m.put("budget", ""); | ||
| 574 | + m.put("change", ""); | ||
| 575 | + m.put("formal", ""); | ||
| 576 | + for(int i = 1; i <= 12; i++){ | ||
| 577 | + m.put("mon"+i, ""); | ||
| 578 | + m.put("bud"+i, ""); | ||
| 579 | + m.put("pre"+i, ""); | ||
| 580 | + } | ||
| 581 | + m.put("monAll", "0"); | ||
| 582 | + xlMap.put(key, m); | ||
| 583 | + xlList.add(m); | ||
| 584 | + } | ||
| 585 | + Map<String, Object> map = xlMap.get(key); | ||
| 586 | + String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getDate())); | ||
| 587 | + String val = map.get(pre).toString(); | ||
| 588 | + BigDecimal num = new BigDecimal(cs1.getSjzlc().toString()); | ||
| 589 | + if(val.length() == 0){ | ||
| 590 | + map.put(pre, num.doubleValue()); | ||
| 591 | + } else { | ||
| 592 | + map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 593 | + } | ||
| 594 | + } | ||
| 595 | + | ||
| 596 | + for(Map<String, Object> m : xlList){ | ||
| 597 | + String gsBm = m.get("gsBm").toString(); | ||
| 598 | + int type = Integer.valueOf(m.get("sfyy").toString()); | ||
| 599 | + int item = Integer.valueOf(m.get("sfjc").toString()) == 1 ? 0 : 1; | ||
| 600 | + List<String> strList = new ArrayList<String>(); | ||
| 601 | + if(1 == type){ | ||
| 602 | + strList.add(gsBm + "_" + type + "_" + item); | ||
| 603 | + strList.add(gsBm + "_" + type + "_all"); | ||
| 604 | + } else { | ||
| 605 | + strList.add(gsBm + "_" + type); | ||
| 606 | + } | ||
| 607 | + strList.add(gsBm + "_all"); | ||
| 608 | + | ||
| 609 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 610 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 611 | + for(int i = 1; i <= 12; i++){ | ||
| 612 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 613 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 614 | + monAll = monAll.add(val); | ||
| 615 | + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 616 | + m.put("mon"+i, val.doubleValue()); | ||
| 617 | + } | ||
| 618 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 619 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 620 | + preAll = preAll.add(val); | ||
| 621 | + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 622 | + m.put("pre"+i, val.doubleValue()); | ||
| 623 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 624 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 625 | + BigDecimal sub = monVal.subtract(val); | ||
| 626 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 627 | + } else { | ||
| 628 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 629 | + } | ||
| 630 | + } | ||
| 631 | + } | ||
| 632 | + monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 633 | + preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 634 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 635 | + m.put("monAll", monAll.doubleValue()); | ||
| 636 | + m.put("preAll", preAll.doubleValue()); | ||
| 637 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 638 | + | ||
| 639 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 640 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 641 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 642 | + m.put("complete", monAll.divide( | ||
| 643 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 644 | + new BigDecimal(100)).divide( | ||
| 645 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 646 | + BigDecimal diff = monAll.subtract(formal); | ||
| 647 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 648 | + } else { | ||
| 649 | + m.put("complete", ""); | ||
| 650 | + m.put("diff", ""); | ||
| 651 | + } | ||
| 652 | + | ||
| 653 | + for(String str : strList){ | ||
| 654 | + if(!keyMap.containsKey(str)){ | ||
| 655 | + continue; | ||
| 656 | + } | ||
| 657 | + Map<String, Object> map = keyMap.get(str); | ||
| 658 | + if(m.get("budget").toString().length() > 0){ | ||
| 659 | + if(map.get("budget").toString().length() > 0){ | ||
| 660 | + map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 661 | + new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 662 | + } else { | ||
| 663 | + map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 664 | + } | ||
| 665 | + } | ||
| 666 | + if(m.get("change").toString().length() > 0){ | ||
| 667 | + if(map.get("change").toString().length() > 0){ | ||
| 668 | + map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 669 | + new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 670 | + } else { | ||
| 671 | + map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 672 | + } | ||
| 673 | + } | ||
| 674 | + if(m.get("formal").toString().length() > 0){ | ||
| 675 | + if(map.get("formal").toString().length() > 0){ | ||
| 676 | + map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 677 | + new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 678 | + } else { | ||
| 679 | + map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 680 | + } | ||
| 681 | + } | ||
| 682 | + for(int i = 1; i <= 12; i++){ | ||
| 683 | + String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 684 | + if(m.get(mon).toString().length() > 0){ | ||
| 685 | + if(map.get(mon).toString().length() > 0){ | ||
| 686 | + map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 687 | + new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 688 | + } else { | ||
| 689 | + map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 690 | + } | ||
| 691 | + } | ||
| 692 | + if(m.get(bud).toString().length() > 0){ | ||
| 693 | + if(map.get(bud).toString().length() > 0){ | ||
| 694 | + map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 695 | + new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 696 | + } else { | ||
| 697 | + map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 698 | + } | ||
| 699 | + } | ||
| 700 | + if(m.get(pre).toString().length() > 0){ | ||
| 701 | + if(map.get(pre).toString().length() > 0){ | ||
| 702 | + map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 703 | + new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 704 | + } else { | ||
| 705 | + map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 706 | + } | ||
| 707 | + } | ||
| 708 | + } | ||
| 709 | + List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 710 | + dataList.add(m); | ||
| 711 | + } | ||
| 712 | + } | ||
| 713 | + | ||
| 714 | + for(String key : strs){ | ||
| 715 | + if(!(key.contains("all_"))){ | ||
| 716 | + String[] sp = key.split("_"); | ||
| 717 | + String allKey = "all"; | ||
| 718 | + for(int i = 1; i < sp.length; i++){ | ||
| 719 | + allKey += "_" + sp[i]; | ||
| 720 | + } | ||
| 721 | + Map<String, Object> map = keyMap.get(key); | ||
| 722 | + Map<String, Object> allMap = keyMap.get(allKey); | ||
| 723 | + for(String k : map.keySet()){ | ||
| 724 | + if("year".equals(k)){ // 不想被计算的数字型字段 | ||
| 725 | + continue; | ||
| 726 | + } | ||
| 727 | + try { | ||
| 728 | + allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 729 | + new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 730 | + } catch (Exception e) { | ||
| 731 | + // TODO: handle exception | ||
| 732 | + } | ||
| 733 | + } | ||
| 734 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 735 | + dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 736 | + allMap.put("dataList", dataList); | ||
| 737 | + | ||
| 738 | + for(Map<String, Object> m : dataList){ | ||
| 739 | + for(int i = 1; i <= 12; i++){ | ||
| 740 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 741 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 742 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 743 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 744 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 745 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 746 | + } else { | ||
| 747 | + m.put("com" + i, ""); | ||
| 748 | + } | ||
| 749 | + } | ||
| 750 | + } | ||
| 751 | + } | ||
| 752 | + } | ||
| 753 | + | ||
| 754 | + for(String key : strs){ | ||
| 755 | + Map<String, Object> m = keyMap.get(key); | ||
| 756 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 757 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 758 | + for(int i = 1; i <= 12; i++){ | ||
| 759 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 760 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 761 | + monAll = monAll.add(val); | ||
| 762 | + } | ||
| 763 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 764 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 765 | + preAll = preAll.add(val); | ||
| 766 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 767 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 768 | + BigDecimal sub = monVal.subtract(val); | ||
| 769 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 770 | + } else { | ||
| 771 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 772 | + } | ||
| 773 | + } | ||
| 774 | + } | ||
| 775 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 776 | + m.put("monAll", monAll.doubleValue()); | ||
| 777 | + m.put("preAll", preAll.doubleValue()); | ||
| 778 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 779 | + | ||
| 780 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 781 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 782 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 783 | + m.put("complete", monAll.divide( | ||
| 784 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 785 | + new BigDecimal(100)).divide( | ||
| 786 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 787 | + BigDecimal diff = monAll.subtract(formal); | ||
| 788 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 789 | + } else { | ||
| 790 | + m.put("complete", ""); | ||
| 791 | + m.put("diff", ""); | ||
| 792 | + } | ||
| 793 | + m.put("year", year); | ||
| 794 | + | ||
| 795 | + for(int i = 1; i <= 12; i++){ | ||
| 796 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 797 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 798 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 799 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 800 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 801 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 802 | + } else { | ||
| 803 | + m.put("com" + i, ""); | ||
| 804 | + } | ||
| 805 | + } | ||
| 806 | + } | ||
| 807 | + | ||
| 808 | + if(tttt.equals("export")){ | ||
| 809 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 810 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 811 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 812 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 813 | + String xls="budgetMileage.xls"; | ||
| 814 | + ReportUtils ee = new ReportUtils(); | ||
| 815 | + try { | ||
| 816 | + String dateTime = ""; | ||
| 817 | + m.put("date", year); | ||
| 818 | + dateTime = year; | ||
| 819 | + listI.add(resList.iterator()); | ||
| 820 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 821 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 822 | + path + "export/"+dateTime+"-预算公里明细表.xls"); | ||
| 823 | + } catch (Exception e) { | ||
| 824 | + // TODO: handle exception | ||
| 825 | + e.printStackTrace(); | ||
| 826 | + } | ||
| 827 | + } | ||
| 828 | + | ||
| 829 | + if(tttt.equals("exportData")){ | ||
| 830 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 831 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 832 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 833 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 834 | + m.put("date", year); | ||
| 835 | + ReportUtils ee = new ReportUtils(); | ||
| 836 | + try { | ||
| 837 | + for(Map<String, Object> map : resList){ | ||
| 838 | + if(kkk.equals(map.get("key").toString())){ | ||
| 839 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 840 | + listI.add(dataList.iterator()); | ||
| 841 | + } | ||
| 842 | + } | ||
| 843 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 844 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetMileage_data.xls", | ||
| 845 | + path + "export/" + year + "-预算公里明细表-线路明细.xls"); | ||
| 846 | + } catch (Exception e) { | ||
| 847 | + // TODO: handle exception | ||
| 848 | + e.printStackTrace(); | ||
| 849 | + logger.info("", e); | ||
| 850 | + } | ||
| 851 | + } | ||
| 852 | + | ||
| 853 | + return resList; | ||
| 854 | + } | ||
| 855 | + | ||
| 856 | + @Override | ||
| 857 | + public List<Map<String, Object>> budgetPerson(String year, String tttt, String kkk) { | ||
| 858 | + // TODO Auto-generated method stub | ||
| 859 | + SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 860 | + SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 861 | + DecimalFormat df = new DecimalFormat("0.###"); | ||
| 862 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 863 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 864 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 865 | + List<Budget> findByYear = repository.findByYear(year); | ||
| 866 | + List<Revenue> list = revenueRepository.findByDates(year+"-01-01", year+"-12-31"); | ||
| 867 | + | ||
| 868 | + String year_1 = ""; | ||
| 869 | + try { | ||
| 870 | + year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 871 | + } catch (ParseException e) { | ||
| 872 | + // TODO Auto-generated catch block | ||
| 873 | + e.printStackTrace(); | ||
| 874 | + } | ||
| 875 | + List<Revenue> revenueList_1 = revenueRepository.findByDates(year_1+"-01-01", year_1+"-12-31"); | ||
| 876 | + | ||
| 877 | + Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 878 | + List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 879 | + | ||
| 880 | + String[] strs = createBudgetMap(resList, keyMap); | ||
| 881 | + | ||
| 882 | + for(Budget b : findByYear){ | ||
| 883 | + if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 884 | + continue; | ||
| 885 | + } | ||
| 886 | + if(b.getFormalPerson()==null || b.getFormalPerson() < 0d){ | ||
| 887 | + continue; | ||
| 888 | + } | ||
| 889 | + String gsBm = b.getGsBm(); | ||
| 890 | + String xlBm = b.getXlBm(); | ||
| 891 | + String xlName = b.getXlName(); | ||
| 892 | + int sfyy = b.getSfyy()?1:0; | ||
| 893 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 894 | + | ||
| 895 | + String key = gsBm + "_" + xlBm; | ||
| 896 | + if(!(xlMap.containsKey(key))){ | ||
| 897 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 898 | + m.put("gsBm", gsBm); | ||
| 899 | + m.put("gsName", b.getGsName()); | ||
| 900 | + m.put("xlBm", xlBm); | ||
| 901 | + m.put("xlName", xlName); | ||
| 902 | + m.put("sfyy", sfyy); | ||
| 903 | + m.put("sfjc", sfjc); | ||
| 904 | + m.put("budget", b.getBudgetPerson()!=null?df.format(b.getBudgetPerson()):""); | ||
| 905 | + m.put("change", b.getChangePerson()!=null?df.format(b.getChangePerson()):""); | ||
| 906 | + m.put("formal", b.getFormalPerson()!=null?df.format(b.getFormalPerson()):""); | ||
| 907 | + for(int i = 1; i <= 12; i++){ | ||
| 908 | + m.put("mon"+i, ""); | ||
| 909 | + m.put("bud"+i, ""); | ||
| 910 | + m.put("pre"+i, ""); | ||
| 911 | + } | ||
| 912 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 913 | + if(b.getFormalPerson()!=null){ | ||
| 914 | + m.put(bud, b.getFormalPerson()); | ||
| 915 | + } | ||
| 916 | + m.put("monAll", "0"); | ||
| 917 | + xlMap.put(key, m); | ||
| 918 | + xlList.add(m); | ||
| 919 | + } else { | ||
| 920 | + Map<String, Object> m = xlMap.get(key); | ||
| 921 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 922 | + if(b.getBudgetPerson()!=null){ | ||
| 923 | + if(m.get("budget").toString().length() > 0){ | ||
| 924 | + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 925 | + new BigDecimal(b.getBudgetPerson())).doubleValue())); | ||
| 926 | + } else { | ||
| 927 | + m.put("budget", df.format(b.getBudgetPerson())); | ||
| 928 | + } | ||
| 929 | + } | ||
| 930 | + if(b.getChangePerson()!=null){ | ||
| 931 | + if(m.get("change").toString().length() > 0){ | ||
| 932 | + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 933 | + new BigDecimal(b.getChangePerson())).doubleValue())); | ||
| 934 | + } else { | ||
| 935 | + m.put("change", df.format(b.getChangePerson())); | ||
| 936 | + } | ||
| 937 | + } | ||
| 938 | + if(b.getFormalPerson()!=null){ | ||
| 939 | + if(m.get("formal").toString().length() > 0){ | ||
| 940 | + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 941 | + new BigDecimal(b.getFormalPerson())).doubleValue())); | ||
| 942 | + } else { | ||
| 943 | + m.put("formal", df.format(b.getFormalPerson())); | ||
| 944 | + } | ||
| 945 | + m.put(bud, df.format(b.getFormalPerson())); | ||
| 946 | + } | ||
| 947 | + } | ||
| 948 | + } | ||
| 949 | + | ||
| 950 | + for(Revenue cs : list){ | ||
| 951 | + String gsBm = cs.getGsBm(); | ||
| 952 | + String xlBm = cs.getXlBm(); | ||
| 953 | + String xlName = cs.getXlName(); | ||
| 954 | + int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 955 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 956 | + | ||
| 957 | + String key = gsBm + "_" + xlBm; | ||
| 958 | + if(!(xlMap.containsKey(key))){ | ||
| 959 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 960 | + m.put("gsBm", gsBm); | ||
| 961 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 962 | + m.put("xlBm", xlBm); | ||
| 963 | + m.put("xlName", xlName); | ||
| 964 | + m.put("sfyy", sfyy); | ||
| 965 | + m.put("sfjc", sfjc); | ||
| 966 | + m.put("budget", ""); | ||
| 967 | + m.put("change", ""); | ||
| 968 | + m.put("formal", ""); | ||
| 969 | + for(int i = 1; i <= 12; i++){ | ||
| 970 | + m.put("mon"+i, ""); | ||
| 971 | + m.put("bud"+i, ""); | ||
| 972 | + m.put("pre"+i, ""); | ||
| 973 | + } | ||
| 974 | + m.put("monAll", "0"); | ||
| 975 | + xlMap.put(key, m); | ||
| 976 | + xlList.add(m); | ||
| 977 | + } | ||
| 978 | + Map<String, Object> map = xlMap.get(key); | ||
| 979 | + String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 980 | + String val = map.get(mon).toString(); | ||
| 981 | + BigDecimal num = new BigDecimal(cs.getNum().toString()); | ||
| 982 | + if(val.length() == 0){ | ||
| 983 | + map.put(mon, num.doubleValue()); | ||
| 984 | + } else { | ||
| 985 | + map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 986 | + } | ||
| 987 | + } | ||
| 988 | + | ||
| 989 | + for(Revenue cs1 : revenueList_1){ // 去年人次与营收 | ||
| 990 | + String gsBm = cs1.getGsBm(); | ||
| 991 | + String xlBm = cs1.getXlBm(); | ||
| 992 | + String xlName = cs1.getXlName(); | ||
| 993 | + int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 994 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 995 | + | ||
| 996 | + { // 去年人次 | ||
| 997 | + String key = gsBm + "_" + xlBm; | ||
| 998 | + if(!(xlMap.containsKey(key))){ | ||
| 999 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1000 | + m.put("gsBm", gsBm); | ||
| 1001 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 1002 | + m.put("xlBm", xlBm); | ||
| 1003 | + m.put("xlName", xlName); | ||
| 1004 | + m.put("sfyy", sfyy); | ||
| 1005 | + m.put("sfjc", sfjc); | ||
| 1006 | + m.put("budget", ""); | ||
| 1007 | + m.put("change", ""); | ||
| 1008 | + m.put("formal", ""); | ||
| 1009 | + for(int i = 1; i <= 12; i++){ | ||
| 1010 | + m.put("mon"+i, ""); | ||
| 1011 | + m.put("bud"+i, ""); | ||
| 1012 | + m.put("pre"+i, ""); | ||
| 1013 | + } | ||
| 1014 | + m.put("monAll", "0"); | ||
| 1015 | + xlMap.put(key, m); | ||
| 1016 | + xlList.add(m); | ||
| 1017 | + } | ||
| 1018 | + Map<String, Object> map = xlMap.get(key); | ||
| 1019 | + String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 1020 | + String val = map.get(pre).toString(); | ||
| 1021 | + BigDecimal num = new BigDecimal(cs1.getNum().toString()); | ||
| 1022 | + if(val.length() == 0){ | ||
| 1023 | + map.put(pre, num.doubleValue()); | ||
| 1024 | + } else { | ||
| 1025 | + map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 1026 | + } | ||
| 1027 | + } | ||
| 1028 | + } | ||
| 1029 | + | ||
| 1030 | + for(Map<String, Object> m : xlList){ | ||
| 1031 | + String gsBm = m.get("gsBm").toString(); | ||
| 1032 | + int type = Integer.valueOf(m.get("sfyy").toString()); | ||
| 1033 | + int item = Integer.valueOf(m.get("sfjc").toString()) == 1 ? 0 : 1; | ||
| 1034 | + List<String> strList = new ArrayList<String>(); | ||
| 1035 | + if(1 == type){ | ||
| 1036 | + strList.add(gsBm + "_" + type + "_" + item); | ||
| 1037 | + strList.add(gsBm + "_" + type + "_all"); | ||
| 1038 | + } else { | ||
| 1039 | + strList.add(gsBm + "_" + type); | ||
| 1040 | + } | ||
| 1041 | + strList.add(gsBm + "_all"); | ||
| 1042 | + | ||
| 1043 | + for(String str : strList){ | ||
| 1044 | + if(!keyMap.containsKey(str)){ | ||
| 1045 | + continue; | ||
| 1046 | + } | ||
| 1047 | + Map<String, Object> map = keyMap.get(str); | ||
| 1048 | + if(m.get("budget").toString().length() > 0){ | ||
| 1049 | + if(map.get("budget").toString().length() > 0){ | ||
| 1050 | + map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 1051 | + new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 1052 | + } else { | ||
| 1053 | + map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 1054 | + } | ||
| 1055 | + } | ||
| 1056 | + if(m.get("change").toString().length() > 0){ | ||
| 1057 | + if(map.get("change").toString().length() > 0){ | ||
| 1058 | + map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 1059 | + new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 1060 | + } else { | ||
| 1061 | + map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 1062 | + } | ||
| 1063 | + } | ||
| 1064 | + if(m.get("formal").toString().length() > 0){ | ||
| 1065 | + if(map.get("formal").toString().length() > 0){ | ||
| 1066 | + map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 1067 | + new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 1068 | + } else { | ||
| 1069 | + map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 1070 | + } | ||
| 1071 | + } | ||
| 1072 | + for(int i = 1; i <= 12; i++){ | ||
| 1073 | + String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 1074 | + if(m.get(mon).toString().length() > 0){ | ||
| 1075 | + if(map.get(mon).toString().length() > 0){ | ||
| 1076 | + map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 1077 | + new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 1078 | + } else { | ||
| 1079 | + map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 1080 | + } | ||
| 1081 | + } | ||
| 1082 | + if(m.get(bud).toString().length() > 0){ | ||
| 1083 | + if(map.get(bud).toString().length() > 0){ | ||
| 1084 | + map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 1085 | + new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 1086 | + } else { | ||
| 1087 | + map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 1088 | + } | ||
| 1089 | + } | ||
| 1090 | + if(m.get(pre).toString().length() > 0){ | ||
| 1091 | + if(map.get(pre).toString().length() > 0){ | ||
| 1092 | + map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 1093 | + new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 1094 | + } else { | ||
| 1095 | + map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 1096 | + } | ||
| 1097 | + } | ||
| 1098 | + } | ||
| 1099 | + List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1100 | + dataList.add(m); | ||
| 1101 | + } | ||
| 1102 | + | ||
| 1103 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 1104 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 1105 | + for(int i = 1; i <= 12; i++){ | ||
| 1106 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1107 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1108 | + monAll = monAll.add(val); | ||
| 1109 | + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1110 | + m.put("mon"+i, val.doubleValue()); | ||
| 1111 | + } | ||
| 1112 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 1113 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1114 | + preAll = preAll.add(val); | ||
| 1115 | + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1116 | + m.put("pre"+i, val.doubleValue()); | ||
| 1117 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1118 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1119 | + BigDecimal sub = monVal.subtract(val); | ||
| 1120 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1121 | + } else { | ||
| 1122 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1123 | + } | ||
| 1124 | + } | ||
| 1125 | + } | ||
| 1126 | + monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1127 | + preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1128 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1129 | + m.put("monAll", monAll.doubleValue()); | ||
| 1130 | + m.put("preAll", preAll.doubleValue()); | ||
| 1131 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1132 | + | ||
| 1133 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1134 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1135 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1136 | + m.put("complete", monAll.divide( | ||
| 1137 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1138 | + new BigDecimal(100)).divide( | ||
| 1139 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1140 | + BigDecimal diff = monAll.subtract(formal); | ||
| 1141 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1142 | + } else { | ||
| 1143 | + m.put("complete", ""); | ||
| 1144 | + m.put("diff", ""); | ||
| 1145 | + } | ||
| 1146 | + } | ||
| 1147 | + | ||
| 1148 | + for(String key : strs){ | ||
| 1149 | + if(!(key.contains("all_"))){ | ||
| 1150 | + String[] sp = key.split("_"); | ||
| 1151 | + String allKey = "all"; | ||
| 1152 | + for(int i = 1; i < sp.length; i++){ | ||
| 1153 | + allKey += "_" + sp[i]; | ||
| 1154 | + } | ||
| 1155 | + Map<String, Object> map = keyMap.get(key); | ||
| 1156 | + Map<String, Object> allMap = keyMap.get(allKey); | ||
| 1157 | + for(String k : map.keySet()){ | ||
| 1158 | + if("year".equals(k)){ // 不想被计算的数字型字段 | ||
| 1159 | + continue; | ||
| 1160 | + } | ||
| 1161 | + try { | ||
| 1162 | + allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 1163 | + new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 1164 | + } catch (Exception e) { | ||
| 1165 | + // TODO: handle exception | ||
| 1166 | + } | ||
| 1167 | + } | ||
| 1168 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 1169 | + dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 1170 | + allMap.put("dataList", dataList); | ||
| 1171 | + | ||
| 1172 | + for(Map<String, Object> m : dataList){ | ||
| 1173 | + for(int i = 1; i <= 12; i++){ | ||
| 1174 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 1175 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1176 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1177 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1178 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1179 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1180 | + } else { | ||
| 1181 | + m.put("com" + i, ""); | ||
| 1182 | + } | ||
| 1183 | + } | ||
| 1184 | + } | ||
| 1185 | + } | ||
| 1186 | + } | ||
| 1187 | + | ||
| 1188 | + for(String key : strs){ | ||
| 1189 | + Map<String, Object> m = keyMap.get(key); | ||
| 1190 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 1191 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 1192 | + for(int i = 1; i <= 12; i++){ | ||
| 1193 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1194 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1195 | + monAll = monAll.add(val); | ||
| 1196 | + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1197 | + m.put("mon"+i, val.doubleValue()); | ||
| 1198 | + } | ||
| 1199 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 1200 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1201 | + preAll = preAll.add(val); | ||
| 1202 | + val = val.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1203 | + m.put("pre"+i, val.doubleValue()); | ||
| 1204 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1205 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1206 | + BigDecimal sub = monVal.subtract(val); | ||
| 1207 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1208 | + } else { | ||
| 1209 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1210 | + } | ||
| 1211 | + } | ||
| 1212 | + } | ||
| 1213 | + monAll = monAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1214 | + preAll = preAll.divide(new BigDecimal("10000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1215 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1216 | + m.put("monAll", monAll.doubleValue()); | ||
| 1217 | + m.put("preAll", preAll.doubleValue()); | ||
| 1218 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1219 | + | ||
| 1220 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1221 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1222 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1223 | + m.put("complete", monAll.divide( | ||
| 1224 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1225 | + new BigDecimal(100)).divide( | ||
| 1226 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1227 | + BigDecimal diff = monAll.subtract(formal); | ||
| 1228 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1229 | + } else { | ||
| 1230 | + m.put("complete", ""); | ||
| 1231 | + m.put("diff", ""); | ||
| 1232 | + } | ||
| 1233 | + m.put("year", year); | ||
| 1234 | + | ||
| 1235 | + for(int i = 1; i <= 12; i++){ | ||
| 1236 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 1237 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1238 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1239 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1240 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1241 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1242 | + } else { | ||
| 1243 | + m.put("com" + i, ""); | ||
| 1244 | + } | ||
| 1245 | + } | ||
| 1246 | + } | ||
| 1247 | + | ||
| 1248 | + if(tttt.equals("export")){ | ||
| 1249 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1250 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1251 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1252 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1253 | + String xls="budgetPerson.xls"; | ||
| 1254 | + ReportUtils ee = new ReportUtils(); | ||
| 1255 | + try { | ||
| 1256 | + String dateTime = ""; | ||
| 1257 | + m.put("date", year); | ||
| 1258 | + dateTime = year; | ||
| 1259 | + listI.add(resList.iterator()); | ||
| 1260 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1261 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 1262 | + path + "export/"+dateTime+"-预算人次明细表.xls"); | ||
| 1263 | + } catch (Exception e) { | ||
| 1264 | + // TODO: handle exception | ||
| 1265 | + e.printStackTrace(); | ||
| 1266 | + } | ||
| 1267 | + } | ||
| 1268 | + | ||
| 1269 | + if(tttt.equals("exportData")){ | ||
| 1270 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1271 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1272 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1273 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1274 | + m.put("date", year); | ||
| 1275 | + ReportUtils ee = new ReportUtils(); | ||
| 1276 | + try { | ||
| 1277 | + for(Map<String, Object> map : resList){ | ||
| 1278 | + if(kkk.equals(map.get("key").toString())){ | ||
| 1279 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1280 | + listI.add(dataList.iterator()); | ||
| 1281 | + } | ||
| 1282 | + } | ||
| 1283 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1284 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetPerson_data.xls", | ||
| 1285 | + path + "export/" + year + "-预算人次明细表-线路明细.xls"); | ||
| 1286 | + } catch (Exception e) { | ||
| 1287 | + // TODO: handle exception | ||
| 1288 | + e.printStackTrace(); | ||
| 1289 | + logger.info("", e); | ||
| 1290 | + } | ||
| 1291 | + } | ||
| 1292 | + | ||
| 1293 | + return resList; | ||
| 1294 | + } | ||
| 1295 | + | ||
| 1296 | + @Override | ||
| 1297 | + public List<Map<String, Object>> budgetAmounts(String year, String tttt, String kkk) { | ||
| 1298 | + // TODO Auto-generated method stub | ||
| 1299 | + SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 1300 | + SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 1301 | + DecimalFormat df = new DecimalFormat("0.###"); | ||
| 1302 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 1303 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 1304 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 1305 | + List<Budget> findByYear = repository.findByYear(year); | ||
| 1306 | + List<Revenue> list = revenueRepository.findByDates(year+"-01-01", year+"-12-31"); | ||
| 1307 | + | ||
| 1308 | + String year_1 = ""; | ||
| 1309 | + try { | ||
| 1310 | + year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 1311 | + } catch (ParseException e) { | ||
| 1312 | + // TODO Auto-generated catch block | ||
| 1313 | + e.printStackTrace(); | ||
| 1314 | + } | ||
| 1315 | + List<CalcStatistics> scheduleList_1 = calcStatisticsRepository.selectByDateAndLineTj3(year_1+"-01-01", year_1+"-12-31"); | ||
| 1316 | + List<Revenue> revenueList_1 = revenueRepository.findByDates(year_1+"-01-01", year_1+"-12-31"); | ||
| 1317 | + | ||
| 1318 | + Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 1319 | + List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 1320 | + | ||
| 1321 | + String[] strs = createBudgetMap(resList, keyMap); | ||
| 1322 | + | ||
| 1323 | + for(Budget b : findByYear){ | ||
| 1324 | + if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 1325 | + continue; | ||
| 1326 | + } | ||
| 1327 | + if(b.getFormalAmounts()==null || b.getFormalAmounts() < 0d){ | ||
| 1328 | + continue; | ||
| 1329 | + } | ||
| 1330 | + String gsBm = b.getGsBm(); | ||
| 1331 | + String xlBm = b.getXlBm(); | ||
| 1332 | + String xlName = b.getXlName(); | ||
| 1333 | + int sfyy = b.getSfyy()?1:0; | ||
| 1334 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 1335 | + | ||
| 1336 | + String key = gsBm + "_" + xlBm; | ||
| 1337 | + if(!(xlMap.containsKey(key))){ | ||
| 1338 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1339 | + m.put("gsBm", gsBm); | ||
| 1340 | + m.put("gsName", b.getGsName()); | ||
| 1341 | + m.put("xlBm", xlBm); | ||
| 1342 | + m.put("xlName", xlName); | ||
| 1343 | + m.put("sfyy", sfyy); | ||
| 1344 | + m.put("sfjc", sfjc); | ||
| 1345 | + m.put("budget", b.getBudgetAmounts()!=null?df.format(b.getBudgetAmounts()):""); | ||
| 1346 | + m.put("change", b.getChangeAmounts()!=null?df.format(b.getChangeAmounts()):""); | ||
| 1347 | + m.put("formal", b.getFormalAmounts()!=null?df.format(b.getFormalAmounts()):""); | ||
| 1348 | + for(int i = 1; i <= 12; i++){ | ||
| 1349 | + m.put("mon"+i, ""); | ||
| 1350 | + m.put("bud"+i, ""); | ||
| 1351 | + m.put("pre"+i, ""); | ||
| 1352 | + } | ||
| 1353 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1354 | + if(b.getFormalAmounts()!=null){ | ||
| 1355 | + m.put(bud, b.getFormalAmounts()); | ||
| 1356 | + } | ||
| 1357 | + m.put("monAll", "0"); | ||
| 1358 | + m.put("num", "0"); | ||
| 1359 | + xlMap.put(key, m); | ||
| 1360 | + xlList.add(m); | ||
| 1361 | + } else { | ||
| 1362 | + Map<String, Object> m = xlMap.get(key); | ||
| 1363 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1364 | + if(b.getBudgetAmounts()!=null){ | ||
| 1365 | + if(m.get("budget").toString().length() > 0){ | ||
| 1366 | + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1367 | + new BigDecimal(b.getBudgetAmounts())).doubleValue())); | ||
| 1368 | + } else { | ||
| 1369 | + m.put("budget", df.format(b.getBudgetAmounts())); | ||
| 1370 | + } | ||
| 1371 | + } | ||
| 1372 | + if(b.getChangeAmounts()!=null){ | ||
| 1373 | + if(m.get("change").toString().length() > 0){ | ||
| 1374 | + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1375 | + new BigDecimal(b.getChangeAmounts())).doubleValue())); | ||
| 1376 | + } else { | ||
| 1377 | + m.put("change", df.format(b.getChangeAmounts())); | ||
| 1378 | + } | ||
| 1379 | + } | ||
| 1380 | + if(b.getFormalAmounts()!=null){ | ||
| 1381 | + if(m.get("formal").toString().length() > 0){ | ||
| 1382 | + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1383 | + new BigDecimal(b.getFormalAmounts())).doubleValue())); | ||
| 1384 | + } else { | ||
| 1385 | + m.put("formal", df.format(b.getFormalAmounts())); | ||
| 1386 | + } | ||
| 1387 | + m.put(bud, df.format(b.getFormalAmounts())); | ||
| 1388 | + } | ||
| 1389 | + } | ||
| 1390 | + } | ||
| 1391 | + | ||
| 1392 | + for(Revenue cs : list){ | ||
| 1393 | + String gsBm = cs.getGsBm(); | ||
| 1394 | + String xlBm = cs.getXlBm(); | ||
| 1395 | + String xlName = cs.getXlName(); | ||
| 1396 | + int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 1397 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 1398 | + | ||
| 1399 | + String key = gsBm + "_" + xlBm; | ||
| 1400 | + if(!(xlMap.containsKey(key))){ | ||
| 1401 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1402 | + m.put("gsBm", gsBm); | ||
| 1403 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 1404 | + m.put("xlBm", xlBm); | ||
| 1405 | + m.put("xlName", xlName); | ||
| 1406 | + m.put("sfyy", sfyy); | ||
| 1407 | + m.put("sfjc", sfjc); | ||
| 1408 | + m.put("budget", ""); | ||
| 1409 | + m.put("change", ""); | ||
| 1410 | + m.put("formal", ""); | ||
| 1411 | + for(int i = 1; i <= 12; i++){ | ||
| 1412 | + m.put("mon"+i, ""); | ||
| 1413 | + m.put("bud"+i, ""); | ||
| 1414 | + m.put("pre"+i, ""); | ||
| 1415 | + } | ||
| 1416 | + m.put("monAll", "0"); | ||
| 1417 | + m.put("num", "0"); | ||
| 1418 | + xlMap.put(key, m); | ||
| 1419 | + xlList.add(m); | ||
| 1420 | + } | ||
| 1421 | + Map<String, Object> map = xlMap.get(key); | ||
| 1422 | + String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 1423 | + String val = map.get(mon).toString(); | ||
| 1424 | + BigDecimal amount = new BigDecimal(cs.getAmount().toString()); | ||
| 1425 | + if(val.length() == 0){ | ||
| 1426 | + map.put(mon, amount.doubleValue()); | ||
| 1427 | + } else { | ||
| 1428 | + map.put(mon, new BigDecimal(val).add(amount).doubleValue()); | ||
| 1429 | + } | ||
| 1430 | + | ||
| 1431 | + BigDecimal num = new BigDecimal(cs.getNum().toString()); | ||
| 1432 | + if(map.containsKey("num")){ | ||
| 1433 | + map.put("num", new BigDecimal(map.get("num").toString()).add(num).doubleValue()); | ||
| 1434 | + } else { | ||
| 1435 | + map.put("num", num.doubleValue()); | ||
| 1436 | + } | ||
| 1437 | + } | ||
| 1438 | + | ||
| 1439 | + for(Revenue cs1 : revenueList_1){ // 去年人次与营收 | ||
| 1440 | + String gsBm = cs1.getGsBm(); | ||
| 1441 | + String xlBm = cs1.getXlBm(); | ||
| 1442 | + String xlName = cs1.getXlName(); | ||
| 1443 | + int sfyy = lineNature.containsKey(xlBm)&&lineNature.get(xlBm)?1:0; | ||
| 1444 | + int sfjc = xlName.contains("机场")?1:0; | ||
| 1445 | + | ||
| 1446 | + { // 去年营收 | ||
| 1447 | + String key = gsBm + "_" + xlBm; | ||
| 1448 | + if(!(xlMap.containsKey(key))){ | ||
| 1449 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1450 | + m.put("gsBm", gsBm); | ||
| 1451 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 1452 | + m.put("xlBm", xlBm); | ||
| 1453 | + m.put("xlName", xlName); | ||
| 1454 | + m.put("sfyy", sfyy); | ||
| 1455 | + m.put("sfjc", sfjc); | ||
| 1456 | + m.put("budget", ""); | ||
| 1457 | + m.put("change", ""); | ||
| 1458 | + m.put("formal", ""); | ||
| 1459 | + for(int i = 1; i <= 12; i++){ | ||
| 1460 | + m.put("mon"+i, ""); | ||
| 1461 | + m.put("bud"+i, ""); | ||
| 1462 | + m.put("pre"+i, ""); | ||
| 1463 | + } | ||
| 1464 | + m.put("monAll", "0"); | ||
| 1465 | + xlMap.put(key, m); | ||
| 1466 | + xlList.add(m); | ||
| 1467 | + } | ||
| 1468 | + Map<String, Object> map = xlMap.get(key); | ||
| 1469 | + String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 1470 | + String val = map.get(pre).toString(); | ||
| 1471 | + BigDecimal num = new BigDecimal(cs1.getAmount().toString()); | ||
| 1472 | + if(val.length() == 0){ | ||
| 1473 | + map.put(pre, num.doubleValue()); | ||
| 1474 | + } else { | ||
| 1475 | + map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 1476 | + } | ||
| 1477 | + } | ||
| 1478 | + } | ||
| 1479 | + | ||
| 1480 | + for(Map<String, Object> m : xlList){ | ||
| 1481 | + String gsBm = m.get("gsBm").toString(); | ||
| 1482 | + int type = Integer.valueOf(m.get("sfyy").toString()); | ||
| 1483 | + int item = Integer.valueOf(m.get("sfjc").toString()) == 1 ? 0 : 1; | ||
| 1484 | + List<String> strList = new ArrayList<String>(); | ||
| 1485 | + if(1 == type){ | ||
| 1486 | + strList.add(gsBm + "_" + type + "_" + item); | ||
| 1487 | + strList.add(gsBm + "_" + type + "_all"); | ||
| 1488 | + } else { | ||
| 1489 | + strList.add(gsBm + "_" + type); | ||
| 1490 | + } | ||
| 1491 | + strList.add(gsBm + "_all"); | ||
| 1492 | + | ||
| 1493 | + for(String str : strList){ | ||
| 1494 | + if(!keyMap.containsKey(str)){ | ||
| 1495 | + continue; | ||
| 1496 | + } | ||
| 1497 | + Map<String, Object> map = keyMap.get(str); | ||
| 1498 | + if(m.get("budget").toString().length() > 0){ | ||
| 1499 | + if(map.get("budget").toString().length() > 0){ | ||
| 1500 | + map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 1501 | + new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 1502 | + } else { | ||
| 1503 | + map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 1504 | + } | ||
| 1505 | + } | ||
| 1506 | + if(m.get("change").toString().length() > 0){ | ||
| 1507 | + if(map.get("change").toString().length() > 0){ | ||
| 1508 | + map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 1509 | + new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 1510 | + } else { | ||
| 1511 | + map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 1512 | + } | ||
| 1513 | + } | ||
| 1514 | + if(m.get("formal").toString().length() > 0){ | ||
| 1515 | + if(map.get("formal").toString().length() > 0){ | ||
| 1516 | + map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 1517 | + new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 1518 | + } else { | ||
| 1519 | + map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 1520 | + } | ||
| 1521 | + } | ||
| 1522 | + for(int i = 1; i <= 12; i++){ | ||
| 1523 | + String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 1524 | + if(m.get(mon).toString().length() > 0){ | ||
| 1525 | + if(map.get(mon).toString().length() > 0){ | ||
| 1526 | + map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 1527 | + new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 1528 | + } else { | ||
| 1529 | + map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 1530 | + } | ||
| 1531 | + } | ||
| 1532 | + if(m.get(bud).toString().length() > 0){ | ||
| 1533 | + if(map.get(bud).toString().length() > 0){ | ||
| 1534 | + map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 1535 | + new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 1536 | + } else { | ||
| 1537 | + map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 1538 | + } | ||
| 1539 | + } | ||
| 1540 | + if(m.get(pre).toString().length() > 0){ | ||
| 1541 | + if(map.get(pre).toString().length() > 0){ | ||
| 1542 | + map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 1543 | + new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 1544 | + } else { | ||
| 1545 | + map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 1546 | + } | ||
| 1547 | + } | ||
| 1548 | + } | ||
| 1549 | + if(m.containsKey("num") && m.get("num").toString().length() > 0){ | ||
| 1550 | + if(map.containsKey("num") && map.get("num").toString().length() > 0){ | ||
| 1551 | + map.put("num", new BigDecimal(m.get("num").toString()).add( | ||
| 1552 | + new BigDecimal(map.get("num").toString())).doubleValue()); | ||
| 1553 | + } else { | ||
| 1554 | + map.put("num", new BigDecimal(m.get("num").toString()).doubleValue()); | ||
| 1555 | + } | ||
| 1556 | + } | ||
| 1557 | + List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1558 | + dataList.add(m); | ||
| 1559 | + } | ||
| 1560 | + | ||
| 1561 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 1562 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 1563 | + for(int i = 1; i <= 12; i++){ | ||
| 1564 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1565 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1566 | + monAll = monAll.add(val); | ||
| 1567 | + val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1568 | + m.put("mon"+i, val.doubleValue()); | ||
| 1569 | + } | ||
| 1570 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 1571 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1572 | + preAll = preAll.add(val); | ||
| 1573 | + val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1574 | + m.put("pre"+i, val.doubleValue()); | ||
| 1575 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1576 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1577 | + BigDecimal sub = monVal.subtract(val); | ||
| 1578 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1579 | + } else { | ||
| 1580 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1581 | + } | ||
| 1582 | + } | ||
| 1583 | + } | ||
| 1584 | + monAll = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1585 | + preAll = preAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1586 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1587 | + m.put("monAll", monAll.doubleValue()); | ||
| 1588 | + m.put("preAll", preAll.doubleValue()); | ||
| 1589 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1590 | + | ||
| 1591 | + if(m.containsKey("num") && m.get("num").toString().length() > 0 | ||
| 1592 | + && Double.valueOf(m.get("num").toString()) > 0){ | ||
| 1593 | + m.put("average", monAll.divide( | ||
| 1594 | + new BigDecimal(m.get("num").toString()).multiply(new BigDecimal("100")), | ||
| 1595 | + 2, BigDecimal.ROUND_HALF_UP).doubleValue()); | ||
| 1596 | + } else { | ||
| 1597 | + m.put("average", ""); | ||
| 1598 | + } | ||
| 1599 | + | ||
| 1600 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1601 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1602 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1603 | + m.put("complete", monAll.divide( | ||
| 1604 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1605 | + new BigDecimal(100)).divide( | ||
| 1606 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1607 | + BigDecimal diff = monAll.subtract(formal); | ||
| 1608 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1609 | + } else { | ||
| 1610 | + m.put("complete", ""); | ||
| 1611 | + m.put("diff", ""); | ||
| 1612 | + } | ||
| 1613 | + } | ||
| 1614 | + | ||
| 1615 | + for(String key : strs){ | ||
| 1616 | + if(!(key.contains("all_"))){ | ||
| 1617 | + String[] sp = key.split("_"); | ||
| 1618 | + String allKey = "all"; | ||
| 1619 | + for(int i = 1; i < sp.length; i++){ | ||
| 1620 | + allKey += "_" + sp[i]; | ||
| 1621 | + } | ||
| 1622 | + Map<String, Object> map = keyMap.get(key); | ||
| 1623 | + Map<String, Object> allMap = keyMap.get(allKey); | ||
| 1624 | + for(String k : map.keySet()){ | ||
| 1625 | + if("year".equals(k) || "num".equals(k)){ // 不想被计算的数字型字段 | ||
| 1626 | + continue; | ||
| 1627 | + } | ||
| 1628 | + try { | ||
| 1629 | + allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 1630 | + new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 1631 | + } catch (Exception e) { | ||
| 1632 | + // TODO: handle exception | ||
| 1633 | + } | ||
| 1634 | + } | ||
| 1635 | + if(map.containsKey("num") && map.get("num").toString().length() > 0){ | ||
| 1636 | + if(allMap.containsKey("num") && allMap.get("num").toString().length() > 0){ | ||
| 1637 | + allMap.put("num", new BigDecimal(map.get("num").toString()).add( | ||
| 1638 | + new BigDecimal(allMap.get("num").toString())).doubleValue()); | ||
| 1639 | + } else { | ||
| 1640 | + allMap.put("num", new BigDecimal(map.get("num").toString()).doubleValue()); | ||
| 1641 | + } | ||
| 1642 | + } | ||
| 1643 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 1644 | + dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 1645 | + allMap.put("dataList", dataList); | ||
| 1646 | + | ||
| 1647 | + for(Map<String, Object> m : dataList){ | ||
| 1648 | + for(int i = 1; i <= 12; i++){ | ||
| 1649 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 1650 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1651 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1652 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1653 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1654 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1655 | + } else { | ||
| 1656 | + m.put("com" + i, ""); | ||
| 1657 | + } | ||
| 1658 | + } | ||
| 1659 | + } | ||
| 1660 | + } | ||
| 1661 | + } | ||
| 1662 | + | ||
| 1663 | + for(String key : strs){ | ||
| 1664 | + Map<String, Object> m = keyMap.get(key); | ||
| 1665 | + | ||
| 1666 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 1667 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 1668 | + for(int i = 1; i <= 12; i++){ | ||
| 1669 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1670 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1671 | + monAll = monAll.add(val); | ||
| 1672 | + val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1673 | + m.put("mon"+i, val.doubleValue()); | ||
| 1674 | + } | ||
| 1675 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 1676 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 1677 | + preAll = preAll.add(val); | ||
| 1678 | + val = val.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1679 | + m.put("pre"+i, val.doubleValue()); | ||
| 1680 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 1681 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 1682 | + BigDecimal sub = monVal.subtract(val); | ||
| 1683 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 1684 | + } else { | ||
| 1685 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 1686 | + } | ||
| 1687 | + } | ||
| 1688 | + } | ||
| 1689 | + monAll = monAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1690 | + preAll = preAll.divide(new BigDecimal("1000000"), 3, BigDecimal.ROUND_HALF_UP); | ||
| 1691 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 1692 | + m.put("monAll", monAll.doubleValue()); | ||
| 1693 | + m.put("preAll", preAll.doubleValue()); | ||
| 1694 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 1695 | + | ||
| 1696 | + if(m.containsKey("num") && m.get("num").toString().length() > 0 | ||
| 1697 | + && Double.valueOf(m.get("num").toString()) > 0){ | ||
| 1698 | + m.put("average", monAll.divide( | ||
| 1699 | + new BigDecimal(m.get("num").toString()).multiply(new BigDecimal("100")), | ||
| 1700 | + 2, BigDecimal.ROUND_HALF_UP).doubleValue()); | ||
| 1701 | + } else { | ||
| 1702 | + m.put("average", ""); | ||
| 1703 | + } | ||
| 1704 | + | ||
| 1705 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 1706 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 1707 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 1708 | + m.put("complete", monAll.divide( | ||
| 1709 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 1710 | + new BigDecimal(100)).divide( | ||
| 1711 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1712 | + BigDecimal diff = monAll.subtract(formal); | ||
| 1713 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 1714 | + } else { | ||
| 1715 | + m.put("complete", ""); | ||
| 1716 | + m.put("diff", ""); | ||
| 1717 | + } | ||
| 1718 | + m.put("year", year); | ||
| 1719 | + | ||
| 1720 | + for(int i = 1; i <= 12; i++){ | ||
| 1721 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 1722 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 1723 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 1724 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 1725 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 1726 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 1727 | + } else { | ||
| 1728 | + m.put("com" + i, ""); | ||
| 1729 | + } | ||
| 1730 | + } | ||
| 1731 | + } | ||
| 1732 | + | ||
| 1733 | + if(tttt.equals("export")){ | ||
| 1734 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1735 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1736 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1737 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1738 | + String xls="budgetAmounts.xls"; | ||
| 1739 | + ReportUtils ee = new ReportUtils(); | ||
| 1740 | + try { | ||
| 1741 | + String dateTime = ""; | ||
| 1742 | + m.put("date", year); | ||
| 1743 | + dateTime = year; | ||
| 1744 | + listI.add(resList.iterator()); | ||
| 1745 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1746 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 1747 | + path + "export/"+dateTime+"-预算营收明细表.xls"); | ||
| 1748 | + } catch (Exception e) { | ||
| 1749 | + // TODO: handle exception | ||
| 1750 | + e.printStackTrace(); | ||
| 1751 | + } | ||
| 1752 | + } | ||
| 1753 | + | ||
| 1754 | + if(tttt.equals("exportData")){ | ||
| 1755 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1756 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1757 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1758 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1759 | + m.put("date", year); | ||
| 1760 | + ReportUtils ee = new ReportUtils(); | ||
| 1761 | + try { | ||
| 1762 | + for(Map<String, Object> map : resList){ | ||
| 1763 | + if(kkk.equals(map.get("key").toString())){ | ||
| 1764 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 1765 | + listI.add(dataList.iterator()); | ||
| 1766 | + } | ||
| 1767 | + } | ||
| 1768 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 1769 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetAmounts_data.xls", | ||
| 1770 | + path + "export/" + year + "-预算营收明细表-线路明细.xls"); | ||
| 1771 | + } catch (Exception e) { | ||
| 1772 | + // TODO: handle exception | ||
| 1773 | + e.printStackTrace(); | ||
| 1774 | + logger.info("", e); | ||
| 1775 | + } | ||
| 1776 | + } | ||
| 1777 | + | ||
| 1778 | + return resList; | ||
| 1779 | + } | ||
| 1780 | + | ||
| 1781 | + @Override | ||
| 1782 | + public List<Map<String, Object>> budgetSum(String year, String nature, String tttt, String kkk) { | ||
| 1783 | + // TODO Auto-generated method stub | ||
| 1784 | + SimpleDateFormat sdfYY = new SimpleDateFormat("YYYY"); | ||
| 1785 | + SimpleDateFormat sdfMM = new SimpleDateFormat("MM"); | ||
| 1786 | + DecimalFormat df = new DecimalFormat("0.###"); | ||
| 1787 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 1788 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 1789 | + List<Budget> findByYear = repository.findByYear(year); | ||
| 1790 | + List<CalcStatistics> scheduleList = calcStatisticsRepository.selectByDateAndLineTj3(year+"-01-01", year+"-12-31"); | ||
| 1791 | + List<Revenue> revenueList = revenueRepository.findByDates(year+"-01-01", year+"-12-31"); | ||
| 1792 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 1793 | + | ||
| 1794 | + String year_1 = ""; | ||
| 1795 | + try { | ||
| 1796 | + year_1 = sdfYY.format(sdfYY.parse((Integer.valueOf(year)-1)+"")); | ||
| 1797 | + } catch (ParseException e) { | ||
| 1798 | + // TODO Auto-generated catch block | ||
| 1799 | + e.printStackTrace(); | ||
| 1800 | + } | ||
| 1801 | + List<CalcStatistics> scheduleList_1 = calcStatisticsRepository.selectByDateAndLineTj3(year_1+"-01-01", year_1+"-12-31"); | ||
| 1802 | + List<Revenue> revenueList_1 = revenueRepository.findByDates(year_1+"-01-01", year_1+"-12-31"); | ||
| 1803 | + | ||
| 1804 | + Map<String, Map<String, Object>> xlMap = new HashMap<String, Map<String, Object>>(); | ||
| 1805 | + List<Map<String, Object>> xlList = new ArrayList<Map<String, Object>>(); | ||
| 1806 | + | ||
| 1807 | + String[] strs = createBudgetMap_sum(resList, keyMap); | ||
| 1808 | + | ||
| 1809 | + for(Budget b : findByYear){ | ||
| 1810 | + if(!(b.getYear().contains("-")) || b.getYear().length() != 7){ | ||
| 1811 | + continue; | ||
| 1812 | + } | ||
| 1813 | + Boolean flag = true; | ||
| 1814 | + if("0".equals(nature)){ | ||
| 1815 | + flag = false; | ||
| 1816 | + } else if("1".equals(nature) && b.getSfyy()){ | ||
| 1817 | + flag = false; | ||
| 1818 | + } else if("2".equals(nature) && !(b.getSfyy())){ | ||
| 1819 | + flag = false; | ||
| 1820 | + } | ||
| 1821 | + if(flag){ | ||
| 1822 | + continue; | ||
| 1823 | + } | ||
| 1824 | + String gsBm = b.getGsBm(); | ||
| 1825 | + String xlBm = b.getXlBm(); | ||
| 1826 | + String xlName = b.getXlName(); | ||
| 1827 | + String key = gsBm + "_" + xlBm; | ||
| 1828 | + if(b.getFormalMileage()!=null && b.getFormalMileage() >= 0d){ | ||
| 1829 | + String key1 = key + "_1"; | ||
| 1830 | + if(!(xlMap.containsKey(key1))){ | ||
| 1831 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1832 | + m.put("gsBm", gsBm); | ||
| 1833 | + m.put("gsName", b.getGsName()); | ||
| 1834 | + m.put("xlBm", xlBm); | ||
| 1835 | + m.put("xlName", xlName); | ||
| 1836 | + m.put("type", "公里"); | ||
| 1837 | + m.put("budget", b.getBudgetMileage()!=null?df.format(b.getBudgetMileage()):""); | ||
| 1838 | + m.put("change", b.getChangeMileage()!=null?df.format(b.getChangeMileage()):""); | ||
| 1839 | + m.put("formal", b.getFormalMileage()!=null?df.format(b.getFormalMileage()):""); | ||
| 1840 | + for(int i = 1; i <= 12; i++){ | ||
| 1841 | + m.put("mon"+i, ""); | ||
| 1842 | + m.put("bud"+i, ""); | ||
| 1843 | + m.put("pre"+i, ""); | ||
| 1844 | + } | ||
| 1845 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1846 | + if(b.getFormalMileage()!=null){ | ||
| 1847 | + m.put(bud, df.format(b.getFormalMileage())); | ||
| 1848 | + } | ||
| 1849 | + m.put("monAll", "0"); | ||
| 1850 | + xlMap.put(key1, m); | ||
| 1851 | + xlList.add(m); | ||
| 1852 | + } else { | ||
| 1853 | + Map<String, Object> m = xlMap.get(key1); | ||
| 1854 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1855 | + if(b.getBudgetMileage()!=null){ | ||
| 1856 | + if(m.get("budget").toString().length() > 0){ | ||
| 1857 | + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1858 | + new BigDecimal(b.getBudgetMileage())).doubleValue())); | ||
| 1859 | + } else { | ||
| 1860 | + m.put("budget", df.format(b.getBudgetMileage())); | ||
| 1861 | + } | ||
| 1862 | + } | ||
| 1863 | + if(b.getChangeMileage()!=null){ | ||
| 1864 | + if(m.get("change").toString().length() > 0){ | ||
| 1865 | + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1866 | + new BigDecimal(b.getChangeMileage())).doubleValue())); | ||
| 1867 | + } else { | ||
| 1868 | + m.put("change", df.format(b.getChangeMileage())); | ||
| 1869 | + } | ||
| 1870 | + } | ||
| 1871 | + if(b.getFormalMileage()!=null){ | ||
| 1872 | + if(m.get("formal").toString().length() > 0){ | ||
| 1873 | + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1874 | + new BigDecimal(b.getFormalMileage())).doubleValue())); | ||
| 1875 | + } else { | ||
| 1876 | + m.put("formal", df.format(b.getFormalMileage())); | ||
| 1877 | + } | ||
| 1878 | + m.put(bud, df.format(b.getFormalMileage())); | ||
| 1879 | + } | ||
| 1880 | + } | ||
| 1881 | + } | ||
| 1882 | + if(b.getFormalPerson()!=null && b.getFormalPerson() >= 0d){ | ||
| 1883 | + String key2 = key + "_2"; | ||
| 1884 | + if(!(xlMap.containsKey(key2))){ | ||
| 1885 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1886 | + m.put("gsBm", gsBm); | ||
| 1887 | + m.put("gsName", b.getGsName()); | ||
| 1888 | + m.put("xlBm", xlBm); | ||
| 1889 | + m.put("xlName", xlName); | ||
| 1890 | + m.put("type", "人次"); | ||
| 1891 | + m.put("budget", b.getBudgetPerson()!=null?df.format(b.getBudgetPerson()):""); | ||
| 1892 | + m.put("change", b.getChangePerson()!=null?df.format(b.getChangePerson()):""); | ||
| 1893 | + m.put("formal", b.getFormalPerson()!=null?df.format(b.getFormalPerson()):""); | ||
| 1894 | + for(int i = 1; i <= 12; i++){ | ||
| 1895 | + m.put("mon"+i, ""); | ||
| 1896 | + m.put("bud"+i, ""); | ||
| 1897 | + m.put("pre"+i, ""); | ||
| 1898 | + } | ||
| 1899 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1900 | + if(b.getFormalPerson()!=null){ | ||
| 1901 | + m.put(bud, df.format(b.getFormalPerson())); | ||
| 1902 | + } | ||
| 1903 | + m.put("monAll", "0"); | ||
| 1904 | + xlMap.put(key2, m); | ||
| 1905 | + xlList.add(m); | ||
| 1906 | + } else { | ||
| 1907 | + Map<String, Object> m = xlMap.get(key2); | ||
| 1908 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1909 | + if(b.getBudgetPerson()!=null){ | ||
| 1910 | + if(m.get("budget").toString().length() > 0){ | ||
| 1911 | + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1912 | + new BigDecimal(b.getBudgetPerson())).doubleValue())); | ||
| 1913 | + } else { | ||
| 1914 | + m.put("budget", df.format(b.getBudgetPerson())); | ||
| 1915 | + } | ||
| 1916 | + } | ||
| 1917 | + if(b.getChangePerson()!=null){ | ||
| 1918 | + if(m.get("change").toString().length() > 0){ | ||
| 1919 | + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1920 | + new BigDecimal(b.getChangePerson())).doubleValue())); | ||
| 1921 | + } else { | ||
| 1922 | + m.put("change", df.format(b.getChangePerson())); | ||
| 1923 | + } | ||
| 1924 | + } | ||
| 1925 | + if(b.getFormalPerson()!=null){ | ||
| 1926 | + if(m.get("formal").toString().length() > 0){ | ||
| 1927 | + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1928 | + new BigDecimal(b.getFormalPerson())).doubleValue())); | ||
| 1929 | + } else { | ||
| 1930 | + m.put("formal", df.format(b.getFormalPerson())); | ||
| 1931 | + } | ||
| 1932 | + m.put(bud, df.format(b.getFormalPerson())); | ||
| 1933 | + } | ||
| 1934 | + } | ||
| 1935 | + } | ||
| 1936 | + if(b.getFormalAmounts()!=null && b.getFormalAmounts() >= 0d){ | ||
| 1937 | + String key3 = key + "_3"; | ||
| 1938 | + if(!(xlMap.containsKey(key3))){ | ||
| 1939 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1940 | + m.put("gsBm", gsBm); | ||
| 1941 | + m.put("gsName", b.getGsName()); | ||
| 1942 | + m.put("xlBm", xlBm); | ||
| 1943 | + m.put("xlName", xlName); | ||
| 1944 | + m.put("type", "营收"); | ||
| 1945 | + m.put("budget", b.getBudgetAmounts()!=null?df.format(b.getBudgetAmounts()):""); | ||
| 1946 | + m.put("change", b.getChangeAmounts()!=null?df.format(b.getChangeAmounts()):""); | ||
| 1947 | + m.put("formal", b.getFormalAmounts()!=null?df.format(b.getFormalAmounts()):""); | ||
| 1948 | + for(int i = 1; i <= 12; i++){ | ||
| 1949 | + m.put("mon"+i, ""); | ||
| 1950 | + m.put("bud"+i, ""); | ||
| 1951 | + m.put("pre"+i, ""); | ||
| 1952 | + } | ||
| 1953 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1954 | + if(b.getFormalAmounts()!=null){ | ||
| 1955 | + m.put(bud, df.format(b.getFormalAmounts())); | ||
| 1956 | + } | ||
| 1957 | + m.put("monAll", "0"); | ||
| 1958 | + xlMap.put(key3, m); | ||
| 1959 | + xlList.add(m); | ||
| 1960 | + } else { | ||
| 1961 | + Map<String, Object> m = xlMap.get(key3); | ||
| 1962 | + String bud = "bud" + Integer.valueOf(b.getYear().split("-")[1]); | ||
| 1963 | + if(b.getBudgetAmounts()!=null){ | ||
| 1964 | + if(m.get("budget").toString().length() > 0){ | ||
| 1965 | + m.put("budget", df.format(new BigDecimal(m.get("budget").toString()).add( | ||
| 1966 | + new BigDecimal(b.getBudgetAmounts())).doubleValue())); | ||
| 1967 | + } else { | ||
| 1968 | + m.put("budget", df.format(b.getBudgetAmounts())); | ||
| 1969 | + } | ||
| 1970 | + } | ||
| 1971 | + if(b.getChangeAmounts()!=null){ | ||
| 1972 | + if(m.get("change").toString().length() > 0){ | ||
| 1973 | + m.put("change", df.format(new BigDecimal(m.get("change").toString()).add( | ||
| 1974 | + new BigDecimal(b.getChangeAmounts())).doubleValue())); | ||
| 1975 | + } else { | ||
| 1976 | + m.put("change", df.format(b.getChangeAmounts())); | ||
| 1977 | + } | ||
| 1978 | + } | ||
| 1979 | + if(b.getFormalAmounts()!=null){ | ||
| 1980 | + if(m.get("formal").toString().length() > 0){ | ||
| 1981 | + m.put("formal", df.format(new BigDecimal(m.get("formal").toString()).add( | ||
| 1982 | + new BigDecimal(b.getFormalAmounts())).doubleValue())); | ||
| 1983 | + } else { | ||
| 1984 | + m.put("formal", df.format(b.getFormalAmounts())); | ||
| 1985 | + } | ||
| 1986 | + m.put(bud, df.format(b.getFormalAmounts())); | ||
| 1987 | + } | ||
| 1988 | + } | ||
| 1989 | + } | ||
| 1990 | + } | ||
| 1991 | + | ||
| 1992 | + for(CalcStatistics cs : scheduleList){ // 公里 | ||
| 1993 | + Boolean flag = true; | ||
| 1994 | + if("0".equals(nature)){ | ||
| 1995 | + flag = false; | ||
| 1996 | + } else if("1".equals(nature) && lineNature.containsKey(cs.getXl()) && lineNature.get(cs.getXl())){ | ||
| 1997 | + flag = false; | ||
| 1998 | + } else if("2".equals(nature) && !(lineNature.containsKey(cs.getXl()) && lineNature.get(cs.getXl()))){ | ||
| 1999 | + flag = false; | ||
| 2000 | + } | ||
| 2001 | + if(flag){ | ||
| 2002 | + continue; | ||
| 2003 | + } | ||
| 2004 | + String gsBm = cs.getGsdm(); | ||
| 2005 | + String xlBm = cs.getXl(); | ||
| 2006 | + String xlName = cs.getXlName(); | ||
| 2007 | + | ||
| 2008 | + String key = gsBm + "_" + xlBm + "_1"; | ||
| 2009 | + if(!(xlMap.containsKey(key))){ | ||
| 2010 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2011 | + m.put("gsBm", gsBm); | ||
| 2012 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2013 | + m.put("xlBm", xlBm); | ||
| 2014 | + m.put("xlName", xlName); | ||
| 2015 | + m.put("type", "公里"); | ||
| 2016 | + m.put("budget", ""); | ||
| 2017 | + m.put("change", ""); | ||
| 2018 | + m.put("formal", ""); | ||
| 2019 | + for(int i = 1; i <= 12; i++){ | ||
| 2020 | + m.put("mon"+i, ""); | ||
| 2021 | + m.put("bud"+i, ""); | ||
| 2022 | + m.put("pre"+i, ""); | ||
| 2023 | + } | ||
| 2024 | + m.put("monAll", "0"); | ||
| 2025 | + xlMap.put(key, m); | ||
| 2026 | + xlList.add(m); | ||
| 2027 | + } | ||
| 2028 | + Map<String, Object> map = xlMap.get(key); | ||
| 2029 | + String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getDate())); | ||
| 2030 | + String val = map.get(mon).toString(); | ||
| 2031 | + BigDecimal num = new BigDecimal(cs.getSjzlc().toString()); | ||
| 2032 | + if(val.length() == 0){ | ||
| 2033 | + map.put(mon, num.doubleValue()); | ||
| 2034 | + } else { | ||
| 2035 | + map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 2036 | + } | ||
| 2037 | + } | ||
| 2038 | + | ||
| 2039 | + for(Revenue cs : revenueList){ // 人次与营收 | ||
| 2040 | + Boolean flag = true; | ||
| 2041 | + if("0".equals(nature)){ | ||
| 2042 | + flag = false; | ||
| 2043 | + } else if("1".equals(nature) && cs.getSfyy()){ | ||
| 2044 | + flag = false; | ||
| 2045 | + } else if("2".equals(nature) && !(cs.getSfyy())){ | ||
| 2046 | + flag = false; | ||
| 2047 | + } | ||
| 2048 | + if(flag){ | ||
| 2049 | + continue; | ||
| 2050 | + } | ||
| 2051 | + String gsBm = cs.getGsBm(); | ||
| 2052 | + String xlBm = cs.getXlBm(); | ||
| 2053 | + String xlName = cs.getXlName(); | ||
| 2054 | + | ||
| 2055 | + { // 人次 | ||
| 2056 | + String key2 = gsBm + "_" + xlBm + "_2"; | ||
| 2057 | + if(!(xlMap.containsKey(key2))){ | ||
| 2058 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2059 | + m.put("gsBm", gsBm); | ||
| 2060 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2061 | + m.put("xlBm", xlBm); | ||
| 2062 | + m.put("xlName", xlName); | ||
| 2063 | + m.put("type", "人次"); | ||
| 2064 | + m.put("budget", ""); | ||
| 2065 | + m.put("change", ""); | ||
| 2066 | + m.put("formal", ""); | ||
| 2067 | + for(int i = 1; i <= 12; i++){ | ||
| 2068 | + m.put("mon"+i, ""); | ||
| 2069 | + m.put("bud"+i, ""); | ||
| 2070 | + m.put("pre"+i, ""); | ||
| 2071 | + } | ||
| 2072 | + m.put("monAll", "0"); | ||
| 2073 | + xlMap.put(key2, m); | ||
| 2074 | + xlList.add(m); | ||
| 2075 | + } | ||
| 2076 | + Map<String, Object> map = xlMap.get(key2); | ||
| 2077 | + String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 2078 | + String val = map.get(mon).toString(); | ||
| 2079 | + BigDecimal num = new BigDecimal(cs.getNum().toString()); | ||
| 2080 | + if(val.length() == 0){ | ||
| 2081 | + map.put(mon, num.doubleValue()); | ||
| 2082 | + } else { | ||
| 2083 | + map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 2084 | + } | ||
| 2085 | + } | ||
| 2086 | + { // 营收 | ||
| 2087 | + String key3 = gsBm + "_" + xlBm + "_3"; | ||
| 2088 | + if(!(xlMap.containsKey(key3))){ | ||
| 2089 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2090 | + m.put("gsBm", gsBm); | ||
| 2091 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2092 | + m.put("xlBm", xlBm); | ||
| 2093 | + m.put("xlName", xlName); | ||
| 2094 | + m.put("type", "营收"); | ||
| 2095 | + m.put("budget", ""); | ||
| 2096 | + m.put("change", ""); | ||
| 2097 | + m.put("formal", ""); | ||
| 2098 | + for(int i = 1; i <= 12; i++){ | ||
| 2099 | + m.put("mon"+i, ""); | ||
| 2100 | + m.put("bud"+i, ""); | ||
| 2101 | + m.put("pre"+i, ""); | ||
| 2102 | + } | ||
| 2103 | + m.put("monAll", "0"); | ||
| 2104 | + xlMap.put(key3, m); | ||
| 2105 | + xlList.add(m); | ||
| 2106 | + } | ||
| 2107 | + Map<String, Object> map = xlMap.get(key3); | ||
| 2108 | + String mon = "mon" + Integer.valueOf(sdfMM.format(cs.getScheduleDate())); | ||
| 2109 | + String val = map.get(mon).toString(); | ||
| 2110 | + BigDecimal num = new BigDecimal(cs.getAmount().toString()); | ||
| 2111 | + if(val.length() == 0){ | ||
| 2112 | + map.put(mon, num.doubleValue()); | ||
| 2113 | + } else { | ||
| 2114 | + map.put(mon, new BigDecimal(val).add(num).doubleValue()); | ||
| 2115 | + } | ||
| 2116 | + } | ||
| 2117 | + } | ||
| 2118 | + | ||
| 2119 | + for(CalcStatistics cs1 : scheduleList_1){ // 去年公里 | ||
| 2120 | + Boolean flag = true; | ||
| 2121 | + if("0".equals(nature)){ | ||
| 2122 | + flag = false; | ||
| 2123 | + } else if("1".equals(nature) && lineNature.containsKey(cs1.getXl()) && lineNature.get(cs1.getXl())){ | ||
| 2124 | + flag = false; | ||
| 2125 | + } else if("2".equals(nature) && !(lineNature.containsKey(cs1.getXl()) && lineNature.get(cs1.getXl()))){ | ||
| 2126 | + flag = false; | ||
| 2127 | + } | ||
| 2128 | + if(flag){ | ||
| 2129 | + continue; | ||
| 2130 | + } | ||
| 2131 | + String gsdm = cs1.getGsdm(); | ||
| 2132 | + String xlBm = cs1.getXl(); | ||
| 2133 | + String xlName = cs1.getXlName(); | ||
| 2134 | + String key = gsdm + "_" + xlBm; | ||
| 2135 | + String key1 = key + "_1"; | ||
| 2136 | + if(!(xlMap.containsKey(key1))){ | ||
| 2137 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2138 | + m.put("gsBm", gsdm); | ||
| 2139 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsdm)); | ||
| 2140 | + m.put("xlBm", xlBm); | ||
| 2141 | + m.put("xlName", xlName); | ||
| 2142 | + m.put("type", "公里"); | ||
| 2143 | + m.put("budget", ""); | ||
| 2144 | + m.put("change", ""); | ||
| 2145 | + m.put("formal", ""); | ||
| 2146 | + for(int i = 1; i <= 12; i++){ | ||
| 2147 | + m.put("mon"+i, ""); | ||
| 2148 | + m.put("bud"+i, ""); | ||
| 2149 | + m.put("pre"+i, ""); | ||
| 2150 | + } | ||
| 2151 | + m.put("monAll", "0"); | ||
| 2152 | + xlMap.put(key1, m); | ||
| 2153 | + xlList.add(m); | ||
| 2154 | + } | ||
| 2155 | + Map<String, Object> map = xlMap.get(key1); | ||
| 2156 | + String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getDate())); | ||
| 2157 | + String val = map.get(pre).toString(); | ||
| 2158 | + BigDecimal num = new BigDecimal(cs1.getSjzlc().toString()); | ||
| 2159 | + if(val.length() == 0){ | ||
| 2160 | + map.put(pre, num.doubleValue()); | ||
| 2161 | + } else { | ||
| 2162 | + map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 2163 | + } | ||
| 2164 | + } | ||
| 2165 | + | ||
| 2166 | + for(Revenue cs1 : revenueList_1){ // 去年人次与营收 | ||
| 2167 | + Boolean flag = true; | ||
| 2168 | + if("0".equals(nature)){ | ||
| 2169 | + flag = false; | ||
| 2170 | + } else if("1".equals(nature) && cs1.getSfyy()){ | ||
| 2171 | + flag = false; | ||
| 2172 | + } else if("2".equals(nature) && !(cs1.getSfyy())){ | ||
| 2173 | + flag = false; | ||
| 2174 | + } | ||
| 2175 | + if(flag){ | ||
| 2176 | + continue; | ||
| 2177 | + } | ||
| 2178 | + String gsBm = cs1.getGsBm(); | ||
| 2179 | + String xlBm = cs1.getXlBm(); | ||
| 2180 | + String xlName = cs1.getXlName(); | ||
| 2181 | + | ||
| 2182 | + { // 去年人次 | ||
| 2183 | + String key2 = gsBm + "_" + xlBm + "_2"; | ||
| 2184 | + if(!(xlMap.containsKey(key2))){ | ||
| 2185 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2186 | + m.put("gsBm", gsBm); | ||
| 2187 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2188 | + m.put("xlBm", xlBm); | ||
| 2189 | + m.put("xlName", xlName); | ||
| 2190 | + m.put("type", "人次"); | ||
| 2191 | + m.put("budget", ""); | ||
| 2192 | + m.put("change", ""); | ||
| 2193 | + m.put("formal", ""); | ||
| 2194 | + for(int i = 1; i <= 12; i++){ | ||
| 2195 | + m.put("mon"+i, ""); | ||
| 2196 | + m.put("bud"+i, ""); | ||
| 2197 | + m.put("pre"+i, ""); | ||
| 2198 | + } | ||
| 2199 | + m.put("monAll", "0"); | ||
| 2200 | + xlMap.put(key2, m); | ||
| 2201 | + xlList.add(m); | ||
| 2202 | + } | ||
| 2203 | + Map<String, Object> map = xlMap.get(key2); | ||
| 2204 | + String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 2205 | + String val = map.get(pre).toString(); | ||
| 2206 | + BigDecimal num = new BigDecimal(cs1.getNum().toString()); | ||
| 2207 | + if(val.length() == 0){ | ||
| 2208 | + map.put(pre, num.doubleValue()); | ||
| 2209 | + } else { | ||
| 2210 | + map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 2211 | + } | ||
| 2212 | + } | ||
| 2213 | + { // 去年营收 | ||
| 2214 | + String key3 = gsBm + "_" + xlBm + "_3"; | ||
| 2215 | + if(!(xlMap.containsKey(key3))){ | ||
| 2216 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2217 | + m.put("gsBm", gsBm); | ||
| 2218 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2219 | + m.put("xlBm", xlBm); | ||
| 2220 | + m.put("xlName", xlName); | ||
| 2221 | + m.put("type", "营收"); | ||
| 2222 | + m.put("budget", ""); | ||
| 2223 | + m.put("change", ""); | ||
| 2224 | + m.put("formal", ""); | ||
| 2225 | + for(int i = 1; i <= 12; i++){ | ||
| 2226 | + m.put("mon"+i, ""); | ||
| 2227 | + m.put("bud"+i, ""); | ||
| 2228 | + m.put("pre"+i, ""); | ||
| 2229 | + } | ||
| 2230 | + m.put("monAll", "0"); | ||
| 2231 | + xlMap.put(key3, m); | ||
| 2232 | + xlList.add(m); | ||
| 2233 | + } | ||
| 2234 | + Map<String, Object> map = xlMap.get(key3); | ||
| 2235 | + String pre = "pre" + Integer.valueOf(sdfMM.format(cs1.getScheduleDate())); | ||
| 2236 | + String val = map.get(pre).toString(); | ||
| 2237 | + BigDecimal num = new BigDecimal(cs1.getAmount().toString()); | ||
| 2238 | + if(val.length() == 0){ | ||
| 2239 | + map.put(pre, num.doubleValue()); | ||
| 2240 | + } else { | ||
| 2241 | + map.put(pre, new BigDecimal(val).add(num).doubleValue()); | ||
| 2242 | + } | ||
| 2243 | + } | ||
| 2244 | + } | ||
| 2245 | + | ||
| 2246 | + for(Map<String, Object> m : xlList){ | ||
| 2247 | + | ||
| 2248 | + String gsBm = m.get("gsBm").toString(); | ||
| 2249 | + String type = m.get("type").toString(); | ||
| 2250 | + if("公里".equals(type)){ | ||
| 2251 | + type = "1"; | ||
| 2252 | + } else if("人次".equals(type)){ | ||
| 2253 | + type = "2"; | ||
| 2254 | + } else if("营收".equals(type)){ | ||
| 2255 | + type = "3"; | ||
| 2256 | + } | ||
| 2257 | + List<String> strList = new ArrayList<String>(); | ||
| 2258 | + strList.add(gsBm + "_" + type); | ||
| 2259 | + | ||
| 2260 | + for(String str : strList){ | ||
| 2261 | + if(!keyMap.containsKey(str)){ | ||
| 2262 | + continue; | ||
| 2263 | + } | ||
| 2264 | + Map<String, Object> map = keyMap.get(str); | ||
| 2265 | + if(m.get("budget").toString().length() > 0){ | ||
| 2266 | + if(map.get("budget").toString().length() > 0){ | ||
| 2267 | + map.put("budget", new BigDecimal(m.get("budget").toString()).add( | ||
| 2268 | + new BigDecimal(map.get("budget").toString())).doubleValue()); | ||
| 2269 | + } else { | ||
| 2270 | + map.put("budget", new BigDecimal(m.get("budget").toString()).doubleValue()); | ||
| 2271 | + } | ||
| 2272 | + } | ||
| 2273 | + if(m.get("change").toString().length() > 0){ | ||
| 2274 | + if(map.get("change").toString().length() > 0){ | ||
| 2275 | + map.put("change", new BigDecimal(m.get("change").toString()).add( | ||
| 2276 | + new BigDecimal(map.get("change").toString())).doubleValue()); | ||
| 2277 | + } else { | ||
| 2278 | + map.put("change", new BigDecimal(m.get("change").toString()).doubleValue()); | ||
| 2279 | + } | ||
| 2280 | + } | ||
| 2281 | + if(m.get("formal").toString().length() > 0){ | ||
| 2282 | + if(map.get("formal").toString().length() > 0){ | ||
| 2283 | + map.put("formal", new BigDecimal(m.get("formal").toString()).add( | ||
| 2284 | + new BigDecimal(map.get("formal").toString())).doubleValue()); | ||
| 2285 | + } else { | ||
| 2286 | + map.put("formal", new BigDecimal(m.get("formal").toString()).doubleValue()); | ||
| 2287 | + } | ||
| 2288 | + } | ||
| 2289 | + for(int i = 1; i <= 12; i++){ | ||
| 2290 | + String mon = "mon"+i, bud = "bud"+i, pre = "pre"+i; | ||
| 2291 | + if(m.get(mon).toString().length() > 0){ | ||
| 2292 | + if(map.get(mon).toString().length() > 0){ | ||
| 2293 | + map.put(mon, new BigDecimal(m.get(mon).toString()).add( | ||
| 2294 | + new BigDecimal(map.get(mon).toString())).doubleValue()); | ||
| 2295 | + } else { | ||
| 2296 | + map.put(mon, new BigDecimal(m.get(mon).toString()).doubleValue()); | ||
| 2297 | + } | ||
| 2298 | + } | ||
| 2299 | + if(m.get(bud).toString().length() > 0){ | ||
| 2300 | + if(map.get(bud).toString().length() > 0){ | ||
| 2301 | + map.put(bud, new BigDecimal(m.get(bud).toString()).add( | ||
| 2302 | + new BigDecimal(map.get(bud).toString())).doubleValue()); | ||
| 2303 | + } else { | ||
| 2304 | + map.put(bud, new BigDecimal(m.get(bud).toString()).doubleValue()); | ||
| 2305 | + } | ||
| 2306 | + } | ||
| 2307 | + if(m.get(pre).toString().length() > 0){ | ||
| 2308 | + if(map.get(pre).toString().length() > 0){ | ||
| 2309 | + map.put(pre, new BigDecimal(m.get(pre).toString()).add( | ||
| 2310 | + new BigDecimal(map.get(pre).toString())).doubleValue()); | ||
| 2311 | + } else { | ||
| 2312 | + map.put(pre, new BigDecimal(m.get(pre).toString()).doubleValue()); | ||
| 2313 | + } | ||
| 2314 | + } | ||
| 2315 | + } | ||
| 2316 | + List<Map<String, Object>>dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 2317 | + dataList.add(m); | ||
| 2318 | + } | ||
| 2319 | + | ||
| 2320 | + String digit = "10000"; | ||
| 2321 | + if("营收".equals(m.get("type").toString())){ | ||
| 2322 | + digit = "1000000"; | ||
| 2323 | + } | ||
| 2324 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 2325 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 2326 | + for(int i = 1; i <= 12; i++){ | ||
| 2327 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 2328 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2329 | + monAll = monAll.add(val); | ||
| 2330 | + val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2331 | + m.put("mon"+i, val.doubleValue()); | ||
| 2332 | + } | ||
| 2333 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 2334 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 2335 | + preAll = preAll.add(val); | ||
| 2336 | + val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2337 | + m.put("pre"+i, val.doubleValue()); | ||
| 2338 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 2339 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2340 | + BigDecimal sub = monVal.subtract(val); | ||
| 2341 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 2342 | + } else { | ||
| 2343 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 2344 | + } | ||
| 2345 | + } | ||
| 2346 | + } | ||
| 2347 | + monAll = monAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2348 | + preAll = preAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2349 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 2350 | + m.put("monAll", monAll.doubleValue()); | ||
| 2351 | + m.put("preAll", preAll.doubleValue()); | ||
| 2352 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 2353 | + | ||
| 2354 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 2355 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 2356 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 2357 | + m.put("complete", monAll.divide( | ||
| 2358 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 2359 | + new BigDecimal(100)).divide( | ||
| 2360 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2361 | + BigDecimal diff = monAll.subtract(formal); | ||
| 2362 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 2363 | + } else { | ||
| 2364 | + m.put("complete", ""); | ||
| 2365 | + m.put("diff", ""); | ||
| 2366 | + } | ||
| 2367 | + } | ||
| 2368 | + | ||
| 2369 | + for(String key : strs){ | ||
| 2370 | + if(!(key.contains("all_"))){ | ||
| 2371 | + String[] sp = key.split("_"); | ||
| 2372 | + String allKey = "all"; | ||
| 2373 | + for(int i = 1; i < sp.length; i++){ | ||
| 2374 | + allKey += "_" + sp[i]; | ||
| 2375 | + } | ||
| 2376 | + Map<String, Object> map = keyMap.get(key); | ||
| 2377 | + Map<String, Object> allMap = keyMap.get(allKey); | ||
| 2378 | + for(String k : map.keySet()){ | ||
| 2379 | + if("year".equals(k)){ // 不想被计算的数字型字段 | ||
| 2380 | + continue; | ||
| 2381 | + } | ||
| 2382 | + try { | ||
| 2383 | + allMap.put(k, new BigDecimal(map.get(k).toString()).add( | ||
| 2384 | + new BigDecimal(allMap.get(k).toString())).doubleValue()); | ||
| 2385 | + } catch (Exception e) { | ||
| 2386 | + // TODO: handle exception | ||
| 2387 | + } | ||
| 2388 | + } | ||
| 2389 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)allMap.get("dataList"); | ||
| 2390 | + dataList.addAll((List<Map<String, Object>>)map.get("dataList")); | ||
| 2391 | + allMap.put("dataList", dataList); | ||
| 2392 | + | ||
| 2393 | + for(Map<String, Object> m : dataList){ | ||
| 2394 | + for(int i = 1; i <= 12; i++){ | ||
| 2395 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 2396 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 2397 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 2398 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 2399 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 2400 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2401 | + } else { | ||
| 2402 | + m.put("com" + i, ""); | ||
| 2403 | + } | ||
| 2404 | + } | ||
| 2405 | + } | ||
| 2406 | + } | ||
| 2407 | + } | ||
| 2408 | + | ||
| 2409 | + for(String key : strs){ | ||
| 2410 | + Map<String, Object> m = keyMap.get(key); | ||
| 2411 | + BigDecimal monAll = new BigDecimal("0"); | ||
| 2412 | + BigDecimal preAll = new BigDecimal("0"); | ||
| 2413 | + String digit = "10000"; | ||
| 2414 | + if("营收".equals(m.get("type").toString())){ | ||
| 2415 | + digit = "1000000"; | ||
| 2416 | + } | ||
| 2417 | + for(int i = 1; i <= 12; i++){ | ||
| 2418 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 2419 | + BigDecimal val = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2420 | + monAll = monAll.add(val); | ||
| 2421 | + val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2422 | + m.put("mon"+i, val.doubleValue()); | ||
| 2423 | + } | ||
| 2424 | + if(m.get("pre"+i).toString().length() > 0){ | ||
| 2425 | + BigDecimal val = new BigDecimal(m.get("pre"+i).toString()); | ||
| 2426 | + preAll = preAll.add(val); | ||
| 2427 | + val = val.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2428 | + m.put("pre"+i, val.doubleValue()); | ||
| 2429 | + if(m.get("mon"+i).toString().length() > 0){ | ||
| 2430 | + BigDecimal monVal = new BigDecimal(m.get("mon"+i).toString()); | ||
| 2431 | + BigDecimal sub = monVal.subtract(val); | ||
| 2432 | + m.put("sub"+i, sub.doubleValue() > 0 ? "+" + sub.doubleValue() : sub.doubleValue()); | ||
| 2433 | + } else { | ||
| 2434 | + m.put("sub"+i, "-" + val.doubleValue()); | ||
| 2435 | + } | ||
| 2436 | + } | ||
| 2437 | + } | ||
| 2438 | + monAll = monAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2439 | + preAll = preAll.divide(new BigDecimal(digit), 3, BigDecimal.ROUND_HALF_UP); | ||
| 2440 | + Double subAll = monAll.subtract(preAll).doubleValue(); | ||
| 2441 | + m.put("monAll", monAll.doubleValue()); | ||
| 2442 | + m.put("preAll", preAll.doubleValue()); | ||
| 2443 | + m.put("subAll", subAll > 0 ? "+" + subAll : subAll); | ||
| 2444 | + | ||
| 2445 | + if(m.get("formal").toString().length() > 0 && m.get("monAll").toString().length() > 0 | ||
| 2446 | + && new BigDecimal(m.get("formal").toString()).doubleValue() > 0d){ | ||
| 2447 | + BigDecimal formal = new BigDecimal(m.get("formal").toString()); | ||
| 2448 | + m.put("complete", monAll.divide( | ||
| 2449 | + formal, 4, BigDecimal.ROUND_HALF_UP).multiply( | ||
| 2450 | + new BigDecimal(100)).divide( | ||
| 2451 | + new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2452 | + BigDecimal diff = monAll.subtract(formal); | ||
| 2453 | + m.put("diff", diff.doubleValue() > 0 ? "+" + diff.doubleValue() : diff.doubleValue()); | ||
| 2454 | + } else { | ||
| 2455 | + m.put("complete", ""); | ||
| 2456 | + m.put("diff", ""); | ||
| 2457 | + } | ||
| 2458 | + m.put("year", year); | ||
| 2459 | + | ||
| 2460 | + for(int i = 1; i <= 12; i++){ | ||
| 2461 | + String mon = "mon" + i, bud = "bud" + i; | ||
| 2462 | + if(m.get(mon).toString().length() > 0 && m.get(bud).toString().length() > 0 | ||
| 2463 | + && new BigDecimal(m.get(bud).toString()).doubleValue() > 0d){ | ||
| 2464 | + BigDecimal a = new BigDecimal(m.get(mon).toString().length()>0?m.get(mon).toString():"0"); | ||
| 2465 | + BigDecimal b = new BigDecimal(m.get(bud).toString()); | ||
| 2466 | + m.put("com" + i, a.multiply(new BigDecimal(100)).divide(b, 2, BigDecimal.ROUND_HALF_UP)+ "%"); | ||
| 2467 | + } else { | ||
| 2468 | + m.put("com" + i, ""); | ||
| 2469 | + } | ||
| 2470 | + } | ||
| 2471 | + } | ||
| 2472 | + | ||
| 2473 | + if(tttt.equals("export")){ | ||
| 2474 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2475 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2476 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2477 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2478 | + String xls="budgetSum.xls"; | ||
| 2479 | + ReportUtils ee = new ReportUtils(); | ||
| 2480 | + try { | ||
| 2481 | + String dateTime = ""; | ||
| 2482 | + m.put("date", year); | ||
| 2483 | + dateTime = year; | ||
| 2484 | + listI.add(resList.iterator()); | ||
| 2485 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2486 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls, | ||
| 2487 | + path + "export/"+dateTime+"-预算汇总表.xls"); | ||
| 2488 | + } catch (Exception e) { | ||
| 2489 | + // TODO: handle exception | ||
| 2490 | + e.printStackTrace(); | ||
| 2491 | + } | ||
| 2492 | + } | ||
| 2493 | + | ||
| 2494 | + if(tttt.equals("exportData")){ | ||
| 2495 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2496 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2497 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2498 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2499 | + m.put("date", year); | ||
| 2500 | + ReportUtils ee = new ReportUtils(); | ||
| 2501 | + try { | ||
| 2502 | + if("allData".equals(kkk)){ | ||
| 2503 | + List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | ||
| 2504 | + Map<String, List<Map<String, Object>>> tempMap = new HashMap<String, List<Map<String, Object>>>(); | ||
| 2505 | + List<String> tempList = new ArrayList<String>(); | ||
| 2506 | + for(Map<String, Object> m1 : (List<Map<String, Object>>)resList.get(resList.size() - 3).get("dataList")){ | ||
| 2507 | + String xlName = m1.get("xlName")!=null?m1.get("xlName").toString():""; | ||
| 2508 | + if(!tempMap.containsKey(xlName)){ | ||
| 2509 | + tempMap.put(xlName, new ArrayList<Map<String, Object>>()); | ||
| 2510 | + tempList.add(xlName); | ||
| 2511 | + } | ||
| 2512 | + tempMap.get(xlName).add(m1); | ||
| 2513 | + } | ||
| 2514 | + for(Map<String, Object> m2 : (List<Map<String, Object>>)resList.get(resList.size() - 2).get("dataList")){ | ||
| 2515 | + String xlName = m2.get("xlName")!=null?m2.get("xlName").toString():""; | ||
| 2516 | + if(!tempMap.containsKey(xlName)){ | ||
| 2517 | + tempMap.put(xlName, new ArrayList<Map<String, Object>>()); | ||
| 2518 | + tempList.add(xlName); | ||
| 2519 | + } | ||
| 2520 | + tempMap.get(xlName).add(m2); | ||
| 2521 | + } | ||
| 2522 | + for(Map<String, Object> m3 : (List<Map<String, Object>>)resList.get(resList.size() - 1).get("dataList")){ | ||
| 2523 | + String xlName = m3.get("xlName")!=null?m3.get("xlName").toString():""; | ||
| 2524 | + if(!tempMap.containsKey(xlName)){ | ||
| 2525 | + tempMap.put(xlName, new ArrayList<Map<String, Object>>()); | ||
| 2526 | + tempList.add(xlName); | ||
| 2527 | + } | ||
| 2528 | + tempMap.get(xlName).add(m3); | ||
| 2529 | + } | ||
| 2530 | + for(String xlName : tempList){ | ||
| 2531 | + dataList.addAll(tempMap.get(xlName)); | ||
| 2532 | + } | ||
| 2533 | + listI.add(dataList.iterator()); | ||
| 2534 | + } else { | ||
| 2535 | + for(Map<String, Object> map : resList){ | ||
| 2536 | + if(kkk.equals(map.get("key").toString())){ | ||
| 2537 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 2538 | + listI.add(dataList.iterator()); | ||
| 2539 | + } | ||
| 2540 | + } | ||
| 2541 | + } | ||
| 2542 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2543 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/budgetSum_data.xls", | ||
| 2544 | + path + "export/" + year + "-预算汇总表-线路明细.xls"); | ||
| 2545 | + } catch (Exception e) { | ||
| 2546 | + // TODO: handle exception | ||
| 2547 | + e.printStackTrace(); | ||
| 2548 | + logger.info("", e); | ||
| 2549 | + } | ||
| 2550 | + } | ||
| 2551 | + | ||
| 2552 | + return resList; | ||
| 2553 | + } | ||
| 2554 | + | ||
| 2555 | + @Override | ||
| 2556 | + public List<Map<String, Object>> timeSum(String date1, String date2, String tttt, String k) throws Exception { | ||
| 2557 | + // TODO Auto-generated method stub | ||
| 2558 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 2559 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 2560 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 2561 | + Map<String, Map<String, Map<String, Long>>> timeMap = new HashMap<String, Map<String, Map<String, Long>>>(); | ||
| 2562 | + Map<String, Boolean> lineNature = lineService.lineNature(); | ||
| 2563 | + | ||
| 2564 | + Date d1 = sdf.parse(date1); | ||
| 2565 | + Date d2 = sdf.parse(date2); | ||
| 2566 | + | ||
| 2567 | + List<SchedulePlanInfo> findByDates = schedulePlanRepository.findByDates(d1, d2); | ||
| 2568 | + Iterable<Line> findAll = lineService.findAll(); | ||
| 2569 | + Map<String, Line> lineMap = new HashMap<String, Line>(); | ||
| 2570 | + for(Line line : findAll){ | ||
| 2571 | + lineMap.put(line.getLineCode(), line); | ||
| 2572 | + } | ||
| 2573 | + | ||
| 2574 | + List<Object[]> findPersonnelSchedule = schedulePlanRepository.findPersonnelSchedule(d1, d2); | ||
| 2575 | + List<Object[]> findCancelSchedule = scheduleRealRepository.findCancelSchedule(date1, date2, "缺人"); | ||
| 2576 | + Map<String, Long> psMap = new HashMap<String, Long>(), | ||
| 2577 | + csMap = new HashMap<String, Long>(); | ||
| 2578 | + for(Object[] objects : findPersonnelSchedule){ | ||
| 2579 | + if(!psMap.containsKey(objects[1])){ | ||
| 2580 | + psMap.put(objects[1].toString(), 1l); | ||
| 2581 | + } else { | ||
| 2582 | + psMap.put(objects[1].toString(), 1l + psMap.get(objects[1].toString())); | ||
| 2583 | + } | ||
| 2584 | + } | ||
| 2585 | + for(Object[] objects : findCancelSchedule){ | ||
| 2586 | + if(!csMap.containsKey(objects[1])){ | ||
| 2587 | + csMap.put(objects[1].toString(), 1l); | ||
| 2588 | + } else { | ||
| 2589 | + csMap.put(objects[1].toString(), 1l + csMap.get(objects[1].toString())); | ||
| 2590 | + } | ||
| 2591 | + } | ||
| 2592 | + | ||
| 2593 | + List<Object[]> findLineConfigCar = ccRepository.findLineConfigCar(d1); | ||
| 2594 | + List<Object[]> findLineConfigEmp = ecRepository.findLineConfigEmp(d1); | ||
| 2595 | + List<Object[]> findPlanGroupCar = schedulePlanRepository.findPlanGroupCar(d1, d2); | ||
| 2596 | + List<Object[]> findPlanGroupDriver = schedulePlanRepository.findPlanGroupDriver(d1, d2); | ||
| 2597 | + List<Object[]> findPlanGroupBusConductor = schedulePlanRepository.findPlanGroupBusConductor(d1, d2); | ||
| 2598 | + Map<String, Map<String, Object>> carMap = new HashMap<String, Map<String, Object>>(), | ||
| 2599 | + driverMap = new HashMap<String, Map<String, Object>>(), | ||
| 2600 | + busConductorMap = new HashMap<String, Map<String, Object>>(); | ||
| 2601 | + for(Object[] objects : findPlanGroupCar){ | ||
| 2602 | + String key = objects[0].toString(); | ||
| 2603 | + if(!carMap.containsKey(key)){ | ||
| 2604 | + carMap.put(key, new HashMap<String, Object>()); | ||
| 2605 | + } | ||
| 2606 | + carMap.get(key).put(objects[1].toString(), objects[2]); | ||
| 2607 | + } | ||
| 2608 | + for(Object[] objects : findPlanGroupDriver){ | ||
| 2609 | + String key = objects[0].toString(); | ||
| 2610 | + if(!driverMap.containsKey(key)){ | ||
| 2611 | + driverMap.put(key, new HashMap<String, Object>()); | ||
| 2612 | + } | ||
| 2613 | + driverMap.get(key).put(objects[1].toString(), objects[2]); | ||
| 2614 | + } | ||
| 2615 | + for(Object[] objects : findPlanGroupBusConductor){ | ||
| 2616 | + String key = objects[0].toString(); | ||
| 2617 | + if(!busConductorMap.containsKey(key)){ | ||
| 2618 | + busConductorMap.put(key, new HashMap<String, Object>()); | ||
| 2619 | + } | ||
| 2620 | + busConductorMap.get(key).put(objects[1].toString(), objects[2]); | ||
| 2621 | + } | ||
| 2622 | + | ||
| 2623 | + Map<String, Long> ccMap = new HashMap<String, Long>(); | ||
| 2624 | + Map<String, Long> ecMap = new HashMap<String, Long>(); | ||
| 2625 | + for(Object[] objects : findLineConfigCar){ | ||
| 2626 | + if(!ccMap.containsKey(objects[0].toString())){ | ||
| 2627 | + ccMap.put(objects[0].toString(), 1l); | ||
| 2628 | + } else { | ||
| 2629 | + ccMap.put(objects[0].toString(), 1l + ccMap.get(objects[0].toString())); | ||
| 2630 | + } | ||
| 2631 | + } | ||
| 2632 | + for(Object[] objects : findLineConfigEmp){ | ||
| 2633 | + if(!ecMap.containsKey(objects[0].toString())){ | ||
| 2634 | + ecMap.put(objects[0].toString(), 1l); | ||
| 2635 | + } else { | ||
| 2636 | + ecMap.put(objects[0].toString(), 1l + ecMap.get(objects[0].toString())); | ||
| 2637 | + } | ||
| 2638 | + } | ||
| 2639 | + | ||
| 2640 | + String temp = ""; | ||
| 2641 | + Long tempLong = 0l; | ||
| 2642 | + Long l = 0l; | ||
| 2643 | + SchedulePlanInfo tempSchedule = new SchedulePlanInfo(); | ||
| 2644 | + for(SchedulePlanInfo s : findByDates){ | ||
| 2645 | + String scheduleDate = sdf.format(s.getScheduleDate()); | ||
| 2646 | + String gs = s.getGsBm(); | ||
| 2647 | + String xlBm = s.getXlBm(); | ||
| 2648 | + String lpName = s.getLpName(); | ||
| 2649 | + String jGh = s.getjGh(); | ||
| 2650 | + String temp1 = gs + "/" + scheduleDate + "/" + xlBm + "/" + lpName + "/" + jGh; | ||
| 2651 | + String fcsj = s.getFcsj(); | ||
| 2652 | + String[] split = fcsj.split(":"); | ||
| 2653 | + Long tempLong1 = Long.valueOf(split[0])*60l + Long.valueOf(split[1]); | ||
| 2654 | + if(!(temp1.equals(temp)) || temp.length() == 0){ | ||
| 2655 | + if(l > 0l){ | ||
| 2656 | + String gsFgs = tempSchedule.getGsBm(); | ||
| 2657 | + String xl = tempSchedule.getXlBm(); | ||
| 2658 | + String jj = sdf.format(tempSchedule.getScheduleDate()) + "/" + tempSchedule.getjGh(); | ||
| 2659 | + if(!timeMap.containsKey(gsFgs)){ | ||
| 2660 | + timeMap.put(gsFgs, new HashMap<String, Map<String, Long>>()); | ||
| 2661 | + } | ||
| 2662 | + if(!timeMap.get(gsFgs).containsKey(xl)){ | ||
| 2663 | + timeMap.get(gsFgs).put(xl, new HashMap<String, Long>()); | ||
| 2664 | + } | ||
| 2665 | + if(timeMap.get(gsFgs).get(xl).containsKey(jj)){ | ||
| 2666 | + timeMap.get(gsFgs).get(xl).put(jj, timeMap.get(gsFgs).get(xl).get(jj) + l); | ||
| 2667 | + } else { | ||
| 2668 | + timeMap.get(gsFgs).get(xl).put(jj, l); | ||
| 2669 | + } | ||
| 2670 | + } | ||
| 2671 | + l = 0l; | ||
| 2672 | + tempLong = tempLong1; | ||
| 2673 | + temp = temp1; | ||
| 2674 | + tempSchedule = s; | ||
| 2675 | + } else { | ||
| 2676 | + tempLong1 += s.getBcsj(); | ||
| 2677 | + if(tempLong1 < tempLong){ | ||
| 2678 | + tempLong1 += (1l*60*24); | ||
| 2679 | + } | ||
| 2680 | + l += tempLong1 - tempLong; | ||
| 2681 | + tempLong = tempLong1; | ||
| 2682 | + } | ||
| 2683 | + } | ||
| 2684 | + | ||
| 2685 | + String[] strs = createBudgetMap_sum2(resList, keyMap); | ||
| 2686 | + | ||
| 2687 | + for(String key : strs){ | ||
| 2688 | + Map<String, Object> map = keyMap.get(key); | ||
| 2689 | + String[] split = key.split("_"); | ||
| 2690 | + String gs = split[0]; | ||
| 2691 | + String nature = split[1]; | ||
| 2692 | + List<Long> lList = new ArrayList<Long>(); | ||
| 2693 | + List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | ||
| 2694 | + Long warrantCar = 0l, ccNum = 0l, ecNum = 0l, | ||
| 2695 | + carNum = 0l, driverNum = 0l, busConductorNum = 0l, | ||
| 2696 | + psNum = 0l, csNum = 0l; | ||
| 2697 | + for(String gsFgs : timeMap.keySet()){ | ||
| 2698 | + if("all".equals(gs) || gsFgs.equals(gs)){ | ||
| 2699 | + Map<String, Map<String, Long>> xlMap = timeMap.get(gsFgs); | ||
| 2700 | + for(String xl : xlMap.keySet()){ | ||
| 2701 | + Boolean b = false; | ||
| 2702 | + if("1".equals(nature) && lineNature.containsKey(xl) && lineNature.get(xl)){ | ||
| 2703 | + b = true; | ||
| 2704 | + } | ||
| 2705 | + if("2".equals(nature) && !(lineNature.containsKey(xl) && lineNature.get(xl))){ | ||
| 2706 | + b = true; | ||
| 2707 | + } | ||
| 2708 | + if("0".equals(nature)){ | ||
| 2709 | + b = true; | ||
| 2710 | + } | ||
| 2711 | + if(b){ | ||
| 2712 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2713 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsFgs)); | ||
| 2714 | + m.put("xlName", lineMap.containsKey(xl)?lineMap.get(xl).getName():""); | ||
| 2715 | + List<Long> xl_lList = new ArrayList<Long>(); | ||
| 2716 | + | ||
| 2717 | + Map<String, Long> jjMap = xlMap.get(xl); | ||
| 2718 | + for(String jj : jjMap.keySet()){ //营运工时 | ||
| 2719 | + lList.add(jjMap.get(jj)); | ||
| 2720 | + xl_lList.add(jjMap.get(jj)); | ||
| 2721 | + } | ||
| 2722 | + Long sum = 0l; | ||
| 2723 | + for(Long ll : xl_lList){ | ||
| 2724 | + sum += ll; | ||
| 2725 | + } | ||
| 2726 | + m.put("time", xl_lList.size()>0?new BigDecimal(sum).divide( | ||
| 2727 | + new BigDecimal(xl_lList.size()*60l), 2, BigDecimal.ROUND_HALF_UP):""); | ||
| 2728 | + | ||
| 2729 | + if(lineMap.containsKey(xl)){ //权证配车数 | ||
| 2730 | + warrantCar += lineMap.get(xl).getWarrantCar()!=null?lineMap.get(xl).getWarrantCar():0l; | ||
| 2731 | + m.put("warrantCar", lineMap.get(xl).getWarrantCar()); | ||
| 2732 | + } else { | ||
| 2733 | + m.put("warrantCar", ""); | ||
| 2734 | + } | ||
| 2735 | + if(ccMap.containsKey(xl)){ //机务保管数 | ||
| 2736 | + ccNum += ccMap.get(xl); | ||
| 2737 | + m.put("ccNum", ccMap.get(xl)); | ||
| 2738 | + } else { | ||
| 2739 | + m.put("ccNum", ""); | ||
| 2740 | + } | ||
| 2741 | + if(ecMap.containsKey(xl)){ //人事配档数 | ||
| 2742 | + ecNum += ecMap.get(xl); | ||
| 2743 | + m.put("ecNum", ecMap.get(xl)); | ||
| 2744 | + } else { | ||
| 2745 | + m.put("ecNum", ""); | ||
| 2746 | + } | ||
| 2747 | + if(carMap.containsKey(gsFgs) && carMap.get(gsFgs).containsKey(xl)){ //最高配车数 | ||
| 2748 | + carNum += Long.valueOf(carMap.get(gsFgs).get(xl).toString()); | ||
| 2749 | + m.put("carNum", Long.valueOf(carMap.get(gsFgs).get(xl).toString())); | ||
| 2750 | + } else { | ||
| 2751 | + m.put("carNum", ""); | ||
| 2752 | + } | ||
| 2753 | + if(driverMap.containsKey(gsFgs) && driverMap.get(gsFgs).containsKey(xl)){ //司最高陪人数 | ||
| 2754 | + driverNum += Long.valueOf(driverMap.get(gsFgs).get(xl).toString()); | ||
| 2755 | + m.put("driverNum", Long.valueOf(driverMap.get(gsFgs).get(xl).toString())); | ||
| 2756 | + } else { | ||
| 2757 | + m.put("driverNum", ""); | ||
| 2758 | + } | ||
| 2759 | + if(busConductorMap.containsKey(gsFgs) && busConductorMap.get(gsFgs).containsKey(xl)){ //售最高陪人数 | ||
| 2760 | + busConductorNum += Long.valueOf(busConductorMap.get(gsFgs).get(xl).toString()); | ||
| 2761 | + m.put("busConductorNum", Long.valueOf(busConductorMap.get(gsFgs).get(xl).toString())); | ||
| 2762 | + } else { | ||
| 2763 | + m.put("busConductorNum", ""); | ||
| 2764 | + } | ||
| 2765 | + if(psMap.containsKey(xl)){ //总排挡数 | ||
| 2766 | + psNum += psMap.get(xl); | ||
| 2767 | + m.put("psNum", psMap.get(xl)); | ||
| 2768 | + } else { | ||
| 2769 | + m.put("psNum", ""); | ||
| 2770 | + } | ||
| 2771 | + if(csMap.containsKey(xl)){ //总病缺勤数(缺人烂班) | ||
| 2772 | + csNum += csMap.get(xl); | ||
| 2773 | + m.put("csNum", csMap.get(xl)); | ||
| 2774 | + } else { | ||
| 2775 | + m.put("csNum", ""); | ||
| 2776 | + } | ||
| 2777 | + | ||
| 2778 | + if(m.containsKey("carNum") && m.get("carNum").toString().length() > 0 | ||
| 2779 | + && m.containsKey("ccNum") && m.get("ccNum").toString().length() > 0){ | ||
| 2780 | + Long car = Long.valueOf(m.get("carNum").toString()); | ||
| 2781 | + Long cc = Long.valueOf(m.get("ccNum").toString()); | ||
| 2782 | + m.put("bcl", cc>0l?new BigDecimal((cc>car?cc-car:0)*100l).divide( | ||
| 2783 | + new BigDecimal(cc), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2784 | + } else { | ||
| 2785 | + m.put("bcl", "%"); | ||
| 2786 | + } | ||
| 2787 | + if(m.containsKey("csNum") && m.get("csNum").toString().length() > 0 | ||
| 2788 | + && m.containsKey("psNum") && m.get("psNum").toString().length() > 0){ | ||
| 2789 | + Long cs = Long.valueOf(m.get("csNum").toString()); | ||
| 2790 | + Long ps = Long.valueOf(m.get("psNum").toString()); | ||
| 2791 | + m.put("cspsNum", ps>0l?new BigDecimal((cs<ps?cs:ps)*100l).divide( | ||
| 2792 | + new BigDecimal(ps), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2793 | + } else { | ||
| 2794 | + m.put("cspsNum", "%"); | ||
| 2795 | + } | ||
| 2796 | + dataList.add(m); | ||
| 2797 | + } | ||
| 2798 | + } | ||
| 2799 | + } | ||
| 2800 | + } | ||
| 2801 | + map.put("warrantCar", warrantCar); | ||
| 2802 | + map.put("ccNum", ccNum); | ||
| 2803 | + map.put("carNum", carNum); | ||
| 2804 | + map.put("bcl", ccNum>0l?new BigDecimal((ccNum>carNum?ccNum-carNum:0)*100l).divide( | ||
| 2805 | + new BigDecimal(ccNum), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2806 | + map.put("ecNum", ecNum); | ||
| 2807 | + map.put("driverNum", driverNum); | ||
| 2808 | + map.put("busConductorNum", busConductorNum); | ||
| 2809 | + map.put("cspsNum", psNum>0l?new BigDecimal((csNum<psNum?csNum:psNum)*100l).divide( | ||
| 2810 | + new BigDecimal(psNum), 2, BigDecimal.ROUND_HALF_UP)+"%":"%"); | ||
| 2811 | + Long sum = 0l; | ||
| 2812 | + for(Long ll : lList){ | ||
| 2813 | + sum += ll; | ||
| 2814 | + } | ||
| 2815 | + map.put("time", lList.size()>0?new BigDecimal(sum).divide( | ||
| 2816 | + new BigDecimal(lList.size()*60l), 2, BigDecimal.ROUND_HALF_UP):""); | ||
| 2817 | + map.put("dataList", dataList); | ||
| 2818 | + } | ||
| 2819 | + | ||
| 2820 | + if(tttt.equals("export")){ | ||
| 2821 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2822 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2823 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2824 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2825 | + m.put("date", date1 + "至" + date2); | ||
| 2826 | + m.put("typeName", "线路性质"); | ||
| 2827 | + ReportUtils ee = new ReportUtils(); | ||
| 2828 | + try { | ||
| 2829 | + String dateTime = ""; | ||
| 2830 | + if (date1.equals(date2)) { | ||
| 2831 | + dateTime = sdfSimple.format(sdfMonth.parse(date1)); | ||
| 2832 | + } else { | ||
| 2833 | + dateTime = sdfSimple.format(sdfMonth.parse(date1)) | ||
| 2834 | + + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 2835 | + } | ||
| 2836 | + listI.add(resList.iterator()); | ||
| 2837 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2838 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/timeSum.xls", | ||
| 2839 | + path + "export/" + dateTime + "-时刻表汇总表.xls"); | ||
| 2840 | + } catch (Exception e) { | ||
| 2841 | + // TODO: handle exception | ||
| 2842 | + e.printStackTrace(); | ||
| 2843 | + logger.info("", e); | ||
| 2844 | + } | ||
| 2845 | + } | ||
| 2846 | + | ||
| 2847 | + if(tttt.equals("exportData")){ | ||
| 2848 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 2849 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 2850 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 2851 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2852 | + m.put("date", date1 + "至" + date2); | ||
| 2853 | + m.put("typeName", "线路名"); | ||
| 2854 | + ReportUtils ee = new ReportUtils(); | ||
| 2855 | + try { | ||
| 2856 | + String dateTime = ""; | ||
| 2857 | + if (date1.equals(date2)) { | ||
| 2858 | + dateTime = sdfSimple.format(sdfMonth.parse(date1)); | ||
| 2859 | + } else { | ||
| 2860 | + dateTime = sdfSimple.format(sdfMonth.parse(date1)) | ||
| 2861 | + + "-" + sdfSimple.format(sdfMonth.parse(date2)); | ||
| 2862 | + } | ||
| 2863 | + for(Map<String, Object> map : resList){ | ||
| 2864 | + if(k.equals(map.get("key").toString())){ | ||
| 2865 | + List<Map<String, Object>> dataList = (List<Map<String, Object>>)map.get("dataList"); | ||
| 2866 | + for(Map<String, Object> mm : dataList){ | ||
| 2867 | + mm.put("type", mm.get("xlName")); | ||
| 2868 | + } | ||
| 2869 | + listI.add(dataList.iterator()); | ||
| 2870 | + } | ||
| 2871 | + } | ||
| 2872 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 2873 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/timeSum.xls", | ||
| 2874 | + path + "export/" + dateTime + "-时刻表汇总表-线路明细.xls"); | ||
| 2875 | + } catch (Exception e) { | ||
| 2876 | + // TODO: handle exception | ||
| 2877 | + e.printStackTrace(); | ||
| 2878 | + logger.info("", e); | ||
| 2879 | + } | ||
| 2880 | + } | ||
| 2881 | + | ||
| 2882 | + return resList; | ||
| 2883 | + } | ||
| 2884 | + | ||
| 2885 | + @Override | ||
| 2886 | + public Map<String, Object> timeAnaly(String company, String subCompany, String date, | ||
| 2887 | + String line, String model, String tttt, String kkkk) throws Exception { | ||
| 2888 | + // TODO Auto-generated method stub | ||
| 2889 | + | ||
| 2890 | + int | ||
| 2891 | + zgf1 = 6 * 60 + 31, | ||
| 2892 | + zgf2 = 8 * 60 + 30, | ||
| 2893 | + wgf1 = 16 * 60 + 1, | ||
| 2894 | + wgf2 = 18 * 60, | ||
| 2895 | + xxsj = 90; | ||
| 2896 | + | ||
| 2897 | + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 2898 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 2899 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 2900 | + Map<String, List<SchedulePlanInfo>> keyList = new HashMap<String, List<SchedulePlanInfo>>(); | ||
| 2901 | + List<SchedulePlanInfo> planList = new ArrayList<SchedulePlanInfo>(); | ||
| 2902 | + List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | ||
| 2903 | + | ||
| 2904 | + if(model.trim().length() > 0){ | ||
| 2905 | + planList = schedulePlanRepository.findPlanByTTinfo(line, Long.valueOf(model), date); | ||
| 2906 | + } else { | ||
| 2907 | + planList = schedulePlanRepository.findPlanByXlAndDate(line, date); | ||
| 2908 | + } | ||
| 2909 | + | ||
| 2910 | + Map<String, Object> dMap=new HashMap<>(); | ||
| 2911 | + dMap.put("dGroup_eq", "ScheduleBxType"); | ||
| 2912 | + Iterator<Dictionary> it= dictionaryService.list(dMap).iterator(); | ||
| 2913 | + while (it.hasNext()) { | ||
| 2914 | + Dictionary d=it.next(); | ||
| 2915 | + dMap.put(d.getdCode(), d.getdName()); | ||
| 2916 | + } | ||
| 2917 | + | ||
| 2918 | + for(SchedulePlanInfo plan : planList){ | ||
| 2919 | + String gsBm = plan.getGsBm(); | ||
| 2920 | + String fgsBm = plan.getFgsBm(); | ||
| 2921 | + String xl = plan.getXl().toString(); | ||
| 2922 | + String lp = plan.getLp().toString(); | ||
| 2923 | + String ttInfo = plan.getTtInfo().toString(); | ||
| 2924 | + String key = gsBm + "/" + fgsBm + "/" + xl + "/" + lp + "/" + ttInfo; | ||
| 2925 | + if(!keyMap.containsKey(key)){ | ||
| 2926 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 2927 | + m.put("gsBm", gsBm); | ||
| 2928 | + m.put("fgsBm", fgsBm); | ||
| 2929 | + m.put("gsName", BasicData.businessCodeNameMap.get(gsBm)); | ||
| 2930 | + m.put("fgsName", BasicData.businessFgsCodeNameMap.get(fgsBm + "_" + gsBm)); | ||
| 2931 | + m.put("xl", xl); | ||
| 2932 | + m.put("xlName", plan.getXlName()); | ||
| 2933 | + m.put("lp", lp); | ||
| 2934 | + m.put("lpName", plan.getLpName()); | ||
| 2935 | + m.put("outStation", ""); | ||
| 2936 | + m.put("qdzName0", ""); | ||
| 2937 | + m.put("zdzName0", ""); | ||
| 2938 | + m.put("qdzName1", ""); | ||
| 2939 | + m.put("zdzName1", ""); | ||
| 2940 | + m.put("inStation", ""); | ||
| 2941 | + keyMap.put(key, m); | ||
| 2942 | + keyList.put(key, new ArrayList<SchedulePlanInfo>()); | ||
| 2943 | + list.add(m); | ||
| 2944 | + } | ||
| 2945 | + keyList.get(key).add(plan); | ||
| 2946 | + } | ||
| 2947 | + | ||
| 2948 | + Set<String> ecSet = new HashSet<String>(); // 人事配档数 | ||
| 2949 | + Set<String> carSet = new HashSet<String>(); // 配车数 | ||
| 2950 | + for(String key : keyList.keySet()){ | ||
| 2951 | + String[] keys = key.split("/"); | ||
| 2952 | + Long ttInfo = Long.valueOf(keys[4]); | ||
| 2953 | + int xl = Integer.valueOf(keys[2]); | ||
| 2954 | + Long lp = Long.valueOf(keys[3]); | ||
| 2955 | + Map<String, Object> m = keyMap.get(key); | ||
| 2956 | + int p_fcsj = 0, p_dzsj = 0; | ||
| 2957 | + int yssj_bc = 0, yssj_all = 0, yssj_z = 0, yssj_w = 0, yssj_d = 0; | ||
| 2958 | + int tzsj_bc = 0, tzsj_all = 0, tzsj_z = 0, tzsj_w = 0, tzsj_d = 0; | ||
| 2959 | + int ksbc = 0, yybc = 0, zgs = 15; // 总工时:加上报到例保时间15分钟、复驶路牌10分钟 | ||
| 2960 | + BigDecimal kslc = new BigDecimal(0), yylc = new BigDecimal(0); | ||
| 2961 | + for(SchedulePlanInfo plan : keyList.get(key)){ | ||
| 2962 | + String[] split = plan.getFcsj().split(":"); | ||
| 2963 | + int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | ||
| 2964 | + int bcsj = plan.getBcsj(); | ||
| 2965 | + if(fcsj < p_fcsj){ | ||
| 2966 | + fcsj += 24*60; | ||
| 2967 | + } | ||
| 2968 | + int dzsj = fcsj + bcsj; | ||
| 2969 | + | ||
| 2970 | + String jGh = plan.getjGh() != null ? plan.getjGh().trim() : ""; | ||
| 2971 | + String sGh = plan.getsGh() != null ? plan.getsGh().trim() : ""; | ||
| 2972 | + String zbh = plan.getClZbh() != null ? plan.getClZbh().trim() : ""; | ||
| 2973 | + ecSet.add(jGh + "/" + sGh); | ||
| 2974 | + carSet.add(zbh); | ||
| 2975 | + | ||
| 2976 | + if(m.get("outStation").toString().length() == 0 && "out".equals(plan.getBcType())){ | ||
| 2977 | + m.put("outStation", plan.getQdzName()!=null?plan.getQdzName():""); | ||
| 2978 | + } | ||
| 2979 | + if(m.get("qdzName0").toString().length() == 0 && "0".equals(plan.getXlDir()) | ||
| 2980 | + && "normal".equals(plan.getBcType())){ | ||
| 2981 | + m.put("qdzName0", plan.getQdzName()!=null?plan.getQdzName():""); | ||
| 2982 | + m.put("zdzName0", plan.getZdzName()!=null?plan.getZdzName():""); | ||
| 2983 | + } | ||
| 2984 | + if(m.get("qdzName1").toString().length() == 0 && "1".equals(plan.getXlDir()) | ||
| 2985 | + && "normal".equals(plan.getBcType())){ | ||
| 2986 | + m.put("qdzName1", plan.getQdzName()!=null?plan.getQdzName():""); | ||
| 2987 | + m.put("zdzName1", plan.getZdzName()!=null?plan.getZdzName():""); | ||
| 2988 | + } | ||
| 2989 | + if(m.get("inStation").toString().length() == 0 && "in".equals(plan.getBcType())){ | ||
| 2990 | + m.put("inStation", plan.getZdzName()!=null?plan.getZdzName():""); | ||
| 2991 | + } | ||
| 2992 | + | ||
| 2993 | + if(p_dzsj > 0 && fcsj - p_dzsj < xxsj){ | ||
| 2994 | + zgs += dzsj - p_dzsj; | ||
| 2995 | + } else { | ||
| 2996 | + zgs += bcsj; | ||
| 2997 | + } | ||
| 2998 | + | ||
| 2999 | + if("in/out/ldks".contains(plan.getBcType())){ | ||
| 3000 | + ksbc += 1; | ||
| 3001 | + kslc = kslc.add(BigDecimal.valueOf(plan.getJhlc())); | ||
| 3002 | + } else { | ||
| 3003 | + yybc += 1; | ||
| 3004 | + yylc = yylc.add(BigDecimal.valueOf(plan.getJhlc())); | ||
| 3005 | + } | ||
| 3006 | + | ||
| 3007 | + if(!("in/out/ldks".contains(plan.getBcType()))){ | ||
| 3008 | + yssj_bc += 1; | ||
| 3009 | + yssj_all += bcsj; | ||
| 3010 | + if(fcsj <= zgf2 && dzsj >= zgf1){ | ||
| 3011 | + int a = fcsj >= zgf1 ? fcsj : zgf1; | ||
| 3012 | + int b = dzsj >= zgf2 ? zgf2 : dzsj; | ||
| 3013 | + yssj_z += b - a; | ||
| 3014 | + } | ||
| 3015 | + if(fcsj <= wgf2 && dzsj >= wgf1){ | ||
| 3016 | + int a = fcsj >= wgf1 ? fcsj : wgf1; | ||
| 3017 | + int b = dzsj >= wgf2 ? wgf2 : dzsj; | ||
| 3018 | + yssj_w += b - a; | ||
| 3019 | + } | ||
| 3020 | + yssj_d += bcsj; // 低谷运送时间,下面减去高峰时段的时间就是低谷时间 | ||
| 3021 | + if(fcsj >= zgf1 && fcsj <= zgf2){ | ||
| 3022 | + if(dzsj < zgf2){ | ||
| 3023 | + yssj_d -= dzsj - fcsj; | ||
| 3024 | + } else { | ||
| 3025 | + yssj_d -= zgf2 - fcsj; | ||
| 3026 | + } | ||
| 3027 | + } else if(dzsj >= zgf1 && dzsj <= zgf2){ | ||
| 3028 | + yssj_d -= dzsj - zgf1; | ||
| 3029 | + } else if(fcsj < zgf1 && dzsj > zgf2){ | ||
| 3030 | + yssj_d -= zgf2 - zgf1; | ||
| 3031 | + } | ||
| 3032 | + if(fcsj >= wgf1 && fcsj <= wgf2){ | ||
| 3033 | + if(dzsj < wgf2){ | ||
| 3034 | + yssj_d -= dzsj - fcsj; | ||
| 3035 | + } else { | ||
| 3036 | + yssj_d -= wgf2 - fcsj; | ||
| 3037 | + } | ||
| 3038 | + } else if(dzsj >= wgf1 && dzsj <= wgf2){ | ||
| 3039 | + yssj_d -= dzsj - wgf1; | ||
| 3040 | + } else if(fcsj < wgf1 && dzsj > wgf2){ | ||
| 3041 | + yssj_d -= wgf2 - wgf1; | ||
| 3042 | + } | ||
| 3043 | + } | ||
| 3044 | + | ||
| 3045 | + if(!("in/out".contains(plan.getBcType()))){ | ||
| 3046 | + int tzsj = fcsj - p_dzsj; // 停站时间,1、前个计划运送后到这个计划发车前;2、超过2小时或者下个班次为进出场时为空。 | ||
| 3047 | + if(tzsj < 0){ | ||
| 3048 | + tzsj = 0; | ||
| 3049 | + } | ||
| 3050 | + if(tzsj < xxsj){ | ||
| 3051 | + tzsj_bc += 1; | ||
| 3052 | + tzsj_all += tzsj; | ||
| 3053 | + } | ||
| 3054 | + if(tzsj > 0 && tzsj < xxsj){ | ||
| 3055 | + if(p_dzsj <= zgf2 && fcsj >= zgf1){ | ||
| 3056 | + int a = p_dzsj >= zgf1 ? p_dzsj : zgf1; | ||
| 3057 | + int b = fcsj >= zgf2 ? zgf2 : fcsj; | ||
| 3058 | + tzsj_z += b - a; | ||
| 3059 | + } | ||
| 3060 | + if(p_dzsj <= wgf2 && fcsj >= wgf1){ | ||
| 3061 | + int a = p_dzsj >= wgf1 ? p_dzsj : wgf1; | ||
| 3062 | + int b = fcsj >= wgf2 ? wgf2 : fcsj; | ||
| 3063 | + tzsj_w += b - a; | ||
| 3064 | + } | ||
| 3065 | + tzsj_d += tzsj; // 低谷停站时间,下面减去高峰时段的时间就是低谷时间 | ||
| 3066 | + if(p_dzsj >= zgf1 && p_dzsj <= zgf2){ | ||
| 3067 | + if(fcsj < zgf2){ | ||
| 3068 | + tzsj_d -= fcsj - p_dzsj; | ||
| 3069 | + } else { | ||
| 3070 | + tzsj_d -= zgf2 - p_dzsj; | ||
| 3071 | + } | ||
| 3072 | + } else if(fcsj >= zgf1 && fcsj <= zgf2){ | ||
| 3073 | + tzsj_d -= fcsj - zgf1; | ||
| 3074 | + } else if(p_dzsj < zgf1 && fcsj > zgf2){ | ||
| 3075 | + tzsj_d -= zgf2 - zgf1; | ||
| 3076 | + } | ||
| 3077 | + if(p_dzsj >= wgf1 && p_dzsj <= wgf2){ | ||
| 3078 | + if(fcsj < wgf2){ | ||
| 3079 | + tzsj_d -= fcsj - p_dzsj; | ||
| 3080 | + } else { | ||
| 3081 | + tzsj_d -= wgf2 - p_dzsj; | ||
| 3082 | + } | ||
| 3083 | + } else if(fcsj >= wgf1 && fcsj <= wgf2){ | ||
| 3084 | + tzsj_d -= fcsj - wgf1; | ||
| 3085 | + } else if(p_dzsj < wgf1 && fcsj > wgf2){ | ||
| 3086 | + tzsj_d -= wgf2 - wgf1; | ||
| 3087 | + } | ||
| 3088 | + } | ||
| 3089 | + } | ||
| 3090 | + | ||
| 3091 | + p_fcsj = fcsj; | ||
| 3092 | + p_dzsj = dzsj; | ||
| 3093 | + } | ||
| 3094 | + | ||
| 3095 | + m.put("yssj_z", yssj_z); | ||
| 3096 | + m.put("yssj_w", yssj_w); | ||
| 3097 | + m.put("yssj_d", yssj_d); | ||
| 3098 | + m.put("yssj_average", yssj_bc > 0 ? new BigDecimal(yssj_all).divide( | ||
| 3099 | + new BigDecimal(yssj_bc), 2, BigDecimal.ROUND_HALF_UP) : ""); | ||
| 3100 | + m.put("tzsj_z", tzsj_z); | ||
| 3101 | + m.put("tzsj_w", tzsj_w); | ||
| 3102 | + m.put("tzsj_d", tzsj_d); | ||
| 3103 | + m.put("tzsj_average", tzsj_bc > 0 ? new BigDecimal(tzsj_all).divide( | ||
| 3104 | + new BigDecimal(tzsj_bc), 2, BigDecimal.ROUND_HALF_UP) : ""); | ||
| 3105 | + m.put("ksbc", ksbc); | ||
| 3106 | + m.put("kslc", kslc); | ||
| 3107 | + m.put("ks", ksbc + "/" + kslc); | ||
| 3108 | + m.put("yybc", yybc); | ||
| 3109 | + m.put("yylc", yylc); | ||
| 3110 | + m.put("yy", yybc + "/" + yylc); | ||
| 3111 | + m.put("yygs", yssj_all/60 + "." + (yssj_all%60>9?"":"0") + yssj_all%60); | ||
| 3112 | + m.put("zgs", zgs/60 + "." + (zgs%60>9?"":"0") + zgs%60); | ||
| 3113 | + | ||
| 3114 | + String bx = ""; | ||
| 3115 | + List<TTInfoBxDetail> findBxDetail = ttInfoBxDetailRepository.findBxDetail(ttInfo, xl, lp); | ||
| 3116 | + if(findBxDetail.size() > 0){ | ||
| 3117 | + for(TTInfoBxDetail b : findBxDetail){ | ||
| 3118 | + if(b.getBxType1() != null && b.getBxType1().getDicDesc() != null | ||
| 3119 | + && !("null".equals(b.getBxType1().getDicDesc()))){ | ||
| 3120 | + String dic = b.getBxType1().getDicDesc(); | ||
| 3121 | + if(dMap.containsKey(dic)){ | ||
| 3122 | + dic = dMap.get(dic).toString(); | ||
| 3123 | + } | ||
| 3124 | + bx += bx.length() > 0 ? "/" + dic : dic; | ||
| 3125 | + } | ||
| 3126 | + if(b.getBxType2() != null && b.getBxType2().getDicDesc() != null | ||
| 3127 | + && !("null".equals(b.getBxType2().getDicDesc()))){ | ||
| 3128 | + String dic = b.getBxType2().getDicDesc(); | ||
| 3129 | + if(dMap.containsKey(dic)){ | ||
| 3130 | + dic = dMap.get(dic).toString(); | ||
| 3131 | + } | ||
| 3132 | + bx += bx.length() > 0 ? "/" + dic : dic; | ||
| 3133 | + } | ||
| 3134 | + } | ||
| 3135 | + } | ||
| 3136 | + m.put("bx", bx); | ||
| 3137 | + } | ||
| 3138 | + | ||
| 3139 | + resMap.put("ecNum", ecSet.size()); | ||
| 3140 | + resMap.put("carNum", carSet.size()); | ||
| 3141 | + resMap.put("dataList", list); | ||
| 3142 | + | ||
| 3143 | + if(tttt.equals("export")){ | ||
| 3144 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 3145 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 3146 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 3147 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 3148 | + m.put("date", date); | ||
| 3149 | + m.put("ecNum", ecSet.size()); | ||
| 3150 | + m.put("carNum", carSet.size()); | ||
| 3151 | + m.put("lineName", BasicData.lineCodeAllNameMap.get(line)); | ||
| 3152 | + ReportUtils ee = new ReportUtils(); | ||
| 3153 | + try { | ||
| 3154 | + listI.add(list.iterator()); | ||
| 3155 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 3156 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/timeAnaly.xls", | ||
| 3157 | + path + "export/" + date + "-" + BasicData.lineCodeAllNameMap.get(line) + "-线路时刻表分析明细.xls"); | ||
| 3158 | + } catch (Exception e) { | ||
| 3159 | + // TODO: handle exception | ||
| 3160 | + e.printStackTrace(); | ||
| 3161 | + logger.info("", e); | ||
| 3162 | + } | ||
| 3163 | + } | ||
| 3164 | + | ||
| 3165 | + return resMap; | ||
| 3166 | + } | ||
| 3167 | + | ||
| 3168 | + public String[] createBudgetMap(List<Map<String, Object>> list, Map<String, Map<String, Object>> keyMap){ | ||
| 3169 | + | ||
| 3170 | + String[] strs = {"05_1_1", "05_1_0", "05_1_all", "05_0", "05_all" | ||
| 3171 | + ,"55_1_1", "55_1_0", "55_1_all", "55_0", "55_all" | ||
| 3172 | + ,"22_1_1", "22_1_0", "22_1_all", "22_0", "22_all" | ||
| 3173 | + ,"26_1_1", "26_1_0", "26_1_all", "26_0", "26_all" | ||
| 3174 | + ,"all_1_1", "all_1_0", "all_1_all", "all_0", "all_all"}; | ||
| 3175 | + for(String s : strs){ | ||
| 3176 | + String[] sp = s.split("_"); | ||
| 3177 | + Map<String, Object> m1 = new HashMap<String, Object>(); | ||
| 3178 | + String gs = "", type = "", item = "", num = ""; | ||
| 3179 | + if("05".equals(sp[0])){ | ||
| 3180 | + gs = "杨高公司"; | ||
| 3181 | + } else if("55".equals(sp[0])){ | ||
| 3182 | + gs = "上南公司"; | ||
| 3183 | + } else if("22".equals(sp[0])){ | ||
| 3184 | + gs = "金高公司"; | ||
| 3185 | + } else if("26".equals(sp[0])){ | ||
| 3186 | + gs = "南汇公司"; | ||
| 3187 | + } else if("all".equals(sp[0])){ | ||
| 3188 | + gs = "滨海合计"; | ||
| 3189 | + num = "0"; | ||
| 3190 | + } | ||
| 3191 | + if("1".equals(sp[1])){ | ||
| 3192 | + type = "营运线路"; | ||
| 3193 | + } else if("0".equals(sp[1])){ | ||
| 3194 | + type = "非营运线路"; | ||
| 3195 | + } else if("all".equals(sp[1])){ | ||
| 3196 | + type = "全部线路"; | ||
| 3197 | + } | ||
| 3198 | + if(sp.length > 2){ | ||
| 3199 | + if("1".equals(sp[2])){ | ||
| 3200 | + item = "营运线路"; | ||
| 3201 | + } else if("0".equals(sp[2])){ | ||
| 3202 | + item = "机场线路"; | ||
| 3203 | + } else if("all".equals(sp[2])){ | ||
| 3204 | + item = "小计"; | ||
| 3205 | + } | ||
| 3206 | + } | ||
| 3207 | + m1.put("gsName", gs);m1.put("type", type);m1.put("item", item); | ||
| 3208 | + m1.put("budget", num);m1.put("change", num);m1.put("formal", num); | ||
| 3209 | + for(int i = 1; i <= 12; i++){ | ||
| 3210 | + m1.put("mon"+i, num); | ||
| 3211 | + m1.put("bud"+i, num); | ||
| 3212 | + m1.put("pre"+i, num); | ||
| 3213 | + m1.put("sub"+i, ""); | ||
| 3214 | + } | ||
| 3215 | + m1.put("monAll", "0"); | ||
| 3216 | + m1.put("subAll", "0"); | ||
| 3217 | + m1.put("key", s); | ||
| 3218 | + m1.put("dataList", new ArrayList<Map<String, Object>>()); | ||
| 3219 | + list.add(m1); | ||
| 3220 | + keyMap.put(s, m1); | ||
| 3221 | + } | ||
| 3222 | + return strs; | ||
| 3223 | + } | ||
| 3224 | + | ||
| 3225 | + public String[] createBudgetMap_sum(List<Map<String, Object>> list, Map<String, Map<String, Object>> keyMap){ | ||
| 3226 | + | ||
| 3227 | + String[] strs = {"05_1", "05_2", "05_3" | ||
| 3228 | + ,"55_1", "55_2", "55_3" | ||
| 3229 | + ,"22_1", "22_2", "22_3" | ||
| 3230 | + ,"26_1", "26_2", "26_3" | ||
| 3231 | + ,"all_1", "all_2", "all_3"}; | ||
| 3232 | + for(String s : strs){ | ||
| 3233 | + String[] sp = s.split("_"); | ||
| 3234 | + Map<String, Object> m1 = new HashMap<String, Object>(); | ||
| 3235 | + String gs = "", type = "", num = ""; | ||
| 3236 | + if("05".equals(sp[0])){ | ||
| 3237 | + gs = "杨高公司"; | ||
| 3238 | + } else if("55".equals(sp[0])){ | ||
| 3239 | + gs = "上南公司"; | ||
| 3240 | + } else if("22".equals(sp[0])){ | ||
| 3241 | + gs = "金高公司"; | ||
| 3242 | + } else if("26".equals(sp[0])){ | ||
| 3243 | + gs = "南汇公司"; | ||
| 3244 | + } else if("all".equals(sp[0])){ | ||
| 3245 | + gs = "滨海合计"; | ||
| 3246 | + num = "0"; | ||
| 3247 | + } | ||
| 3248 | + if("1".equals(sp[1])){ | ||
| 3249 | + type = "公里"; | ||
| 3250 | + } else if("2".equals(sp[1])){ | ||
| 3251 | + type = "人次"; | ||
| 3252 | + } else if("3".equals(sp[1])){ | ||
| 3253 | + type = "营收"; | ||
| 3254 | + } | ||
| 3255 | + m1.put("gsName", gs);m1.put("type", type); | ||
| 3256 | + m1.put("budget", num);m1.put("change", num);m1.put("formal", num); | ||
| 3257 | + for(int i = 1; i <= 12; i++){ | ||
| 3258 | + m1.put("mon"+i, num); | ||
| 3259 | + m1.put("bud"+i, num); | ||
| 3260 | + m1.put("pre"+i, num); | ||
| 3261 | + m1.put("sub"+i, ""); | ||
| 3262 | + } | ||
| 3263 | + m1.put("monAll", "0"); | ||
| 3264 | + m1.put("subAll", "0"); | ||
| 3265 | + m1.put("key", s); | ||
| 3266 | + m1.put("dataList", new ArrayList<Map<String, Object>>()); | ||
| 3267 | + list.add(m1); | ||
| 3268 | + keyMap.put(s, m1); | ||
| 3269 | + } | ||
| 3270 | + return strs; | ||
| 3271 | + } | ||
| 3272 | + | ||
| 3273 | +public String[] createBudgetMap_sum2(List<Map<String, Object>> list, Map<String, Map<String, Object>> keyMap){ | ||
| 3274 | + | ||
| 3275 | + String[] strs = {"05_1", "05_2", "05_0" | ||
| 3276 | + ,"55_1", "55_2", "55_0" | ||
| 3277 | + ,"22_1", "22_2", "22_0" | ||
| 3278 | + ,"26_1", "26_2", "26_0" | ||
| 3279 | + ,"all_1", "all_2", "all_0"}; | ||
| 3280 | + for(String s : strs){ | ||
| 3281 | + String[] sp = s.split("_"); | ||
| 3282 | + Map<String, Object> m1 = new HashMap<String, Object>(); | ||
| 3283 | + String gs = "", type = "", num = ""; | ||
| 3284 | + if("05".equals(sp[0])){ | ||
| 3285 | + gs = "杨高公司"; | ||
| 3286 | + } else if("55".equals(sp[0])){ | ||
| 3287 | + gs = "上南公司"; | ||
| 3288 | + } else if("22".equals(sp[0])){ | ||
| 3289 | + gs = "金高公司"; | ||
| 3290 | + } else if("26".equals(sp[0])){ | ||
| 3291 | + gs = "南汇公司"; | ||
| 3292 | + } else if("all".equals(sp[0])){ | ||
| 3293 | + gs = "浦交合计"; | ||
| 3294 | + num = "0"; | ||
| 3295 | + } | ||
| 3296 | + if("1".equals(sp[1])){ | ||
| 3297 | + type = "营运线路"; | ||
| 3298 | + } else if("2".equals(sp[1])){ | ||
| 3299 | + type = "非营运线路"; | ||
| 3300 | + } else if("0".equals(sp[1])){ | ||
| 3301 | + type = "小计"; | ||
| 3302 | + } | ||
| 3303 | + m1.put("gsName", gs); | ||
| 3304 | + m1.put("type", type); | ||
| 3305 | + m1.put("key", s); | ||
| 3306 | + m1.put("dataList", new ArrayList<Map<String, Object>>()); | ||
| 3307 | + list.add(m1); | ||
| 3308 | + keyMap.put(s, m1); | ||
| 3309 | + } | ||
| 3310 | + return strs; | ||
| 3311 | + } | ||
| 3312 | + | ||
| 3313 | +} |
src/main/java/com/bsth/service/forms/impl/RevenueLoader.java
| 1 | -package com.bsth.service.forms.impl; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.bsth.util.ConfigUtil; | ||
| 5 | -import org.apache.http.HttpEntity; | ||
| 6 | -import org.apache.http.client.config.RequestConfig; | ||
| 7 | -import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 8 | -import org.apache.http.client.methods.HttpGet; | ||
| 9 | -import org.apache.http.impl.client.CloseableHttpClient; | ||
| 10 | -import org.apache.http.impl.client.HttpClients; | ||
| 11 | -import org.slf4j.Logger; | ||
| 12 | -import org.slf4j.LoggerFactory; | ||
| 13 | -import org.springframework.stereotype.Component; | ||
| 14 | - | ||
| 15 | -import java.io.BufferedReader; | ||
| 16 | -import java.io.InputStreamReader; | ||
| 17 | -import java.util.ArrayList; | ||
| 18 | -import java.util.List; | ||
| 19 | -import java.util.Map; | ||
| 20 | - | ||
| 21 | -@Component | ||
| 22 | -public class RevenueLoader { | ||
| 23 | - | ||
| 24 | - static Logger logger = LoggerFactory.getLogger(RevenueLoader.class); | ||
| 25 | - | ||
| 26 | - static String url; | ||
| 27 | - static List<Map<String, Object>> list; | ||
| 28 | - static CloseableHttpClient httpClient = null; | ||
| 29 | - static HttpGet get; | ||
| 30 | - static RequestConfig requestConfig; | ||
| 31 | - static CloseableHttpResponse response; | ||
| 32 | - static HttpEntity entity; | ||
| 33 | - static BufferedReader br; | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * 从票务系统获取营收 | ||
| 37 | - * @param date | ||
| 38 | - * @param gsBm | ||
| 39 | - * @return | ||
| 40 | - */ | ||
| 41 | - public static List<Map<String, Object>> load(String date, String gsBm){ | ||
| 42 | - try { | ||
| 43 | - url = ConfigUtil.get("http.ticketing.interface") + "?revenueFlag=1&txnType=getLineRevenue&busiDate="+date+"&companyCode="+gsBm; | ||
| 44 | - list = new ArrayList<>(); | ||
| 45 | - httpClient = HttpClients.createDefault(); | ||
| 46 | - get = new HttpGet(url); | ||
| 47 | - requestConfig = RequestConfig.custom() | ||
| 48 | - .setConnectTimeout(10000).setConnectionRequestTimeout(10000) | ||
| 49 | - .setSocketTimeout(60000).build(); | ||
| 50 | - get.setConfig(requestConfig); | ||
| 51 | - if(list.size() > 0) | ||
| 52 | - list.clear(); | ||
| 53 | - logger.info("load start..."); | ||
| 54 | - response = httpClient.execute(get); | ||
| 55 | - entity = response.getEntity(); | ||
| 56 | - if(null == entity) | ||
| 57 | - return list; | ||
| 58 | - | ||
| 59 | - br = new BufferedReader(new InputStreamReader(entity.getContent())); | ||
| 60 | - StringBuilder sb = new StringBuilder(); | ||
| 61 | - String str; | ||
| 62 | - while ((str = br.readLine()) != null) | ||
| 63 | - sb.append(str); | ||
| 64 | - | ||
| 65 | - Map<String, Object> parseObj = JSON.parseObject(sb.toString(), Map.class); | ||
| 66 | - if(parseObj.get("status") != null && "SUCCESS".equals(parseObj.get("status").toString())){ | ||
| 67 | - for(Map<String, Object> m : (List<Map<String, Object>>) parseObj.get("respData")){ | ||
| 68 | - list.add(m); | ||
| 69 | - } | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - logger.info("load end ! size: " + list.size()); | ||
| 73 | - | ||
| 74 | - if (null != response) | ||
| 75 | - response.close(); | ||
| 76 | - } catch (Exception e) { | ||
| 77 | - logger.error("", e); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - return list; | ||
| 81 | - } | ||
| 82 | -} | 1 | +package com.bsth.service.forms.impl; |
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import org.apache.http.HttpEntity; | ||
| 5 | +import org.apache.http.client.config.RequestConfig; | ||
| 6 | +import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 7 | +import org.apache.http.client.methods.HttpGet; | ||
| 8 | +import org.apache.http.impl.client.CloseableHttpClient; | ||
| 9 | +import org.apache.http.impl.client.HttpClients; | ||
| 10 | +import org.slf4j.Logger; | ||
| 11 | +import org.slf4j.LoggerFactory; | ||
| 12 | +import org.springframework.beans.factory.annotation.Value; | ||
| 13 | +import org.springframework.stereotype.Component; | ||
| 14 | + | ||
| 15 | +import java.io.BufferedReader; | ||
| 16 | +import java.io.InputStreamReader; | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Map; | ||
| 20 | + | ||
| 21 | +@Component | ||
| 22 | +public class RevenueLoader { | ||
| 23 | + | ||
| 24 | + static Logger logger = LoggerFactory.getLogger(RevenueLoader.class); | ||
| 25 | + | ||
| 26 | + static String url; | ||
| 27 | + static List<Map<String, Object>> list; | ||
| 28 | + static CloseableHttpClient httpClient = null; | ||
| 29 | + static HttpGet get; | ||
| 30 | + static RequestConfig requestConfig; | ||
| 31 | + static CloseableHttpResponse response; | ||
| 32 | + static HttpEntity entity; | ||
| 33 | + static BufferedReader br; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 从票务系统获取营收 | ||
| 37 | + * @param date | ||
| 38 | + * @param gsBm | ||
| 39 | + * @return | ||
| 40 | + */ | ||
| 41 | + public static List<Map<String, Object>> load(String date, String gsBm){ | ||
| 42 | + try { | ||
| 43 | + list = new ArrayList<>(); | ||
| 44 | + httpClient = HttpClients.createDefault(); | ||
| 45 | + get = new HttpGet(url + "?revenueFlag=1&txnType=getLineRevenue&busiDate="+date+"&companyCode="+gsBm); | ||
| 46 | + requestConfig = RequestConfig.custom() | ||
| 47 | + .setConnectTimeout(10000).setConnectionRequestTimeout(10000) | ||
| 48 | + .setSocketTimeout(60000).build(); | ||
| 49 | + get.setConfig(requestConfig); | ||
| 50 | + if(list.size() > 0) | ||
| 51 | + list.clear(); | ||
| 52 | + logger.info("load start..."); | ||
| 53 | + response = httpClient.execute(get); | ||
| 54 | + entity = response.getEntity(); | ||
| 55 | + if(null == entity) | ||
| 56 | + return list; | ||
| 57 | + | ||
| 58 | + br = new BufferedReader(new InputStreamReader(entity.getContent())); | ||
| 59 | + StringBuilder sb = new StringBuilder(); | ||
| 60 | + String str; | ||
| 61 | + while ((str = br.readLine()) != null) | ||
| 62 | + sb.append(str); | ||
| 63 | + | ||
| 64 | + Map<String, Object> parseObj = JSON.parseObject(sb.toString(), Map.class); | ||
| 65 | + if(parseObj.get("status") != null && "SUCCESS".equals(parseObj.get("status").toString())){ | ||
| 66 | + for(Map<String, Object> m : (List<Map<String, Object>>) parseObj.get("respData")){ | ||
| 67 | + list.add(m); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + logger.info("load end ! size: " + list.size()); | ||
| 72 | + | ||
| 73 | + if (null != response) | ||
| 74 | + response.close(); | ||
| 75 | + } catch (Exception e) { | ||
| 76 | + logger.error("", e); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + return list; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Value("${http.ticketing.interface}") | ||
| 83 | + public void setUrl(String url) { | ||
| 84 | + RevenueLoader.url = url; | ||
| 85 | + } | ||
| 86 | +} |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -121,7 +121,6 @@ import com.bsth.util.Arith; | @@ -121,7 +121,6 @@ import com.bsth.util.Arith; | ||
| 121 | import com.bsth.util.ComparableChild; | 121 | import com.bsth.util.ComparableChild; |
| 122 | import com.bsth.util.ComparableLp; | 122 | import com.bsth.util.ComparableLp; |
| 123 | import com.bsth.util.ComparableReal; | 123 | import com.bsth.util.ComparableReal; |
| 124 | -import com.bsth.util.ConfigUtil; | ||
| 125 | import com.bsth.util.DateUtils; | 124 | import com.bsth.util.DateUtils; |
| 126 | import com.bsth.util.ReportRelatedUtils; | 125 | import com.bsth.util.ReportRelatedUtils; |
| 127 | import com.bsth.util.ReportUtils; | 126 | import com.bsth.util.ReportUtils; |
| @@ -6615,7 +6614,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -6615,7 +6614,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 6615 | // 分公司保存格式 分公司编码_公司编码 | 6614 | // 分公司保存格式 分公司编码_公司编码 |
| 6616 | String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode); | 6615 | String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode); |
| 6617 | String[] arr = val.split("_"); | 6616 | String[] arr = val.split("_"); |
| 6618 | - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1])); | 6617 | + StringBuilder url = new StringBuilder(); |
| 6619 | url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]); | 6618 | url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]); |
| 6620 | 6619 | ||
| 6621 | int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0); | 6620 | int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0); |
| @@ -6655,7 +6654,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -6655,7 +6654,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 6655 | // 分公司保存格式 分公司编码_公司编码 | 6654 | // 分公司保存格式 分公司编码_公司编码 |
| 6656 | String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode()); | 6655 | String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode()); |
| 6657 | String[] arr = val.split("_"); | 6656 | String[] arr = val.split("_"); |
| 6658 | - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1])); | 6657 | + StringBuilder url = new StringBuilder(); |
| 6659 | url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]); | 6658 | url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]); |
| 6660 | 6659 | ||
| 6661 | Map<String, Object> res = request(url.toString()); | 6660 | Map<String, Object> res = request(url.toString()); |
src/main/java/com/bsth/util/BatchSaveUtils.java
| 1 | -package com.bsth.util; | ||
| 2 | - | ||
| 3 | -import java.lang.reflect.Field; | ||
| 4 | -import java.sql.Connection; | ||
| 5 | -import java.sql.DriverManager; | ||
| 6 | -import java.sql.PreparedStatement; | ||
| 7 | -import java.sql.ResultSet; | ||
| 8 | -import java.util.ArrayList; | ||
| 9 | -import java.util.List; | ||
| 10 | - | ||
| 11 | -import javax.persistence.ManyToMany; | ||
| 12 | -import javax.persistence.ManyToOne; | ||
| 13 | -import javax.persistence.OneToMany; | ||
| 14 | -import javax.persistence.OneToOne; | ||
| 15 | -import javax.persistence.Table; | ||
| 16 | -import javax.persistence.Transient; | ||
| 17 | - | ||
| 18 | -import org.apache.commons.lang3.CharUtils; | ||
| 19 | -import org.apache.commons.lang3.StringUtils; | ||
| 20 | -import org.slf4j.Logger; | ||
| 21 | -import org.slf4j.LoggerFactory; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * | ||
| 25 | - * @ClassName: BatchSaveUtils | ||
| 26 | - * @Description: TODO(批量持久化工具类) | ||
| 27 | - * @author PanZhao | ||
| 28 | - * @date 2016年6月14日 上午10:21:53 | ||
| 29 | - * | ||
| 30 | - */ | ||
| 31 | -public class BatchSaveUtils<T> { | ||
| 32 | - | ||
| 33 | - private static String driver; | ||
| 34 | - private static String url; | ||
| 35 | - private static String uname; | ||
| 36 | - private static String pwd; | ||
| 37 | - | ||
| 38 | - final static int batchSize = 5000; | ||
| 39 | - | ||
| 40 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 41 | - | ||
| 42 | - static { | ||
| 43 | - driver = ConfigUtil.get("spring.datasource.driver-class-name"); | ||
| 44 | - url = ConfigUtil.get("spring.datasource.url"); | ||
| 45 | - uname = ConfigUtil.get("spring.datasource.username"); | ||
| 46 | - pwd = ConfigUtil.get("spring.datasource.password"); | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - /** | ||
| 50 | - * | ||
| 51 | - * @Title: saveListMysql | ||
| 52 | - * @Description: TODO(批量对象入库) | ||
| 53 | - * @param @param list | ||
| 54 | - * @param @param clazz | ||
| 55 | - * @throws | ||
| 56 | - */ | ||
| 57 | - public int saveList(List<T> list, Class<T> clazz){ | ||
| 58 | - //获取泛型 T 的字节码 | ||
| 59 | - Table table = clazz.getAnnotation(Table.class); | ||
| 60 | - if(null == table){ | ||
| 61 | - logger.error("找不到" + clazz.getSimpleName() + "类的表映射"); | ||
| 62 | - return -1; | ||
| 63 | - } | ||
| 64 | - List<Field> fs = fieldFilter(clazz.getDeclaredFields()); | ||
| 65 | - String sql = createSql(table, fs); | ||
| 66 | - logger.info(sql); | ||
| 67 | - | ||
| 68 | - //每5000条批量入库一次 | ||
| 69 | - Connection conn = null; | ||
| 70 | - PreparedStatement ps = null; | ||
| 71 | - try{ | ||
| 72 | - conn = getConn(); | ||
| 73 | - conn.setAutoCommit(false); | ||
| 74 | - ps = conn.prepareStatement(sql); | ||
| 75 | - | ||
| 76 | - int fsize = fs.size(), count = 0; | ||
| 77 | - for(T t : list){ | ||
| 78 | - count ++; | ||
| 79 | - for(int i = 0; i < fsize; i ++){ | ||
| 80 | - ps.setObject(i + 1, fs.get(i).get(t)); | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - ps.addBatch(); | ||
| 84 | - if(count % batchSize == 0){ | ||
| 85 | - ps.executeBatch(); | ||
| 86 | - conn.commit(); | ||
| 87 | - ps.clearBatch(); | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | - ps.executeBatch(); | ||
| 91 | - conn.commit(); | ||
| 92 | - }catch(Exception e){ | ||
| 93 | - logger.error("",e); | ||
| 94 | - return -1; | ||
| 95 | - }finally { | ||
| 96 | - closeAll(conn, ps, null); | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - return 0; | ||
| 100 | - } | ||
| 101 | - | ||
| 102 | - public int saveList2(List<T> list, Class<T> clazz) throws Exception{ | ||
| 103 | - //获取泛型 T 的字节码 | ||
| 104 | - Table table = clazz.getAnnotation(Table.class); | ||
| 105 | - if(null == table){ | ||
| 106 | - logger.error("找不到" + clazz.getSimpleName() + "类的表映射"); | ||
| 107 | - return -1; | ||
| 108 | - } | ||
| 109 | - List<Field> fs = fieldFilter(clazz.getDeclaredFields()); | ||
| 110 | - String sql = createSql(table, fs); | ||
| 111 | - logger.info(sql); | ||
| 112 | - | ||
| 113 | - //每5000条批量入库一次 | ||
| 114 | - Connection conn = null; | ||
| 115 | - PreparedStatement ps = null; | ||
| 116 | - try{ | ||
| 117 | - conn = getConn(); | ||
| 118 | - conn.setAutoCommit(false); | ||
| 119 | - ps = conn.prepareStatement(sql); | ||
| 120 | - | ||
| 121 | - int fsize = fs.size(), count = 0; | ||
| 122 | - for(T t : list){ | ||
| 123 | - count ++; | ||
| 124 | - for(int i = 0; i < fsize; i ++){ | ||
| 125 | - ps.setObject(i + 1, fs.get(i).get(t)); | ||
| 126 | - } | ||
| 127 | - | ||
| 128 | - ps.addBatch(); | ||
| 129 | - if(count % batchSize == 0){ | ||
| 130 | - ps.executeBatch(); | ||
| 131 | - conn.commit(); | ||
| 132 | - ps.clearBatch(); | ||
| 133 | - } | ||
| 134 | - } | ||
| 135 | - ps.executeBatch(); | ||
| 136 | - conn.commit(); | ||
| 137 | - }finally { | ||
| 138 | - closeAll(conn, ps, null); | ||
| 139 | - } | ||
| 140 | - | ||
| 141 | - return 0; | ||
| 142 | - } | ||
| 143 | - public String createSql(Table table, List<Field> fs){ | ||
| 144 | - String sqlBefore = "insert into " + table.name() + "(" | ||
| 145 | - ,sqlValues = " values("; | ||
| 146 | - for(Field field : fs){ | ||
| 147 | - sqlBefore += (propertyToField(field.getName()) + ","); | ||
| 148 | - sqlValues += "?,"; | ||
| 149 | - } | ||
| 150 | - sqlBefore = sqlBefore.substring(0, sqlBefore.length() - 1) + ")"; | ||
| 151 | - sqlValues = sqlValues.substring(0, sqlValues.length() - 1) + ")"; | ||
| 152 | - | ||
| 153 | - return sqlBefore + " " + sqlValues; | ||
| 154 | - } | ||
| 155 | - | ||
| 156 | - /** | ||
| 157 | - * | ||
| 158 | - * @Title: propertyToField | ||
| 159 | - * @Description: TODO(java转数据库字段名) | ||
| 160 | - * @param @param property | ||
| 161 | - * @throws | ||
| 162 | - */ | ||
| 163 | - public static String propertyToField(String property) { | ||
| 164 | - if (null == property) { | ||
| 165 | - return ""; | ||
| 166 | - } | ||
| 167 | - char[] chars = property.toCharArray(); | ||
| 168 | - StringBuffer sb = new StringBuffer(); | ||
| 169 | - for (char c : chars) { | ||
| 170 | - if (CharUtils.isAsciiAlphaUpper(c)) { | ||
| 171 | - sb.append("_" + StringUtils.lowerCase(CharUtils.toString(c))); | ||
| 172 | - } else { | ||
| 173 | - sb.append(c); | ||
| 174 | - } | ||
| 175 | - } | ||
| 176 | - return sb.toString(); | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - public static List<Field> fieldFilter(Field[] fields){ | ||
| 180 | - List<Field> fs = new ArrayList<>(); | ||
| 181 | - for(Field field : fields){ | ||
| 182 | - field.setAccessible(true); | ||
| 183 | - //忽略 Transient 字段 | ||
| 184 | - if(field.getAnnotation(Transient.class) != null) | ||
| 185 | - continue; | ||
| 186 | - //忽略关联 | ||
| 187 | - if(field.getAnnotation(OneToMany.class) != null | ||
| 188 | - || field.getAnnotation(OneToOne.class) != null | ||
| 189 | - || field.getAnnotation(ManyToOne.class) != null | ||
| 190 | - || field.getAnnotation(ManyToMany.class) != null) | ||
| 191 | - continue; | ||
| 192 | - fs.add(field); | ||
| 193 | - } | ||
| 194 | - return fs; | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - public static Connection getConn() throws Exception{ | ||
| 198 | - Class.forName(driver); | ||
| 199 | - Connection conn = DriverManager.getConnection(url,uname,pwd); | ||
| 200 | - return conn; | ||
| 201 | - } | ||
| 202 | - | ||
| 203 | - public static void closeAll(Connection conn, PreparedStatement ps, ResultSet rs){ | ||
| 204 | - try { | ||
| 205 | - if(conn != null){ | ||
| 206 | - conn.close(); | ||
| 207 | - } | ||
| 208 | - if(ps != null){ | ||
| 209 | - ps.close(); | ||
| 210 | - } | ||
| 211 | - if(rs != null){ | ||
| 212 | - rs.close(); | ||
| 213 | - } | ||
| 214 | - } catch (Exception e) { | ||
| 215 | - e.printStackTrace(); | ||
| 216 | - } | ||
| 217 | - } | ||
| 218 | -} | 1 | +package com.bsth.util; |
| 2 | + | ||
| 3 | +import java.lang.reflect.Field; | ||
| 4 | +import java.sql.Connection; | ||
| 5 | +import java.sql.DriverManager; | ||
| 6 | +import java.sql.PreparedStatement; | ||
| 7 | +import java.sql.ResultSet; | ||
| 8 | +import java.util.ArrayList; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +import javax.persistence.ManyToMany; | ||
| 12 | +import javax.persistence.ManyToOne; | ||
| 13 | +import javax.persistence.OneToMany; | ||
| 14 | +import javax.persistence.OneToOne; | ||
| 15 | +import javax.persistence.Table; | ||
| 16 | +import javax.persistence.Transient; | ||
| 17 | + | ||
| 18 | +import org.apache.commons.lang3.CharUtils; | ||
| 19 | +import org.apache.commons.lang3.StringUtils; | ||
| 20 | +import org.slf4j.Logger; | ||
| 21 | +import org.slf4j.LoggerFactory; | ||
| 22 | +import org.springframework.beans.factory.InitializingBean; | ||
| 23 | +import org.springframework.beans.factory.annotation.Value; | ||
| 24 | +import org.springframework.stereotype.Component; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * | ||
| 28 | + * @ClassName: BatchSaveUtils | ||
| 29 | + * @Description: TODO(批量持久化工具类) | ||
| 30 | + * @author PanZhao | ||
| 31 | + * @date 2016年6月14日 上午10:21:53 | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | +@Component | ||
| 35 | +public class BatchSaveUtils<T> { | ||
| 36 | + | ||
| 37 | + private static String driver; | ||
| 38 | + private static String url; | ||
| 39 | + private static String uname; | ||
| 40 | + private static String pwd; | ||
| 41 | + | ||
| 42 | + final static int batchSize = 5000; | ||
| 43 | + | ||
| 44 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 45 | + | ||
| 46 | + @Value("${spring.datasource.driver-class-name}") | ||
| 47 | + public void setDriver(String driver) { | ||
| 48 | + BatchSaveUtils.driver = driver; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Value("${spring.datasource.url}") | ||
| 52 | + public void setUrl(String url) { | ||
| 53 | + BatchSaveUtils.url = url; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Value("${spring.datasource.username}") | ||
| 57 | + public void setUname(String uname) { | ||
| 58 | + BatchSaveUtils.uname = uname; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Value("${spring.datasource.password}") | ||
| 62 | + public void setPwd(String pwd) { | ||
| 63 | + BatchSaveUtils.pwd = pwd; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * | ||
| 68 | + * @Title: saveListMysql | ||
| 69 | + * @Description: TODO(批量对象入库) | ||
| 70 | + * @param @param list | ||
| 71 | + * @param @param clazz | ||
| 72 | + * @throws | ||
| 73 | + */ | ||
| 74 | + public int saveList(List<T> list, Class<T> clazz){ | ||
| 75 | + //获取泛型 T 的字节码 | ||
| 76 | + Table table = clazz.getAnnotation(Table.class); | ||
| 77 | + if(null == table){ | ||
| 78 | + logger.error("找不到" + clazz.getSimpleName() + "类的表映射"); | ||
| 79 | + return -1; | ||
| 80 | + } | ||
| 81 | + List<Field> fs = fieldFilter(clazz.getDeclaredFields()); | ||
| 82 | + String sql = createSql(table, fs); | ||
| 83 | + logger.info(sql); | ||
| 84 | + | ||
| 85 | + //每5000条批量入库一次 | ||
| 86 | + Connection conn = null; | ||
| 87 | + PreparedStatement ps = null; | ||
| 88 | + try{ | ||
| 89 | + conn = getConn(); | ||
| 90 | + conn.setAutoCommit(false); | ||
| 91 | + ps = conn.prepareStatement(sql); | ||
| 92 | + | ||
| 93 | + int fsize = fs.size(), count = 0; | ||
| 94 | + for(T t : list){ | ||
| 95 | + count ++; | ||
| 96 | + for(int i = 0; i < fsize; i ++){ | ||
| 97 | + ps.setObject(i + 1, fs.get(i).get(t)); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + ps.addBatch(); | ||
| 101 | + if(count % batchSize == 0){ | ||
| 102 | + ps.executeBatch(); | ||
| 103 | + conn.commit(); | ||
| 104 | + ps.clearBatch(); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + ps.executeBatch(); | ||
| 108 | + conn.commit(); | ||
| 109 | + }catch(Exception e){ | ||
| 110 | + logger.error("",e); | ||
| 111 | + return -1; | ||
| 112 | + }finally { | ||
| 113 | + closeAll(conn, ps, null); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + return 0; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + public int saveList2(List<T> list, Class<T> clazz) throws Exception{ | ||
| 120 | + //获取泛型 T 的字节码 | ||
| 121 | + Table table = clazz.getAnnotation(Table.class); | ||
| 122 | + if(null == table){ | ||
| 123 | + logger.error("找不到" + clazz.getSimpleName() + "类的表映射"); | ||
| 124 | + return -1; | ||
| 125 | + } | ||
| 126 | + List<Field> fs = fieldFilter(clazz.getDeclaredFields()); | ||
| 127 | + String sql = createSql(table, fs); | ||
| 128 | + logger.info(sql); | ||
| 129 | + | ||
| 130 | + //每5000条批量入库一次 | ||
| 131 | + Connection conn = null; | ||
| 132 | + PreparedStatement ps = null; | ||
| 133 | + try{ | ||
| 134 | + conn = getConn(); | ||
| 135 | + conn.setAutoCommit(false); | ||
| 136 | + ps = conn.prepareStatement(sql); | ||
| 137 | + | ||
| 138 | + int fsize = fs.size(), count = 0; | ||
| 139 | + for(T t : list){ | ||
| 140 | + count ++; | ||
| 141 | + for(int i = 0; i < fsize; i ++){ | ||
| 142 | + ps.setObject(i + 1, fs.get(i).get(t)); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + ps.addBatch(); | ||
| 146 | + if(count % batchSize == 0){ | ||
| 147 | + ps.executeBatch(); | ||
| 148 | + conn.commit(); | ||
| 149 | + ps.clearBatch(); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + ps.executeBatch(); | ||
| 153 | + conn.commit(); | ||
| 154 | + }finally { | ||
| 155 | + closeAll(conn, ps, null); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + return 0; | ||
| 159 | + } | ||
| 160 | + public String createSql(Table table, List<Field> fs){ | ||
| 161 | + String sqlBefore = "insert into " + table.name() + "(" | ||
| 162 | + ,sqlValues = " values("; | ||
| 163 | + for(Field field : fs){ | ||
| 164 | + sqlBefore += (propertyToField(field.getName()) + ","); | ||
| 165 | + sqlValues += "?,"; | ||
| 166 | + } | ||
| 167 | + sqlBefore = sqlBefore.substring(0, sqlBefore.length() - 1) + ")"; | ||
| 168 | + sqlValues = sqlValues.substring(0, sqlValues.length() - 1) + ")"; | ||
| 169 | + | ||
| 170 | + return sqlBefore + " " + sqlValues; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + /** | ||
| 174 | + * | ||
| 175 | + * @Title: propertyToField | ||
| 176 | + * @Description: TODO(java转数据库字段名) | ||
| 177 | + * @param @param property | ||
| 178 | + * @throws | ||
| 179 | + */ | ||
| 180 | + public static String propertyToField(String property) { | ||
| 181 | + if (null == property) { | ||
| 182 | + return ""; | ||
| 183 | + } | ||
| 184 | + char[] chars = property.toCharArray(); | ||
| 185 | + StringBuffer sb = new StringBuffer(); | ||
| 186 | + for (char c : chars) { | ||
| 187 | + if (CharUtils.isAsciiAlphaUpper(c)) { | ||
| 188 | + sb.append("_" + StringUtils.lowerCase(CharUtils.toString(c))); | ||
| 189 | + } else { | ||
| 190 | + sb.append(c); | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + return sb.toString(); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public static List<Field> fieldFilter(Field[] fields){ | ||
| 197 | + List<Field> fs = new ArrayList<>(); | ||
| 198 | + for(Field field : fields){ | ||
| 199 | + field.setAccessible(true); | ||
| 200 | + //忽略 Transient 字段 | ||
| 201 | + if(field.getAnnotation(Transient.class) != null) | ||
| 202 | + continue; | ||
| 203 | + //忽略关联 | ||
| 204 | + if(field.getAnnotation(OneToMany.class) != null | ||
| 205 | + || field.getAnnotation(OneToOne.class) != null | ||
| 206 | + || field.getAnnotation(ManyToOne.class) != null | ||
| 207 | + || field.getAnnotation(ManyToMany.class) != null) | ||
| 208 | + continue; | ||
| 209 | + fs.add(field); | ||
| 210 | + } | ||
| 211 | + return fs; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + public static Connection getConn() throws Exception{ | ||
| 215 | + Class.forName(driver); | ||
| 216 | + Connection conn = DriverManager.getConnection(url,uname,pwd); | ||
| 217 | + return conn; | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + public static void closeAll(Connection conn, PreparedStatement ps, ResultSet rs){ | ||
| 221 | + try { | ||
| 222 | + if(conn != null){ | ||
| 223 | + conn.close(); | ||
| 224 | + } | ||
| 225 | + if(ps != null){ | ||
| 226 | + ps.close(); | ||
| 227 | + } | ||
| 228 | + if(rs != null){ | ||
| 229 | + rs.close(); | ||
| 230 | + } | ||
| 231 | + } catch (Exception e) { | ||
| 232 | + e.printStackTrace(); | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | +} |
src/main/java/com/bsth/util/ConfigUtil.java deleted
100644 → 0
| 1 | -package com.bsth.util; | ||
| 2 | - | ||
| 3 | -public class ConfigUtil { | ||
| 4 | - | ||
| 5 | - static Tools tools; | ||
| 6 | - | ||
| 7 | - static{ | ||
| 8 | - tools = new Tools("application.properties"); | ||
| 9 | - String active = tools.getValue("spring.profiles.active"); | ||
| 10 | - tools = new Tools("application-"+active+".properties"); | ||
| 11 | - } | ||
| 12 | - | ||
| 13 | - public static String get(String key){ | ||
| 14 | - return tools.getValue(key); | ||
| 15 | - } | ||
| 16 | -} |
src/main/resources/application-prod.properties
| @@ -13,7 +13,7 @@ spring.jpa.show-sql= false | @@ -13,7 +13,7 @@ spring.jpa.show-sql= false | ||
| 13 | 13 | ||
| 14 | #DATABASE | 14 | #DATABASE |
| 15 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver | 15 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 16 | -spring.datasource.url= jdbc:mysql://10.10.150.101/control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai | 16 | +spring.datasource.url= jdbc:mysql://58.34.47.74/control?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai |
| 17 | spring.datasource.username= root | 17 | spring.datasource.username= root |
| 18 | spring.datasource.password= A123456ab | 18 | spring.datasource.password= A123456ab |
| 19 | spring.datasource.type= com.zaxxer.hikari.HikariDataSource | 19 | spring.datasource.type= com.zaxxer.hikari.HikariDataSource |
| @@ -62,7 +62,7 @@ admin.mail= 3090342880@qq.com | @@ -62,7 +62,7 @@ admin.mail= 3090342880@qq.com | ||
| 62 | enabled.whiteip= false | 62 | enabled.whiteip= false |
| 63 | 63 | ||
| 64 | ms.mysql.driver= com.mysql.jdbc.Driver | 64 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 65 | -ms.mysql.url= jdbc:mysql://10.10.150.101/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false | 65 | +ms.mysql.url= jdbc:mysql://58.34.47.74/ms?useUnicode=true&characterEncoding=utf-8&useSSL=false |
| 66 | ms.mysql.username= root | 66 | ms.mysql.username= root |
| 67 | ms.mysql.password= A123456ab | 67 | ms.mysql.password= A123456ab |
| 68 | 68 |
src/main/resources/logback.xml
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | <configuration> | 3 | <configuration> |
| 4 | 4 | ||
| 5 | <!-- <property resource="application.properties" /> --> | 5 | <!-- <property resource="application.properties" /> --> |
| 6 | - <property name="LOG_BASE" value="E:/bsth_control_logs" /> | 6 | + <property name="LOG_BASE" value="bsth_control_logs" /> |
| 7 | <!-- 控制台输出 --> | 7 | <!-- 控制台输出 --> |
| 8 | <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | 8 | <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
| 9 | 9 |
src/main/resources/rules/kBase1_core_plan.drl
| @@ -75,7 +75,7 @@ function Map gsMap(List gses) { | @@ -75,7 +75,7 @@ function Map gsMap(List gses) { | ||
| 75 | for (int i = 0; i < gses.size(); i++) { | 75 | for (int i = 0; i < gses.size(); i++) { |
| 76 | Business gs = (Business) gses.get(i); | 76 | Business gs = (Business) gses.get(i); |
| 77 | if (StringUtils.isNotEmpty(gs.getBusinessCode())) { | 77 | if (StringUtils.isNotEmpty(gs.getBusinessCode())) { |
| 78 | - if ("88".equals(gs.getUpCode())) { // 浦东公交 | 78 | + if ("88".equals(gs.getUpCode())) { // 滨海 |
| 79 | gsMap.put(gs.getBusinessCode(), gs); | 79 | gsMap.put(gs.getBusinessCode(), gs); |
| 80 | } | 80 | } |
| 81 | if (gs.getBusinessCode().equals(gs.getUpCode())) { // 闵行,青浦 | 81 | if (gs.getBusinessCode().equals(gs.getUpCode())) { // 闵行,青浦 |
src/main/resources/static/favicon.ico deleted
100644 → 0
No preview for this file type
src/main/resources/static/index.html
| @@ -220,7 +220,7 @@ | @@ -220,7 +220,7 @@ | ||
| 220 | <!-- LOGO --> | 220 | <!-- LOGO --> |
| 221 | <div class="page-logo"> | 221 | <div class="page-logo"> |
| 222 | <a href="index.html" class="logo-default logo-default-text"> | 222 | <a href="index.html" class="logo-default logo-default-text"> |
| 223 | - 浦东公交调度系统 </a> | 223 | + 滨海调度系统 </a> |
| 224 | <div class="menu-toggler sidebar-toggler"></div> | 224 | <div class="menu-toggler sidebar-toggler"></div> |
| 225 | </div> | 225 | </div> |
| 226 | <!-- END LOGO --> | 226 | <!-- END LOGO --> |
src/main/resources/static/login.html
| @@ -181,7 +181,7 @@ | @@ -181,7 +181,7 @@ | ||
| 181 | <div class="wrapper ng-scope"> | 181 | <div class="wrapper ng-scope"> |
| 182 | <div id="loginPanel" class="dialog dialog-shadow"> | 182 | <div id="loginPanel" class="dialog dialog-shadow"> |
| 183 | <br> | 183 | <br> |
| 184 | - <h3 class="logo-text">浦东公交调度系统</h3> | 184 | + <h3 class="logo-text">滨海调度系统</h3> |
| 185 | <hr> | 185 | <hr> |
| 186 | <form style="padding: 0px 35px;"> | 186 | <form style="padding: 0px 35px;"> |
| 187 | <div class="form-group" style="margin-bottom: 0"> | 187 | <div class="form-group" style="margin-bottom: 0"> |
| @@ -221,8 +221,8 @@ | @@ -221,8 +221,8 @@ | ||
| 221 | <div class="alert alert-danger"></div> | 221 | <div class="alert alert-danger"></div> |
| 222 | </div> | 222 | </div> |
| 223 | 223 | ||
| 224 | - <div class="login-footer">© 2016 上海巴士拓华科技发展有限公司 Some Rights | ||
| 225 | - Reserved</div> | 224 | + <!--<div class="login-footer">© 2016 上海巴士拓华科技发展有限公司 Some Rights |
| 225 | + Reserved</div>--> | ||
| 226 | </div> | 226 | </div> |
| 227 | 227 | ||
| 228 | <script> | 228 | <script> |
src/main/resources/static/pages/base/stationroute/addstationstemplate.html
| @@ -213,6 +213,7 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | @@ -213,6 +213,7 @@ $('#add_station_template_mobal').on('AddStationTempMobal.show', function(e,map,a | ||
| 213 | // versions:版本号 | 213 | // versions:版本号 |
| 214 | params.versions = '1'; | 214 | params.versions = '1'; |
| 215 | map.lineInfoPanl(lineNameV,directionData,function(BusLine){ | 215 | map.lineInfoPanl(lineNameV,directionData,function(BusLine){ |
| 216 | + debugger | ||
| 216 | // 如果线路信息不为空 | 217 | // 如果线路信息不为空 |
| 217 | if(BusLine && Polygon){ | 218 | if(BusLine && Polygon){ |
| 218 | // 获取公交线几何对象, 仅当结果自动添加到地图上时有效 | 219 | // 获取公交线几何对象, 仅当结果自动添加到地图上时有效 |
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
| @@ -139,11 +139,12 @@ window.WorldsBMap = function () { | @@ -139,11 +139,12 @@ window.WorldsBMap = function () { | ||
| 139 | lineInfoPanl: function (lineNameValue, i, cb) { | 139 | lineInfoPanl: function (lineNameValue, i, cb) { |
| 140 | 140 | ||
| 141 | /** 根据线路名称与方向从百度地图获取站点与路段 @param lineNameValue:线路名称;i:方向<0:上行;1:下行> */ | 141 | /** 根据线路名称与方向从百度地图获取站点与路段 @param lineNameValue:线路名称;i:方向<0:上行;1:下行> */ |
| 142 | - WorldsBMap.getBmapStationNames(lineNameValue, i, function (BusLine) { | 142 | + return cb && cb(); |
| 143 | + //WorldsBMap.getBmapStationNames(lineNameValue, i, function (BusLine) { | ||
| 143 | 144 | ||
| 144 | - return cb && cb(BusLine); | 145 | + // return cb && cb(BusLine); |
| 145 | 146 | ||
| 146 | - }); | 147 | + //}); |
| 147 | 148 | ||
| 148 | }, | 149 | }, |
| 149 | 150 | ||
| @@ -163,57 +164,9 @@ window.WorldsBMap = function () { | @@ -163,57 +164,9 @@ window.WorldsBMap = function () { | ||
| 163 | } | 164 | } |
| 164 | // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | 165 | // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) |
| 165 | var f = arguments.callee; | 166 | var f = arguments.callee; |
| 166 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 167 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 168 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 169 | - var destination = points[index + 1].potion.lat + ',' + points[index + 1].potion.lng; | ||
| 170 | - var region = '上海'; | ||
| 171 | - var origin_region = '上海'; | ||
| 172 | - var destination_region = '上海'; | ||
| 173 | - var output = 'json'; | ||
| 174 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 175 | - /** | ||
| 176 | - * origin:起点名称或经纬度; | ||
| 177 | - * destination:终点名称或经纬度; | ||
| 178 | - * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 179 | - * destination_region:终点所在城市,驾车导航时必填。 | ||
| 180 | - * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 181 | - **/ | ||
| 182 | - var paramsB = { | ||
| 183 | - origin: origin, | ||
| 184 | - destination: destination, | ||
| 185 | - region: region, | ||
| 186 | - origin_region: origin_region, | ||
| 187 | - destination_region: destination_region, | ||
| 188 | - output: output, | ||
| 189 | - ak: ak_My | ||
| 190 | - }; | ||
| 191 | - | ||
| 192 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 193 | - $.ajax({ | ||
| 194 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 195 | - url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 196 | - data: paramsB, | ||
| 197 | - dataType: 'jsonp', | ||
| 198 | - success: function (r) { | ||
| 199 | - if (r) { | ||
| 200 | - if (r.message == 'ok') { | ||
| 201 | - if (r.result.taxi == null) { | ||
| 202 | - // 获取距离(单位:米) | ||
| 203 | - points[index + 1].distance = 0; | ||
| 204 | - // 获取时间(单位:秒) | ||
| 205 | - points[index + 1].duration = 0; | ||
| 206 | - } else { | ||
| 207 | - // 获取距离(单位:米) | ||
| 208 | - points[index + 1].distance = r.result.taxi.distance; | ||
| 209 | - // 获取时间(单位:秒) | ||
| 210 | - points[index + 1].duration = r.result.taxi.duration; | ||
| 211 | - } | ||
| 212 | - } | ||
| 213 | - } | ||
| 214 | - f(); | ||
| 215 | - } | ||
| 216 | - }); | 167 | + points[index + 1].distance = ''; |
| 168 | + points[index + 1].duration = ''; | ||
| 169 | + f(); | ||
| 217 | })(); | 170 | })(); |
| 218 | }, | 171 | }, |
| 219 | 172 | ||
| @@ -583,7 +536,12 @@ window.WorldsBMap = function () { | @@ -583,7 +536,12 @@ window.WorldsBMap = function () { | ||
| 583 | return; | 536 | return; |
| 584 | } | 537 | } |
| 585 | var f = arguments.callee; | 538 | var f = arguments.callee; |
| 586 | - if (arra[index].name != '') { | 539 | + stationList.push({ |
| 540 | + name: arra[index].name.replace('公交车站', ''), | ||
| 541 | + wgs: arra[index].wgs, | ||
| 542 | + potion: {lng: arra[index].wgs.x, lat: arra[index].wgs.y} | ||
| 543 | + }); | ||
| 544 | + /*if (arra[index].name != '') { | ||
| 587 | var localSearch = new BMap.LocalSearch(mapBValue); | 545 | var localSearch = new BMap.LocalSearch(mapBValue); |
| 588 | localSearch.search(arra[index].name); | 546 | localSearch.search(arra[index].name); |
| 589 | localSearch.setSearchCompleteCallback(function (searchResult) { | 547 | localSearch.setSearchCompleteCallback(function (searchResult) { |
| @@ -605,7 +563,8 @@ window.WorldsBMap = function () { | @@ -605,7 +563,8 @@ window.WorldsBMap = function () { | ||
| 605 | }); | 563 | }); |
| 606 | } else { | 564 | } else { |
| 607 | f(); | 565 | f(); |
| 608 | - } | 566 | + }*/ |
| 567 | + f(); | ||
| 609 | })(); | 568 | })(); |
| 610 | }, | 569 | }, |
| 611 | 570 | ||
| @@ -668,27 +627,7 @@ window.WorldsBMap = function () { | @@ -668,27 +627,7 @@ window.WorldsBMap = function () { | ||
| 668 | return; | 627 | return; |
| 669 | } | 628 | } |
| 670 | var f = arguments.callee; | 629 | var f = arguments.callee; |
| 671 | - var poiOne = new BMap.Point(stationsPoint[index].potion.lng, stationsPoint[index].potion.lat); | ||
| 672 | - var poiTwo = new BMap.Point(stationsPoint[index + 1].potion.lng, stationsPoint[index + 1].potion.lat); | ||
| 673 | - /* var transit = new BMap.TransitRoute(mapB, {renderOptions: {map: mapB},onPolylinesSet: searchPolylinesSet});*/ | ||
| 674 | - var transit = new BMap.DrivingRoute(mapBValue, { | ||
| 675 | - renderOptions: {map: mapBValue}, | ||
| 676 | - onPolylinesSet: searchPolylinesSet | ||
| 677 | - }); | ||
| 678 | - function searchPolylinesSet(results) { | ||
| 679 | - if (transit.getStatus() != BMAP_STATUS_SUCCESS) { | ||
| 680 | - } else { | ||
| 681 | - var sectionArrayList = []; | ||
| 682 | - for (i = 0; i < results.length; i++) { | ||
| 683 | - // console.log(results[i].getPolyline().getPath()); | ||
| 684 | - sectionArrayList = sectionArrayList.concat(results[i].getPolyline().getPath()); | ||
| 685 | - } | ||
| 686 | - var sectionName = stationsPoint[index].name + '至' + stationsPoint[index + 1].name; | ||
| 687 | - sectionList.push({sectionName: sectionName, points: sectionArrayList}); | ||
| 688 | - } | ||
| 689 | - f(); | ||
| 690 | - } | ||
| 691 | - transit.search(poiOne, poiTwo); | 630 | + f(); |
| 692 | })(); | 631 | })(); |
| 693 | }, | 632 | }, |
| 694 | 633 | ||
| @@ -1414,77 +1353,9 @@ window.WorldsBMap = function () { | @@ -1414,77 +1353,9 @@ window.WorldsBMap = function () { | ||
| 1414 | 1353 | ||
| 1415 | // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) | 1354 | // 当函数被调用时,它的arguments.callee对象就会指向自身,也就是一个对自己的引用。(当前正在执行的函数。) |
| 1416 | var f = arguments.callee; | 1355 | var f = arguments.callee; |
| 1417 | - // 起点坐标 <坐标格式:40.056878,116.30815> | ||
| 1418 | - var origin = points[index].potion.lat + ',' + points[index].potion.lng; | ||
| 1419 | - | ||
| 1420 | - // 终点坐标 <坐标格式:40.056878,116.30815> | ||
| 1421 | - var destination = points[index+1].potion.lat + ',' + points[index+1].potion.lng; | ||
| 1422 | - var region = '上海'; | ||
| 1423 | - | ||
| 1424 | - var origin_region = '上海'; | ||
| 1425 | - | ||
| 1426 | - var destination_region = '上海'; | ||
| 1427 | - | ||
| 1428 | - var output = 'json'; | ||
| 1429 | - | ||
| 1430 | - var ak_My = 'wjlITmXeCek5MxyU3ZUBkTeU8B0o0npk'; | ||
| 1431 | - | ||
| 1432 | - /** | ||
| 1433 | - * origin:起点名称或经纬度; | ||
| 1434 | - * | ||
| 1435 | - * destination:终点名称或经纬度; | ||
| 1436 | - * | ||
| 1437 | - * origin_region:起始点所在城市,驾车导航时必填。 | ||
| 1438 | - * | ||
| 1439 | - * destination_region:终点所在城市,驾车导航时必填。 | ||
| 1440 | - * | ||
| 1441 | - * output :表示输出类型,可设置为xml或json,默认为xml。 | ||
| 1442 | - * | ||
| 1443 | - **/ | ||
| 1444 | - var paramsB = {origin:origin,destination:destination,region:region,origin_region:origin_region,destination_region:destination_region,output:output,ak:ak_My}; | ||
| 1445 | - | ||
| 1446 | - /** @description :未认证开发者默认配额为:2000次/天。 */ | ||
| 1447 | - $.ajax({ | ||
| 1448 | - | ||
| 1449 | - // 百度地图根据坐标获取两点之间的时间与距离 | ||
| 1450 | - url: '//api.map.baidu.com/direction/v1?mode=transit', | ||
| 1451 | - | ||
| 1452 | - data: paramsB, | ||
| 1453 | - | ||
| 1454 | - dataType: 'jsonp', | ||
| 1455 | - | ||
| 1456 | - success: function(r){ | ||
| 1457 | - | ||
| 1458 | - if(r) { | ||
| 1459 | - | ||
| 1460 | - if(r.message=='ok') { | ||
| 1461 | - | ||
| 1462 | - if(r.result.taxi==null) { | ||
| 1463 | - | ||
| 1464 | - // 获取距离(单位:米) | ||
| 1465 | - points[index+1].distance = 0; | ||
| 1466 | - | ||
| 1467 | - // 获取时间(单位:秒) | ||
| 1468 | - points[index+1].duration = 0; | ||
| 1469 | - | ||
| 1470 | - }else { | ||
| 1471 | - | ||
| 1472 | - // 获取距离(单位:米) | ||
| 1473 | - points[index+1].distance = r.result.taxi.distance; | ||
| 1474 | - | ||
| 1475 | - // 获取时间(单位:秒) | ||
| 1476 | - points[index+1].duration = r.result.taxi.duration; | ||
| 1477 | - | ||
| 1478 | - } | ||
| 1479 | - | ||
| 1480 | - | ||
| 1481 | - } | ||
| 1482 | - | ||
| 1483 | - } | ||
| 1484 | - | ||
| 1485 | - f(); | ||
| 1486 | - } | ||
| 1487 | - }); | 1356 | + points[index + 1].distance = ''; |
| 1357 | + points[index + 1].duration = ''; | ||
| 1358 | + f(); | ||
| 1488 | 1359 | ||
| 1489 | })(); | 1360 | })(); |
| 1490 | 1361 |
src/main/resources/static/pages/control/line/index.html
| 1 | -<link href="/pages/control/line/css/lineControl.css" rel="stylesheet" type="text/css" /> | ||
| 2 | -<link href="/metronic_v4.5.4/css/animate.min.css" rel="stylesheet" type="text/css" /> | ||
| 3 | - | ||
| 4 | -<!-- 初始load界面 --> | ||
| 5 | -<div class="load-anim" > | ||
| 6 | - <div class="load-anim-list"> | ||
| 7 | - <div class="spinner"></div> | ||
| 8 | - <!-- <div class="item load_resource">加载资源文件...</div> --> | ||
| 9 | -<!-- <div class="item">校准客户端时间...</div> | ||
| 10 | - <div class="item">加载GPS模块...</div> | ||
| 11 | - <div class="item">加载班次信息...</div> | ||
| 12 | - <div class="item">webSocket 连接...</div> --> | ||
| 13 | - </div> | ||
| 14 | -</div> | ||
| 15 | - | ||
| 16 | -<div class="portlet light portlet-fullscreen" style="transition: all .5s ease;padding: 0;" oncontextmenu=self.event.returnValue=false> | ||
| 17 | - | ||
| 18 | - <div class="portlet-title banner" > | ||
| 19 | - <div class="caption col_hide_1280" style="color: #FFF;"> | ||
| 20 | - <i class="fa fa-life-ring" style="font-size: 22px;color: #FFF;"></i> <span | ||
| 21 | - class="caption-subject bold" style="font-size: 24px;">浦东公交线路调度系统</span> | ||
| 22 | - </div> | ||
| 23 | - <div class="col_hide_1440" style="color: white;font-size: 18px;position: absolute;right: 25px;top: 75px;"> | ||
| 24 | - <span class="top_username"></span> <span class="operation_mode_text animated" ></span> | ||
| 25 | - </div> | ||
| 26 | - <div class="actions col_hide_1280" > | ||
| 27 | - <div class="btn-group"> | ||
| 28 | - | ||
| 29 | - <div class="btn-group"> | ||
| 30 | - <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > | ||
| 31 | - <i class="fa fa-database"></i> 基础数据 | ||
| 32 | - <i class="fa fa-angle-down"></i> | ||
| 33 | - </button> | ||
| 34 | - <ul class="dropdown-menu"> | ||
| 35 | - <li> | ||
| 36 | - <a href="javascript:;" id=""> 车辆配置 </a> | ||
| 37 | - </li> | ||
| 38 | - <li> | ||
| 39 | - <a href="javascript:;" id=""> 人员配置 </a> | ||
| 40 | - </li> | ||
| 41 | - </ul> | ||
| 42 | - </div> | ||
| 43 | - | ||
| 44 | - <div class="btn-group"> | ||
| 45 | - <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > | ||
| 46 | - <i class="fa fa-bus"></i> 车载设备 | ||
| 47 | - <i class="fa fa-angle-down"></i> | ||
| 48 | - </button> | ||
| 49 | - <ul class="dropdown-menu"> | ||
| 50 | - <li> | ||
| 51 | - <a href="javascript:;" id="deviceConfig"> 设备管理 </a> | ||
| 52 | - </li> | ||
| 53 | - <li> | ||
| 54 | - <a href="javascript:;" id="deviceReport"> 设备上报记录 </a> | ||
| 55 | - </li> | ||
| 56 | - <li> | ||
| 57 | - <a href="javascript:;" id="msgAndDirect"> 指令下发记录 </a> | ||
| 58 | - </li> | ||
| 59 | - </ul> | ||
| 60 | - </div> | ||
| 61 | - | ||
| 62 | - <div class="btn-group"> | ||
| 63 | - <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > | ||
| 64 | - <i class="fa fa-gavel"></i> 系统设置 | ||
| 65 | - <i class="fa fa-angle-down"></i> | ||
| 66 | - </button> | ||
| 67 | - <ul class="dropdown-menu"> | ||
| 68 | - <li> | ||
| 69 | - <a href="javascript:;" id="ttsConfigure"> TTS 语音设置 </a> | ||
| 70 | - </li> | ||
| 71 | - <li> | ||
| 72 | - <a href="javascript:;" id="updateLogLink"> 更新日志 </a> | ||
| 73 | - </li> | ||
| 74 | - </ul> | ||
| 75 | - </div> | ||
| 76 | - | ||
| 77 | - <button id="exitBtn" type="button" class="btn btn-danger" style="margin-left: 8px;padding: 6.5px 9px !important;" > | ||
| 78 | - <!-- <i class="fa fa-close" ></i> -->退出线路调度</button> | ||
| 79 | - </div> | ||
| 80 | - </div> | ||
| 81 | - </div> | ||
| 82 | - <div class="portlet-body" id="top-tabs-wrap" > | ||
| 83 | - <ul class="nav nav-tabs top-nav" > | ||
| 84 | - <li class="active"> | ||
| 85 | - <a href="#tab_home" data-toggle="tab" aria-expanded="false" style="padding: 10px 15px;"> | ||
| 86 | - <i class="fa fa-home"></i> 主页 | ||
| 87 | - </a> | ||
| 88 | - </li> | ||
| 89 | - <li class=""><a href="#tab_map" data-toggle="tab" style="padding: 10px 15px;" | ||
| 90 | - aria-expanded="false"><i class="fa fa-map"></i> 地图 </a></li> | ||
| 91 | - </ul> | ||
| 92 | - | ||
| 93 | - <div class="tab-content" > | ||
| 94 | - <div class="tab-pane fade active in" id="tab_home" ></div> | ||
| 95 | - <div class="tab-pane fade" id="tab_map" style="position: relative;"></div> | ||
| 96 | - | ||
| 97 | - <!-- <div class="tab-pane fade tab_line active in" id="tab_line" > | ||
| 98 | - | ||
| 99 | - </div> --> | ||
| 100 | - </div> | ||
| 101 | - </div> | ||
| 102 | -<div id="tooltipShade" class="animated fadeIn"></div> | ||
| 103 | - | ||
| 104 | -<div id="menuWrap"></div> | ||
| 105 | -<!-- 线路调度右键菜单 --> | ||
| 106 | -<menu class="menu" id="rightMenu" style="display: none;"> | ||
| 107 | - <li class="menu-item submenu"> | ||
| 108 | - <button type="button" class="menu-btn" data-method="outgoAdjust"> | ||
| 109 | - <span class="menu-text">待发调整</span> | ||
| 110 | - </button> | ||
| 111 | - <menu class="menu"> | ||
| 112 | - <li class="menu-item"> | ||
| 113 | - <button type="button" class="menu-btn" data-method="outgoAdjust"> | ||
| 114 | - <span class="menu-text">基于班次</span> | ||
| 115 | - </button> | ||
| 116 | - </li> | ||
| 117 | - <li class="menu-item"> | ||
| 118 | - <button type="button" class="menu-btn" data-method="outgoAdjustAll"> | ||
| 119 | - <span class="menu-text">基于车辆</span> | ||
| 120 | - </button> | ||
| 121 | - </li> | ||
| 122 | - </menu> | ||
| 123 | - </li> | ||
| 124 | - | ||
| 125 | - | ||
| 126 | - <li class="menu-separator"></li> | ||
| 127 | - <li class="menu-item" > | ||
| 128 | - <button type="button" class="menu-btn" data-method="planDestroy"> | ||
| 129 | - <span class="menu-text">计划烂班</span> | ||
| 130 | - </button> | ||
| 131 | - </li> | ||
| 132 | - <li class="menu-item" > | ||
| 133 | - <button type="button" class="menu-btn" data-method="revokeDestroy"> | ||
| 134 | - <span class="menu-text">撤销烂班</span> | ||
| 135 | - </button> | ||
| 136 | - </li> | ||
| 137 | - <li class="menu-item" > | ||
| 138 | - <button type="button" class="menu-btn" data-method="realOutgoAdjust"> | ||
| 139 | - <span class="menu-text">实发调整</span> | ||
| 140 | - </button> | ||
| 141 | - </li> | ||
| 142 | - <li class="menu-item" > | ||
| 143 | - <button type="button" class="menu-btn" data-method="revokeRealOutgo"> | ||
| 144 | - <span class="menu-text">撤销实发</span> | ||
| 145 | - </button> | ||
| 146 | - </li> | ||
| 147 | - <li class="menu-separator"></li> | ||
| 148 | - <li class="menu-item" > | ||
| 149 | - <button type="button" class="menu-btn" data-multi=1 data-method="spaceAdjust"> | ||
| 150 | - <span class="menu-text">间隔调整</span> | ||
| 151 | - </button> | ||
| 152 | - </li> | ||
| 153 | - <!-- <li class="menu-item disabled" > | ||
| 154 | - <button type="button" class="menu-btn"> | ||
| 155 | - <span class="menu-text">误点调整</span> | ||
| 156 | - </button> | ||
| 157 | - </li> --> | ||
| 158 | - <li class="menu-item" > | ||
| 159 | - <button type="button" class="menu-btn" data-method="schInfoFineTune"> | ||
| 160 | - <span class="menu-text">发车信息微调</span> | ||
| 161 | - </button> | ||
| 162 | - </li> | ||
| 163 | - <li class="menu-separator"></li> | ||
| 164 | - <li class="menu-item" > | ||
| 165 | - <button type="button" class="menu-btn" data-method="childTask"> | ||
| 166 | - <i class="fa fa-plus"></i> | ||
| 167 | - <span class="menu-text">临加/子任务</span> | ||
| 168 | - </button> | ||
| 169 | - </li> | ||
| 170 | - <li class="menu-separator"></li> | ||
| 171 | - <li class="menu-item" > | ||
| 172 | - <button type="button" class="menu-btn" data-method="vehicAndPerAdjust"> | ||
| 173 | - <i class="fa fa-retweet"></i> | ||
| 174 | - <span class="menu-text">调整车/人</span> | ||
| 175 | - </button> | ||
| 176 | - </li> | ||
| 177 | - <li class="menu-separator"></li> | ||
| 178 | - <li class="menu-item" > | ||
| 179 | - <button type="button" class="menu-btn" data-method="directiveRepeat"> | ||
| 180 | - <i class="fa fa-bell-o"></i> | ||
| 181 | - <span class="menu-text">指令重发</span> | ||
| 182 | - </button> | ||
| 183 | - </li> | ||
| 184 | -</menu> | ||
| 185 | -<!-- 主页右键菜单 --> | ||
| 186 | -<menu class="menu" id="homeMenu" style="display: none;"> | ||
| 187 | - <li class="menu-item disabled" id="menu-linename"> | ||
| 188 | - <button type="button" class="menu-btn"> | ||
| 189 | - <span class="menu-text">--- <span class="menu-title-nbbm"></span> ---</span> | ||
| 190 | - </button> | ||
| 191 | - </li> | ||
| 192 | - <li class="menu-item" > | ||
| 193 | - <button type="button" class="menu-btn" data-method="sendPhrase"> | ||
| 194 | - <span class="menu-text">发送消息短语</span> | ||
| 195 | - </button> | ||
| 196 | - </li> | ||
| 197 | - <li class="menu-separator"></li> | ||
| 198 | - <li class="menu-item" > | ||
| 199 | - <button type="button" class="menu-btn" data-method="showState"> | ||
| 200 | - <span class="menu-text">车辆状态查看</span> | ||
| 201 | - </button> | ||
| 202 | - </li> | ||
| 203 | - <li class="menu-item submenu"> | ||
| 204 | - <button type="button" class="menu-btn"> | ||
| 205 | - <span class="menu-text">车辆状态切换</span> | ||
| 206 | - </button> | ||
| 207 | - <menu class="menu"> | ||
| 208 | - <li class="menu-item"> | ||
| 209 | - <button type="button" class="menu-btn" data-method="changeUp"> | ||
| 210 | - <span class="menu-text">上行营运</span> | ||
| 211 | - </button> | ||
| 212 | - </li> | ||
| 213 | - <li class="menu-item"> | ||
| 214 | - <button type="button" class="menu-btn" data-method="changeDown"> | ||
| 215 | - <span class="menu-text">下行营运</span> | ||
| 216 | - </button> | ||
| 217 | - </li> | ||
| 218 | - </menu> | ||
| 219 | - </li> | ||
| 220 | -</menu> | ||
| 221 | - | ||
| 222 | -<div class="ctm-note animated bounceInDown"> | ||
| 223 | - <div class="content"></div> | ||
| 224 | -</div> | ||
| 225 | -</div> | ||
| 226 | -<div id="temps"></div> | ||
| 227 | - | ||
| 228 | -<div id="tooltip" style="display: none;"> | ||
| 229 | -</div> | ||
| 230 | - | ||
| 231 | -<script> | ||
| 232 | -//JS文件加载计数,countDownLatch为0 时则加载完成 | ||
| 233 | -var countDownLatch = 13; | ||
| 234 | -function countDown(name){ | ||
| 235 | - countDownLatch --; | ||
| 236 | - if(!countDownLatch) | ||
| 237 | - _main.start(); | ||
| 238 | - | ||
| 239 | - console.log('countDown: ' + countDownLatch, 'file: ' + name); | ||
| 240 | -} | ||
| 241 | -</script> | ||
| 242 | -<script src="/assets/js/eventproxy.js"></script> | ||
| 243 | - | ||
| 244 | -<script src="/pages/control/line/js/main.js"></script> | ||
| 245 | -<script src="/pages/control/line/js/tooltip.js"></script> | ||
| 246 | -<script src="/pages/control/line/js/drawSvg.js"></script> | ||
| 247 | -<script src="/pages/control/line/js/data.js"></script> | ||
| 248 | -<script src="/pages/control/line/js/rightMenu.js"></script> | ||
| 249 | -<script src="/pages/control/line/js/homeMenu.js"></script> | ||
| 250 | -<script src="/pages/control/line/js/alone.js"></script> | ||
| 251 | -<script src="/pages/control/line/js/messenger.js"></script> | ||
| 252 | -<script src="/pages/control/line/js/keyboardListen.js"></script> | ||
| 253 | -<script src="/pages/control/line/js/toolbarEvent.js"></script> | ||
| 254 | -<script src="/pages/control/line/js/speech.js" data-exclude=1></script> | ||
| 255 | -<script src="/pages/control/line/js/home.js"></script> | ||
| 256 | - | ||
| 257 | -<script> | ||
| 258 | -var updateLog = { | ||
| 259 | - text: '<div class="updete_log"><p>1、过滤掉未加入调度配置的GPS信号。</p></div>' | ||
| 260 | - ,title: '2016年9月13号更新日志' | ||
| 261 | -} | ||
| 262 | - | ||
| 263 | -var lineCodes = '' //全部线路编码字符串,由data.js初始化 | ||
| 264 | - , lineMap = {} //编码和线路详细对照,由data.js初始化; | ||
| 265 | - ,animationend = 'webkitAnimationEnd animationend'; | ||
| 266 | -moment.locale('zh-cn'); | ||
| 267 | - | ||
| 268 | -var cUser | ||
| 269 | - , storage = window.localStorage | ||
| 270 | - , operationMode = storage.getItem('operationMode'); | ||
| 271 | - | ||
| 272 | -//当前用户 | ||
| 273 | -$.get('/user/currentUser', function(user){ | ||
| 274 | - cUser = user; | ||
| 275 | - $('.portlet-fullscreen .top_username').text(cUser.userName) | ||
| 276 | - var t = operationMode == 0?',<abbr title="系统将对当前的提交请求进行拦截">监控模式</abbr> 在线' | ||
| 277 | - :',主调模式 在线'; | ||
| 278 | - $('.portlet-fullscreen .operation_mode_text').html(t); | ||
| 279 | -}); | ||
| 280 | - | ||
| 281 | -//打个标记 | ||
| 282 | -storage.setItem('real_control_flag', 1); | ||
| 283 | - | ||
| 284 | -var reqCodeMap = {0xA1: '请求恢复运营', 0xA2: '申请调档', 0xA3: '出场请求', 0xA5: '进场请求', 0xA7: '加油请求', 0x50: '车辆故障', 0x70: '路阻报告', 0x60: '事故报告', 0x11: '扣证纠纷', 0x12 : '报警'}; | ||
| 285 | - | ||
| 286 | -function _fadeOut($that){ | ||
| 287 | - $that.fadeOut('normal', function(){ | ||
| 288 | - $that.remove(); | ||
| 289 | - }); | ||
| 290 | -} | ||
| 291 | -$(function() { | ||
| 292 | - //主调和监控模式横幅颜色 | ||
| 293 | - if(operationMode == 0) | ||
| 294 | - $('.portlet-fullscreen').addClass('monitor'); | ||
| 295 | - else | ||
| 296 | - $('.portlet-fullscreen').addClass('main'); | ||
| 297 | - | ||
| 298 | - //加载模板文件 | ||
| 299 | - getTemp('temps/home_tp.html'); | ||
| 300 | - getTemp('temps/tooltip_tp.html'); | ||
| 301 | - getTemp('temps/alone_tp.html'); | ||
| 302 | - getTemp('temps/child_task_case_tp.html'); | ||
| 303 | - getTemp('temps/messenger.html'); | ||
| 304 | - | ||
| 305 | - function getTemp(url){ | ||
| 306 | - $.get(url, function(template){ | ||
| 307 | - $('#temps').append(template); | ||
| 308 | - }); | ||
| 309 | - } | ||
| 310 | -}); | ||
| 311 | - | ||
| 312 | -//监控模式下拦截POST请求 | ||
| 313 | -function interceptPOST(e, xhr, t){ | ||
| 314 | - if(t && (t.method == 'POST' || t.type == 'POST')){ | ||
| 315 | - console.log(e, xhr, t); | ||
| 316 | - xhr.abort(); | ||
| 317 | - layer.msg('监控模式!',{offset: 'ct', shift : 6}); | ||
| 318 | - } | ||
| 319 | -} | ||
| 320 | - | ||
| 321 | -</script> | 1 | +<link href="/pages/control/line/css/lineControl.css" rel="stylesheet" type="text/css" /> |
| 2 | +<link href="/metronic_v4.5.4/css/animate.min.css" rel="stylesheet" type="text/css" /> | ||
| 3 | + | ||
| 4 | +<!-- 初始load界面 --> | ||
| 5 | +<div class="load-anim" > | ||
| 6 | + <div class="load-anim-list"> | ||
| 7 | + <div class="spinner"></div> | ||
| 8 | + <!-- <div class="item load_resource">加载资源文件...</div> --> | ||
| 9 | +<!-- <div class="item">校准客户端时间...</div> | ||
| 10 | + <div class="item">加载GPS模块...</div> | ||
| 11 | + <div class="item">加载班次信息...</div> | ||
| 12 | + <div class="item">webSocket 连接...</div> --> | ||
| 13 | + </div> | ||
| 14 | +</div> | ||
| 15 | + | ||
| 16 | +<div class="portlet light portlet-fullscreen" style="transition: all .5s ease;padding: 0;" oncontextmenu=self.event.returnValue=false> | ||
| 17 | + | ||
| 18 | + <div class="portlet-title banner" > | ||
| 19 | + <div class="caption col_hide_1280" style="color: #FFF;"> | ||
| 20 | + <i class="fa fa-life-ring" style="font-size: 22px;color: #FFF;"></i> <span | ||
| 21 | + class="caption-subject bold" style="font-size: 24px;">滨海线路调度系统</span> | ||
| 22 | + </div> | ||
| 23 | + <div class="col_hide_1440" style="color: white;font-size: 18px;position: absolute;right: 25px;top: 75px;"> | ||
| 24 | + <span class="top_username"></span> <span class="operation_mode_text animated" ></span> | ||
| 25 | + </div> | ||
| 26 | + <div class="actions col_hide_1280" > | ||
| 27 | + <div class="btn-group"> | ||
| 28 | + | ||
| 29 | + <div class="btn-group"> | ||
| 30 | + <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > | ||
| 31 | + <i class="fa fa-database"></i> 基础数据 | ||
| 32 | + <i class="fa fa-angle-down"></i> | ||
| 33 | + </button> | ||
| 34 | + <ul class="dropdown-menu"> | ||
| 35 | + <li> | ||
| 36 | + <a href="javascript:;" id=""> 车辆配置 </a> | ||
| 37 | + </li> | ||
| 38 | + <li> | ||
| 39 | + <a href="javascript:;" id=""> 人员配置 </a> | ||
| 40 | + </li> | ||
| 41 | + </ul> | ||
| 42 | + </div> | ||
| 43 | + | ||
| 44 | + <div class="btn-group"> | ||
| 45 | + <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > | ||
| 46 | + <i class="fa fa-bus"></i> 车载设备 | ||
| 47 | + <i class="fa fa-angle-down"></i> | ||
| 48 | + </button> | ||
| 49 | + <ul class="dropdown-menu"> | ||
| 50 | + <li> | ||
| 51 | + <a href="javascript:;" id="deviceConfig"> 设备管理 </a> | ||
| 52 | + </li> | ||
| 53 | + <li> | ||
| 54 | + <a href="javascript:;" id="deviceReport"> 设备上报记录 </a> | ||
| 55 | + </li> | ||
| 56 | + <li> | ||
| 57 | + <a href="javascript:;" id="msgAndDirect"> 指令下发记录 </a> | ||
| 58 | + </li> | ||
| 59 | + </ul> | ||
| 60 | + </div> | ||
| 61 | + | ||
| 62 | + <div class="btn-group"> | ||
| 63 | + <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" > | ||
| 64 | + <i class="fa fa-gavel"></i> 系统设置 | ||
| 65 | + <i class="fa fa-angle-down"></i> | ||
| 66 | + </button> | ||
| 67 | + <ul class="dropdown-menu"> | ||
| 68 | + <li> | ||
| 69 | + <a href="javascript:;" id="ttsConfigure"> TTS 语音设置 </a> | ||
| 70 | + </li> | ||
| 71 | + <li> | ||
| 72 | + <a href="javascript:;" id="updateLogLink"> 更新日志 </a> | ||
| 73 | + </li> | ||
| 74 | + </ul> | ||
| 75 | + </div> | ||
| 76 | + | ||
| 77 | + <button id="exitBtn" type="button" class="btn btn-danger" style="margin-left: 8px;padding: 6.5px 9px !important;" > | ||
| 78 | + <!-- <i class="fa fa-close" ></i> -->退出线路调度</button> | ||
| 79 | + </div> | ||
| 80 | + </div> | ||
| 81 | + </div> | ||
| 82 | + <div class="portlet-body" id="top-tabs-wrap" > | ||
| 83 | + <ul class="nav nav-tabs top-nav" > | ||
| 84 | + <li class="active"> | ||
| 85 | + <a href="#tab_home" data-toggle="tab" aria-expanded="false" style="padding: 10px 15px;"> | ||
| 86 | + <i class="fa fa-home"></i> 主页 | ||
| 87 | + </a> | ||
| 88 | + </li> | ||
| 89 | + <li class=""><a href="#tab_map" data-toggle="tab" style="padding: 10px 15px;" | ||
| 90 | + aria-expanded="false"><i class="fa fa-map"></i> 地图 </a></li> | ||
| 91 | + </ul> | ||
| 92 | + | ||
| 93 | + <div class="tab-content" > | ||
| 94 | + <div class="tab-pane fade active in" id="tab_home" ></div> | ||
| 95 | + <div class="tab-pane fade" id="tab_map" style="position: relative;"></div> | ||
| 96 | + | ||
| 97 | + <!-- <div class="tab-pane fade tab_line active in" id="tab_line" > | ||
| 98 | + | ||
| 99 | + </div> --> | ||
| 100 | + </div> | ||
| 101 | + </div> | ||
| 102 | +<div id="tooltipShade" class="animated fadeIn"></div> | ||
| 103 | + | ||
| 104 | +<div id="menuWrap"></div> | ||
| 105 | +<!-- 线路调度右键菜单 --> | ||
| 106 | +<menu class="menu" id="rightMenu" style="display: none;"> | ||
| 107 | + <li class="menu-item submenu"> | ||
| 108 | + <button type="button" class="menu-btn" data-method="outgoAdjust"> | ||
| 109 | + <span class="menu-text">待发调整</span> | ||
| 110 | + </button> | ||
| 111 | + <menu class="menu"> | ||
| 112 | + <li class="menu-item"> | ||
| 113 | + <button type="button" class="menu-btn" data-method="outgoAdjust"> | ||
| 114 | + <span class="menu-text">基于班次</span> | ||
| 115 | + </button> | ||
| 116 | + </li> | ||
| 117 | + <li class="menu-item"> | ||
| 118 | + <button type="button" class="menu-btn" data-method="outgoAdjustAll"> | ||
| 119 | + <span class="menu-text">基于车辆</span> | ||
| 120 | + </button> | ||
| 121 | + </li> | ||
| 122 | + </menu> | ||
| 123 | + </li> | ||
| 124 | + | ||
| 125 | + | ||
| 126 | + <li class="menu-separator"></li> | ||
| 127 | + <li class="menu-item" > | ||
| 128 | + <button type="button" class="menu-btn" data-method="planDestroy"> | ||
| 129 | + <span class="menu-text">计划烂班</span> | ||
| 130 | + </button> | ||
| 131 | + </li> | ||
| 132 | + <li class="menu-item" > | ||
| 133 | + <button type="button" class="menu-btn" data-method="revokeDestroy"> | ||
| 134 | + <span class="menu-text">撤销烂班</span> | ||
| 135 | + </button> | ||
| 136 | + </li> | ||
| 137 | + <li class="menu-item" > | ||
| 138 | + <button type="button" class="menu-btn" data-method="realOutgoAdjust"> | ||
| 139 | + <span class="menu-text">实发调整</span> | ||
| 140 | + </button> | ||
| 141 | + </li> | ||
| 142 | + <li class="menu-item" > | ||
| 143 | + <button type="button" class="menu-btn" data-method="revokeRealOutgo"> | ||
| 144 | + <span class="menu-text">撤销实发</span> | ||
| 145 | + </button> | ||
| 146 | + </li> | ||
| 147 | + <li class="menu-separator"></li> | ||
| 148 | + <li class="menu-item" > | ||
| 149 | + <button type="button" class="menu-btn" data-multi=1 data-method="spaceAdjust"> | ||
| 150 | + <span class="menu-text">间隔调整</span> | ||
| 151 | + </button> | ||
| 152 | + </li> | ||
| 153 | + <!-- <li class="menu-item disabled" > | ||
| 154 | + <button type="button" class="menu-btn"> | ||
| 155 | + <span class="menu-text">误点调整</span> | ||
| 156 | + </button> | ||
| 157 | + </li> --> | ||
| 158 | + <li class="menu-item" > | ||
| 159 | + <button type="button" class="menu-btn" data-method="schInfoFineTune"> | ||
| 160 | + <span class="menu-text">发车信息微调</span> | ||
| 161 | + </button> | ||
| 162 | + </li> | ||
| 163 | + <li class="menu-separator"></li> | ||
| 164 | + <li class="menu-item" > | ||
| 165 | + <button type="button" class="menu-btn" data-method="childTask"> | ||
| 166 | + <i class="fa fa-plus"></i> | ||
| 167 | + <span class="menu-text">临加/子任务</span> | ||
| 168 | + </button> | ||
| 169 | + </li> | ||
| 170 | + <li class="menu-separator"></li> | ||
| 171 | + <li class="menu-item" > | ||
| 172 | + <button type="button" class="menu-btn" data-method="vehicAndPerAdjust"> | ||
| 173 | + <i class="fa fa-retweet"></i> | ||
| 174 | + <span class="menu-text">调整车/人</span> | ||
| 175 | + </button> | ||
| 176 | + </li> | ||
| 177 | + <li class="menu-separator"></li> | ||
| 178 | + <li class="menu-item" > | ||
| 179 | + <button type="button" class="menu-btn" data-method="directiveRepeat"> | ||
| 180 | + <i class="fa fa-bell-o"></i> | ||
| 181 | + <span class="menu-text">指令重发</span> | ||
| 182 | + </button> | ||
| 183 | + </li> | ||
| 184 | +</menu> | ||
| 185 | +<!-- 主页右键菜单 --> | ||
| 186 | +<menu class="menu" id="homeMenu" style="display: none;"> | ||
| 187 | + <li class="menu-item disabled" id="menu-linename"> | ||
| 188 | + <button type="button" class="menu-btn"> | ||
| 189 | + <span class="menu-text">--- <span class="menu-title-nbbm"></span> ---</span> | ||
| 190 | + </button> | ||
| 191 | + </li> | ||
| 192 | + <li class="menu-item" > | ||
| 193 | + <button type="button" class="menu-btn" data-method="sendPhrase"> | ||
| 194 | + <span class="menu-text">发送消息短语</span> | ||
| 195 | + </button> | ||
| 196 | + </li> | ||
| 197 | + <li class="menu-separator"></li> | ||
| 198 | + <li class="menu-item" > | ||
| 199 | + <button type="button" class="menu-btn" data-method="showState"> | ||
| 200 | + <span class="menu-text">车辆状态查看</span> | ||
| 201 | + </button> | ||
| 202 | + </li> | ||
| 203 | + <li class="menu-item submenu"> | ||
| 204 | + <button type="button" class="menu-btn"> | ||
| 205 | + <span class="menu-text">车辆状态切换</span> | ||
| 206 | + </button> | ||
| 207 | + <menu class="menu"> | ||
| 208 | + <li class="menu-item"> | ||
| 209 | + <button type="button" class="menu-btn" data-method="changeUp"> | ||
| 210 | + <span class="menu-text">上行营运</span> | ||
| 211 | + </button> | ||
| 212 | + </li> | ||
| 213 | + <li class="menu-item"> | ||
| 214 | + <button type="button" class="menu-btn" data-method="changeDown"> | ||
| 215 | + <span class="menu-text">下行营运</span> | ||
| 216 | + </button> | ||
| 217 | + </li> | ||
| 218 | + </menu> | ||
| 219 | + </li> | ||
| 220 | +</menu> | ||
| 221 | + | ||
| 222 | +<div class="ctm-note animated bounceInDown"> | ||
| 223 | + <div class="content"></div> | ||
| 224 | +</div> | ||
| 225 | +</div> | ||
| 226 | +<div id="temps"></div> | ||
| 227 | + | ||
| 228 | +<div id="tooltip" style="display: none;"> | ||
| 229 | +</div> | ||
| 230 | + | ||
| 231 | +<script> | ||
| 232 | +//JS文件加载计数,countDownLatch为0 时则加载完成 | ||
| 233 | +var countDownLatch = 13; | ||
| 234 | +function countDown(name){ | ||
| 235 | + countDownLatch --; | ||
| 236 | + if(!countDownLatch) | ||
| 237 | + _main.start(); | ||
| 238 | + | ||
| 239 | + console.log('countDown: ' + countDownLatch, 'file: ' + name); | ||
| 240 | +} | ||
| 241 | +</script> | ||
| 242 | +<script src="/assets/js/eventproxy.js"></script> | ||
| 243 | + | ||
| 244 | +<script src="/pages/control/line/js/main.js"></script> | ||
| 245 | +<script src="/pages/control/line/js/tooltip.js"></script> | ||
| 246 | +<script src="/pages/control/line/js/drawSvg.js"></script> | ||
| 247 | +<script src="/pages/control/line/js/data.js"></script> | ||
| 248 | +<script src="/pages/control/line/js/rightMenu.js"></script> | ||
| 249 | +<script src="/pages/control/line/js/homeMenu.js"></script> | ||
| 250 | +<script src="/pages/control/line/js/alone.js"></script> | ||
| 251 | +<script src="/pages/control/line/js/messenger.js"></script> | ||
| 252 | +<script src="/pages/control/line/js/keyboardListen.js"></script> | ||
| 253 | +<script src="/pages/control/line/js/toolbarEvent.js"></script> | ||
| 254 | +<script src="/pages/control/line/js/speech.js" data-exclude=1></script> | ||
| 255 | +<script src="/pages/control/line/js/home.js"></script> | ||
| 256 | + | ||
| 257 | +<script> | ||
| 258 | +var updateLog = { | ||
| 259 | + text: '<div class="updete_log"><p>1、过滤掉未加入调度配置的GPS信号。</p></div>' | ||
| 260 | + ,title: '2016年9月13号更新日志' | ||
| 261 | +} | ||
| 262 | + | ||
| 263 | +var lineCodes = '' //全部线路编码字符串,由data.js初始化 | ||
| 264 | + , lineMap = {} //编码和线路详细对照,由data.js初始化; | ||
| 265 | + ,animationend = 'webkitAnimationEnd animationend'; | ||
| 266 | +moment.locale('zh-cn'); | ||
| 267 | + | ||
| 268 | +var cUser | ||
| 269 | + , storage = window.localStorage | ||
| 270 | + , operationMode = storage.getItem('operationMode'); | ||
| 271 | + | ||
| 272 | +//当前用户 | ||
| 273 | +$.get('/user/currentUser', function(user){ | ||
| 274 | + cUser = user; | ||
| 275 | + $('.portlet-fullscreen .top_username').text(cUser.userName) | ||
| 276 | + var t = operationMode == 0?',<abbr title="系统将对当前的提交请求进行拦截">监控模式</abbr> 在线' | ||
| 277 | + :',主调模式 在线'; | ||
| 278 | + $('.portlet-fullscreen .operation_mode_text').html(t); | ||
| 279 | +}); | ||
| 280 | + | ||
| 281 | +//打个标记 | ||
| 282 | +storage.setItem('real_control_flag', 1); | ||
| 283 | + | ||
| 284 | +var reqCodeMap = {0xA1: '请求恢复运营', 0xA2: '申请调档', 0xA3: '出场请求', 0xA5: '进场请求', 0xA7: '加油请求', 0x50: '车辆故障', 0x70: '路阻报告', 0x60: '事故报告', 0x11: '扣证纠纷', 0x12 : '报警'}; | ||
| 285 | + | ||
| 286 | +function _fadeOut($that){ | ||
| 287 | + $that.fadeOut('normal', function(){ | ||
| 288 | + $that.remove(); | ||
| 289 | + }); | ||
| 290 | +} | ||
| 291 | +$(function() { | ||
| 292 | + //主调和监控模式横幅颜色 | ||
| 293 | + if(operationMode == 0) | ||
| 294 | + $('.portlet-fullscreen').addClass('monitor'); | ||
| 295 | + else | ||
| 296 | + $('.portlet-fullscreen').addClass('main'); | ||
| 297 | + | ||
| 298 | + //加载模板文件 | ||
| 299 | + getTemp('temps/home_tp.html'); | ||
| 300 | + getTemp('temps/tooltip_tp.html'); | ||
| 301 | + getTemp('temps/alone_tp.html'); | ||
| 302 | + getTemp('temps/child_task_case_tp.html'); | ||
| 303 | + getTemp('temps/messenger.html'); | ||
| 304 | + | ||
| 305 | + function getTemp(url){ | ||
| 306 | + $.get(url, function(template){ | ||
| 307 | + $('#temps').append(template); | ||
| 308 | + }); | ||
| 309 | + } | ||
| 310 | +}); | ||
| 311 | + | ||
| 312 | +//监控模式下拦截POST请求 | ||
| 313 | +function interceptPOST(e, xhr, t){ | ||
| 314 | + if(t && (t.method == 'POST' || t.type == 'POST')){ | ||
| 315 | + console.log(e, xhr, t); | ||
| 316 | + xhr.abort(); | ||
| 317 | + layer.msg('监控模式!',{offset: 'ct', shift : 6}); | ||
| 318 | + } | ||
| 319 | +} | ||
| 320 | + | ||
| 321 | +</script> | ||
| 322 | <script src="/pages/control/line/js/webSocketHandle.js"></script> | 322 | <script src="/pages/control/line/js/webSocketHandle.js"></script> |
| 323 | \ No newline at end of file | 323 | \ No newline at end of file |
src/main/resources/static/real_control_v2/js/safe_driv/safeDriv.js
| @@ -83,7 +83,7 @@ var gb_safe_driv = (function () { | @@ -83,7 +83,7 @@ var gb_safe_driv = (function () { | ||
| 83 | $.post('/realSchedule/ackCp', {id : id}, function(res) {}); | 83 | $.post('/realSchedule/ackCp', {id : id}, function(res) {}); |
| 84 | } | 84 | } |
| 85 | break; | 85 | break; |
| 86 | - // 浦东公交维修库 | 86 | + // 滨海维修库 |
| 87 | case 'mt': | 87 | case 'mt': |
| 88 | var data = { zbh: $(this).data('zbh'), bydj: $(this).data('bydj'), bysj: $(this).data('bysj'), bydd: $(this).data('bydd')}; | 88 | var data = { zbh: $(this).data('zbh'), bydj: $(this).data('bydj'), bysj: $(this).data('bysj'), bydd: $(this).data('bydd')}; |
| 89 | $(this).remove(); | 89 | $(this).remove(); |
src/main/resources/static/real_control_v2/main.html
| @@ -55,7 +55,7 @@ | @@ -55,7 +55,7 @@ | ||
| 55 | <div class="uk-width-4-10"> | 55 | <div class="uk-width-4-10"> |
| 56 | <div class="uk-panel"> | 56 | <div class="uk-panel"> |
| 57 | <h2 class="north-logo"> | 57 | <h2 class="north-logo"> |
| 58 | - <!--<i class="uk-icon-life-ring"></i>--> 浦东公交线路调度 | 58 | + <!--<i class="uk-icon-life-ring"></i>--> 滨海线路调度 |
| 59 | </h2> | 59 | </h2> |
| 60 | </div> | 60 | </div> |
| 61 | </div> | 61 | </div> |
| @@ -249,7 +249,7 @@ | @@ -249,7 +249,7 @@ | ||
| 249 | <div> | 249 | <div> |
| 250 | <span class="title">维修保养计划</span> | 250 | <span class="title">维修保养计划</span> |
| 251 | <span class="text"> {{zbh}} {{timeStr}} 进场保养</span> | 251 | <span class="text"> {{zbh}} {{timeStr}} 进场保养</span> |
| 252 | - <span class="desc">--浦东公交维修库</span> | 252 | + <span class="desc">--滨海维修库</span> |
| 253 | </div> | 253 | </div> |
| 254 | </div> | 254 | </div> |
| 255 | </script> | 255 | </script> |