Commit ec4279a2eeb6addf5b3c798d2e1dd1684fe62e8f
1 parent
c2d594c8
1.
Showing
20 changed files
with
3804 additions
and
3992 deletions
src/main/java/com/bsth/XDApplication.java
| ... | ... | @@ -87,8 +87,8 @@ public class XDApplication implements CommandLineRunner { |
| 87 | 87 | @Autowired |
| 88 | 88 | SafeDrivDataLoadThread safeDrivDataLoadThread; |
| 89 | 89 | |
| 90 | - @Autowired | |
| 91 | - MtPlanDataLoadThread mtPlanDataLoadThread; | |
| 90 | +// @Autowired | |
| 91 | +// MtPlanDataLoadThread mtPlanDataLoadThread; | |
| 92 | 92 | |
| 93 | 93 | @Autowired |
| 94 | 94 | FixedCheckStationCodeThread fixedCheckStationCodeThread; |
| ... | ... | @@ -190,7 +190,7 @@ public class XDApplication implements CommandLineRunner { |
| 190 | 190 | ScheduledExecutorService sexec = Application.mainServices; |
| 191 | 191 | //安全驾驶 |
| 192 | 192 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 193 | - sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 193 | + //sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 194 | 194 | |
| 195 | 195 | GpsDataLoaderThread.setFlag(-1); |
| 196 | 196 | /** 线调业务 */ |
| ... | ... | @@ -235,7 +235,7 @@ public class XDApplication implements CommandLineRunner { |
| 235 | 235 | ScheduledExecutorService sexec = Application.mainServices; |
| 236 | 236 | //安全驾驶 |
| 237 | 237 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 238 | - sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 238 | + //sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 239 | 239 | |
| 240 | 240 | GpsDataLoaderThread.setFlag(-1); |
| 241 | 241 | //dayOfSchedule.dataRecovery(); |
| ... | ... | @@ -281,7 +281,7 @@ public class XDApplication implements CommandLineRunner { |
| 281 | 281 | ScheduledExecutorService sexec = Application.mainServices; |
| 282 | 282 | //安全驾驶 |
| 283 | 283 | sexec.scheduleWithFixedDelay(safeDrivDataLoadThread, 180, 10, TimeUnit.SECONDS); |
| 284 | - sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 284 | + //sexec.scheduleWithFixedDelay(mtPlanDataLoadThread, 180, 10, TimeUnit.SECONDS); | |
| 285 | 285 | |
| 286 | 286 | GpsDataLoaderThread.setFlag(-1); |
| 287 | 287 | /** 线调业务 */ | ... | ... |
src/main/java/com/bsth/controller/calc/CalcMixController.java
| 1 | -package com.bsth.controller.calc; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | -import java.util.Map; | |
| 5 | - | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 8 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 9 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | -import org.springframework.web.bind.annotation.RestController; | |
| 11 | - | |
| 12 | -import com.bsth.entity.calc.CalcInvestigateMonth; | |
| 13 | -import com.bsth.service.calc.CalcMixService; | |
| 14 | - | |
| 15 | -@RestController | |
| 16 | -@RequestMapping("calc_mix") | |
| 17 | -public class CalcMixController { | |
| 18 | - | |
| 19 | - @Autowired | |
| 20 | - CalcMixService service; | |
| 21 | - | |
| 22 | - @RequestMapping(value="/calcjsyspy") | |
| 23 | - public List<Map<String, Object>> calcjsyspy(@RequestParam Map<String, Object> map){ | |
| 24 | - String line=""; | |
| 25 | - if(map.get("line")!=null){ | |
| 26 | - line=map.get("line").toString().trim(); | |
| 27 | - } | |
| 28 | - String startDate=""; | |
| 29 | - if(map.get("startDate")!=null){ | |
| 30 | - startDate=map.get("startDate").toString().trim(); | |
| 31 | - } | |
| 32 | - String endDate=""; | |
| 33 | - if(map.get("endDate")!=null){ | |
| 34 | - endDate=map.get("endDate").toString().trim(); | |
| 35 | - } | |
| 36 | - String empnames=""; | |
| 37 | - if(map.get("empnames")!=null){ | |
| 38 | - empnames=map.get("empnames").toString().trim(); | |
| 39 | - } | |
| 40 | - String cont=""; | |
| 41 | - if(map.get("cont")!=null){ | |
| 42 | - cont=map.get("cont").toString().trim(); | |
| 43 | - } | |
| 44 | - String gsdmManth=""; | |
| 45 | - if(map.get("gsdmManth")!=null){ | |
| 46 | - gsdmManth=map.get("gsdmManth").toString().trim(); | |
| 47 | - } | |
| 48 | - String fgsdmManth=""; | |
| 49 | - if(map.get("fgsdmManth")!=null){ | |
| 50 | - fgsdmManth=map.get("fgsdmManth").toString().trim(); | |
| 51 | - } | |
| 52 | - return service.calcjsyspy(line, startDate, endDate, empnames, cont, gsdmManth, fgsdmManth); | |
| 53 | - } | |
| 54 | - | |
| 55 | - @RequestMapping(value = "/singledatatj", method = RequestMethod.GET) | |
| 56 | - public List<Map<String, Object>> singledatatj(@RequestParam Map<String, Object> map) { | |
| 57 | - String line=""; | |
| 58 | - if(map.get("line")!=null){ | |
| 59 | - line=map.get("line").toString().trim(); | |
| 60 | - } | |
| 61 | - String startDate=""; | |
| 62 | - if(map.get("startDate")!=null){ | |
| 63 | - startDate=map.get("startDate").toString().trim(); | |
| 64 | - } | |
| 65 | - String endDate=""; | |
| 66 | - if(map.get("endDate")!=null){ | |
| 67 | - endDate=map.get("endDate").toString().trim(); | |
| 68 | - } | |
| 69 | - String tjtype=""; | |
| 70 | - if(map.get("tjtype")!=null){ | |
| 71 | - tjtype=map.get("tjtype").toString().trim(); | |
| 72 | - } | |
| 73 | - String cont=""; | |
| 74 | - if(map.get("cont")!=null){ | |
| 75 | - cont=map.get("cont").toString().trim(); | |
| 76 | - } | |
| 77 | - String gsdmSing=""; | |
| 78 | - if(map.get("gsdmSing")!=null){ | |
| 79 | - gsdmSing=map.get("gsdmSing").toString().trim(); | |
| 80 | - } | |
| 81 | - String fgsdmSing=""; | |
| 82 | - if(map.get("fgsdmSing")!=null){ | |
| 83 | - fgsdmSing=map.get("fgsdmSing").toString().trim(); | |
| 84 | - } | |
| 85 | - String sfdc=""; | |
| 86 | - if(map.get("sfdc")!=null){ | |
| 87 | - sfdc=map.get("sfdc").toString().trim(); | |
| 88 | - } | |
| 89 | - return service.singledatatj(line, startDate, endDate, tjtype, cont, gsdmSing, fgsdmSing, sfdc); | |
| 90 | - } | |
| 91 | - | |
| 92 | - //浦东公交线路调查表 | |
| 93 | - @RequestMapping(value = "/calcInvestigateMonth", method = RequestMethod.GET) | |
| 94 | - public List<CalcInvestigateMonth> calcInvestigateMonth(@RequestParam Map<String, Object> map) { | |
| 95 | - String gsbm=""; | |
| 96 | - if(map.get("gsbm")!=null){ | |
| 97 | - gsbm=map.get("gsbm").toString().trim(); | |
| 98 | - } | |
| 99 | - String fgsbm=""; | |
| 100 | - if(map.get("fgsbm")!=null){ | |
| 101 | - fgsbm=map.get("fgsbm").toString().trim(); | |
| 102 | - } | |
| 103 | - String month=""; | |
| 104 | - if(map.get("month")!=null){ | |
| 105 | - month=map.get("month").toString().trim(); | |
| 106 | - } | |
| 107 | - String line=""; | |
| 108 | - if(map.get("line")!=null){ | |
| 109 | - line=map.get("line").toString().trim(); | |
| 110 | - } | |
| 111 | - String xlName=""; | |
| 112 | - if(map.get("xlName")!=null){ | |
| 113 | - xlName=map.get("xlName").toString().trim(); | |
| 114 | - } | |
| 115 | - String nature=""; | |
| 116 | - if(map.get("nature")!=null){ | |
| 117 | - nature=map.get("nature").toString().trim(); | |
| 118 | - } | |
| 119 | - String type=""; | |
| 120 | - if(map.get("type")!=null){ | |
| 121 | - type=map.get("type").toString().trim(); | |
| 122 | - } | |
| 123 | - return service.calcInvestigateMonth(gsbm, fgsbm, month, line, xlName, nature, type); | |
| 124 | - } | |
| 125 | - | |
| 126 | -} | |
| 1 | +package com.bsth.controller.calc; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | +import java.util.Map; | |
| 5 | + | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 8 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 9 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | +import org.springframework.web.bind.annotation.RestController; | |
| 11 | + | |
| 12 | +import com.bsth.entity.calc.CalcInvestigateMonth; | |
| 13 | +import com.bsth.service.calc.CalcMixService; | |
| 14 | + | |
| 15 | +@RestController | |
| 16 | +@RequestMapping("calc_mix") | |
| 17 | +public class CalcMixController { | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + CalcMixService service; | |
| 21 | + | |
| 22 | + @RequestMapping(value="/calcjsyspy") | |
| 23 | + public List<Map<String, Object>> calcjsyspy(@RequestParam Map<String, Object> map){ | |
| 24 | + String line=""; | |
| 25 | + if(map.get("line")!=null){ | |
| 26 | + line=map.get("line").toString().trim(); | |
| 27 | + } | |
| 28 | + String startDate=""; | |
| 29 | + if(map.get("startDate")!=null){ | |
| 30 | + startDate=map.get("startDate").toString().trim(); | |
| 31 | + } | |
| 32 | + String endDate=""; | |
| 33 | + if(map.get("endDate")!=null){ | |
| 34 | + endDate=map.get("endDate").toString().trim(); | |
| 35 | + } | |
| 36 | + String empnames=""; | |
| 37 | + if(map.get("empnames")!=null){ | |
| 38 | + empnames=map.get("empnames").toString().trim(); | |
| 39 | + } | |
| 40 | + String cont=""; | |
| 41 | + if(map.get("cont")!=null){ | |
| 42 | + cont=map.get("cont").toString().trim(); | |
| 43 | + } | |
| 44 | + String gsdmManth=""; | |
| 45 | + if(map.get("gsdmManth")!=null){ | |
| 46 | + gsdmManth=map.get("gsdmManth").toString().trim(); | |
| 47 | + } | |
| 48 | + String fgsdmManth=""; | |
| 49 | + if(map.get("fgsdmManth")!=null){ | |
| 50 | + fgsdmManth=map.get("fgsdmManth").toString().trim(); | |
| 51 | + } | |
| 52 | + return service.calcjsyspy(line, startDate, endDate, empnames, cont, gsdmManth, fgsdmManth); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @RequestMapping(value = "/singledatatj", method = RequestMethod.GET) | |
| 56 | + public List<Map<String, Object>> singledatatj(@RequestParam Map<String, Object> map) { | |
| 57 | + String line=""; | |
| 58 | + if(map.get("line")!=null){ | |
| 59 | + line=map.get("line").toString().trim(); | |
| 60 | + } | |
| 61 | + String startDate=""; | |
| 62 | + if(map.get("startDate")!=null){ | |
| 63 | + startDate=map.get("startDate").toString().trim(); | |
| 64 | + } | |
| 65 | + String endDate=""; | |
| 66 | + if(map.get("endDate")!=null){ | |
| 67 | + endDate=map.get("endDate").toString().trim(); | |
| 68 | + } | |
| 69 | + String tjtype=""; | |
| 70 | + if(map.get("tjtype")!=null){ | |
| 71 | + tjtype=map.get("tjtype").toString().trim(); | |
| 72 | + } | |
| 73 | + String cont=""; | |
| 74 | + if(map.get("cont")!=null){ | |
| 75 | + cont=map.get("cont").toString().trim(); | |
| 76 | + } | |
| 77 | + String gsdmSing=""; | |
| 78 | + if(map.get("gsdmSing")!=null){ | |
| 79 | + gsdmSing=map.get("gsdmSing").toString().trim(); | |
| 80 | + } | |
| 81 | + String fgsdmSing=""; | |
| 82 | + if(map.get("fgsdmSing")!=null){ | |
| 83 | + fgsdmSing=map.get("fgsdmSing").toString().trim(); | |
| 84 | + } | |
| 85 | + String sfdc=""; | |
| 86 | + if(map.get("sfdc")!=null){ | |
| 87 | + sfdc=map.get("sfdc").toString().trim(); | |
| 88 | + } | |
| 89 | + return service.singledatatj(line, startDate, endDate, tjtype, cont, gsdmSing, fgsdmSing, sfdc); | |
| 90 | + } | |
| 91 | + | |
| 92 | + //陆家嘴旅游线路调查表 | |
| 93 | + @RequestMapping(value = "/calcInvestigateMonth", method = RequestMethod.GET) | |
| 94 | + public List<CalcInvestigateMonth> calcInvestigateMonth(@RequestParam Map<String, Object> map) { | |
| 95 | + String gsbm=""; | |
| 96 | + if(map.get("gsbm")!=null){ | |
| 97 | + gsbm=map.get("gsbm").toString().trim(); | |
| 98 | + } | |
| 99 | + String fgsbm=""; | |
| 100 | + if(map.get("fgsbm")!=null){ | |
| 101 | + fgsbm=map.get("fgsbm").toString().trim(); | |
| 102 | + } | |
| 103 | + String month=""; | |
| 104 | + if(map.get("month")!=null){ | |
| 105 | + month=map.get("month").toString().trim(); | |
| 106 | + } | |
| 107 | + String line=""; | |
| 108 | + if(map.get("line")!=null){ | |
| 109 | + line=map.get("line").toString().trim(); | |
| 110 | + } | |
| 111 | + String xlName=""; | |
| 112 | + if(map.get("xlName")!=null){ | |
| 113 | + xlName=map.get("xlName").toString().trim(); | |
| 114 | + } | |
| 115 | + String nature=""; | |
| 116 | + if(map.get("nature")!=null){ | |
| 117 | + nature=map.get("nature").toString().trim(); | |
| 118 | + } | |
| 119 | + String type=""; | |
| 120 | + if(map.get("type")!=null){ | |
| 121 | + type=map.get("type").toString().trim(); | |
| 122 | + } | |
| 123 | + return service.calcInvestigateMonth(gsbm, fgsbm, month, line, xlName, nature, type); | |
| 124 | + } | |
| 125 | + | |
| 126 | +} | ... | ... |
src/main/java/com/bsth/controller/sys/UserController.java
| ... | ... | @@ -192,25 +192,6 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 192 | 192 | return rs; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - // 检验密码有效期 | |
| 196 | - Date lastPwdDate = user.getLastPwdDate(); | |
| 197 | - if (lastPwdDate != null) { | |
| 198 | - if (user.getPwdExpiredDate().before(new Date())) { | |
| 199 | - return put(rs, "msg", "密码已过期,不能登录,请联系管理员"); | |
| 200 | - } | |
| 201 | - | |
| 202 | - Integer validPeriod = user.getPwdValidPeriod(); | |
| 203 | - if (validPeriod == null) { | |
| 204 | - validPeriod = 30; | |
| 205 | - } | |
| 206 | - Period p = new Period(new DateTime(lastPwdDate), new DateTime(new Date()), PeriodType.days()); | |
| 207 | - if (p.getDays() > validPeriod) { | |
| 208 | - return put(rs, "msg", "天没有修改密码,不能登录,请联系管理员"); | |
| 209 | - } | |
| 210 | - } else { | |
| 211 | - return put(rs, "msg", "从未更新过密码,不能登录,请联系管理员"); | |
| 212 | - } | |
| 213 | - | |
| 214 | 195 | // 弱密码检查 |
| 215 | 196 | Matcher matcher = pattern.matcher(password); |
| 216 | 197 | if (!matcher.matches()) { |
| ... | ... | @@ -489,66 +470,4 @@ public class UserController extends BaseController<SysUser, Integer> { |
| 489 | 470 | |
| 490 | 471 | return result; |
| 491 | 472 | } |
| 492 | - | |
| 493 | - /** | |
| 494 | - * 弱密码 | |
| 495 | - * @return | |
| 496 | - */ | |
| 497 | - @RequestMapping(value = "/isRealName", method = RequestMethod.POST) | |
| 498 | - public Map<String, Object> hasJobCode() { | |
| 499 | - Map<String, Object> result = new HashMap<>(); | |
| 500 | - SysUser user = SecurityUtils.getCurrentUser(); | |
| 501 | - result.put("status", ResponseCode.SUCCESS); | |
| 502 | - result.put("data", (StringUtils.isBlank(user.getJobCode()) || StringUtils.isBlank(user.getRealName())) ? 0 : 1); | |
| 503 | - | |
| 504 | - return result; | |
| 505 | - } | |
| 506 | - | |
| 507 | - // 重置密码 | |
| 508 | - @RequestMapping(value = "/realName", method = RequestMethod.POST) | |
| 509 | - public Map<String, Object> setJobCode(@RequestParam String jobCode, @RequestParam String realName) throws Exception { | |
| 510 | - Map<String, Object> data = new HashMap<>(), result = new HashMap<>(); | |
| 511 | - result.put("status", ResponseCode.ERROR); | |
| 512 | - result.put("data", "设置成功"); | |
| 513 | - | |
| 514 | - if (jobCode == null || realName == null) { | |
| 515 | - result.put("data", "你跳过验证了是吧"); | |
| 516 | - return result; | |
| 517 | - } | |
| 518 | - data.put("account", jobCode); | |
| 519 | - data.put("pageSize", 2); | |
| 520 | - data.put("pageNum", 1); | |
| 521 | - StringBuilder stringBuilder = HttpClientUtils.post("https://112.64.45.51/businessCenter/userInfo/queryUserList", mapper.writeValueAsString(data)); | |
| 522 | - if (stringBuilder == null) { | |
| 523 | - result.put("data", "统一平台验证失败1"); | |
| 524 | - return result; | |
| 525 | - } else { | |
| 526 | - List<Map<String, Object>> maps = mapper.readValue(mapper.writeValueAsString(((Map) mapper.readValue(stringBuilder.toString(), Map.class).get("data")).get("list")), mapper.getTypeFactory().constructParametricType(List.class, Map.class)); | |
| 527 | - if (maps.size() == 0) { | |
| 528 | - result.put("data", "统一平台验证失败2"); | |
| 529 | - return result; | |
| 530 | - } else { | |
| 531 | - boolean isAuth = false; | |
| 532 | - for (Map<String, Object> map : maps) { | |
| 533 | - if (realName.equals(map.get("name"))) { | |
| 534 | - isAuth = true; | |
| 535 | - break; | |
| 536 | - } | |
| 537 | - } | |
| 538 | - if (!isAuth) { | |
| 539 | - result.put("data", "统一平台验证失败3"); | |
| 540 | - return result; | |
| 541 | - } | |
| 542 | - } | |
| 543 | - } | |
| 544 | - | |
| 545 | - SysUser user = SecurityUtils.getCurrentUser(); | |
| 546 | - sysUserService.realName(jobCode, realName, user.getId()); | |
| 547 | - user.setJobCode(jobCode); | |
| 548 | - user.setRealName(realName); | |
| 549 | - | |
| 550 | - result.put("status", ResponseCode.SUCCESS); | |
| 551 | - return result; | |
| 552 | - } | |
| 553 | - | |
| 554 | 473 | } | ... | ... |
src/main/java/com/bsth/data/maintenance_plan/MtPlanDataLoadThread.java
src/main/java/com/bsth/entity/sys/SecurityUser.java
| ... | ... | @@ -21,8 +21,6 @@ public class SecurityUser extends SysUser implements UserDetails { |
| 21 | 21 | this.setAgencies(user.getAgencies()); |
| 22 | 22 | this.setRoles(user.getRoles()); |
| 23 | 23 | this.setEnabled(user.isEnabled()); |
| 24 | - this.setJobCode(user.getJobCode()); | |
| 25 | - this.setRealName(user.getRealName()); | |
| 26 | 24 | } |
| 27 | 25 | } |
| 28 | 26 | ... | ... |
src/main/java/com/bsth/entity/sys/SysUser.java
| ... | ... | @@ -42,12 +42,6 @@ public class SysUser implements Serializable { |
| 42 | 42 | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| 43 | 43 | private Date lastLoginDate; |
| 44 | 44 | |
| 45 | - /** 最近密码更新时间 */ | |
| 46 | - @DateTimeFormat(pattern = "yyyy-MM-dd") | |
| 47 | - private Date lastPwdDate; | |
| 48 | - /** 密码有效期 */ | |
| 49 | - private Integer pwdValidPeriod; | |
| 50 | - | |
| 51 | 45 | private String agencies; |
| 52 | 46 | |
| 53 | 47 | private boolean enabled; |
| ... | ... | @@ -55,16 +49,6 @@ public class SysUser implements Serializable { |
| 55 | 49 | @ManyToMany(fetch = FetchType.EAGER) |
| 56 | 50 | private Set<Role> roles = new LinkedHashSet<>(); |
| 57 | 51 | |
| 58 | - private String jobCode; | |
| 59 | - | |
| 60 | - private String realName; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * 密码过期时间 | |
| 64 | - */ | |
| 65 | - @Transient | |
| 66 | - private Date pwdExpiredDate; | |
| 67 | - | |
| 68 | 52 | public Integer getId() { |
| 69 | 53 | return id; |
| 70 | 54 | } |
| ... | ... | @@ -145,22 +129,6 @@ public class SysUser implements Serializable { |
| 145 | 129 | this.roles = roles; |
| 146 | 130 | } |
| 147 | 131 | |
| 148 | - public String getJobCode() { | |
| 149 | - return jobCode; | |
| 150 | - } | |
| 151 | - | |
| 152 | - public void setJobCode(String jobCode) { | |
| 153 | - this.jobCode = jobCode; | |
| 154 | - } | |
| 155 | - | |
| 156 | - public String getRealName() { | |
| 157 | - return realName; | |
| 158 | - } | |
| 159 | - | |
| 160 | - public void setRealName(String realName) { | |
| 161 | - this.realName = realName; | |
| 162 | - } | |
| 163 | - | |
| 164 | 132 | public Set<String> getLinks() { |
| 165 | 133 | Set<String> links = new HashSet<>(); |
| 166 | 134 | if (links.size() == 0) { |
| ... | ... | @@ -181,33 +149,4 @@ public class SysUser implements Serializable { |
| 181 | 149 | |
| 182 | 150 | return links; |
| 183 | 151 | } |
| 184 | - | |
| 185 | - public Date getLastPwdDate() { | |
| 186 | - return lastPwdDate; | |
| 187 | - } | |
| 188 | - | |
| 189 | - public void setLastPwdDate(Date lastPwdDate) { | |
| 190 | - this.lastPwdDate = lastPwdDate; | |
| 191 | - } | |
| 192 | - | |
| 193 | - public Integer getPwdValidPeriod() { | |
| 194 | - return pwdValidPeriod; | |
| 195 | - } | |
| 196 | - | |
| 197 | - public void setPwdValidPeriod(Integer pwdValidPeriod) { | |
| 198 | - this.pwdValidPeriod = pwdValidPeriod; | |
| 199 | - } | |
| 200 | - | |
| 201 | - public Date getPwdExpiredDate() { | |
| 202 | - DateTime dateTime = new DateTime(getLastPwdDate()); | |
| 203 | - if (pwdValidPeriod != null) { | |
| 204 | - dateTime = dateTime.plusDays(pwdValidPeriod); | |
| 205 | - } | |
| 206 | - | |
| 207 | - return dateTime.toDate(); | |
| 208 | - } | |
| 209 | - | |
| 210 | - public void setPwdExpiredDate(Date pwdExpiredDate) { | |
| 211 | - this.pwdExpiredDate = pwdExpiredDate; | |
| 212 | - } | |
| 213 | 152 | } | ... | ... |
src/main/java/com/bsth/service/calc/CalcMixService.java
| 1 | -package com.bsth.service.calc; | |
| 2 | - | |
| 3 | -import java.util.List; | |
| 4 | -import java.util.Map; | |
| 5 | - | |
| 6 | -import com.bsth.entity.calc.CalcInvestigateMonth; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * Created by 19/02/28. | |
| 10 | - */ | |
| 11 | -public interface CalcMixService { | |
| 12 | - | |
| 13 | - List<Map<String, Object>> calcjsyspy(String line, String startDate, String endDate, String cont, String empnames, String gsdmManth, String fgsdmManth); | |
| 14 | - | |
| 15 | - List<Map<String, Object>> singledatatj(String line, String startDate, String endDate, String tjtype, String cont, String gsdmSing, String fgsdmSing, String sfdc); | |
| 16 | - | |
| 17 | - //浦东公交线路调查表 | |
| 18 | - List<CalcInvestigateMonth> calcInvestigateMonth(String gsbm, String fgsbm, String month, String line, String xlName, String nature, String type); | |
| 19 | - | |
| 20 | -} | |
| 1 | +package com.bsth.service.calc; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | +import java.util.Map; | |
| 5 | + | |
| 6 | +import com.bsth.entity.calc.CalcInvestigateMonth; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Created by 19/02/28. | |
| 10 | + */ | |
| 11 | +public interface CalcMixService { | |
| 12 | + | |
| 13 | + List<Map<String, Object>> calcjsyspy(String line, String startDate, String endDate, String cont, String empnames, String gsdmManth, String fgsdmManth); | |
| 14 | + | |
| 15 | + List<Map<String, Object>> singledatatj(String line, String startDate, String endDate, String tjtype, String cont, String gsdmSing, String fgsdmSing, String sfdc); | |
| 16 | + | |
| 17 | + //陆家嘴旅游线路调查表 | |
| 18 | + List<CalcInvestigateMonth> calcInvestigateMonth(String gsbm, String fgsbm, String month, String line, String xlName, String nature, String type); | |
| 19 | + | |
| 20 | +} | ... | ... |
src/main/java/com/bsth/service/calc/impl/CalcMixServiceImpl.java
| ... | ... | @@ -353,7 +353,7 @@ public class CalcMixServiceImpl implements CalcMixService { |
| 353 | 353 | return resList; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - //浦东公交线路调查表 | |
| 356 | + //陆家嘴旅游线路调查表 | |
| 357 | 357 | @Override |
| 358 | 358 | public List<CalcInvestigateMonth> calcInvestigateMonth(String gsbm, String fgsbm, String month, String line, |
| 359 | 359 | String xlName, String nature, String type) { |
| ... | ... | @@ -445,7 +445,7 @@ public class CalcMixServiceImpl implements CalcMixService { |
| 445 | 445 | listI.add(mapList.iterator()); |
| 446 | 446 | String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; |
| 447 | 447 | ee.excelReplace(listI, new Object[]{m}, path + "mould/calcInvestigateMonth.xls", |
| 448 | - path + "export/" + "浦东公交线路调查表"+month+".xls"); | |
| 448 | + path + "export/" + "陆家嘴旅游线路调查表"+month+".xls"); | |
| 449 | 449 | } catch (Exception e) { |
| 450 | 450 | // TODO: handle exception |
| 451 | 451 | e.printStackTrace(); | ... | ... |
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/sys/impl/SysUserServiceImpl.java
| ... | ... | @@ -74,28 +74,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem |
| 74 | 74 | |
| 75 | 75 | @Override |
| 76 | 76 | public boolean validPWDExpired(String userName) { |
| 77 | - SysUser sysUser = this.sysUserRepository.findByUserName(userName); | |
| 78 | - if (sysUser == null) { | |
| 79 | - throw new RuntimeException("用户[" + userName + "]不存在!"); | |
| 80 | - } | |
| 81 | - if (sysUser.getPwdValidPeriod() == null || sysUser.getLastPwdDate() == null) { | |
| 82 | - // 如果没有设定密码过期时间,判定为不过期 | |
| 83 | - return true; | |
| 84 | - } | |
| 85 | - DateTime now = new DateTime(); | |
| 86 | - DateTime lastPwdDate = new DateTime(sysUser.getLastPwdDate()); | |
| 87 | - Integer now_period_days = Days.daysBetween(lastPwdDate, now).getDays(); | |
| 88 | - Integer expiredTipDays = 3; // 密码过期提前提示天数 | |
| 89 | - if (now_period_days < (sysUser.getPwdValidPeriod() - expiredTipDays)) { | |
| 90 | - return true; | |
| 91 | - } else if (now_period_days >= (sysUser.getPwdValidPeriod() - expiredTipDays) && | |
| 92 | - now_period_days < sysUser.getPwdValidPeriod()) { | |
| 93 | - // 快过期前提示 | |
| 94 | - throw new RuntimeException("当前用户密码还有[" + (sysUser.getPwdValidPeriod() - now_period_days) + "]天过期!"); | |
| 95 | - } else { | |
| 96 | - throw new RuntimeException("当前用户密码已过期!"); | |
| 97 | - } | |
| 98 | - | |
| 77 | + return true; | |
| 99 | 78 | } |
| 100 | 79 | |
| 101 | 80 | @Override |
| ... | ... | @@ -204,7 +183,6 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUser, Integer> implem |
| 204 | 183 | if(Legality){ |
| 205 | 184 | String pwd = PwdGenerator.randomPassword(16); |
| 206 | 185 | user = sysUserRepository.findById(id).get(); |
| 207 | - user.setPwdValidPeriod(pwdValidPeriod); | |
| 208 | 186 | sysUserRepository.save(user); |
| 209 | 187 | sysUserRepository.changePWD(id, new BCryptPasswordEncoder(4).encode(pwd)); |
| 210 | 188 | //发送邮件 | ... | ... |
src/main/resources/application-cloud.properties
| ... | ... | @@ -14,7 +14,7 @@ spring.jpa.properties.hibernate.dialect= org.hibernate.spatial.dialect.mysql.MyS |
| 14 | 14 | |
| 15 | 15 | #DATABASE |
| 16 | 16 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 17 | -spring.datasource.url= jdbc:mysql://192.170.100.132/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 17 | +spring.datasource.url= jdbc:mysql://47.101.175.82/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 18 | 18 | spring.datasource.username= root |
| 19 | 19 | spring.datasource.password= root2jsp |
| 20 | 20 | spring.datasource.type= com.zaxxer.hikari.HikariDataSource |
| ... | ... | @@ -31,7 +31,7 @@ spring.datasource.hikari.connection-test-query= SELECT 1 |
| 31 | 31 | spring.datasource.hikari.validation-timeout= 3000 |
| 32 | 32 | spring.datasource.hikari.register-mbeans=true |
| 33 | 33 | |
| 34 | -kafka.use= true | |
| 34 | +kafka.use= false | |
| 35 | 35 | spring.kafka.consumer.bootstrap-servers= 192.170.100.114:9092,192.170.100.114:9093,192.170.100.114:9094 |
| 36 | 36 | spring.kafka.key-serializer= org.apache.kafka.common.serialization.StringSerializer |
| 37 | 37 | spring.kafka.value-serializer= org.apache.kafka.common.serialization.StringSerializer |
| ... | ... | @@ -40,7 +40,7 @@ spring.kafka.producer.acks= all |
| 40 | 40 | spring.kafka.consumer.group-id= schedule-system |
| 41 | 41 | spring.kafka.consumer.auto-offset-reset= latest |
| 42 | 42 | |
| 43 | -sso.enabled= true | |
| 43 | +sso.enabled= false | |
| 44 | 44 | sso.systemcode = SYS0023 |
| 45 | 45 | sso.http.url.login= https://112.64.45.51/portal/index.html#/login |
| 46 | 46 | sso.http.url.logout= https://112.64.45.51/information/api/v1/logout | ... | ... |
src/main/resources/ms-jdbc.properties
| ... | ... | @@ -4,6 +4,6 @@ |
| 4 | 4 | #ms.mysql.password= 123456 |
| 5 | 5 | |
| 6 | 6 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | -ms.mysql.url= jdbc:mysql://192.170.100.63/ms?useUnicode=true&characterEncoding=utf-8 | |
| 7 | +ms.mysql.url= jdbc:mysql://47.101.175.82/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | 8 | ms.mysql.username= root |
| 9 | 9 | ms.mysql.password= root2jsp |
| 10 | 10 | \ No newline at end of file | ... | ... |
src/main/resources/rules/kBase1_core_plan.drl
| ... | ... | @@ -75,7 +75,7 @@ function Map gsMap(List gses) { |
| 75 | 75 | for (int i = 0; i < gses.size(); i++) { |
| 76 | 76 | Business gs = (Business) gses.get(i); |
| 77 | 77 | if (StringUtils.isNotEmpty(gs.getBusinessCode())) { |
| 78 | - if ("88".equals(gs.getUpCode())) { // 浦东公交 | |
| 78 | + if ("88".equals(gs.getUpCode())) { // 陆家嘴旅游 | |
| 79 | 79 | gsMap.put(gs.getBusinessCode(), gs); |
| 80 | 80 | } |
| 81 | 81 | if (gs.getBusinessCode().equals(gs.getUpCode())) { // 闵行,青浦 | ... | ... |
src/main/resources/static/index.html
| ... | ... | @@ -220,7 +220,7 @@ |
| 220 | 220 | <!-- LOGO --> |
| 221 | 221 | <div class="page-logo"> |
| 222 | 222 | <a href="index.html" class="logo-default logo-default-text"> |
| 223 | - 浦东公交调度系统 </a> | |
| 223 | + 陆家嘴旅游调度系统 </a> | |
| 224 | 224 | <div class="menu-toggler sidebar-toggler"></div> |
| 225 | 225 | </div> |
| 226 | 226 | <!-- END LOGO --> |
| ... | ... | @@ -454,28 +454,6 @@ |
| 454 | 454 | } |
| 455 | 455 | }); |
| 456 | 456 | |
| 457 | - $.ajax({ | |
| 458 | - url: '/user/isRealName', | |
| 459 | - type: 'POST', | |
| 460 | - async: false, | |
| 461 | - success: function (result,status,xhr) { | |
| 462 | - if (result.data == 0) { | |
| 463 | - $.get('/pages/permission/user/jobCode.html', function (content) { | |
| 464 | - layer.open({ | |
| 465 | - type: 1, | |
| 466 | - area: ['600px', '360px'], | |
| 467 | - content: content, | |
| 468 | - title: '设置工号(后期统一登录平台接入)', | |
| 469 | - shift: 5, | |
| 470 | - scrollbar: false, | |
| 471 | - success: function () { | |
| 472 | - } | |
| 473 | - }); | |
| 474 | - }); | |
| 475 | - } | |
| 476 | - } | |
| 477 | - }); | |
| 478 | - | |
| 479 | 457 | $.get('/user/currentUser', function (user) { |
| 480 | 458 | $('#indexTopUName').text(user.userName); |
| 481 | 459 | }); | ... | ... |
src/main/resources/static/login.html
| ... | ... | @@ -181,7 +181,7 @@ |
| 181 | 181 | <div class="wrapper ng-scope"> |
| 182 | 182 | <div id="loginPanel" class="dialog dialog-shadow"> |
| 183 | 183 | <br> |
| 184 | - <h3 class="logo-text">浦东公交调度系统</h3> | |
| 184 | + <h3 class="logo-text">陆家嘴旅游调度系统</h3> | |
| 185 | 185 | <hr> |
| 186 | 186 | <form style="padding: 0px 35px;"> |
| 187 | 187 | <div class="form-group" style="margin-bottom: 0"> | ... | ... |
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 | 322 | <script src="/pages/control/line/js/webSocketHandle.js"></script> |
| 323 | 323 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/forms/calc/calcInvestigateMonth.html
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | |
| 37 | 37 | <div class="page-head"> |
| 38 | 38 | <div class="page-title"> |
| 39 | - <h1>浦东公交线路调查表</h1> | |
| 39 | + <h1>陆家嘴旅游线路调查表</h1> | |
| 40 | 40 | </div> |
| 41 | 41 | </div> |
| 42 | 42 | |
| ... | ... | @@ -83,7 +83,7 @@ |
| 83 | 83 | <table class="table table-bordered table-hover table-checkable" id="forms"> |
| 84 | 84 | <thead> |
| 85 | 85 | <tr> |
| 86 | - <th colspan="35"><label id="tjrq"></label>浦东公交线路调查表</th> | |
| 86 | + <th colspan="35"><label id="tjrq"></label>陆家嘴旅游线路调查表</th> | |
| 87 | 87 | </tr> |
| 88 | 88 | <tr> |
| 89 | 89 | <td rowspan="2">序号</td> |
| ... | ... | @@ -308,7 +308,7 @@ |
| 308 | 308 | params['nature'] = nature; |
| 309 | 309 | params['type'] = "export"; |
| 310 | 310 | $get('/calc_mix/calcInvestigateMonth',params,function(result){ |
| 311 | - window.open("/downloadFile/download?fileName=浦东公交线路调查表"+moment(month).format("YYYY-MM")); | |
| 311 | + window.open("/downloadFile/download?fileName=陆家嘴旅游线路调查表"+moment(month).format("YYYY-MM")); | |
| 312 | 312 | }); |
| 313 | 313 | }); |
| 314 | 314 | ... | ... |
src/main/resources/static/real_control_v2/js/safe_driv/safeDriv.js
| ... | ... | @@ -83,7 +83,7 @@ var gb_safe_driv = (function () { |
| 83 | 83 | $.post('/realSchedule/ackCp', {id : id}, function(res) {}); |
| 84 | 84 | } |
| 85 | 85 | break; |
| 86 | - // 浦东公交维修库 | |
| 86 | + // 陆家嘴旅游维修库 | |
| 87 | 87 | case 'mt': |
| 88 | 88 | var data = { zbh: $(this).data('zbh'), bydj: $(this).data('bydj'), bysj: $(this).data('bysj'), bydd: $(this).data('bydd')}; |
| 89 | 89 | $(this).remove(); | ... | ... |
src/main/resources/static/real_control_v2/main.html
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | <div class="uk-width-4-10"> |
| 56 | 56 | <div class="uk-panel"> |
| 57 | 57 | <h2 class="north-logo"> |
| 58 | - <!--<i class="uk-icon-life-ring"></i>--> 浦东公交线路调度 | |
| 58 | + <!--<i class="uk-icon-life-ring"></i>--> 陆家嘴旅游线路调度 | |
| 59 | 59 | </h2> |
| 60 | 60 | </div> |
| 61 | 61 | </div> |
| ... | ... | @@ -252,7 +252,7 @@ |
| 252 | 252 | <span class="title">维修保养计划</span> |
| 253 | 253 | <br/> |
| 254 | 254 | <span class="text"> {{zbh}} {{timeStr}} 进场保养</span> |
| 255 | - <span class="desc">--浦东公交维修库</span> | |
| 255 | + <span class="desc">--陆家嘴旅游维修库</span> | |
| 256 | 256 | </div> |
| 257 | 257 | </div> |
| 258 | 258 | </script> |
| ... | ... | @@ -272,7 +272,7 @@ |
| 272 | 272 | <span class="title">{{errType}}私自绕改道</span> |
| 273 | 273 | <br/> |
| 274 | 274 | <span class="text"> {{line}} {{nbbm}} 在 {{findTime}} {{errType}}私自绕改道,<br/>请到运管中心处理</span> |
| 275 | - <span class="desc" style="color: #ffffff">--浦东公交运管中心管理系统</span> | |
| 275 | + <span class="desc" style="color: #ffffff">--陆家嘴旅游运管中心管理系统</span> | |
| 276 | 276 | </div> |
| 277 | 277 | </div> |
| 278 | 278 | </script> | ... | ... |
src/main/resources/traffic-jdbc.properties
| ... | ... | @@ -4,6 +4,6 @@ |
| 4 | 4 | #ms.mysql.password= 123456 |
| 5 | 5 | |
| 6 | 6 | ms.mysql.driver= com.mysql.jdbc.Driver |
| 7 | -ms.mysql.url= jdbc:mysql://192.170.100.63/ms?useUnicode=true&characterEncoding=utf-8 | |
| 7 | +ms.mysql.url= jdbc:mysql://47.101.175.82/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | 8 | ms.mysql.username= root |
| 9 | 9 | ms.mysql.password= root2jsp |
| 10 | 10 | \ No newline at end of file | ... | ... |