Commit c4c57d72a7ed11235a4bc5bcae9d2bdb0edb35eb
Merge branch 'pudong' of 192.168.168.201:panzhaov5/bsth_control into pudong
Showing
32 changed files
with
3094 additions
and
1366 deletions
Too many changes to show.
To preserve performance only 32 of 73 files are displayed.
src/main/java/com/bsth/controller/calc/CalcWaybillController.java
| ... | ... | @@ -151,6 +151,39 @@ public class CalcWaybillController extends BaseController<CalcWaybill, Integer> |
| 151 | 151 | return calcWaybillService.calcStatisticsDaily(gsdm,fgsdm,line,date,date2,xlName,type); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | + @RequestMapping(value="/calcStatisticsDaily2") | |
| 155 | + public List<Map<String, Object>> calcStatisticsDaily2(@RequestParam Map<String, Object> map){ | |
| 156 | + String gsdm=""; | |
| 157 | + if(map.get("gsdm")!=null){ | |
| 158 | + gsdm=map.get("gsdm").toString().trim(); | |
| 159 | + } | |
| 160 | + String fgsdm=""; | |
| 161 | + if(map.get("fgsdm")!=null){ | |
| 162 | + fgsdm=map.get("fgsdm").toString().trim(); | |
| 163 | + } | |
| 164 | + String line=""; | |
| 165 | + if(map.get("line")!=null){ | |
| 166 | + line=map.get("line").toString().trim(); | |
| 167 | + } | |
| 168 | + String date=""; | |
| 169 | + if(map.get("date")!=null){ | |
| 170 | + date=map.get("date").toString().trim(); | |
| 171 | + } | |
| 172 | + String date2=""; | |
| 173 | + if(map.get("date2")!=null){ | |
| 174 | + date2=map.get("date2").toString().trim(); | |
| 175 | + } | |
| 176 | + String xlName=""; | |
| 177 | + if(map.get("xlName")!=null){ | |
| 178 | + xlName=map.get("xlName").toString().trim(); | |
| 179 | + } | |
| 180 | + String type=""; | |
| 181 | + if(map.get("type")!=null){ | |
| 182 | + type=map.get("type").toString().trim(); | |
| 183 | + } | |
| 184 | + return calcWaybillService.calcStatisticsDaily2(gsdm,fgsdm,line,date,date2,xlName,type); | |
| 185 | + } | |
| 186 | + | |
| 154 | 187 | @RequestMapping(value="/generateLineMileage") |
| 155 | 188 | public Map<String, Object> generateLineMileage(@RequestParam Map<String, Object> map) throws Exception{ |
| 156 | 189 | Map<String, Object> m = new HashMap<String, Object>(); | ... | ... |
src/main/java/com/bsth/controller/oil/LsylbController.java
0 → 100644
| 1 | +package com.bsth.controller.oil; | |
| 2 | + | |
| 3 | +import java.text.SimpleDateFormat; | |
| 4 | +import java.util.ArrayList; | |
| 5 | +import java.util.HashMap; | |
| 6 | +import java.util.Iterator; | |
| 7 | +import java.util.List; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 12 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 13 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 14 | +import org.springframework.web.bind.annotation.RestController; | |
| 15 | + | |
| 16 | +import com.bsth.controller.BaseController; | |
| 17 | +import com.bsth.entity.oil.Lsylb; | |
| 18 | +import com.bsth.entity.oil.Ylb; | |
| 19 | +import com.bsth.service.oil.LsylbService; | |
| 20 | +import com.bsth.util.Arith; | |
| 21 | +import com.bsth.util.ReportUtils; | |
| 22 | + | |
| 23 | +@RestController | |
| 24 | +@RequestMapping("lsylb") | |
| 25 | +public class LsylbController extends BaseController<Ylb, Integer>{ | |
| 26 | + @Autowired | |
| 27 | + LsylbService lsylbService; | |
| 28 | + | |
| 29 | + @RequestMapping(value = "/lsylbList",method = RequestMethod.GET) | |
| 30 | + public List<Lsylb> lsylbList(@RequestParam Map<String, Object> map){ | |
| 31 | + List<Lsylb> ylbList=lsylbService.listYlb(map); | |
| 32 | + return ylbList; | |
| 33 | + } | |
| 34 | + | |
| 35 | + @RequestMapping(value = "/sumLsylb",method = RequestMethod.GET) | |
| 36 | + public Map<String, Object> sumLsylb(@RequestParam Map<String, Object> map){ | |
| 37 | + Map<String, Object> list=lsylbService.sumYlb(map); | |
| 38 | + return list; | |
| 39 | + } | |
| 40 | + | |
| 41 | + @RequestMapping(value = "/listExport",method = RequestMethod.POST) | |
| 42 | + public List<Map<String, Object>> listExport(@RequestParam Map<String, Object> map){ | |
| 43 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 44 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 45 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 46 | + ReportUtils ee = new ReportUtils(); | |
| 47 | + List<Lsylb> lsylb= lsylbService.listYlb(map); | |
| 48 | + String nylx=map.get("nylx").toString(); | |
| 49 | +// (new CustomerSpecs<Ylb>(map)).iterator(); | |
| 50 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | |
| 51 | + for (Lsylb y : lsylb) { | |
| 52 | + Map<String, Object> m = new HashMap<String, Object>(); | |
| 53 | + m.put("rq", sdfMonth.format(y.getRq())); | |
| 54 | + m.put("gsname",y.getGsname() ); | |
| 55 | + m.put("fgsname", y.getFgsname()); | |
| 56 | + m.put("xlname", y.getXlname()==null?"":y.getXlname()); | |
| 57 | + m.put("nbbm", y.getNbbm()); | |
| 58 | + m.put("jsy", y.getJsy()); | |
| 59 | + m.put("name", y.getName()); | |
| 60 | + m.put("czlc", "0"); | |
| 61 | + m.put("jzlc", "0"); | |
| 62 | + m.put("sh", y.getSh()==null?"0":y.getSh()); | |
| 63 | + | |
| 64 | + String shyy ="无"; | |
| 65 | + | |
| 66 | + if(nylx.equals("0")){ | |
| 67 | + m.put("jzl", y.getJzl()==null?"0":y.getJzl()); | |
| 68 | + m.put("czyl", y.getCzyl()==null?"0":y.getCzyl()); | |
| 69 | + m.put("jzyl", y.getJzyl()==null?"0":y.getJzyl()); | |
| 70 | + m.put("yh", y.getYh()==null?"0":y.getYh()); | |
| 71 | + | |
| 72 | + if(y.getShyy()!=null){ | |
| 73 | + shyy=y.getShyy(); | |
| 74 | + if(shyy.equals("1")){shyy="票务用油";} | |
| 75 | + else if(shyy.equals("2")){shyy="保养用油";} | |
| 76 | + else if(shyy.equals("3")){shyy="报废车用油";} | |
| 77 | + else if(shyy.equals("4")){shyy="其它用油";} | |
| 78 | + else if(shyy.equals("5")){shyy="人保部";} | |
| 79 | + else if(shyy.equals("6")){shyy="车队";} | |
| 80 | + else if(shyy.equals("7")){shyy="车间(高保)";} | |
| 81 | + else if(shyy.equals("8")){shyy="车间(小修)";} | |
| 82 | + else{shyy ="无";} | |
| 83 | + } | |
| 84 | + m.put("zyh", Arith.add(m.get("sh"), m.get("yh"))); | |
| 85 | + | |
| 86 | + String rylx=""; | |
| 87 | + if(y.getRylx()!=null){ | |
| 88 | + if(y.getRylx().equals("0")){rylx="0号柴油";} | |
| 89 | + if(y.getRylx().equals("1")){rylx="负10号柴油";} | |
| 90 | + } | |
| 91 | + m.put("rylx", rylx); | |
| 92 | + }else{ | |
| 93 | + m.put("cdl", y.getJzl()==null?"0":y.getJzl()); | |
| 94 | + m.put("czcd", y.getCzyl()==null?"0":y.getCzyl()); | |
| 95 | + m.put("jzcd", y.getJzyl()==null?"0":y.getJzyl()); | |
| 96 | + m.put("hd", y.getYh()==null?"0":y.getYh()); | |
| 97 | + if(y.getShyy()!=null){ | |
| 98 | + shyy=y.getShyy(); | |
| 99 | + if(shyy.equals("1")){shyy="票务用电";} | |
| 100 | + else if(shyy.equals("2")){shyy="保养用电";} | |
| 101 | + else if(shyy.equals("3")){shyy="报废车用电";} | |
| 102 | + else if(shyy.equals("4")){shyy="其它用电";} | |
| 103 | + else if(shyy.equals("5")){shyy="人保部";} | |
| 104 | + else if(shyy.equals("6")){shyy="车队";} | |
| 105 | + else if(shyy.equals("7")){shyy="车间(高保)";} | |
| 106 | + else if(shyy.equals("8")){shyy="车间(小修)";} | |
| 107 | + else{shyy ="无";} | |
| 108 | + } | |
| 109 | + m.put("zyh", Arith.add(m.get("sh"), m.get("hd"))); | |
| 110 | + m.put("rdlx", ""); | |
| 111 | + | |
| 112 | + } | |
| 113 | + m.put("shyy", shyy); | |
| 114 | + m.put("ns", y.getNs()==null?"0":y.getNs()); | |
| 115 | + m.put("zlc", y.getZlc()==null?"0":y.getZlc()); | |
| 116 | + m.put("bglyh", y.getBglyh()); | |
| 117 | + resList.add(m); | |
| 118 | + } | |
| 119 | + try { | |
| 120 | + map.put("sheetName", map.get("rq")); | |
| 121 | + listI.add(resList.iterator()); | |
| 122 | + String xls=""; | |
| 123 | + String name=""; | |
| 124 | + | |
| 125 | + if(nylx.equals("0")){ | |
| 126 | + xls="list.xls"; | |
| 127 | + name="进出场存油量.xls"; | |
| 128 | + }else{ | |
| 129 | + xls="listDl.xls"; | |
| 130 | + name="进出场存电量.xls"; | |
| 131 | + } | |
| 132 | + String path = this.getClass().getResource("/").getPath()+"static/pages/forms/"; | |
| 133 | + ee.excelReplace(listI, new Object[] { map }, path+"mould/"+xls, | |
| 134 | + path+"export/"+map.get("rq").toString()+ name); | |
| 135 | + } catch (Exception e) { | |
| 136 | + e.printStackTrace(); | |
| 137 | + } | |
| 138 | + | |
| 139 | + return resList; | |
| 140 | + | |
| 141 | + } | |
| 142 | +} | ... | ... |
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| 1 | -package com.bsth.controller.realcontrol; | |
| 2 | - | |
| 3 | -import com.bsth.data.directive.DayOfDirectives; | |
| 4 | -import com.bsth.data.directive.DirectivesPstThread; | |
| 5 | -import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | |
| 6 | -import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 7 | -import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | |
| 8 | -import com.bsth.data.msg_queue.DirectivePushQueue; | |
| 9 | -import com.bsth.data.msg_queue.WebSocketPushQueue; | |
| 10 | -import com.bsth.data.pilot80.PilotReport; | |
| 11 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 12 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 13 | -import com.bsth.websocket.handler.SendUtils; | |
| 14 | -import org.slf4j.Logger; | |
| 15 | -import org.slf4j.LoggerFactory; | |
| 16 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 19 | -import org.springframework.web.bind.annotation.RestController; | |
| 20 | - | |
| 21 | -import java.util.HashMap; | |
| 22 | -import java.util.List; | |
| 23 | -import java.util.Map; | |
| 24 | - | |
| 25 | -/** | |
| 26 | - * Created by panzhao on 2017/4/14. | |
| 27 | - */ | |
| 28 | -@RestController | |
| 29 | -@RequestMapping("adminUtils") | |
| 30 | -public class AdminUtilsController { | |
| 31 | - | |
| 32 | - | |
| 33 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 34 | - | |
| 35 | - @Autowired | |
| 36 | - DayOfSchedule dayOfSchedule; | |
| 37 | - | |
| 38 | - @Autowired | |
| 39 | - GeoCacheData geoCacheData; | |
| 40 | - | |
| 41 | - @Autowired | |
| 42 | - DayOfDirectives dayOfDirectives; | |
| 43 | - | |
| 44 | - @Autowired | |
| 45 | - SendUtils sendUtils; | |
| 46 | - | |
| 47 | - @Autowired | |
| 48 | - PilotReport pilotReport; | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * 出现重复班次的车辆 | |
| 52 | - * @param | |
| 53 | - | |
| 54 | - @RequestMapping(value = "/schRepeat", method = RequestMethod.POST) | |
| 55 | - public void schRepeat(@RequestParam String nbbm){ | |
| 56 | - logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); | |
| 57 | - List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); | |
| 58 | - logger.info("检测前,车辆班次数量:" + list.size()); | |
| 59 | - | |
| 60 | - Map<Long, ScheduleRealInfo> map = new HashMap<>(); | |
| 61 | - for(ScheduleRealInfo sch : list){ | |
| 62 | - if(map.containsKey(sch.getId())){ | |
| 63 | - logger.info("检测到重复ID: " + sch.getId()); | |
| 64 | - } | |
| 65 | - map.put(sch.getId(), sch); | |
| 66 | - } | |
| 67 | - | |
| 68 | - logger.info("检测后,车辆班次数量:" + list.size()); | |
| 69 | - if(map.values().size() > 0){ | |
| 70 | - dayOfSchedule.replaceByNbbm(nbbm, map.values()); | |
| 71 | - } | |
| 72 | - }*/ | |
| 73 | - | |
| 74 | -/* @RequestMapping(value = "/directivePushQueue") | |
| 75 | - public void directivePushQueue(){ | |
| 76 | - DirectivePushQueue.start(); | |
| 77 | - }*/ | |
| 78 | - | |
| 79 | - @RequestMapping(value = "/directiveQueueSize") | |
| 80 | - public void directiveQueueSize(){ | |
| 81 | - DirectivePushQueue.size(); | |
| 82 | - } | |
| 83 | - | |
| 84 | - /*@RequestMapping(value = "/webSocketPushQueue") | |
| 85 | - public void webSocketPushQueue(){ | |
| 86 | - WebSocketPushQueue.start(); | |
| 87 | - }*/ | |
| 88 | - | |
| 89 | - @RequestMapping(value = "/webSocketQueueSize") | |
| 90 | - public void webSocketQueueSize(){ | |
| 91 | - WebSocketPushQueue.size(); | |
| 92 | - } | |
| 93 | - | |
| 94 | - @RequestMapping(value = "/setHttpFlag") | |
| 95 | - public void setHttpFlag(@RequestParam int flag){ | |
| 96 | - if(flag != 0 && flag != -1) | |
| 97 | - return; | |
| 98 | - GpsDataLoaderThread.setFlag(flag); | |
| 99 | - } | |
| 100 | - | |
| 101 | - @RequestMapping(value = "/updateCacheBuff") | |
| 102 | - public void updateCacheBuff(){ | |
| 103 | - geoCacheData.loadData(); | |
| 104 | - } | |
| 105 | - | |
| 106 | - @RequestMapping(value = "/reCalcLpSch") | |
| 107 | - public void reCalcLpSch(){ | |
| 108 | - dayOfSchedule._test_reCalcLpSch(); | |
| 109 | - } | |
| 110 | - | |
| 111 | - @RequestMapping(value = "/findSchByLpName") | |
| 112 | - public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName){ | |
| 113 | - return dayOfSchedule.getLpScheduleMap().get(lpName); | |
| 114 | - } | |
| 115 | - | |
| 116 | - @RequestMapping(value = "/findSchByNbbm") | |
| 117 | - public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm){ | |
| 118 | - return dayOfSchedule.findByNbbm(nbbm); | |
| 119 | - } | |
| 120 | - | |
| 121 | - @RequestMapping(value = "/removeExecPlan") | |
| 122 | - public int removeExecPlan(@RequestParam String nbbm){ | |
| 123 | - dayOfSchedule.removeExecPlan(nbbm); | |
| 124 | - return 1; | |
| 125 | - } | |
| 126 | - | |
| 127 | - @RequestMapping(value = "/sch_re_calc_id_maps") | |
| 128 | - public int reCalcIdMaps(){ | |
| 129 | - return dayOfSchedule.reCalcIdMaps(); | |
| 130 | - } | |
| 131 | - | |
| 132 | - @RequestMapping(value = "/sch_size_string") | |
| 133 | - public String schSizeString(){ | |
| 134 | - return dayOfSchedule.sizeString(); | |
| 135 | - } | |
| 136 | - | |
| 137 | - @RequestMapping(value = "/containerSize") | |
| 138 | - public Map<String, Integer> containerSize(){ | |
| 139 | - Map<String, Integer> rs = new HashMap<>(); | |
| 140 | - rs.put("60_size", dayOfDirectives.all60().size()); | |
| 141 | - rs.put("80_size", pilotReport.findAll().size()); | |
| 142 | - rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); | |
| 143 | - rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); | |
| 144 | - rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); | |
| 145 | - rs.put("pst_sch_size", dayOfSchedule.getPstSize()); | |
| 146 | - rs.put("speeds_size", OverspeedProcess.size()); | |
| 147 | - return rs; | |
| 148 | - } | |
| 149 | - | |
| 150 | - @RequestMapping(value = "/websocketRadioText") | |
| 151 | - public int radioText(String t, String lineCode){ | |
| 152 | - sendUtils.sendRadioText(t, lineCode); | |
| 153 | - return 0; | |
| 154 | - } | |
| 155 | - | |
| 156 | - @Autowired | |
| 157 | - DirectivesPstThread directivesPstThread; | |
| 158 | - | |
| 159 | - @RequestMapping(value = "/_sd_60_pst") | |
| 160 | - public void sd_60_pst(){ | |
| 161 | - logger.info("手动入库指令...."); | |
| 162 | - directivesPstThread.run(); | |
| 163 | - } | |
| 1 | +package com.bsth.controller.realcontrol; | |
| 2 | + | |
| 3 | +import com.bsth.data.directive.DayOfDirectives; | |
| 4 | +import com.bsth.data.directive.DirectivesPstThread; | |
| 5 | +import com.bsth.data.gpsdata_v2.cache.GeoCacheData; | |
| 6 | +import com.bsth.data.gpsdata_v2.handlers.overspeed.OverspeedProcess; | |
| 7 | +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread; | |
| 8 | +import com.bsth.data.msg_queue.DirectivePushQueue; | |
| 9 | +import com.bsth.data.msg_queue.WebSocketPushQueue; | |
| 10 | +import com.bsth.data.pilot80.PilotReport; | |
| 11 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 12 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 13 | +import com.bsth.websocket.handler.SendUtils; | |
| 14 | +import org.slf4j.Logger; | |
| 15 | +import org.slf4j.LoggerFactory; | |
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 19 | +import org.springframework.web.bind.annotation.RestController; | |
| 20 | + | |
| 21 | +import java.util.HashMap; | |
| 22 | +import java.util.List; | |
| 23 | +import java.util.Map; | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * Created by panzhao on 2017/4/14. | |
| 27 | + */ | |
| 28 | +@RestController | |
| 29 | +@RequestMapping("adminUtils") | |
| 30 | +public class AdminUtilsController { | |
| 31 | + | |
| 32 | + | |
| 33 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 34 | + | |
| 35 | + @Autowired | |
| 36 | + DayOfSchedule dayOfSchedule; | |
| 37 | + | |
| 38 | + @Autowired | |
| 39 | + GeoCacheData geoCacheData; | |
| 40 | + | |
| 41 | + @Autowired | |
| 42 | + DayOfDirectives dayOfDirectives; | |
| 43 | + | |
| 44 | + @Autowired | |
| 45 | + SendUtils sendUtils; | |
| 46 | + | |
| 47 | + @Autowired | |
| 48 | + PilotReport pilotReport; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 出现重复班次的车辆 | |
| 52 | + * @param | |
| 53 | + | |
| 54 | + @RequestMapping(value = "/schRepeat", method = RequestMethod.POST) | |
| 55 | + public void schRepeat(@RequestParam String nbbm){ | |
| 56 | + logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); | |
| 57 | + List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); | |
| 58 | + logger.info("检测前,车辆班次数量:" + list.size()); | |
| 59 | + | |
| 60 | + Map<Long, ScheduleRealInfo> map = new HashMap<>(); | |
| 61 | + for(ScheduleRealInfo sch : list){ | |
| 62 | + if(map.containsKey(sch.getId())){ | |
| 63 | + logger.info("检测到重复ID: " + sch.getId()); | |
| 64 | + } | |
| 65 | + map.put(sch.getId(), sch); | |
| 66 | + } | |
| 67 | + | |
| 68 | + logger.info("检测后,车辆班次数量:" + list.size()); | |
| 69 | + if(map.values().size() > 0){ | |
| 70 | + dayOfSchedule.replaceByNbbm(nbbm, map.values()); | |
| 71 | + } | |
| 72 | + }*/ | |
| 73 | + | |
| 74 | +/* @RequestMapping(value = "/directivePushQueue") | |
| 75 | + public void directivePushQueue(){ | |
| 76 | + DirectivePushQueue.start(); | |
| 77 | + }*/ | |
| 78 | + | |
| 79 | + @RequestMapping(value = "/directiveQueueSize") | |
| 80 | + public void directiveQueueSize(){ | |
| 81 | + DirectivePushQueue.size(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + /*@RequestMapping(value = "/webSocketPushQueue") | |
| 85 | + public void webSocketPushQueue(){ | |
| 86 | + WebSocketPushQueue.start(); | |
| 87 | + }*/ | |
| 88 | + | |
| 89 | + @RequestMapping(value = "/webSocketQueueSize") | |
| 90 | + public void webSocketQueueSize(){ | |
| 91 | + WebSocketPushQueue.size(); | |
| 92 | + } | |
| 93 | + | |
| 94 | + @RequestMapping(value = "/setHttpFlag") | |
| 95 | + public void setHttpFlag(@RequestParam int flag){ | |
| 96 | + if(flag != 0 && flag != -1) | |
| 97 | + return; | |
| 98 | + GpsDataLoaderThread.setFlag(flag); | |
| 99 | + } | |
| 100 | + | |
| 101 | + @RequestMapping(value = "/updateCacheBuff") | |
| 102 | + public void updateCacheBuff(){ | |
| 103 | + geoCacheData.loadData(); | |
| 104 | + } | |
| 105 | + | |
| 106 | + @RequestMapping(value = "/reCalcLpSch") | |
| 107 | + public void reCalcLpSch(){ | |
| 108 | + dayOfSchedule._test_reCalcLpSch(); | |
| 109 | + } | |
| 110 | + | |
| 111 | + @RequestMapping(value = "/findSchByLpName") | |
| 112 | + public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName){ | |
| 113 | + return dayOfSchedule.getLpScheduleMap().get(lpName); | |
| 114 | + } | |
| 115 | + | |
| 116 | + @RequestMapping(value = "/findSchByNbbm") | |
| 117 | + public List<ScheduleRealInfo> findSchByNbbm(@RequestParam String nbbm){ | |
| 118 | + return dayOfSchedule.findByNbbm(nbbm); | |
| 119 | + } | |
| 120 | + | |
| 121 | + @RequestMapping(value = "/removeExecPlan") | |
| 122 | + public int removeExecPlan(@RequestParam String nbbm){ | |
| 123 | + dayOfSchedule.removeExecPlan(nbbm); | |
| 124 | + return 1; | |
| 125 | + } | |
| 126 | + | |
| 127 | + @RequestMapping(value = "/sch_re_calc_id_maps") | |
| 128 | + public int reCalcIdMaps(){ | |
| 129 | + return dayOfSchedule.reCalcIdMaps(); | |
| 130 | + } | |
| 131 | + | |
| 132 | + @RequestMapping(value = "/sch_size_string") | |
| 133 | + public String schSizeString(){ | |
| 134 | + return dayOfSchedule.sizeString(); | |
| 135 | + } | |
| 136 | + | |
| 137 | + @RequestMapping(value = "/containerSize") | |
| 138 | + public Map<String, Integer> containerSize(){ | |
| 139 | + Map<String, Integer> rs = new HashMap<>(); | |
| 140 | + rs.put("60_size", dayOfDirectives.all60().size()); | |
| 141 | + rs.put("80_size", pilotReport.findAll().size()); | |
| 142 | + rs.put("nbbm_sch_size", dayOfSchedule.findAll().size()); | |
| 143 | + rs.put("lp_sch_size", dayOfSchedule.findAllByLpContainer().size()); | |
| 144 | + rs.put("id_sch_size", dayOfSchedule.findAllByIdContainer().size()); | |
| 145 | + rs.put("pst_sch_size", dayOfSchedule.getPstSize()); | |
| 146 | + rs.put("speeds_size", OverspeedProcess.size()); | |
| 147 | + return rs; | |
| 148 | + } | |
| 149 | + | |
| 150 | + @RequestMapping(value = "/websocketRadioText") | |
| 151 | + public int radioText(String t, String lineCode){ | |
| 152 | + sendUtils.sendRadioText(t, lineCode); | |
| 153 | + return 0; | |
| 154 | + } | |
| 155 | + | |
| 156 | + @Autowired | |
| 157 | + DirectivesPstThread directivesPstThread; | |
| 158 | + | |
| 159 | + @RequestMapping(value = "/_sd_60_pst") | |
| 160 | + public void sd_60_pst(){ | |
| 161 | + logger.info("手动入库指令...."); | |
| 162 | + directivesPstThread.run(); | |
| 163 | + } | |
| 164 | 164 | } |
| 165 | 165 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -30,7 +30,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 30 | 30 | DayOfSchedule dayOfSchedule; |
| 31 | 31 | |
| 32 | 32 | @RequestMapping(value = "check_fgs_ascription", method = RequestMethod.POST) |
| 33 | - public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId,@RequestParam String jGh, String sGh,@RequestParam String nbbm){ | |
| 33 | + public Map<String, Object> checkPCFgsAscription(@RequestParam Long schId, String jGh, String sGh, String nbbm){ | |
| 34 | 34 | return scheduleRealInfoService.checkPCFgsAscription(schId, jGh, sGh, nbbm); |
| 35 | 35 | } |
| 36 | 36 | ... | ... |
src/main/java/com/bsth/controller/realcontrol/dto/DftzAndDestroy.java
| 1 | -package com.bsth.controller.realcontrol.dto; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Created by panzhao on 2018/3/22. | |
| 5 | - */ | |
| 6 | -public class DftzAndDestroy { | |
| 7 | - | |
| 8 | - /** | |
| 9 | - * 要调整待发的出场班次ID | |
| 10 | - */ | |
| 11 | - private Long dftzId; | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * 要设置的待发时间 | |
| 15 | - */ | |
| 16 | - private String newTimeStr; | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * 要烂掉的班次的 班次id ,号分割多个 | |
| 20 | - */ | |
| 21 | - private String destroyIdx; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * 备注 | |
| 25 | - */ | |
| 26 | - private String remarks; | |
| 27 | - | |
| 28 | - private String reason; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 调派工号 | |
| 32 | - */ | |
| 33 | - private String userId; | |
| 34 | - | |
| 35 | - public String getNewTimeStr() { | |
| 36 | - return newTimeStr; | |
| 37 | - } | |
| 38 | - | |
| 39 | - public void setNewTimeStr(String newTimeStr) { | |
| 40 | - this.newTimeStr = newTimeStr; | |
| 41 | - } | |
| 42 | - | |
| 43 | - public String getDestroyIdx() { | |
| 44 | - return destroyIdx; | |
| 45 | - } | |
| 46 | - | |
| 47 | - public void setDestroyIdx(String destroyIdx) { | |
| 48 | - this.destroyIdx = destroyIdx; | |
| 49 | - } | |
| 50 | - | |
| 51 | - public String getRemarks() { | |
| 52 | - return remarks; | |
| 53 | - } | |
| 54 | - | |
| 55 | - public void setRemarks(String remarks) { | |
| 56 | - this.remarks = remarks; | |
| 57 | - } | |
| 58 | - | |
| 59 | - public Long getDftzId() { | |
| 60 | - return dftzId; | |
| 61 | - } | |
| 62 | - | |
| 63 | - public void setDftzId(Long dftzId) { | |
| 64 | - this.dftzId = dftzId; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public String getReason() { | |
| 68 | - return reason; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public void setReason(String reason) { | |
| 72 | - this.reason = reason; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public String getUserId() { | |
| 76 | - return userId; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public void setUserId(String userId) { | |
| 80 | - this.userId = userId; | |
| 81 | - } | |
| 82 | -} | |
| 1 | +package com.bsth.controller.realcontrol.dto; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by panzhao on 2018/3/22. | |
| 5 | + */ | |
| 6 | +public class DftzAndDestroy { | |
| 7 | + | |
| 8 | + /** | |
| 9 | + * 要调整待发的出场班次ID | |
| 10 | + */ | |
| 11 | + private Long dftzId; | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 要设置的待发时间 | |
| 15 | + */ | |
| 16 | + private String newTimeStr; | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 要烂掉的班次的 班次id ,号分割多个 | |
| 20 | + */ | |
| 21 | + private String destroyIdx; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 备注 | |
| 25 | + */ | |
| 26 | + private String remarks; | |
| 27 | + | |
| 28 | + private String reason; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 调派工号 | |
| 32 | + */ | |
| 33 | + private String userId; | |
| 34 | + | |
| 35 | + public String getNewTimeStr() { | |
| 36 | + return newTimeStr; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setNewTimeStr(String newTimeStr) { | |
| 40 | + this.newTimeStr = newTimeStr; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public String getDestroyIdx() { | |
| 44 | + return destroyIdx; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setDestroyIdx(String destroyIdx) { | |
| 48 | + this.destroyIdx = destroyIdx; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public String getRemarks() { | |
| 52 | + return remarks; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setRemarks(String remarks) { | |
| 56 | + this.remarks = remarks; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public Long getDftzId() { | |
| 60 | + return dftzId; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setDftzId(Long dftzId) { | |
| 64 | + this.dftzId = dftzId; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getReason() { | |
| 68 | + return reason; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setReason(String reason) { | |
| 72 | + this.reason = reason; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public String getUserId() { | |
| 76 | + return userId; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public void setUserId(String userId) { | |
| 80 | + this.userId = userId; | |
| 81 | + } | |
| 82 | +} | ... | ... |
src/main/java/com/bsth/data/Station2ParkBuffer.java
| ... | ... | @@ -50,6 +50,8 @@ public class Station2ParkBuffer implements CommandLineRunner { |
| 50 | 50 | |
| 51 | 51 | public static StationToPark get(String lineCode, String sName, String eName) { |
| 52 | 52 | List<StationToPark> list = get(lineCode); |
| 53 | + if(null == list) | |
| 54 | + return null; | |
| 53 | 55 | StationToPark stp = null; |
| 54 | 56 | for (StationToPark s : list) { |
| 55 | 57 | if (s.getStationName().equals(sName) && s.getParkName().equals(eName)) { | ... | ... |
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
| ... | ... | @@ -158,7 +158,7 @@ public class InStationProcess { |
| 158 | 158 | //webSocket |
| 159 | 159 | sendUtils.sendZdsj(sch, lpNext, doneSum); |
| 160 | 160 | |
| 161 | - logger.info("车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual()); | |
| 161 | + logger.info("车辆:" + nbbm + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual() + " -stopNo: " + gps.getStopNo()); | |
| 162 | 162 | |
| 163 | 163 | //清除车辆误点调整监听 |
| 164 | 164 | LateAdjustHandle.remove(sch); | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -16,6 +16,8 @@ import com.bsth.service.schedule.SchedulePlanInfoService; |
| 16 | 16 | import com.bsth.websocket.handler.SendUtils; |
| 17 | 17 | import com.google.common.collect.ArrayListMultimap; |
| 18 | 18 | import com.google.common.collect.HashMultimap; |
| 19 | +import com.google.common.collect.ListMultimap; | |
| 20 | +import com.google.common.collect.Multimaps; | |
| 19 | 21 | import org.apache.commons.lang3.StringUtils; |
| 20 | 22 | import org.joda.time.format.DateTimeFormat; |
| 21 | 23 | import org.joda.time.format.DateTimeFormatter; |
| ... | ... | @@ -55,7 +57,7 @@ public class DayOfSchedule { |
| 55 | 57 | public static Map<String, List<SchedulePlanInfo>> schedulePlanMap; |
| 56 | 58 | |
| 57 | 59 | // 按车辆分组的班次数据 |
| 58 | - private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap; | |
| 60 | + private static ListMultimap<String, ScheduleRealInfo> nbbmScheduleMap; | |
| 59 | 61 | |
| 60 | 62 | //按线路分组计划用车 |
| 61 | 63 | private static HashMultimap<String, String> lineNbbmsMap; |
| ... | ... | @@ -104,6 +106,8 @@ public class DayOfSchedule { |
| 104 | 106 | |
| 105 | 107 | static { |
| 106 | 108 | nbbmScheduleMap = ArrayListMultimap.create(); |
| 109 | + nbbmScheduleMap = Multimaps.synchronizedListMultimap(nbbmScheduleMap); | |
| 110 | + | |
| 107 | 111 | lpScheduleMap = ArrayListMultimap.create(); |
| 108 | 112 | lineNbbmsMap = HashMultimap.create(); |
| 109 | 113 | ... | ... |
src/main/java/com/bsth/data/schedule/e_state_check/ScheduleStationCodeChecker.java
| 1 | -package com.bsth.data.schedule.e_state_check; | |
| 2 | - | |
| 3 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 4 | -import com.bsth.data.schedule.e_state_check.entity.SCodeInfo; | |
| 5 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 6 | -import com.google.common.collect.ArrayListMultimap; | |
| 7 | -import org.slf4j.Logger; | |
| 8 | -import org.slf4j.LoggerFactory; | |
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 11 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 12 | -import org.springframework.stereotype.Component; | |
| 13 | - | |
| 14 | -import java.util.*; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * 检查班次站点编码和路由编码是否相符合 | |
| 18 | - * Created by panzhao on 2018/4/2. | |
| 19 | - */ | |
| 20 | -@Component | |
| 21 | -public class ScheduleStationCodeChecker { | |
| 22 | - | |
| 23 | - @Autowired | |
| 24 | - DayOfSchedule dayOfSchedule; | |
| 25 | - | |
| 26 | - private static ArrayListMultimap<String, SCodeInfo> multimap; | |
| 27 | - | |
| 28 | - static { | |
| 29 | - multimap = ArrayListMultimap.create(); | |
| 30 | - } | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - JdbcTemplate jdbcTemplate; | |
| 34 | - | |
| 35 | - static Logger logger = LoggerFactory.getLogger(ScheduleStationCodeChecker.class); | |
| 36 | - | |
| 37 | - public static List<SCodeInfo> findByLineIdx(List<String> lineArray){ | |
| 38 | - List<SCodeInfo> rs = new ArrayList<>(); | |
| 39 | - | |
| 40 | - try{ | |
| 41 | - for(String coed : lineArray){ | |
| 42 | - rs.addAll(multimap.get(coed)); | |
| 43 | - } | |
| 44 | - }catch (Exception e){ | |
| 45 | - logger.error("", e); | |
| 46 | - } | |
| 47 | - return rs; | |
| 48 | - } | |
| 49 | - | |
| 50 | - public void checkAll() { | |
| 51 | - try { | |
| 52 | - logger.info("start...."); | |
| 53 | - List<ScheduleRealInfo> all = new ArrayList(dayOfSchedule.findAll()); | |
| 54 | - | |
| 55 | - //按线路站点分组数据(上行) | |
| 56 | - Map<String, ScheduleRealInfo> ups = new HashMap<>(); | |
| 57 | - //按线路站点分组数据(下行) | |
| 58 | - Map<String, ScheduleRealInfo> downs = new HashMap(); | |
| 59 | - | |
| 60 | - String key; | |
| 61 | - for (ScheduleRealInfo sch : all) { | |
| 62 | - if (sch.getBcType().equals("out") | |
| 63 | - || sch.getBcType().equals("in")) | |
| 64 | - continue; | |
| 65 | - key = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | |
| 66 | - | |
| 67 | - ups.put(key + sch.getQdzCode(), sch); | |
| 68 | - downs.put(key + sch.getZdzCode(), sch); | |
| 69 | - } | |
| 70 | - | |
| 71 | - //获取全部实际的站点编码 | |
| 72 | - Map<String, SCodeInfo> realMap = allRealCodeInfo(); | |
| 73 | - | |
| 74 | - List<SCodeInfo> rs = new ArrayList<>(); | |
| 75 | - rs.addAll(checkCode(ups.values(), realMap, "qd")); | |
| 76 | - rs.addAll(checkCode(downs.values(), realMap, "zd")); | |
| 77 | - | |
| 78 | - //按线路分组 | |
| 79 | - ArrayListMultimap<String, SCodeInfo> mList = ArrayListMultimap.create(); | |
| 80 | - for (SCodeInfo sci : rs) { | |
| 81 | - mList.put(sci.getLineCode(), sci); | |
| 82 | - } | |
| 83 | - | |
| 84 | - multimap = mList; | |
| 85 | - logger.info("end...."); | |
| 86 | - } catch (Exception e) { | |
| 87 | - logger.error("", e); | |
| 88 | - } | |
| 89 | - } | |
| 90 | - | |
| 91 | - private List<SCodeInfo> checkCode(Collection<ScheduleRealInfo> list, Map<String, SCodeInfo> realMap, String qdOrZd) { | |
| 92 | - List<SCodeInfo> rs = new ArrayList<>(); | |
| 93 | - String k; | |
| 94 | - SCodeInfo sci; | |
| 95 | - for(ScheduleRealInfo sch : list){ | |
| 96 | - k = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | |
| 97 | - | |
| 98 | - sci = realMap.get(k + getName(sch, qdOrZd));//名称和编码都不存在 | |
| 99 | - if(null == sci && !realMap.containsKey(k + getCode(sch, qdOrZd))){ | |
| 100 | - sci = SCodeInfo.getInstance(sch, qdOrZd); | |
| 101 | - rs.add(sci); | |
| 102 | - continue; | |
| 103 | - } | |
| 104 | - else if(null != sci && !sci.getRealStationCode().equals(getCode(sch, qdOrZd))){//名称一致的站点,编码不一致 | |
| 105 | - sci.setStationCode(getCode(sch, qdOrZd)); | |
| 106 | - rs.add(sci); | |
| 107 | - continue; | |
| 108 | - } | |
| 109 | - } | |
| 110 | - return rs; | |
| 111 | - } | |
| 112 | - | |
| 113 | - private String getName(ScheduleRealInfo sch, String qdOrZd) { | |
| 114 | - return qdOrZd.equals("qd")?sch.getQdzName():sch.getZdzName(); | |
| 115 | - } | |
| 116 | - | |
| 117 | - private String getCode(ScheduleRealInfo sch, String qdOrZd) { | |
| 118 | - return qdOrZd.equals("qd")?sch.getQdzCode():sch.getZdzCode(); | |
| 119 | - } | |
| 120 | - | |
| 121 | - | |
| 122 | - private Map<String, SCodeInfo> allRealCodeInfo() { | |
| 123 | - String sql = "select line_code,directions as up_down,station_code as real_station_code,station_name from bsth_c_stationroute where line in (select id from bsth_c_line where destroy=0) and destroy=0"; | |
| 124 | - List<SCodeInfo> realList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SCodeInfo.class)); | |
| 125 | - Map<String, SCodeInfo> realMap = new HashMap<>(); | |
| 126 | - | |
| 127 | - for (SCodeInfo sci : realList) { | |
| 128 | - realMap.put(sci.getLineCode() + "_" + sci.getUpDown() + "_" + sci.getStationName(), sci); | |
| 129 | - realMap.put(sci.getLineCode() + "_" + sci.getUpDown() + "_" + sci.getRealStationCode(), sci); | |
| 130 | - } | |
| 131 | - | |
| 132 | - return realMap; | |
| 133 | - } | |
| 134 | -} | |
| 1 | +package com.bsth.data.schedule.e_state_check; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 5 | +import com.bsth.data.schedule.e_state_check.entity.SCodeInfo; | |
| 6 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 7 | +import com.google.common.collect.ArrayListMultimap; | |
| 8 | +import org.slf4j.Logger; | |
| 9 | +import org.slf4j.LoggerFactory; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 12 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 13 | +import org.springframework.stereotype.Component; | |
| 14 | + | |
| 15 | +import java.util.*; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 检查班次站点编码和路由编码是否相符合 | |
| 19 | + * Created by panzhao on 2018/4/2. | |
| 20 | + */ | |
| 21 | +@Component | |
| 22 | +public class ScheduleStationCodeChecker { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + DayOfSchedule dayOfSchedule; | |
| 26 | + | |
| 27 | + private static ArrayListMultimap<String, SCodeInfo> multimap; | |
| 28 | + | |
| 29 | + static { | |
| 30 | + multimap = ArrayListMultimap.create(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + JdbcTemplate jdbcTemplate; | |
| 35 | + | |
| 36 | + static Logger logger = LoggerFactory.getLogger(ScheduleStationCodeChecker.class); | |
| 37 | + | |
| 38 | + public static List<SCodeInfo> findByLineIdx(List<String> lineArray){ | |
| 39 | + List<SCodeInfo> rs = new ArrayList<>(); | |
| 40 | + | |
| 41 | + try{ | |
| 42 | + for(String coed : lineArray){ | |
| 43 | + rs.addAll(multimap.get(coed)); | |
| 44 | + } | |
| 45 | + }catch (Exception e){ | |
| 46 | + logger.error("", e); | |
| 47 | + } | |
| 48 | + return rs; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public void checkAll() { | |
| 52 | + try { | |
| 53 | + logger.info("start...."); | |
| 54 | + List<ScheduleRealInfo> all = new ArrayList(dayOfSchedule.findAll()); | |
| 55 | + | |
| 56 | + //按线路站点分组数据(上行) | |
| 57 | + Map<String, ScheduleRealInfo> ups = new HashMap<>(); | |
| 58 | + //按线路站点分组数据(下行) | |
| 59 | + Map<String, ScheduleRealInfo> downs = new HashMap(); | |
| 60 | + | |
| 61 | + String key; | |
| 62 | + for (ScheduleRealInfo sch : all) { | |
| 63 | + if (sch.getBcType().equals("out") | |
| 64 | + || sch.getBcType().equals("in")) | |
| 65 | + continue; | |
| 66 | + | |
| 67 | + key = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | |
| 68 | + | |
| 69 | + ups.put(key + sch.getQdzCode(), sch); | |
| 70 | + downs.put(key + sch.getZdzCode(), sch); | |
| 71 | + } | |
| 72 | + | |
| 73 | + //获取全部实际的站点编码 | |
| 74 | + Map<String, SCodeInfo> realMap = allRealCodeInfo(); | |
| 75 | + | |
| 76 | + List<SCodeInfo> rs = new ArrayList<>(); | |
| 77 | + rs.addAll(checkCode(ups.values(), realMap, "qd")); | |
| 78 | + rs.addAll(checkCode(downs.values(), realMap, "zd")); | |
| 79 | + | |
| 80 | + //按线路分组 | |
| 81 | + ArrayListMultimap<String, SCodeInfo> mList = ArrayListMultimap.create(); | |
| 82 | + for (SCodeInfo sci : rs) { | |
| 83 | + mList.put(sci.getLineCode(), sci); | |
| 84 | + } | |
| 85 | + | |
| 86 | + multimap = mList; | |
| 87 | + logger.info("站点检查 end.... idx: " + (multimap.keySet().size() > 0 ? JSON.toJSONString(multimap.keySet()):"无")); | |
| 88 | + } catch (Exception e) { | |
| 89 | + logger.error("", e); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + private List<SCodeInfo> checkCode(Collection<ScheduleRealInfo> list, Map<String, SCodeInfo> realMap, String qdOrZd) { | |
| 94 | + List<SCodeInfo> rs = new ArrayList<>(); | |
| 95 | + String k; | |
| 96 | + SCodeInfo sci; | |
| 97 | + for(ScheduleRealInfo sch : list){ | |
| 98 | + k = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | |
| 99 | + | |
| 100 | + sci = realMap.get(k + getName(sch, qdOrZd));//名称和编码都不存在 | |
| 101 | + if(null == sci && !realMap.containsKey(k + getCode(sch, qdOrZd))){ | |
| 102 | + sci = SCodeInfo.getInstance(sch, qdOrZd); | |
| 103 | + rs.add(sci); | |
| 104 | + continue; | |
| 105 | + } | |
| 106 | + else if(null != sci && !codeEq(sci, getCode(sch, qdOrZd))){//名称一致的站点,编码不一致 | |
| 107 | + sci.setStationCode(getCode(sch, qdOrZd)); | |
| 108 | + rs.add(sci); | |
| 109 | + continue; | |
| 110 | + } | |
| 111 | + } | |
| 112 | + return rs; | |
| 113 | + } | |
| 114 | + | |
| 115 | + private boolean codeEq(SCodeInfo sci, String code){ | |
| 116 | + return sci.getRealStationCode().equals(code) || sci.getRealStationCode().indexOf(code + "^") != -1; | |
| 117 | + } | |
| 118 | + | |
| 119 | + private String getName(ScheduleRealInfo sch, String qdOrZd) { | |
| 120 | + return qdOrZd.equals("qd")?sch.getQdzName():sch.getZdzName(); | |
| 121 | + } | |
| 122 | + | |
| 123 | + private String getCode(ScheduleRealInfo sch, String qdOrZd) { | |
| 124 | + return qdOrZd.equals("qd")?sch.getQdzCode():sch.getZdzCode(); | |
| 125 | + } | |
| 126 | + | |
| 127 | + | |
| 128 | + private Map<String, SCodeInfo> allRealCodeInfo() { | |
| 129 | + String sql = "select line_code,directions as up_down,station_code as real_station_code,station_name from bsth_c_stationroute where line in (select id from bsth_c_line where destroy=0) and destroy=0"; | |
| 130 | + List<SCodeInfo> realList = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SCodeInfo.class)); | |
| 131 | + Map<String, SCodeInfo> realMap = new HashMap<>(); | |
| 132 | + | |
| 133 | + String kName; | |
| 134 | + SCodeInfo old; | |
| 135 | + for (SCodeInfo sci : realList) { | |
| 136 | + kName = sci.getLineCode() + "_" + sci.getUpDown() + "_" + sci.getStationName(); | |
| 137 | + | |
| 138 | + if(realMap.containsKey(kName)){ | |
| 139 | + //环线可能存在同名的站点 | |
| 140 | + old = realMap.get(kName); | |
| 141 | + old.setRealStationCode(old.getRealStationCode() + "^" + sci.getRealStationCode() + "^"); | |
| 142 | + continue; | |
| 143 | + } | |
| 144 | + | |
| 145 | + realMap.put(kName, sci); | |
| 146 | + realMap.put(sci.getLineCode() + "_" + sci.getUpDown() + "_" + sci.getRealStationCode(), sci); | |
| 147 | + } | |
| 148 | + | |
| 149 | + return realMap; | |
| 150 | + } | |
| 151 | +} | |
| 135 | 152 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/e_state_check/entity/SCodeInfo.java
| 1 | -package com.bsth.data.schedule.e_state_check.entity; | |
| 2 | - | |
| 3 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 4 | - | |
| 5 | -/** | |
| 6 | - * Created by panzhao on 2018/4/2. | |
| 7 | - */ | |
| 8 | -public class SCodeInfo { | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * 线路编码 | |
| 12 | - */ | |
| 13 | - private String lineCode; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * 上下行 | |
| 17 | - */ | |
| 18 | - private int upDown; | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * 站点编码 | |
| 22 | - */ | |
| 23 | - private String stationCode; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 站点名称 | |
| 27 | - */ | |
| 28 | - private String stationName; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 实际站点编码 | |
| 32 | - */ | |
| 33 | - private String realStationCode; | |
| 34 | - | |
| 35 | - public String getLineCode() { | |
| 36 | - return lineCode; | |
| 37 | - } | |
| 38 | - | |
| 39 | - public void setLineCode(String lineCode) { | |
| 40 | - this.lineCode = lineCode; | |
| 41 | - } | |
| 42 | - | |
| 43 | - public int getUpDown() { | |
| 44 | - return upDown; | |
| 45 | - } | |
| 46 | - | |
| 47 | - public void setUpDown(int upDown) { | |
| 48 | - this.upDown = upDown; | |
| 49 | - } | |
| 50 | - | |
| 51 | - public String getStationCode() { | |
| 52 | - return stationCode; | |
| 53 | - } | |
| 54 | - | |
| 55 | - public void setStationCode(String stationCode) { | |
| 56 | - this.stationCode = stationCode; | |
| 57 | - } | |
| 58 | - | |
| 59 | - public String getStationName() { | |
| 60 | - return stationName; | |
| 61 | - } | |
| 62 | - | |
| 63 | - public void setStationName(String stationName) { | |
| 64 | - this.stationName = stationName; | |
| 65 | - } | |
| 66 | - | |
| 67 | - public String getRealStationCode() { | |
| 68 | - return realStationCode; | |
| 69 | - } | |
| 70 | - | |
| 71 | - public void setRealStationCode(String realStationCode) { | |
| 72 | - this.realStationCode = realStationCode; | |
| 73 | - } | |
| 74 | - | |
| 75 | - public static SCodeInfo getUpInstance(ScheduleRealInfo sch) { | |
| 76 | - SCodeInfo sci = new SCodeInfo(); | |
| 77 | - sci.setLineCode(sch.getXlBm()); | |
| 78 | - sci.setUpDown(Integer.parseInt(sch.getXlDir())); | |
| 79 | - sci.setStationName(sch.getQdzName()); | |
| 80 | - sci.setStationCode(sch.getQdzCode()); | |
| 81 | - return sci; | |
| 82 | - } | |
| 83 | - | |
| 84 | - public static SCodeInfo geDownInstance(ScheduleRealInfo sch) { | |
| 85 | - SCodeInfo sci = new SCodeInfo(); | |
| 86 | - sci.setLineCode(sch.getXlBm()); | |
| 87 | - sci.setUpDown(Integer.parseInt(sch.getXlDir())); | |
| 88 | - sci.setStationName(sch.getZdzName()); | |
| 89 | - sci.setStationCode(sch.getZdzCode()); | |
| 90 | - return sci; | |
| 91 | - } | |
| 92 | - | |
| 93 | - public static SCodeInfo getInstance(ScheduleRealInfo sch, String qdOrZd) { | |
| 94 | - return qdOrZd.equals("qd")?getUpInstance(sch):geDownInstance(sch); | |
| 95 | - } | |
| 96 | -} | |
| 1 | +package com.bsth.data.schedule.e_state_check.entity; | |
| 2 | + | |
| 3 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by panzhao on 2018/4/2. | |
| 7 | + */ | |
| 8 | +public class SCodeInfo { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * 线路编码 | |
| 12 | + */ | |
| 13 | + private String lineCode; | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 上下行 | |
| 17 | + */ | |
| 18 | + private int upDown; | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 站点编码 | |
| 22 | + */ | |
| 23 | + private String stationCode; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 站点名称 | |
| 27 | + */ | |
| 28 | + private String stationName; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 实际站点编码 | |
| 32 | + */ | |
| 33 | + private String realStationCode; | |
| 34 | + | |
| 35 | + public String getLineCode() { | |
| 36 | + return lineCode; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setLineCode(String lineCode) { | |
| 40 | + this.lineCode = lineCode; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public int getUpDown() { | |
| 44 | + return upDown; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setUpDown(int upDown) { | |
| 48 | + this.upDown = upDown; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public String getStationCode() { | |
| 52 | + return stationCode; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setStationCode(String stationCode) { | |
| 56 | + this.stationCode = stationCode; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public String getStationName() { | |
| 60 | + return stationName; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setStationName(String stationName) { | |
| 64 | + this.stationName = stationName; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getRealStationCode() { | |
| 68 | + return realStationCode; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setRealStationCode(String realStationCode) { | |
| 72 | + this.realStationCode = realStationCode; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public static SCodeInfo getUpInstance(ScheduleRealInfo sch) { | |
| 76 | + SCodeInfo sci = new SCodeInfo(); | |
| 77 | + sci.setLineCode(sch.getXlBm()); | |
| 78 | + sci.setUpDown(Integer.parseInt(sch.getXlDir())); | |
| 79 | + sci.setStationName(sch.getQdzName()); | |
| 80 | + sci.setStationCode(sch.getQdzCode()); | |
| 81 | + return sci; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public static SCodeInfo geDownInstance(ScheduleRealInfo sch) { | |
| 85 | + SCodeInfo sci = new SCodeInfo(); | |
| 86 | + sci.setLineCode(sch.getXlBm()); | |
| 87 | + sci.setUpDown(Integer.parseInt(sch.getXlDir())); | |
| 88 | + sci.setStationName(sch.getZdzName()); | |
| 89 | + sci.setStationCode(sch.getZdzCode()); | |
| 90 | + return sci; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public static SCodeInfo getInstance(ScheduleRealInfo sch, String qdOrZd) { | |
| 94 | + return qdOrZd.equals("qd")?getUpInstance(sch):geDownInstance(sch); | |
| 95 | + } | |
| 96 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/e_state_check/thread/FixedCheckStationCodeThread.java
| 1 | -package com.bsth.data.schedule.e_state_check.thread; | |
| 2 | - | |
| 3 | -import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker; | |
| 4 | -import org.slf4j.Logger; | |
| 5 | -import org.slf4j.LoggerFactory; | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.stereotype.Component; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 定时检查班次站点编码线程 | |
| 11 | - * Created by panzhao on 2018/4/2. | |
| 12 | - */ | |
| 13 | -@Component | |
| 14 | -public class FixedCheckStationCodeThread extends Thread { | |
| 15 | - | |
| 16 | - @Autowired | |
| 17 | - ScheduleStationCodeChecker scheduleStationCodeChecker; | |
| 18 | - | |
| 19 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 20 | - | |
| 21 | - @Override | |
| 22 | - public void run() { | |
| 23 | - try { | |
| 24 | - scheduleStationCodeChecker.checkAll(); | |
| 25 | - } catch (Exception e) { | |
| 26 | - logger.error("", e); | |
| 27 | - } | |
| 28 | - } | |
| 29 | -} | |
| 1 | +package com.bsth.data.schedule.e_state_check.thread; | |
| 2 | + | |
| 3 | +import com.bsth.data.schedule.e_state_check.ScheduleStationCodeChecker; | |
| 4 | +import org.slf4j.Logger; | |
| 5 | +import org.slf4j.LoggerFactory; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 定时检查班次站点编码线程 | |
| 11 | + * Created by panzhao on 2018/4/2. | |
| 12 | + */ | |
| 13 | +@Component | |
| 14 | +public class FixedCheckStationCodeThread extends Thread { | |
| 15 | + | |
| 16 | + @Autowired | |
| 17 | + ScheduleStationCodeChecker scheduleStationCodeChecker; | |
| 18 | + | |
| 19 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 20 | + | |
| 21 | + @Override | |
| 22 | + public void run() { | |
| 23 | + try { | |
| 24 | + scheduleStationCodeChecker.checkAll(); | |
| 25 | + } catch (Exception e) { | |
| 26 | + logger.error("", e); | |
| 27 | + } | |
| 28 | + } | |
| 29 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/edit_logs/entity/SchEditInfo.java
| ... | ... | @@ -165,7 +165,13 @@ public class SchEditInfo { |
| 165 | 165 | long t = System.currentTimeMillis(); |
| 166 | 166 | sei.setTs(t); |
| 167 | 167 | sei.setTimeStr(fmtHHmm.print(t)); |
| 168 | - sei.setUser(userId); | |
| 168 | + if(null != userId) | |
| 169 | + sei.setUser(userId); | |
| 170 | + else{ | |
| 171 | + SysUser user = SecurityUtils.getCurrentUser(); | |
| 172 | + if(user != null) | |
| 173 | + sei.setUser(user.getUserName()); | |
| 174 | + } | |
| 169 | 175 | sei.setRq(sch.getScheduleDateStr()); |
| 170 | 176 | sei.setSchId(sch.getId()); |
| 171 | 177 | sei.setLineCode(sch.getXlBm()); | ... | ... |
src/main/java/com/bsth/data/schedule/external/TccExternalService.java
| 1 | -package com.bsth.data.schedule.external; | |
| 2 | - | |
| 3 | -import com.bsth.common.ResponseCode; | |
| 4 | -import com.bsth.controller.realcontrol.dto.ChangePersonCar; | |
| 5 | -import com.bsth.controller.realcontrol.dto.DftzAndDestroy; | |
| 6 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | -import com.bsth.service.realcontrol.ScheduleRealInfoService; | |
| 9 | -import com.bsth.websocket.handler.SendUtils; | |
| 10 | -import org.apache.commons.lang3.StringUtils; | |
| 11 | -import org.slf4j.Logger; | |
| 12 | -import org.slf4j.LoggerFactory; | |
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | -import org.springframework.stereotype.Component; | |
| 15 | - | |
| 16 | -import java.util.*; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * 对停车场开放的班次调度服务 | |
| 20 | - * Created by panzhao on 2018/3/22. | |
| 21 | - */ | |
| 22 | -@Component | |
| 23 | -public class TccExternalService { | |
| 24 | - | |
| 25 | - Logger logger = LoggerFactory.getLogger(TccExternalService.class); | |
| 26 | - | |
| 27 | - @Autowired | |
| 28 | - DayOfSchedule dayOfSchedule; | |
| 29 | - | |
| 30 | - @Autowired | |
| 31 | - ScheduleRealInfoService scheduleRealInfoService; | |
| 32 | - | |
| 33 | - @Autowired | |
| 34 | - SendUtils sendUtils; | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * 待发调整 | |
| 38 | - * | |
| 39 | - * @param dad | |
| 40 | - * @return | |
| 41 | - */ | |
| 42 | - public Map<String, Object> dftz(DftzAndDestroy dad) { | |
| 43 | - Map<String, Object> rs = new HashMap(); | |
| 44 | - rs.put("status", ResponseCode.ERROR); | |
| 45 | - try { | |
| 46 | - List<ScheduleRealInfo> updateList = new ArrayList<>();//要刷新的班次 | |
| 47 | - ScheduleRealInfo sch = dayOfSchedule.get(dad.getDftzId()); | |
| 48 | - if (null == sch) { | |
| 49 | - rs.put("msg", "班次已经不存在了!"); | |
| 50 | - return rs; | |
| 51 | - } | |
| 52 | - | |
| 53 | - if (!sch.getBcType().equals("out")) { | |
| 54 | - rs.put("msg", "只能操作出场班次!"); | |
| 55 | - return rs; | |
| 56 | - } | |
| 57 | - | |
| 58 | - //调整待发时间 | |
| 59 | - scheduleRealInfoService.outgoAdjust(sch.getId(), dad.getRemarks(), dad.getNewTimeStr(), sch.getBcType(), "4", dad.getUserId()); | |
| 60 | - updateList.add(sch); | |
| 61 | - | |
| 62 | - //需要烂班的班次 | |
| 63 | - if (StringUtils.isNotEmpty(dad.getDestroyIdx())) { | |
| 64 | - Map<String, Object> dMap = | |
| 65 | - scheduleRealInfoService.destroy(dad.getDestroyIdx(), dad.getRemarks(), dad.getReason(), dad.getUserId()); | |
| 66 | - | |
| 67 | - | |
| 68 | - updateList.addAll((Collection<? extends ScheduleRealInfo>) dMap.get("ts")); | |
| 69 | - } | |
| 70 | - | |
| 71 | - //通知调度客户端更新班次信息 | |
| 72 | - sendUpdate2Page(updateList); | |
| 73 | - | |
| 74 | - rs.put("status", ResponseCode.SUCCESS); | |
| 75 | - rs.put("t", sch); | |
| 76 | - } catch (Exception e) { | |
| 77 | - rs.put("msg", "内部调度服务接口出现异常!"); | |
| 78 | - logger.error("", e); | |
| 79 | - } | |
| 80 | - return rs; | |
| 81 | - } | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * 换人换车 | |
| 85 | - * | |
| 86 | - * @param cpcs | |
| 87 | - * @return | |
| 88 | - */ | |
| 89 | - public Map<String, Object> hrhc(List<ChangePersonCar> cpcs,String tccCode, String userId) { | |
| 90 | - Map<String, Object> rs = new HashMap(); | |
| 91 | - rs.put("status", ResponseCode.ERROR); | |
| 92 | - try { | |
| 93 | - rs = scheduleRealInfoService.multi_tzrc(cpcs, userId); | |
| 94 | - | |
| 95 | - //通知调度客户端更新班次信息 | |
| 96 | - sendUpdate2Page(new ArrayList<ScheduleRealInfo>((Set)rs.get("ts"))); | |
| 97 | - | |
| 98 | - //返回更新结果集中指定停车场的进出场班次 | |
| 99 | - Set<ScheduleRealInfo> ts = (Set<ScheduleRealInfo>) rs.get("ts"); | |
| 100 | - List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 101 | - for(ScheduleRealInfo sch : ts){ | |
| 102 | - if((sch.getBcType().equals("out") && sch.getQdzCode().equals(tccCode)) | |
| 103 | - || (sch.getBcType().equals("in") && sch.getZdzCode().equals(tccCode))) | |
| 104 | - list.add(sch); | |
| 105 | - } | |
| 106 | - rs.put("list", list); | |
| 107 | - rs.remove("ts"); | |
| 108 | - } catch (Exception e) { | |
| 109 | - rs.put("msg", "服务器出现异常!"); | |
| 110 | - logger.error("", e); | |
| 111 | - } | |
| 112 | - return rs; | |
| 113 | - } | |
| 114 | - | |
| 115 | - | |
| 116 | - public void sendUpdate2Page(List<ScheduleRealInfo> list) { | |
| 117 | - sendUtils.refreshSch(list); | |
| 118 | - } | |
| 119 | -} | |
| 1 | +package com.bsth.data.schedule.external; | |
| 2 | + | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 4 | +import com.bsth.controller.realcontrol.dto.ChangePersonCar; | |
| 5 | +import com.bsth.controller.realcontrol.dto.DftzAndDestroy; | |
| 6 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 7 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 8 | +import com.bsth.service.realcontrol.ScheduleRealInfoService; | |
| 9 | +import com.bsth.websocket.handler.SendUtils; | |
| 10 | +import org.apache.commons.lang3.StringUtils; | |
| 11 | +import org.slf4j.Logger; | |
| 12 | +import org.slf4j.LoggerFactory; | |
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | +import org.springframework.stereotype.Component; | |
| 15 | + | |
| 16 | +import java.util.*; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 对停车场开放的班次调度服务 | |
| 20 | + * Created by panzhao on 2018/3/22. | |
| 21 | + */ | |
| 22 | +@Component | |
| 23 | +public class TccExternalService { | |
| 24 | + | |
| 25 | + Logger logger = LoggerFactory.getLogger(TccExternalService.class); | |
| 26 | + | |
| 27 | + @Autowired | |
| 28 | + DayOfSchedule dayOfSchedule; | |
| 29 | + | |
| 30 | + @Autowired | |
| 31 | + ScheduleRealInfoService scheduleRealInfoService; | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + SendUtils sendUtils; | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 待发调整 | |
| 38 | + * | |
| 39 | + * @param dad | |
| 40 | + * @return | |
| 41 | + */ | |
| 42 | + public Map<String, Object> dftz(DftzAndDestroy dad) { | |
| 43 | + Map<String, Object> rs = new HashMap(); | |
| 44 | + rs.put("status", ResponseCode.ERROR); | |
| 45 | + try { | |
| 46 | + List<ScheduleRealInfo> updateList = new ArrayList<>();//要刷新的班次 | |
| 47 | + ScheduleRealInfo sch = dayOfSchedule.get(dad.getDftzId()); | |
| 48 | + if (null == sch) { | |
| 49 | + rs.put("msg", "班次已经不存在了!"); | |
| 50 | + return rs; | |
| 51 | + } | |
| 52 | + | |
| 53 | + if (!sch.getBcType().equals("out")) { | |
| 54 | + rs.put("msg", "只能操作出场班次!"); | |
| 55 | + return rs; | |
| 56 | + } | |
| 57 | + | |
| 58 | + //调整待发时间 | |
| 59 | + scheduleRealInfoService.outgoAdjust(sch.getId(), dad.getRemarks(), dad.getNewTimeStr(), sch.getBcType(), "4", dad.getUserId()); | |
| 60 | + updateList.add(sch); | |
| 61 | + | |
| 62 | + //需要烂班的班次 | |
| 63 | + if (StringUtils.isNotEmpty(dad.getDestroyIdx())) { | |
| 64 | + Map<String, Object> dMap = | |
| 65 | + scheduleRealInfoService.destroy(dad.getDestroyIdx(), dad.getRemarks(), dad.getReason(), dad.getUserId()); | |
| 66 | + | |
| 67 | + | |
| 68 | + updateList.addAll((Collection<? extends ScheduleRealInfo>) dMap.get("ts")); | |
| 69 | + } | |
| 70 | + | |
| 71 | + //通知调度客户端更新班次信息 | |
| 72 | + sendUpdate2Page(updateList); | |
| 73 | + | |
| 74 | + rs.put("status", ResponseCode.SUCCESS); | |
| 75 | + rs.put("t", sch); | |
| 76 | + } catch (Exception e) { | |
| 77 | + rs.put("msg", "内部调度服务接口出现异常!"); | |
| 78 | + logger.error("", e); | |
| 79 | + } | |
| 80 | + return rs; | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 换人换车 | |
| 85 | + * | |
| 86 | + * @param cpcs | |
| 87 | + * @return | |
| 88 | + */ | |
| 89 | + public Map<String, Object> hrhc(List<ChangePersonCar> cpcs,String tccCode, String userId) { | |
| 90 | + Map<String, Object> rs = new HashMap(); | |
| 91 | + rs.put("status", ResponseCode.ERROR); | |
| 92 | + try { | |
| 93 | + rs = scheduleRealInfoService.multi_tzrc(cpcs, userId); | |
| 94 | + | |
| 95 | + //通知调度客户端更新班次信息 | |
| 96 | + sendUpdate2Page(new ArrayList<ScheduleRealInfo>((Set)rs.get("ts"))); | |
| 97 | + | |
| 98 | + //返回更新结果集中指定停车场的进出场班次 | |
| 99 | + Set<ScheduleRealInfo> ts = (Set<ScheduleRealInfo>) rs.get("ts"); | |
| 100 | + List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 101 | + for(ScheduleRealInfo sch : ts){ | |
| 102 | + if((sch.getBcType().equals("out") && sch.getQdzCode().equals(tccCode)) | |
| 103 | + || (sch.getBcType().equals("in") && sch.getZdzCode().equals(tccCode))) | |
| 104 | + list.add(sch); | |
| 105 | + } | |
| 106 | + rs.put("list", list); | |
| 107 | + rs.remove("ts"); | |
| 108 | + } catch (Exception e) { | |
| 109 | + rs.put("msg", "服务器出现异常!"); | |
| 110 | + logger.error("", e); | |
| 111 | + } | |
| 112 | + return rs; | |
| 113 | + } | |
| 114 | + | |
| 115 | + | |
| 116 | + public void sendUpdate2Page(List<ScheduleRealInfo> list) { | |
| 117 | + sendUtils.refreshSch(list); | |
| 118 | + } | |
| 119 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
| ... | ... | @@ -22,12 +22,12 @@ import java.util.List; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * 误点自动调整待发 处理程序 |
| 25 | - * | |
| 25 | + * <p> | |
| 26 | 26 | * 注意 :这里的误点是指应发未到 |
| 27 | 27 | * Created by panzhao on 2017/4/16. |
| 28 | 28 | */ |
| 29 | 29 | @Component |
| 30 | -public class LateAdjustHandle implements ApplicationContextAware{ | |
| 30 | +public class LateAdjustHandle implements ApplicationContextAware { | |
| 31 | 31 | |
| 32 | 32 | static LineConfigData lineConfigData; |
| 33 | 33 | static SendUtils sendUtils; |
| ... | ... | @@ -36,7 +36,7 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * 应发未到车辆 和 班次 |
| 39 | - * | |
| 39 | + * <p> | |
| 40 | 40 | * 起点相同的,保留最后一个班次 |
| 41 | 41 | */ |
| 42 | 42 | private static ArrayListMultimap lateSchMaps; |
| ... | ... | @@ -48,55 +48,57 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * 新增一个误点班次 |
| 51 | + * | |
| 51 | 52 | * @param sch |
| 52 | 53 | */ |
| 53 | - public static void putLate(ScheduleRealInfo sch){ | |
| 54 | - try{ | |
| 54 | + public static void putLate(ScheduleRealInfo sch) { | |
| 55 | + try { | |
| 55 | 56 | //线路配置 |
| 56 | 57 | LineConfig config = lineConfigData.get(sch.getXlBm()); |
| 57 | - if(sch.getLateMinute() == 0){ | |
| 58 | - if(!config.isEnableYjtk()) | |
| 58 | + if (sch.getLateMinute() == 0) { | |
| 59 | + if (!config.isEnableYjtk()) | |
| 59 | 60 | return; |
| 60 | 61 | |
| 61 | - sch.setLateMinute(sch.getXlDir().equals("0")?config.getUpStopMinute():config.getDownStopMinute()); | |
| 62 | + sch.setLateMinute(sch.getXlDir().equals("0") ? config.getUpStopMinute() : config.getDownStopMinute()); | |
| 62 | 63 | } |
| 63 | 64 | |
| 64 | - if(sch.getDfsj().compareTo(config.getYjtkStart()) > 0 | |
| 65 | - && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0){ | |
| 65 | + if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0 | |
| 66 | + && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) { | |
| 66 | 67 | |
| 67 | 68 | ScheduleRealInfo old = popLateSch(sch); |
| 68 | 69 | |
| 69 | 70 | //班次被压入 |
| 70 | - if(lateSchMaps.containsEntry(sch.getClZbh(), sch)){ | |
| 71 | + if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) { | |
| 71 | 72 | |
| 72 | - logger.info("【应发未到 -多个("+lateSchMaps.get(sch.getClZbh()).size()+")】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | |
| 73 | + logger.info("【应发未到 -多个(" + lateSchMaps.get(sch.getClZbh()).size() + ")】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); | |
| 73 | 74 | //通知客户端 |
| 74 | 75 | sch.setLate2(true); |
| 75 | 76 | sendUtils.sendAutoWdtz(sch, old); |
| 76 | 77 | } |
| 77 | 78 | } |
| 78 | 79 | |
| 79 | - }catch (Exception e){ | |
| 80 | + } catch (Exception e) { | |
| 80 | 81 | logger.error("", e); |
| 81 | 82 | } |
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | /** |
| 85 | 86 | * 压入新的误点班次 |
| 87 | + * | |
| 86 | 88 | * @param sch |
| 87 | 89 | * @return 返回被移除的误点班次 |
| 88 | 90 | */ |
| 89 | 91 | private static ScheduleRealInfo popLateSch(ScheduleRealInfo sch) { |
| 90 | 92 | List<ScheduleRealInfo> list = lateSchMaps.get(sch.getClZbh()); |
| 91 | 93 | |
| 92 | - if(null == list || list.size() == 0) | |
| 94 | + if (null == list || list.size() == 0) | |
| 93 | 95 | lateSchMaps.put(sch.getClZbh(), sch); |
| 94 | 96 | else { |
| 95 | - ScheduleRealInfo old = findExistQdz(list, sch.getQdzCode(), sch.getQdzName()); | |
| 97 | + ScheduleRealInfo old = findExistQdz(list, sch.getQdzCode(), sch.getQdzName(), ""); | |
| 96 | 98 | |
| 97 | - if(null == old) | |
| 99 | + if (null == old) | |
| 98 | 100 | lateSchMaps.put(sch.getClZbh(), sch); |
| 99 | - else if(old.getDfsjT() < sch.getDfsjT()){ | |
| 101 | + else if (old.getDfsjT() < sch.getDfsjT()) { | |
| 100 | 102 | //同一个起点,保留时间最大的班次 |
| 101 | 103 | lateSchMaps.remove(old.getClZbh(), old); |
| 102 | 104 | lateSchMaps.put(sch.getClZbh(), sch); |
| ... | ... | @@ -111,13 +113,15 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 111 | 113 | |
| 112 | 114 | /** |
| 113 | 115 | * 搜索同样起点的班次 |
| 116 | + * | |
| 114 | 117 | * @param list |
| 115 | 118 | * @return |
| 116 | 119 | */ |
| 117 | - private static ScheduleRealInfo findExistQdz(List<ScheduleRealInfo> list, String qdzCode, String qdzName) { | |
| 118 | - for(ScheduleRealInfo item : list){ | |
| 119 | - if(item.getQdzCode().equals(qdzCode) | |
| 120 | - || item.getQdzName().equals(qdzName)) | |
| 120 | + private static ScheduleRealInfo findExistQdz(List<ScheduleRealInfo> list, String qdzCode, String nam1, String name2) { | |
| 121 | + for (ScheduleRealInfo item : list) { | |
| 122 | + if (item.getQdzCode().equals(qdzCode) | |
| 123 | + || item.getQdzName().equals(nam1) | |
| 124 | + || item.getQdzName().equals(name2)) | |
| 121 | 125 | return item; |
| 122 | 126 | } |
| 123 | 127 | return null; |
| ... | ... | @@ -126,15 +130,16 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 126 | 130 | |
| 127 | 131 | /** |
| 128 | 132 | * 获取所有应发未到的班次 |
| 133 | + * | |
| 129 | 134 | * @return |
| 130 | 135 | */ |
| 131 | - public static Collection<ScheduleRealInfo> allLateSch(){ | |
| 136 | + public static Collection<ScheduleRealInfo> allLateSch() { | |
| 132 | 137 | return lateSchMaps.values(); |
| 133 | 138 | } |
| 134 | 139 | |
| 135 | - public static void remove(ScheduleRealInfo sch){ | |
| 140 | + public static void remove(ScheduleRealInfo sch) { | |
| 136 | 141 | try { |
| 137 | - if(lateSchMaps.containsEntry(sch.getClZbh(), sch)){ | |
| 142 | + if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) { | |
| 138 | 143 | lateSchMaps.remove(sch.getClZbh(), sch); |
| 139 | 144 | |
| 140 | 145 | sch.setLate2(false); |
| ... | ... | @@ -143,46 +148,55 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 143 | 148 | |
| 144 | 149 | logger.info("移除误点调整 -" + sch.getClZbh() + " -time: " + sch.getDfsj() + " -id: " + sch.getId()); |
| 145 | 150 | } |
| 146 | - }catch (Exception e){ | |
| 151 | + } catch (Exception e) { | |
| 147 | 152 | logger.error("", e); |
| 148 | 153 | } |
| 149 | 154 | } |
| 150 | 155 | |
| 151 | 156 | /** |
| 152 | 157 | * 车辆到站 |
| 158 | + * | |
| 153 | 159 | * @param gps |
| 154 | 160 | */ |
| 155 | - public static void carArrive(GpsEntity gps){ | |
| 156 | - try{ | |
| 161 | + public static void carArrive(GpsEntity gps) { | |
| 162 | + try { | |
| 163 | + if (gps.getInstation() <= 0) { | |
| 164 | + return; | |
| 165 | + } | |
| 166 | + | |
| 157 | 167 | List<ScheduleRealInfo> list = lateSchMaps.get(gps.getNbbm()); |
| 158 | 168 | |
| 159 | - if(null == list || list.size() == 0) | |
| 169 | + if (null == list || list.size() == 0) | |
| 160 | 170 | return; |
| 161 | 171 | |
| 162 | - String key = gps.getStopNo(); | |
| 163 | - if(gps.getInstation()==1){ | |
| 164 | - if(StringUtils.isNotEmpty(gps.getCarparkNo())) | |
| 165 | - key = gps.getCarparkNo();//停车场名称 | |
| 166 | - else | |
| 167 | - key = gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo();//站点名称 | |
| 172 | + | |
| 173 | + String key = gps.getLineId() + "_" + gps.getUpDown() + "_" + gps.getStopNo() | |
| 174 | + , name1 = BasicData.stationCode2NameMap.get(key)//站点名称 | |
| 175 | + , name2 = null; | |
| 176 | + if (StringUtils.isNotEmpty(gps.getCarparkNo())) { | |
| 177 | + name2 = BasicData.stationCode2NameMap.get(gps.getCarparkNo()); | |
| 178 | + } | |
| 179 | + | |
| 180 | + if (gps.getInstation() == 2) { | |
| 181 | + name1 = name2;//进场,没有站 | |
| 168 | 182 | } |
| 169 | 183 | |
| 170 | - gps.setStationName(BasicData.stationCode2NameMap.get(key)); | |
| 184 | + gps.setStationName(name1); | |
| 171 | 185 | //根据起点站获取误点班次 |
| 172 | - ScheduleRealInfo sch = findExistQdz(list, gps.getStopNo(), gps.getStationName()); | |
| 186 | + ScheduleRealInfo sch = findExistQdz(list, gps.getStopNo(), name1, name2); | |
| 173 | 187 | |
| 174 | - if(null == sch) | |
| 188 | + if (null == sch) | |
| 175 | 189 | return; |
| 176 | 190 | |
| 177 | 191 | //可能是延迟信号,gps时间没有误点 |
| 178 | - if(gps.getTimestamp() <= sch.getDfsjT()){ | |
| 192 | + if (gps.getTimestamp() <= sch.getDfsjT()) { | |
| 179 | 193 | sch.setLate2(false); |
| 180 | 194 | lateSchMaps.remove(sch.getClZbh(), sch); |
| 181 | 195 | return; |
| 182 | 196 | } |
| 183 | 197 | |
| 184 | - if(gps.getStationName().equals(sch.getQdzName()) | |
| 185 | - || gps.getStopNo().equals(sch.getQdzCode())){ | |
| 198 | + if (gps.getStationName().equals(sch.getQdzName()) | |
| 199 | + || gps.getStopNo().equals(sch.getQdzCode())) { | |
| 186 | 200 | |
| 187 | 201 | //自动调整待发 到达时间 + 停靠时间 |
| 188 | 202 | long dt = Arith.addLong(gps.getTimestamp(), (sch.getLateMinute() * 60 * 1000)); |
| ... | ... | @@ -195,7 +209,7 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 195 | 209 | lateSchMaps.remove(sch.getClZbh(), sch); |
| 196 | 210 | logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); |
| 197 | 211 | } |
| 198 | - }catch (Exception e){ | |
| 212 | + } catch (Exception e) { | |
| 199 | 213 | e.printStackTrace(); |
| 200 | 214 | logger.error("late2 car arrive", e); |
| 201 | 215 | } | ... | ... |
src/main/java/com/bsth/data/schedule/taopao/TaoPaoDataBuffer.java
0 → 100644
| 1 | +package com.bsth.data.schedule.taopao; | |
| 2 | + | |
| 3 | +import com.bsth.data.schedule.DayOfSchedule; | |
| 4 | +import com.bsth.data.schedule.taopao.entity.CLTaoPaoInfo; | |
| 5 | +import com.google.common.collect.ArrayListMultimap; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 实际班次套跑信息 | |
| 11 | + */ | |
| 12 | +@Component | |
| 13 | +public class TaoPaoDataBuffer { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 线路编码 ——> 套跑信息 | |
| 17 | + */ | |
| 18 | + private static ArrayListMultimap<String, CLTaoPaoInfo> multimap; | |
| 19 | + | |
| 20 | + static { | |
| 21 | + multimap = ArrayListMultimap.create(); | |
| 22 | + } | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + DayOfSchedule dayOfSchedule; | |
| 26 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/taopao/entity/CLTaoPaoInfo.java
0 → 100644
| 1 | +package com.bsth.data.schedule.taopao.entity; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * 车辆套跑 信息 | |
| 5 | + */ | |
| 6 | +public class CLTaoPaoInfo { | |
| 7 | + | |
| 8 | + private String lineCode; | |
| 9 | + | |
| 10 | + private String nbbm; | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * 班次ID , 号分割多个 | |
| 14 | + */ | |
| 15 | + private String schIdx; | |
| 16 | + | |
| 17 | + public String getLineCode() { | |
| 18 | + return lineCode; | |
| 19 | + } | |
| 20 | + | |
| 21 | + public void setLineCode(String lineCode) { | |
| 22 | + this.lineCode = lineCode; | |
| 23 | + } | |
| 24 | + | |
| 25 | + public String getNbbm() { | |
| 26 | + return nbbm; | |
| 27 | + } | |
| 28 | + | |
| 29 | + public void setNbbm(String nbbm) { | |
| 30 | + this.nbbm = nbbm; | |
| 31 | + } | |
| 32 | + | |
| 33 | + public String getSchIdx() { | |
| 34 | + return schIdx; | |
| 35 | + } | |
| 36 | + | |
| 37 | + public void setSchIdx(String schIdx) { | |
| 38 | + this.schIdx = schIdx; | |
| 39 | + } | |
| 40 | +} | ... | ... |
src/main/java/com/bsth/data/schedule/taopao/entity/TPCutRealSchedule.java
0 → 100644
| 1 | +package com.bsth.data.schedule.taopao.entity; | |
| 2 | + | |
| 3 | +import javax.persistence.Transient; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * 精简的班次信息(展示套跑信息用) | |
| 7 | + */ | |
| 8 | +public class TPCutRealSchedule { | |
| 9 | + | |
| 10 | + /** 主键Id */ | |
| 11 | + private Long id; | |
| 12 | + | |
| 13 | + /** 排班日期字符串 YYYY-MM-DD */ | |
| 14 | + private String scheduleDateStr; | |
| 15 | + | |
| 16 | + /** 路牌名称 */ | |
| 17 | + private String lpName; | |
| 18 | + | |
| 19 | + /** 车辆自编号 */ | |
| 20 | + private String clZbh; | |
| 21 | + | |
| 22 | + /** 驾驶员工号 */ | |
| 23 | + private String jGh; | |
| 24 | + /** 驾驶员名字 */ | |
| 25 | + private String jName; | |
| 26 | + /** 售票员工号 */ | |
| 27 | + private String sGh; | |
| 28 | + /** 售票员名字 */ | |
| 29 | + private String sName; | |
| 30 | + | |
| 31 | + /** 线路方向 */ | |
| 32 | + private String xlDir; | |
| 33 | + /** 起点站名字 */ | |
| 34 | + private String qdzName; | |
| 35 | + | |
| 36 | + /** 终点站名字 */ | |
| 37 | + private String zdzName; | |
| 38 | + | |
| 39 | + /** 计划发车时间(格式 HH:mm) */ | |
| 40 | + private String fcsj; | |
| 41 | + /** 计划发车时间戳*/ | |
| 42 | + @Transient | |
| 43 | + private Long fcsjT; | |
| 44 | + | |
| 45 | + /** 计划终点时间(格式 HH:mm) */ | |
| 46 | + private String zdsj; | |
| 47 | + /** 计划终点时间戳*/ | |
| 48 | + @Transient | |
| 49 | + private Long zdsjT; | |
| 50 | + | |
| 51 | + /** 计划里程 */ | |
| 52 | + private Double jhlc; | |
| 53 | + | |
| 54 | + /** 班次历时 */ | |
| 55 | + private Integer bcsj; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * 班次类型 TODO:正常班次、出场、进场、加油、区间班次、放空班次、放大站班次、两点间空驶 | |
| 59 | + */ | |
| 60 | + private String bcType; | |
| 61 | + | |
| 62 | + //放站班次 站点名称 | |
| 63 | + private String majorStationName; | |
| 64 | + | |
| 65 | + /** 实际发车时间*/ | |
| 66 | + private String fcsjActual; | |
| 67 | + /**实际终点时间 */ | |
| 68 | + private String zdsjActual; | |
| 69 | + | |
| 70 | + /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */ | |
| 71 | + private int status; | |
| 72 | + | |
| 73 | + private String adjustExps; | |
| 74 | + | |
| 75 | + /** 是否是临加班次 */ | |
| 76 | + private boolean sflj; | |
| 77 | + | |
| 78 | + /** 备注*/ | |
| 79 | + private String remarks; | |
| 80 | + | |
| 81 | + /**待发时间(格式 HH:mm) */ | |
| 82 | + private String dfsj; | |
| 83 | + | |
| 84 | + /**待发时间戳 */ | |
| 85 | + @Transient | |
| 86 | + private Long dfsjT; | |
| 87 | + | |
| 88 | + /** 指令下发状态 60: 已发送, 100: 设备确认收到, 200:驾驶员确认 0:失败 */ | |
| 89 | + private Integer directiveState = -1; | |
| 90 | + | |
| 91 | + /** 起点站计划到达时间 */ | |
| 92 | + @Transient | |
| 93 | + private String qdzArrDatejh; | |
| 94 | + | |
| 95 | + /** 起点站实际到达时间 */ | |
| 96 | + @Transient | |
| 97 | + private String qdzArrDatesj; | |
| 98 | + | |
| 99 | + public Long getId() { | |
| 100 | + return id; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public void setId(Long id) { | |
| 104 | + this.id = id; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public String getScheduleDateStr() { | |
| 108 | + return scheduleDateStr; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public void setScheduleDateStr(String scheduleDateStr) { | |
| 112 | + this.scheduleDateStr = scheduleDateStr; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public String getLpName() { | |
| 116 | + return lpName; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public void setLpName(String lpName) { | |
| 120 | + this.lpName = lpName; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public String getClZbh() { | |
| 124 | + return clZbh; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public void setClZbh(String clZbh) { | |
| 128 | + this.clZbh = clZbh; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public String getjGh() { | |
| 132 | + return jGh; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public void setjGh(String jGh) { | |
| 136 | + this.jGh = jGh; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getjName() { | |
| 140 | + return jName; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void setjName(String jName) { | |
| 144 | + this.jName = jName; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public String getsGh() { | |
| 148 | + return sGh; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public void setsGh(String sGh) { | |
| 152 | + this.sGh = sGh; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public String getsName() { | |
| 156 | + return sName; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public void setsName(String sName) { | |
| 160 | + this.sName = sName; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public String getXlDir() { | |
| 164 | + return xlDir; | |
| 165 | + } | |
| 166 | + | |
| 167 | + public void setXlDir(String xlDir) { | |
| 168 | + this.xlDir = xlDir; | |
| 169 | + } | |
| 170 | + | |
| 171 | + public String getQdzName() { | |
| 172 | + return qdzName; | |
| 173 | + } | |
| 174 | + | |
| 175 | + public void setQdzName(String qdzName) { | |
| 176 | + this.qdzName = qdzName; | |
| 177 | + } | |
| 178 | + | |
| 179 | + public String getZdzName() { | |
| 180 | + return zdzName; | |
| 181 | + } | |
| 182 | + | |
| 183 | + public void setZdzName(String zdzName) { | |
| 184 | + this.zdzName = zdzName; | |
| 185 | + } | |
| 186 | + | |
| 187 | + public String getFcsj() { | |
| 188 | + return fcsj; | |
| 189 | + } | |
| 190 | + | |
| 191 | + public void setFcsj(String fcsj) { | |
| 192 | + this.fcsj = fcsj; | |
| 193 | + } | |
| 194 | + | |
| 195 | + public Long getFcsjT() { | |
| 196 | + return fcsjT; | |
| 197 | + } | |
| 198 | + | |
| 199 | + public void setFcsjT(Long fcsjT) { | |
| 200 | + this.fcsjT = fcsjT; | |
| 201 | + } | |
| 202 | + | |
| 203 | + public String getZdsj() { | |
| 204 | + return zdsj; | |
| 205 | + } | |
| 206 | + | |
| 207 | + public void setZdsj(String zdsj) { | |
| 208 | + this.zdsj = zdsj; | |
| 209 | + } | |
| 210 | + | |
| 211 | + public Long getZdsjT() { | |
| 212 | + return zdsjT; | |
| 213 | + } | |
| 214 | + | |
| 215 | + public void setZdsjT(Long zdsjT) { | |
| 216 | + this.zdsjT = zdsjT; | |
| 217 | + } | |
| 218 | + | |
| 219 | + public Double getJhlc() { | |
| 220 | + return jhlc; | |
| 221 | + } | |
| 222 | + | |
| 223 | + public void setJhlc(Double jhlc) { | |
| 224 | + this.jhlc = jhlc; | |
| 225 | + } | |
| 226 | + | |
| 227 | + public Integer getBcsj() { | |
| 228 | + return bcsj; | |
| 229 | + } | |
| 230 | + | |
| 231 | + public void setBcsj(Integer bcsj) { | |
| 232 | + this.bcsj = bcsj; | |
| 233 | + } | |
| 234 | + | |
| 235 | + public String getBcType() { | |
| 236 | + return bcType; | |
| 237 | + } | |
| 238 | + | |
| 239 | + public void setBcType(String bcType) { | |
| 240 | + this.bcType = bcType; | |
| 241 | + } | |
| 242 | + | |
| 243 | + public String getMajorStationName() { | |
| 244 | + return majorStationName; | |
| 245 | + } | |
| 246 | + | |
| 247 | + public void setMajorStationName(String majorStationName) { | |
| 248 | + this.majorStationName = majorStationName; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public String getFcsjActual() { | |
| 252 | + return fcsjActual; | |
| 253 | + } | |
| 254 | + | |
| 255 | + public void setFcsjActual(String fcsjActual) { | |
| 256 | + this.fcsjActual = fcsjActual; | |
| 257 | + } | |
| 258 | + | |
| 259 | + public String getZdsjActual() { | |
| 260 | + return zdsjActual; | |
| 261 | + } | |
| 262 | + | |
| 263 | + public void setZdsjActual(String zdsjActual) { | |
| 264 | + this.zdsjActual = zdsjActual; | |
| 265 | + } | |
| 266 | + | |
| 267 | + public int getStatus() { | |
| 268 | + return status; | |
| 269 | + } | |
| 270 | + | |
| 271 | + public void setStatus(int status) { | |
| 272 | + this.status = status; | |
| 273 | + } | |
| 274 | + | |
| 275 | + public String getAdjustExps() { | |
| 276 | + return adjustExps; | |
| 277 | + } | |
| 278 | + | |
| 279 | + public void setAdjustExps(String adjustExps) { | |
| 280 | + this.adjustExps = adjustExps; | |
| 281 | + } | |
| 282 | + | |
| 283 | + public boolean isSflj() { | |
| 284 | + return sflj; | |
| 285 | + } | |
| 286 | + | |
| 287 | + public void setSflj(boolean sflj) { | |
| 288 | + this.sflj = sflj; | |
| 289 | + } | |
| 290 | + | |
| 291 | + public String getRemarks() { | |
| 292 | + return remarks; | |
| 293 | + } | |
| 294 | + | |
| 295 | + public void setRemarks(String remarks) { | |
| 296 | + this.remarks = remarks; | |
| 297 | + } | |
| 298 | + | |
| 299 | + public String getDfsj() { | |
| 300 | + return dfsj; | |
| 301 | + } | |
| 302 | + | |
| 303 | + public void setDfsj(String dfsj) { | |
| 304 | + this.dfsj = dfsj; | |
| 305 | + } | |
| 306 | + | |
| 307 | + public Long getDfsjT() { | |
| 308 | + return dfsjT; | |
| 309 | + } | |
| 310 | + | |
| 311 | + public void setDfsjT(Long dfsjT) { | |
| 312 | + this.dfsjT = dfsjT; | |
| 313 | + } | |
| 314 | + | |
| 315 | + public Integer getDirectiveState() { | |
| 316 | + return directiveState; | |
| 317 | + } | |
| 318 | + | |
| 319 | + public void setDirectiveState(Integer directiveState) { | |
| 320 | + this.directiveState = directiveState; | |
| 321 | + } | |
| 322 | + | |
| 323 | + public String getQdzArrDatejh() { | |
| 324 | + return qdzArrDatejh; | |
| 325 | + } | |
| 326 | + | |
| 327 | + public void setQdzArrDatejh(String qdzArrDatejh) { | |
| 328 | + this.qdzArrDatejh = qdzArrDatejh; | |
| 329 | + } | |
| 330 | + | |
| 331 | + public String getQdzArrDatesj() { | |
| 332 | + return qdzArrDatesj; | |
| 333 | + } | |
| 334 | + | |
| 335 | + public void setQdzArrDatesj(String qdzArrDatesj) { | |
| 336 | + this.qdzArrDatesj = qdzArrDatesj; | |
| 337 | + } | |
| 338 | +} | ... | ... |
src/main/java/com/bsth/entity/oil/Lsylb.java
0 → 100644
| 1 | +package com.bsth.entity.oil; | |
| 2 | + | |
| 3 | +import java.text.DecimalFormat; | |
| 4 | +import java.util.Date; | |
| 5 | + | |
| 6 | +import javax.persistence.Entity; | |
| 7 | +import javax.persistence.GeneratedValue; | |
| 8 | +import javax.persistence.Id; | |
| 9 | +import javax.persistence.Table; | |
| 10 | +import javax.persistence.Transient; | |
| 11 | + | |
| 12 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 13 | + | |
| 14 | +import com.bsth.data.BasicData; | |
| 15 | + | |
| 16 | +@Entity | |
| 17 | +@Table(name = "bsth_ls_ylb") | |
| 18 | +public class Lsylb { | |
| 19 | + @Id | |
| 20 | + @GeneratedValue | |
| 21 | + private Integer id; | |
| 22 | + @DateTimeFormat(pattern="yyyy-MM-dd") | |
| 23 | + private Date rq; | |
| 24 | + private String xlbm; | |
| 25 | + private String ssgsdm; | |
| 26 | + private String fgsdm; | |
| 27 | + private String nbbm; | |
| 28 | + private String jsy; | |
| 29 | + private Double czlc=0.0; | |
| 30 | + private Double jzlc=0.0; | |
| 31 | + private Double czyl=0.0; | |
| 32 | + private Double jzyl=0.0; | |
| 33 | + private Double jzl=0.0; | |
| 34 | + private int sfkt; | |
| 35 | + private String jhsj; | |
| 36 | + private Double yh=0.0; | |
| 37 | + private Double sh=0.0; | |
| 38 | + private String shyy; | |
| 39 | + private Double zlc=0.0; | |
| 40 | + private int yhlx; | |
| 41 | + private String rylx="0"; | |
| 42 | + private Double ns=0.0; | |
| 43 | + private Double fyylc=0.0; | |
| 44 | + private Double jhzlc=0.0; | |
| 45 | + private Double jhfyylc=0.0; | |
| 46 | + private int jhzbc; | |
| 47 | + private int jhbc; | |
| 48 | + private int sjzbc; | |
| 49 | + private int sjbc; | |
| 50 | + private String edituser; | |
| 51 | + private Date edittime; | |
| 52 | + private Date createtime; | |
| 53 | + | |
| 54 | + private int nylx; | |
| 55 | + | |
| 56 | + @Transient | |
| 57 | + private String bglyh; | |
| 58 | + | |
| 59 | + @Transient | |
| 60 | + private String xlname; | |
| 61 | + | |
| 62 | + @Transient | |
| 63 | + private String gsname; | |
| 64 | + | |
| 65 | + @Transient | |
| 66 | + private String fgsname; | |
| 67 | + | |
| 68 | + @Transient | |
| 69 | + private String name; | |
| 70 | + | |
| 71 | + public Integer getId() { | |
| 72 | + return id; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public void setId(Integer id) { | |
| 76 | + this.id = id; | |
| 77 | + } | |
| 78 | + public Date getRq() { | |
| 79 | + return rq; | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void setRq(Date rq) { | |
| 83 | + this.rq = rq; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public String getXlbm() { | |
| 87 | + return xlbm; | |
| 88 | + } | |
| 89 | + | |
| 90 | + public void setXlbm(String xlbm) { | |
| 91 | + this.xlbm = xlbm; | |
| 92 | + } | |
| 93 | + public String getSsgsdm() { | |
| 94 | + return ssgsdm; | |
| 95 | + } | |
| 96 | + public void setSsgsdm(String ssgsdm) { | |
| 97 | + this.ssgsdm = ssgsdm; | |
| 98 | + } | |
| 99 | + public String getFgsdm() { | |
| 100 | + return fgsdm; | |
| 101 | + } | |
| 102 | + public void setFgsdm(String fgsdm) { | |
| 103 | + this.fgsdm = fgsdm; | |
| 104 | + } | |
| 105 | + public String getNbbm() { | |
| 106 | + return nbbm; | |
| 107 | + } | |
| 108 | + public void setNbbm(String nbbm) { | |
| 109 | + this.nbbm = nbbm; | |
| 110 | + } | |
| 111 | + public String getJsy() { | |
| 112 | + return jsy; | |
| 113 | + } | |
| 114 | + public void setJsy(String jsy) { | |
| 115 | + this.jsy = jsy; | |
| 116 | + } | |
| 117 | + public Double getCzlc() { | |
| 118 | + return czlc; | |
| 119 | + } | |
| 120 | + public void setCzlc(Double czlc) { | |
| 121 | + this.czlc = czlc; | |
| 122 | + } | |
| 123 | + public Double getJzlc() { | |
| 124 | + return jzlc; | |
| 125 | + } | |
| 126 | + public void setJzlc(Double jzlc) { | |
| 127 | + this.jzlc = jzlc; | |
| 128 | + } | |
| 129 | + public Double getCzyl() { | |
| 130 | + return czyl; | |
| 131 | + } | |
| 132 | + public void setCzyl(Double czyl) { | |
| 133 | + this.czyl = czyl; | |
| 134 | + } | |
| 135 | + public Double getJzyl() { | |
| 136 | + return jzyl; | |
| 137 | + } | |
| 138 | + public void setJzyl(Double jzyl) { | |
| 139 | + this.jzyl = jzyl; | |
| 140 | + } | |
| 141 | + public Double getJzl() { | |
| 142 | + return jzl; | |
| 143 | + } | |
| 144 | + public void setJzl(Double jzl) { | |
| 145 | + this.jzl = jzl; | |
| 146 | + } | |
| 147 | + public int getSfkt() { | |
| 148 | + return sfkt; | |
| 149 | + } | |
| 150 | + public void setSfkt(int sfkt) { | |
| 151 | + this.sfkt = sfkt; | |
| 152 | + } | |
| 153 | + public String getJhsj() { | |
| 154 | + return jhsj; | |
| 155 | + } | |
| 156 | + public void setJhsj(String jhsj) { | |
| 157 | + this.jhsj = jhsj; | |
| 158 | + } | |
| 159 | + public Double getYh() { | |
| 160 | + return yh; | |
| 161 | + } | |
| 162 | + public void setYh(Double yh) { | |
| 163 | + this.yh = yh; | |
| 164 | + } | |
| 165 | + public Double getSh() { | |
| 166 | + return sh; | |
| 167 | + } | |
| 168 | + public void setSh(Double sh) { | |
| 169 | + this.sh = sh; | |
| 170 | + } | |
| 171 | + public String getShyy() { | |
| 172 | + return shyy; | |
| 173 | + } | |
| 174 | + public void setShyy(String shyy) { | |
| 175 | + this.shyy = shyy; | |
| 176 | + } | |
| 177 | + public Double getZlc() { | |
| 178 | + return zlc; | |
| 179 | + } | |
| 180 | + public void setZlc(Double zlc) { | |
| 181 | + this.zlc = zlc; | |
| 182 | + } | |
| 183 | + public int getYhlx() { | |
| 184 | + return yhlx; | |
| 185 | + } | |
| 186 | + public void setYhlx(int yhlx) { | |
| 187 | + this.yhlx = yhlx; | |
| 188 | + } | |
| 189 | + public String getRylx() { | |
| 190 | + return rylx; | |
| 191 | + } | |
| 192 | + public void setRylx(String rylx) { | |
| 193 | + this.rylx = rylx; | |
| 194 | + } | |
| 195 | + public Double getNs() { | |
| 196 | + return ns; | |
| 197 | + } | |
| 198 | + public void setNs(Double ns) { | |
| 199 | + this.ns = ns; | |
| 200 | + } | |
| 201 | + public Double getFyylc() { | |
| 202 | + return fyylc; | |
| 203 | + } | |
| 204 | + public void setFyylc(Double fyylc) { | |
| 205 | + this.fyylc = fyylc; | |
| 206 | + } | |
| 207 | + public Double getJhzlc() { | |
| 208 | + return jhzlc; | |
| 209 | + } | |
| 210 | + public void setJhzlc(Double jhzlc) { | |
| 211 | + this.jhzlc = jhzlc; | |
| 212 | + } | |
| 213 | + public Double getJhfyylc() { | |
| 214 | + return jhfyylc; | |
| 215 | + } | |
| 216 | + public void setJhfyylc(Double jhfyylc) { | |
| 217 | + this.jhfyylc = jhfyylc; | |
| 218 | + } | |
| 219 | + public int getJhzbc() { | |
| 220 | + return jhzbc; | |
| 221 | + } | |
| 222 | + public void setJhzbc(int jhzbc) { | |
| 223 | + this.jhzbc = jhzbc; | |
| 224 | + } | |
| 225 | + public int getJhbc() { | |
| 226 | + return jhbc; | |
| 227 | + } | |
| 228 | + public void setJhbc(int jhbc) { | |
| 229 | + this.jhbc = jhbc; | |
| 230 | + } | |
| 231 | + public int getSjzbc() { | |
| 232 | + return sjzbc; | |
| 233 | + } | |
| 234 | + public void setSjzbc(int sjzbc) { | |
| 235 | + this.sjzbc = sjzbc; | |
| 236 | + } | |
| 237 | + public int getSjbc() { | |
| 238 | + return sjbc; | |
| 239 | + } | |
| 240 | + public void setSjbc(int sjbc) { | |
| 241 | + this.sjbc = sjbc; | |
| 242 | + } | |
| 243 | + public String getEdituser() { | |
| 244 | + return edituser; | |
| 245 | + } | |
| 246 | + public void setEdituser(String edituser) { | |
| 247 | + this.edituser = edituser; | |
| 248 | + } | |
| 249 | + public Date getEdittime() { | |
| 250 | + return edittime; | |
| 251 | + } | |
| 252 | + public void setEdittime(Date edittime) { | |
| 253 | + this.edittime = edittime; | |
| 254 | + } | |
| 255 | + public Date getCreatetime() { | |
| 256 | + return createtime; | |
| 257 | + } | |
| 258 | + public void setCreatetime(Date createtime) { | |
| 259 | + this.createtime = createtime; | |
| 260 | + } | |
| 261 | + public int getNylx() { | |
| 262 | + return nylx; | |
| 263 | + } | |
| 264 | + public void setNylx(int nylx) { | |
| 265 | + this.nylx = nylx; | |
| 266 | + } | |
| 267 | + | |
| 268 | + public String getBglyh() { | |
| 269 | + if(this.getZlc()==0){ | |
| 270 | + return "0"; | |
| 271 | + }else{ | |
| 272 | + DecimalFormat df = new DecimalFormat("0.00"); | |
| 273 | + return df.format(this.getYh()/this.getZlc()*100); | |
| 274 | + } | |
| 275 | + } | |
| 276 | + | |
| 277 | + public void setBglyh(String bglyh) { | |
| 278 | + this.bglyh = bglyh; | |
| 279 | + } | |
| 280 | + | |
| 281 | + public String getXlname() { | |
| 282 | + return BasicData.lineCode2NameMap.get(this.xlbm); | |
| 283 | + } | |
| 284 | + | |
| 285 | + public void setXlname(String xlname) { | |
| 286 | + this.xlname = xlname; | |
| 287 | + } | |
| 288 | + | |
| 289 | + public String getGsname() { | |
| 290 | + return BasicData.businessCodeNameMap.get(this.ssgsdm); | |
| 291 | + } | |
| 292 | + | |
| 293 | + public void setGsname(String gsname) { | |
| 294 | + this.gsname = gsname; | |
| 295 | + } | |
| 296 | + | |
| 297 | + | |
| 298 | + public String getFgsname() { | |
| 299 | + return BasicData.businessFgsCodeNameMap.get(this.fgsdm+"_"+this.ssgsdm); | |
| 300 | + } | |
| 301 | + | |
| 302 | + public void setFgsname(String fgsname) { | |
| 303 | + this.fgsname = fgsname; | |
| 304 | + } | |
| 305 | + | |
| 306 | + public String getName() { | |
| 307 | + return BasicData.allPerson.get(this.ssgsdm+"-"+this.jsy); | |
| 308 | + } | |
| 309 | + | |
| 310 | + public void setName(String name) { | |
| 311 | + this.name = name; | |
| 312 | + } | |
| 313 | + | |
| 314 | + | |
| 315 | +} | ... | ... |
src/main/java/com/bsth/repository/oil/LsylbRepository.java
0 → 100644
| 1 | +package com.bsth.repository.oil; | |
| 2 | + | |
| 3 | +import java.util.Date; | |
| 4 | +import java.util.List; | |
| 5 | +import java.util.Map; | |
| 6 | + | |
| 7 | +import org.springframework.data.jpa.repository.Modifying; | |
| 8 | +import org.springframework.data.jpa.repository.Query; | |
| 9 | +import org.springframework.stereotype.Repository; | |
| 10 | +import org.springframework.transaction.annotation.Transactional; | |
| 11 | + | |
| 12 | +import com.bsth.entity.oil.Lsylb; | |
| 13 | +import com.bsth.entity.oil.Ylb; | |
| 14 | +import com.bsth.repository.BaseRepository; | |
| 15 | + | |
| 16 | +@Repository | |
| 17 | +public interface LsylbRepository extends BaseRepository<Lsylb, Integer>{ | |
| 18 | + /** | |
| 19 | + * | |
| 20 | + * @param nbbm | |
| 21 | + * @param rq | |
| 22 | + * @param xlbm | |
| 23 | + * @return | |
| 24 | + */ | |
| 25 | + @Query(value="select nbbm,count(nbbm) from bsth_ls_ylb where to_days(?1)=to_days(rq) and " | |
| 26 | + + " ssgsdm like %?2% " | |
| 27 | + + " and fgsdm like %?3%" | |
| 28 | + + " and xlbm like %?4% and nbbm like %?5% and nylx= ?6 " | |
| 29 | + + " group by nbbm,rq,ssgsdm,fgsdm",nativeQuery=true) | |
| 30 | + List<Object[]> checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int nylx); | |
| 31 | + | |
| 32 | + @Query(value="select s from Lsylb s " | |
| 33 | + + " where to_days(?1)=to_days(s.rq) " | |
| 34 | + + " and s.ssgsdm =?2 " | |
| 35 | + + " and s.fgsdm =?3 " | |
| 36 | + + " and s.xlbm like %?4% " | |
| 37 | + + " and s.nylx =?5 " | |
| 38 | + + " and s.nbbm in ?6 order by nbbm,jhsj") | |
| 39 | + List<Lsylb> listYlb(String rq, String gsbm,String fgsbm,String xlbm,int nylx,List<String> listNbbm); | |
| 40 | + | |
| 41 | + @Query(value="select nbbm,sum(jzl*100) as jzl ,sum(zlc*100) as zlc from bsth_ls_ylb where to_days(?1)=to_days(rq) and " | |
| 42 | + + " ssgsdm like %?2% " | |
| 43 | + + " and fgsdm like %?3%" | |
| 44 | + + " and xlbm like %?4% and nbbm like %?5% and nylx =?6 " | |
| 45 | + + " group by nbbm,rq,ssgsdm,fgsdm,xlbm",nativeQuery=true) | |
| 46 | + List<Object[]> checkNbmmYl(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int nylx); | |
| 47 | + | |
| 48 | + | |
| 49 | + @Query(value="select ifnull(jzl,0),ifnull(yh,0),ifnull(sh,0) from bsth_ls_ylb " | |
| 50 | + + " where to_days(?1)=to_days(rq) " | |
| 51 | + + " and ssgsdm like %?2% " | |
| 52 | + + " and fgsdm like %?3%" | |
| 53 | + + " and xlbm like %?4% " | |
| 54 | + + " and nbbm like %?5% " | |
| 55 | + + " and nylx =?6",nativeQuery=true) | |
| 56 | + List<Object[]> sumYlb2(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int nylx); | |
| 57 | + | |
| 58 | + | |
| 59 | + @Query(value="select jzl,yh,sh from Lsylb s " | |
| 60 | + + " where to_days(?1)=to_days(s.rq) " | |
| 61 | + + " and s.ssgsdm like %?2% " | |
| 62 | + + " and s.fgsdm like %?3%" | |
| 63 | + + " and s.xlbm like %?4% " | |
| 64 | + + " and s.nbbm in ?5 and s.nylx=?6") | |
| 65 | + List<Object[]> sumYlb(String rq, String gsbm,String fgsbm,String xlbm,List<String> listNbbm,int nylx); | |
| 66 | + | |
| 67 | +} | ... | ... |
src/main/java/com/bsth/service/calc/CalcWaybillService.java
| ... | ... | @@ -32,6 +32,8 @@ public interface CalcWaybillService extends BaseService<CalcWaybill, Integer> { |
| 32 | 32 | |
| 33 | 33 | List<CalcStatistics> calcStatisticsDaily(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type); |
| 34 | 34 | |
| 35 | + List<Map<String, Object>> calcStatisticsDaily2(String gsdm,String fgsdm, String line, String date, String date2, String xlName, String type); | |
| 36 | + | |
| 35 | 37 | Map<String, Object> calcLineMileage(String date, String line); |
| 36 | 38 | |
| 37 | 39 | Map<String, Object> calcBusMileage(String date, String line); | ... | ... |
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package com.bsth.service.calc.impl; |
| 2 | 2 | |
| 3 | 3 | import java.sql.ResultSet; |
| 4 | 4 | import java.sql.SQLException; |
| 5 | +import java.text.ParseException; | |
| 5 | 6 | import java.text.SimpleDateFormat; |
| 6 | 7 | import java.util.ArrayList; |
| 7 | 8 | import java.util.Calendar; |
| ... | ... | @@ -13,6 +14,7 @@ import java.util.HashSet; |
| 13 | 14 | import java.util.Iterator; |
| 14 | 15 | import java.util.List; |
| 15 | 16 | import java.util.Map; |
| 17 | +import java.util.Map.Entry; | |
| 16 | 18 | import java.util.Set; |
| 17 | 19 | |
| 18 | 20 | import javax.transaction.Transactional; |
| ... | ... | @@ -37,6 +39,7 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 37 | 39 | import com.bsth.service.calc.CalcToolService; |
| 38 | 40 | import com.bsth.service.calc.CalcWaybillService; |
| 39 | 41 | import com.bsth.service.impl.BaseServiceImpl; |
| 42 | +import com.bsth.service.realcontrol.ScheduleRealInfoService; | |
| 40 | 43 | import com.bsth.service.report.CulateMileageService; |
| 41 | 44 | import com.bsth.service.report.ReportService; |
| 42 | 45 | import com.bsth.util.Arith; |
| ... | ... | @@ -81,6 +84,9 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 81 | 84 | private CulateMileageService culateService; |
| 82 | 85 | |
| 83 | 86 | @Autowired |
| 87 | + private ScheduleRealInfoService scheduleRealInfoService; | |
| 88 | + | |
| 89 | + @Autowired | |
| 84 | 90 | private ScheduleRealInfoRepository scheduleRealInfoRepository; |
| 85 | 91 | |
| 86 | 92 | @Autowired |
| ... | ... | @@ -850,6 +856,276 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 850 | 856 | |
| 851 | 857 | return resList; |
| 852 | 858 | } |
| 859 | + | |
| 860 | + @Override | |
| 861 | + public List<Map<String, Object>> calcStatisticsDaily2(String gsdm, String fgsdm, | |
| 862 | + String line, String date, String date2, String xlName, String type) { | |
| 863 | + // TODO Auto-generated method stub | |
| 864 | + SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd"); | |
| 865 | + Date beginDate = new Date(); | |
| 866 | + Calendar calendar = Calendar.getInstance(); | |
| 867 | + calendar.setTime(beginDate); | |
| 868 | + calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 4); | |
| 869 | + String d2 = dft.format(calendar.getTime()); //当前日期前4天 | |
| 870 | + calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) +1); | |
| 871 | + String d3= dft.format(calendar.getTime()); //当前日期前3天 | |
| 872 | + | |
| 873 | + String d1=""; | |
| 874 | + String d4=""; | |
| 875 | + try { | |
| 876 | + long t3 = dft.parse(d2).getTime(); | |
| 877 | + long t1=dft.parse(date).getTime(); | |
| 878 | + long t2=dft.parse(date2).getTime(); | |
| 879 | + | |
| 880 | + if(t1<=t3 && t2>t3){ | |
| 881 | + //所选日期区间区间既有实时数据也有历史数据 | |
| 882 | + d1=date; | |
| 883 | + d4=date2; | |
| 884 | + } else if (t1>t3&&t2>t3){ | |
| 885 | + d1=date; | |
| 886 | + d2=date2; | |
| 887 | + d3=date; | |
| 888 | + d4=date2; | |
| 889 | + }else{ | |
| 890 | + d1=date; | |
| 891 | + d2=date2; | |
| 892 | + //实时数据无需 | |
| 893 | + d3=""; | |
| 894 | + d4=""; | |
| 895 | + } | |
| 896 | + } catch (ParseException e1) { | |
| 897 | + // TODO Auto-generated catch block | |
| 898 | + e1.printStackTrace(); | |
| 899 | + } | |
| 900 | + | |
| 901 | + | |
| 902 | + List<CalcStatistics> list = new ArrayList<CalcStatistics>(); | |
| 903 | + if(line.length() > 0){ | |
| 904 | + list = calcStatisticsRepository.selectByDateAndLineTj2(line, d1, d2); | |
| 905 | + } else { | |
| 906 | + list = calcStatisticsRepository.selectByDateAndLineTj(line, d1, d2, gsdm, fgsdm); | |
| 907 | + } | |
| 908 | + | |
| 909 | + List<CalcStatistics> resList = new ArrayList<CalcStatistics>(); | |
| 910 | + Map<String, List<CalcStatistics>> keyMap = new HashMap<String, List<CalcStatistics>>(); | |
| 911 | + List<String> keyList = new ArrayList<String>(); | |
| 912 | + | |
| 913 | + for(CalcStatistics s : list){ | |
| 914 | + try { | |
| 915 | + String key = PinyinHelper.convertToPinyinString(s.getXlName(), "" , PinyinFormat.WITHOUT_TONE); | |
| 916 | + if(!keyMap.containsKey(key)){ | |
| 917 | + keyMap.put(key, new ArrayList<CalcStatistics>()); | |
| 918 | + keyList.add(key); | |
| 919 | + } | |
| 920 | + keyMap.get(key).add(s); | |
| 921 | + } catch (PinyinException e) { | |
| 922 | + // TODO Auto-generated catch block | |
| 923 | + e.printStackTrace(); | |
| 924 | + } | |
| 925 | + } | |
| 926 | + Collections.sort(keyList, new AccountXlbmStr()); | |
| 927 | + | |
| 928 | + for(String key : keyList){ | |
| 929 | + if(keyMap.get(key).size() > 0){ | |
| 930 | + CalcStatistics s = keyMap.get(key).get(0); | |
| 931 | + if(keyMap.get(key).size() > 1) | |
| 932 | + for(int i = 1; i < keyMap.get(key).size(); i++){ | |
| 933 | + CalcStatistics s_ = keyMap.get(key).get(i); | |
| 934 | + s = addStatistics(s, s_); | |
| 935 | + } | |
| 936 | + resList.add(s); | |
| 937 | + } | |
| 938 | + } | |
| 939 | + | |
| 940 | + if(resList.size() > 0){ | |
| 941 | + CalcStatistics temp = new CalcStatistics(); | |
| 942 | + temp.setXlName("合计"); | |
| 943 | + temp.setXl("hj"); | |
| 944 | + for(CalcStatistics s : resList){ | |
| 945 | + temp = addStatistics(temp, s); | |
| 946 | + } | |
| 947 | + resList.add(temp); | |
| 948 | + } | |
| 949 | + //统计数据 | |
| 950 | + List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | |
| 951 | + for(CalcStatistics c : resList){ | |
| 952 | + Map<String, Object> m = new HashMap<String, Object>(); | |
| 953 | + m.put("xlBm", c.getXl()); | |
| 954 | + m.put("xlName", c.getXlName()); | |
| 955 | + m.put("jhzlc", c.getJhzlc()); | |
| 956 | + m.put("jhlc", c.getJhyylc()); | |
| 957 | + m.put("jcclc", c.getJhkslc()); | |
| 958 | + m.put("sjzgl", c.getSjzlc()); | |
| 959 | + m.put("sjgl", c.getSjyylc()); | |
| 960 | + m.put("sjksgl", c.getSjkslc()); | |
| 961 | + m.put("ssgl", c.getSslc()); | |
| 962 | + m.put("ssbc", c.getSsbc()); | |
| 963 | + m.put("ssgl_lz", c.getLzlc()); | |
| 964 | + m.put("ssgl_dm", c.getDmlc()); | |
| 965 | + m.put("ssgl_gz", c.getGzlc()); | |
| 966 | + m.put("ssgl_jf", c.getJflc()); | |
| 967 | + m.put("ssgl_zs", c.getZslc()); | |
| 968 | + m.put("ssgl_qr", c.getQrlc()); | |
| 969 | + m.put("ssgl_qc", c.getQclc()); | |
| 970 | + m.put("ssgl_kx", c.getKxlc()); | |
| 971 | + m.put("ssgl_qh", c.getQhlc()); | |
| 972 | + m.put("ssgl_yw", c.getYwlc()); | |
| 973 | + m.put("ssgl_other", c.getQtlc()); | |
| 974 | + m.put("ljgl", c.getLjlc()); | |
| 975 | + m.put("jhbc", c.getJhbcq()); | |
| 976 | + m.put("jhbc_m", c.getJhbcz()); | |
| 977 | + m.put("jhbc_a", c.getJhbcw()); | |
| 978 | + m.put("sjbc", c.getSjbcq()); | |
| 979 | + m.put("sjbc_m", c.getSjbcz()); | |
| 980 | + m.put("sjbc_a", c.getSjbcw()); | |
| 981 | + m.put("ljbc", c.getLjbcq()); | |
| 982 | + m.put("ljbc_m", c.getLjbcz()); | |
| 983 | + m.put("ljbc_a", c.getLjbcw()); | |
| 984 | + m.put("fzbc", c.getFzbcq()); | |
| 985 | + m.put("fzbc_m", c.getFzbcz()); | |
| 986 | + m.put("fzbc_a", c.getFzbcw()); | |
| 987 | + m.put("dtbc", c.getDtbcq()); | |
| 988 | + m.put("dtbc_m", c.getDtbcz()); | |
| 989 | + m.put("dtbc_a", c.getDtbcw()); | |
| 990 | + m.put("djg", c.getDjgq()); | |
| 991 | + m.put("djg_m", c.getDjgz()); | |
| 992 | + m.put("djg_a", c.getDjgw()); | |
| 993 | + m.put("djg_time", c.getDjgsj()); | |
| 994 | + double jl = Arith.sub(Arith.add(m.get("jhlc"), m.get("ljgl")), m.get("ssgl")); | |
| 995 | + if (jl == Double.parseDouble(m.get("sjgl").toString())) { | |
| 996 | + m.put("zt", 0); | |
| 997 | + } else { | |
| 998 | + m.put("zt", 1); | |
| 999 | + } | |
| 1000 | + mapList.add(m); | |
| 1001 | + } | |
| 1002 | + | |
| 1003 | + //实时数据 | |
| 1004 | + List<Map<String, Object>> tjlist=new ArrayList<Map<String, Object>>(); | |
| 1005 | + if(!d4.equals("")){ | |
| 1006 | + tjlist= scheduleRealInfoService.statisticsDailyTjHb(gsdm, fgsdm, line, d3, d4, xlName, type); | |
| 1007 | + } | |
| 1008 | + List<Map<String, Object>> mapListHj = new ArrayList<Map<String, Object>>(); | |
| 1009 | +// List<String> lineList=new ArrayList<String>(); | |
| 1010 | + Map<String, Object> kMap=new HashMap<String,Object>(); | |
| 1011 | + mapList.addAll(tjlist); | |
| 1012 | + for (int i = 0; i < mapList.size(); i++) { | |
| 1013 | + Map<String, Object> m =mapList.get(i); | |
| 1014 | + if(kMap.get(m.get("xlBm").toString())==null){ | |
| 1015 | + kMap.put(m.get("xlBm").toString(), m.get("xlBm").toString()); | |
| 1016 | + } | |
| 1017 | + } | |
| 1018 | + for (Object xlbm : kMap.keySet()) { | |
| 1019 | + Map<String, Object> hjMap = new HashMap<String, Object>(); | |
| 1020 | + for (int i = 0; i < mapList.size(); i++) { | |
| 1021 | + Map<String, Object> lsMap=mapList.get(i); | |
| 1022 | + if (lsMap.get("xlBm").toString().equals(xlbm)) { | |
| 1023 | + if(hjMap.get("xlBm")==null){ | |
| 1024 | + hjMap.put("xlBm", lsMap.get("xlBm")); | |
| 1025 | + hjMap.put("xlName", lsMap.get("xlName")); | |
| 1026 | + try { | |
| 1027 | + if(lsMap.get("xlBm").toString().equals("hj")){ | |
| 1028 | + hjMap.put("xlNamePy", "zzzzz"); | |
| 1029 | + | |
| 1030 | + }else{ | |
| 1031 | + hjMap.put("xlNamePy", PinyinHelper.convertToPinyinString(lsMap.get("xlName").toString(), "", PinyinFormat.WITHOUT_TONE)); | |
| 1032 | + } | |
| 1033 | + } catch (PinyinException e) { | |
| 1034 | + // TODO Auto-generated catch block | |
| 1035 | + e.printStackTrace(); | |
| 1036 | + } | |
| 1037 | + } | |
| 1038 | + hjMap.put("jhzlc", Arith.add(lsMap.get("jhzlc"), hjMap.get("jhzlc")==null?"0":hjMap.get("jhzlc"))); | |
| 1039 | + hjMap.put("jhlc", Arith.add(lsMap.get("jhlc"), hjMap.get("jhlc")==null?"0":hjMap.get("jhlc"))); | |
| 1040 | + hjMap.put("jcclc",Arith.add(lsMap.get("jcclc"), hjMap.get("jcclc")==null?"0":hjMap.get("jcclc"))); | |
| 1041 | + hjMap.put("sjzgl",Arith.add(lsMap.get("sjzgl"), hjMap.get("sjzgl")==null?"0": hjMap.get("sjzgl"))); | |
| 1042 | + hjMap.put("sjgl", Arith.add(lsMap.get("sjgl"), hjMap.get("sjgl")==null?"0":hjMap.get("sjgl"))); | |
| 1043 | + hjMap.put("sjksgl", Arith.add(lsMap.get("sjksgl"), hjMap.get("sjksgl")==null?"0":hjMap.get("sjksgl"))); | |
| 1044 | + hjMap.put("ssgl", Arith.add(lsMap.get("ssgl"), hjMap.get("ssgl")==null?"0":hjMap.get("ssgl"))); | |
| 1045 | + hjMap.put("ssbc", Integer.parseInt(lsMap.get("ssbc").toString())+Integer.parseInt(hjMap.get("ssbc")==null?"0":hjMap.get("ssbc").toString())); | |
| 1046 | + hjMap.put("ssgl_lz", Arith.add(lsMap.get("ssgl_lz"), hjMap.get("ssgl_lz")==null?"0":hjMap.get("ssgl_lz"))); | |
| 1047 | + hjMap.put("ssgl_dm", Arith.add(lsMap.get("ssgl_dm"), hjMap.get("ssgl_dm")==null?"0":hjMap.get("ssgl_dm"))); | |
| 1048 | + hjMap.put("ssgl_gz", Arith.add(lsMap.get("ssgl_gz"), hjMap.get("ssgl_gz")==null?"0":hjMap.get("ssgl_gz"))); | |
| 1049 | + hjMap.put("ssgl_jf", Arith.add(lsMap.get("ssgl_jf"), hjMap.get("ssgl_jf")==null?"0":hjMap.get("ssgl_jf"))); | |
| 1050 | + hjMap.put("ssgl_zs", Arith.add(lsMap.get("ssgl_zs"), hjMap.get("ssgl_zs")==null?"0":hjMap.get("ssgl_zs"))); | |
| 1051 | + hjMap.put("ssgl_qr", Arith.add(lsMap.get("ssgl_qr"), hjMap.get("ssgl_qr")==null?"0":hjMap.get("ssgl_qr"))); | |
| 1052 | + hjMap.put("ssgl_qc", Arith.add(lsMap.get("ssgl_qc"), hjMap.get("ssgl_qc")==null?"0":hjMap.get("ssgl_qc"))); | |
| 1053 | + hjMap.put("ssgl_kx", Arith.add(lsMap.get("ssgl_kx"), hjMap.get("ssgl_kx")==null?"0":hjMap.get("ssgl_kx"))); | |
| 1054 | + hjMap.put("ssgl_qh", Arith.add(lsMap.get("ssgl_qh"), hjMap.get("ssgl_qh")==null?"0":hjMap.get("ssgl_qh"))); | |
| 1055 | + hjMap.put("ssgl_yw", Arith.add(lsMap.get("ssgl_yw"), hjMap.get("ssgl_yw")==null?"0":hjMap.get("ssgl_yw"))); | |
| 1056 | + hjMap.put("ssgl_other", Arith.add(lsMap.get("ssgl_other"), hjMap.get("ssgl_other")==null?"0":hjMap.get("ssgl_other"))); | |
| 1057 | + hjMap.put("ljgl", Arith.add(lsMap.get("ljgl"), hjMap.get("ljgl")==null?"0":hjMap.get("ljgl"))); | |
| 1058 | + hjMap.put("jhbc", Integer.parseInt(lsMap.get("jhbc").toString())+ Integer.parseInt(hjMap.get("jhbc")==null?"0":hjMap.get("jhbc").toString())); | |
| 1059 | + hjMap.put("jhbc_m", Integer.parseInt(lsMap.get("jhbc_m").toString())+Integer.parseInt(hjMap.get("jhbc_m")==null?"0":hjMap.get("jhbc_m").toString())); | |
| 1060 | + hjMap.put("jhbc_a", Integer.parseInt(lsMap.get("jhbc_a").toString())+ Integer.parseInt(hjMap.get("jhbc_a")==null?"0":hjMap.get("jhbc_a").toString())); | |
| 1061 | + hjMap.put("sjbc", Integer.parseInt(lsMap.get("sjbc").toString())+ Integer.parseInt(hjMap.get("sjbc")==null?"0":hjMap.get("sjbc").toString())); | |
| 1062 | + hjMap.put("sjbc_m",Integer.parseInt(lsMap.get("sjbc_m").toString())+ Integer.parseInt(hjMap.get("sjbc_m")==null?"0":hjMap.get("sjbc_m").toString())); | |
| 1063 | + hjMap.put("sjbc_a", Integer.parseInt(lsMap.get("sjbc_a").toString())+ Integer.parseInt(hjMap.get("sjbc_a")==null?"0":hjMap.get("sjbc_a").toString())); | |
| 1064 | + hjMap.put("ljbc", Integer.parseInt(lsMap.get("ljbc").toString())+ Integer.parseInt(hjMap.get("ljbc")==null?"0":hjMap.get("ljbc").toString())); | |
| 1065 | + hjMap.put("ljbc_m", Integer.parseInt(lsMap.get("ljbc_m").toString())+ Integer.parseInt(hjMap.get("ljbc_m")==null?"0":hjMap.get("ljbc_m").toString())); | |
| 1066 | + hjMap.put("ljbc_a", Integer.parseInt(lsMap.get("ljbc_a").toString())+Integer.parseInt(hjMap.get("ljbc_a")==null?"0":hjMap.get("ljbc_a").toString())); | |
| 1067 | + hjMap.put("fzbc", Integer.parseInt(lsMap.get("fzbc").toString())+ Integer.parseInt(hjMap.get("fzbc")==null?"0":hjMap.get("fzbc").toString())); | |
| 1068 | + hjMap.put("fzbc_m",Integer.parseInt(lsMap.get("fzbc_m").toString())+ Integer.parseInt(hjMap.get("fzbc_m")==null?"0":hjMap.get("fzbc_m").toString())); | |
| 1069 | + hjMap.put("fzbc_a",Integer.parseInt(lsMap.get("fzbc_a").toString())+ Integer.parseInt(hjMap.get("fzbc_a")==null?"0":hjMap.get("fzbc_a").toString())); | |
| 1070 | + hjMap.put("dtbc", Integer.parseInt(lsMap.get("dtbc").toString())+ Integer.parseInt(hjMap.get("dtbc")==null?"0":hjMap.get("dtbc").toString())); | |
| 1071 | + hjMap.put("dtbc_m", Integer.parseInt(lsMap.get("dtbc_m").toString())+ Integer.parseInt(hjMap.get("dtbc_m")==null?"0":hjMap.get("dtbc_m").toString())); | |
| 1072 | + hjMap.put("dtbc_a", Integer.parseInt(lsMap.get("dtbc_a").toString())+ Integer.parseInt(hjMap.get("dtbc_a")==null?"0":hjMap.get("dtbc_a").toString())); | |
| 1073 | + hjMap.put("djg", Integer.parseInt(lsMap.get("djg").toString())+ Integer.parseInt(hjMap.get("djg")==null?"0":hjMap.get("djg").toString())); | |
| 1074 | + hjMap.put("djg_m", Integer.parseInt(lsMap.get("djg_m").toString())+ Integer.parseInt(hjMap.get("djg_m")==null?"0":hjMap.get("djg_m").toString())); | |
| 1075 | + hjMap.put("djg_a", Integer.parseInt(lsMap.get("djg_a").toString())+ Integer.parseInt(hjMap.get("djg_a")==null?"0":hjMap.get("djg_a").toString())); | |
| 1076 | + if(hjMap.get("djg_time")==null){ | |
| 1077 | + hjMap.put("djg_time", lsMap.get("djg_time")); | |
| 1078 | + }else{ | |
| 1079 | + if(Arith.add(lsMap.get("djg_time"),0)>Arith.add(hjMap.get("djg_time"), 0)){ | |
| 1080 | + hjMap.put("djg_time", lsMap.get("djg_time")); | |
| 1081 | + }else{ | |
| 1082 | + hjMap.put("djg_time",hjMap.get("djg_time")); | |
| 1083 | + } | |
| 1084 | + } | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + double jl = Arith.sub(Arith.add(hjMap.get("jhlc"), hjMap.get("ljgl")), hjMap.get("ssgl")); | |
| 1088 | + if (jl == Double.parseDouble(hjMap.get("sjgl").toString())) { | |
| 1089 | + hjMap.put("zt", 0); | |
| 1090 | + } else { | |
| 1091 | + hjMap.put("zt", 1); | |
| 1092 | + } | |
| 1093 | + } | |
| 1094 | + } | |
| 1095 | + mapListHj.add(hjMap); | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + Collections.sort(mapListHj, new AccountXlbmByping()); | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + if (type != null && type.length() != 0 && type.equals("export")) { | |
| 1102 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 1103 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 1104 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 1105 | + Map<String, Object> m = new HashMap<String, Object>(); | |
| 1106 | + m.put("date", date+"至"+date2); | |
| 1107 | + ReportUtils ee = new ReportUtils(); | |
| 1108 | + try { | |
| 1109 | + String dateTime = ""; | |
| 1110 | + if(date.equals(date2)){ | |
| 1111 | + dateTime = sdfSimple.format(sdfMonth.parse(date)); | |
| 1112 | + } else { | |
| 1113 | + dateTime = sdfSimple.format(sdfMonth.parse(date)) | |
| 1114 | + +"-"+sdfSimple.format(sdfMonth.parse(date2)); | |
| 1115 | + } | |
| 1116 | + listI.add(mapListHj.iterator()); | |
| 1117 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 1118 | + ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_.xls", | |
| 1119 | + path + "export/" + dateTime + "-" + xlName + "-统计日报.xls"); | |
| 1120 | + } catch (Exception e) { | |
| 1121 | + // TODO: handle exception | |
| 1122 | + //e.printStackTrace(); | |
| 1123 | + logger.info("" , e); | |
| 1124 | + } | |
| 1125 | + } | |
| 1126 | + | |
| 1127 | + return mapListHj; | |
| 1128 | + } | |
| 853 | 1129 | |
| 854 | 1130 | public CalcStatistics addStatistics(CalcStatistics s, CalcStatistics s_){ |
| 855 | 1131 | s.setJhzlc(Arith.add(s.getJhzlc()!=null?s.getJhzlc():0, s_.getJhzlc())); |
| ... | ... | @@ -1462,3 +1738,14 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 1462 | 1738 | } |
| 1463 | 1739 | |
| 1464 | 1740 | } |
| 1741 | + | |
| 1742 | +class AccountXlbmByping implements Comparator<Map<String, Object>> { | |
| 1743 | + @Override | |
| 1744 | + public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 1745 | + // TODO Auto-generated method stub | |
| 1746 | +// PinyinHelper.convertToPinyinString(ppy.getName(), | |
| 1747 | +// "" , PinyinFormat.WITHOUT_TONE) | |
| 1748 | + return o1.get("xlNamePy").toString().compareTo( | |
| 1749 | + o2.get("xlNamePy").toString()); | |
| 1750 | + } | |
| 1751 | +} | ... | ... |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| ... | ... | @@ -2560,8 +2560,8 @@ public class FormsServiceImpl implements FormsService { |
| 2560 | 2560 | |
| 2561 | 2561 | String sql = "select gs_name, fgs_name, cl_zbh, fcsj, bc_type, xl_bm, xl_name, schedule_date" |
| 2562 | 2562 | + " from bsth_c_s_sp_info where gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"' " |
| 2563 | - + "and DATE_FORMAT(schedule_date,'%Y-%m-%d') >= '"+startDate+"' " | |
| 2564 | - + "and DATE_FORMAT(schedule_date,'%Y-%m-%d') <= '"+endDate+"' "; | |
| 2563 | + + "and schedule_date >= '"+startDate+"' " | |
| 2564 | + + "and schedule_date <= '"+endDate+"' "; | |
| 2565 | 2565 | if(line.trim().length() != 0){ |
| 2566 | 2566 | sql += "and xl_bm = '"+line+"' "; |
| 2567 | 2567 | } |
| ... | ... | @@ -2718,8 +2718,8 @@ public class FormsServiceImpl implements FormsService { |
| 2718 | 2718 | |
| 2719 | 2719 | String sql = " select b.xlgs, a.gs_bm,a.gs_name, a.fgs_bm,a.fgs_name , a.xl_bm,b.xl_name,b.sbc,b.sxl,b.scl,a.jbc ,a.jxl ,a.jcl,a.gslsbm,a.fgsbm,a.bc_type from " |
| 2720 | 2720 | + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" |
| 2721 | - + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" | |
| 2722 | - + map.get("startDate").toString() + "' and '" + map.get("endDate").toString() + "' and xl_bm='" | |
| 2721 | + + " from bsth_c_s_sp_info" + " where schedule_date >= '" | |
| 2722 | + + map.get("startDate").toString() + "' and schedule_date <= '" + map.get("endDate").toString() + "' and xl_bm='" | |
| 2723 | 2723 | + map.get("line").toString() + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out')" |
| 2724 | 2724 | + " and gs_bm='"+ map.get("gsdmEcecut").toString() + "'" |
| 2725 | 2725 | + " and fgs_bm='"+ map.get("fgsdmEcecut").toString() + "'" |
| ... | ... | @@ -2802,8 +2802,8 @@ public class FormsServiceImpl implements FormsService { |
| 2802 | 2802 | |
| 2803 | 2803 | String sql = " select b.xlgs, a.gs_bm,a.gs_name, a.fgs_bm,a.fgs_name , a.xl_bm,b.xl_name,b.sbc,b.sxl,b.scl,a.jbc ,a.jxl ,a.jcl,a.gslsbm,a.fgsbm,a.bc_type from " |
| 2804 | 2804 | + " (select count(DISTINCT gs_bm) gslsbm, gs_bm, count(DISTINCT fgs_bm) fgsbm,fgs_bm,gs_name,fgs_name ,xl_bm, count(*) as jbc,COUNT(DISTINCT xl_bm) as jxl ,COUNT(DISTINCT cl_zbh) as jcl,bc_type" |
| 2805 | - + " from bsth_c_s_sp_info" + " where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" | |
| 2806 | - + map.get("startDate").toString() + "' and '" + map.get("endDate").toString() + "' and xl_bm='" | |
| 2805 | + + " from bsth_c_s_sp_info" + " where schedule_date >= '" | |
| 2806 | + + map.get("startDate").toString() + "' and schedule_date <='" + map.get("endDate").toString() + "' and xl_bm='" | |
| 2807 | 2807 | + map.get("line").toString() + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out') " |
| 2808 | 2808 | + " and gs_bm='"+ map.get("gsdmAllline").toString() + "'" |
| 2809 | 2809 | + " and fgs_bm='"+ map.get("fgsdmAllline").toString() + "'" |
| ... | ... | @@ -2813,7 +2813,7 @@ public class FormsServiceImpl implements FormsService { |
| 2813 | 2813 | + ") as xlgs,b.gs_bm,b.fgs_bm,b.xl_bm,b." |
| 2814 | 2814 | + "xl_name,b.gs_name,b.fgs_name, b.sbc,b.sxl ,b.scl " |
| 2815 | 2815 | + "from bsth_c_line t RIGHT JOIN (select gs_bm,fgs_bm,xl_bm,xl_name,gs_name,fgs_name, count(*) as sbc,COUNT(DISTINCT xl_bm) as sxl ,COUNT(DISTINCT cl_zbh) as scl,bc_type from bsth_c_s_sp_info_real " |
| 2816 | - + "where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" + map.get("startDate").toString() + "' and '" | |
| 2816 | + + "where schedule_date_str >= '" + map.get("startDate").toString() + "' and schedule_date_str <= '" | |
| 2817 | 2817 | + map.get("endDate").toString() + "' and xl_bm='" + map.get |
| 2818 | 2818 | ("line").toString() |
| 2819 | 2819 | + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out')" | ... | ... |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| ... | ... | @@ -530,7 +530,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 530 | 530 | try { |
| 531 | 531 | //发送邮件 |
| 532 | 532 | EmailBean mail = new EmailBean(); |
| 533 | - mail.setSubject("路单日志数据"+date); | |
| 533 | + mail.setSubject("浦东路单日志数据"+date); | |
| 534 | 534 | mail.setContent(logSuccess+"<br/>成功数:"+countSuccess+"<br/>" +logFailure+"<br/>失败数:"+countFailure); |
| 535 | 535 | sendEmailController.sendMail(emailSendToAddress, mail); |
| 536 | 536 | logger.info("setLD-sendMail:邮件发送成功!"); |
| ... | ... | @@ -942,32 +942,42 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 942 | 942 | public String setSKB(String ids) { |
| 943 | 943 | String result = "failure"; |
| 944 | 944 | StringBuffer sBuffer = new StringBuffer(); |
| 945 | + DecimalFormat df = new DecimalFormat("######0.000"); | |
| 945 | 946 | try { |
| 946 | 947 | String[] idArray = ids.split(","); |
| 947 | - StringBuffer sBufferA; | |
| 948 | - StringBuffer sBufferB; | |
| 948 | + StringBuffer sBufferA ,sBufferB = null,sBufferC = null; | |
| 949 | + double zlc = 0.0f,yylc = 0.0f,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | |
| 950 | + String bcType,sxx;// 班次类型、上下行 | |
| 949 | 951 | // 上传的时刻表集合 |
| 950 | 952 | List<TTInfo> ttinfoList = new ArrayList<>(); |
| 951 | 953 | TTInfo ttInfo; |
| 952 | 954 | TTInfoDetail ttInfoDetail; |
| 955 | + LineInformation lineInformation; | |
| 953 | 956 | Iterator<TTInfoDetail> ttInfoDetailIterator; |
| 954 | - HashMap<String,Object> param = new HashMap<String, Object>(); | |
| 957 | + HashMap<String,Object> param ; | |
| 955 | 958 | sBuffer.append("<SKBs>"); |
| 956 | 959 | HashMap<String,String> paramMap; |
| 957 | - HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 960 | + HashMap<String,String> otherMap = new HashMap<>(); | |
| 958 | 961 | for (int i = 0; i < idArray.length; i++) { |
| 959 | 962 | ttInfo = ttInfoRepository.findOne(Long.valueOf(idArray[i])); |
| 960 | 963 | if(ttInfo == null) |
| 961 | 964 | continue; |
| 962 | 965 | ttinfoList.add(ttInfo); // 保存时刻表 |
| 966 | + // 获得时刻表 | |
| 967 | + param = new HashMap(); | |
| 963 | 968 | param.put("ttinfo.id_eq", ttInfo.getId()); |
| 964 | 969 | ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), |
| 965 | 970 | new Sort(Direction.ASC, "xlDir")).iterator(); |
| 971 | + // 获得lineInformation | |
| 972 | + param = new HashMap(); | |
| 973 | + param.put("line.id_eq", ttInfo.getXl().getId()); | |
| 974 | + lineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | |
| 966 | 975 | if(ttInfoDetailIterator.hasNext()){ |
| 967 | 976 | sBuffer.append("<SKB>"); |
| 968 | 977 | sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(ttInfo.getXl().getId())) |
| 969 | 978 | .append("</XLBM>"); |
| 970 | 979 | sBufferB = new StringBuffer(); |
| 980 | + sBufferC = new StringBuffer(); | |
| 971 | 981 | sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); |
| 972 | 982 | // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 |
| 973 | 983 | sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); |
| ... | ... | @@ -975,43 +985,55 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 975 | 985 | sBufferB.append("<TBYY>").append("").append("</TBYY>"); |
| 976 | 986 | sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); |
| 977 | 987 | sBufferB.append("<BCList>"); |
| 978 | - int num = 1; | |
| 979 | 988 | while (ttInfoDetailIterator.hasNext()) { |
| 980 | 989 | ttInfoDetail = ttInfoDetailIterator.next(); |
| 981 | - if(ttInfoDetail.getBcType().equals("in") || ttInfoDetail.getBcType().equals("out")){ | |
| 990 | + bcType = ttInfoDetail.getBcType(); | |
| 991 | + sxx = ttInfoDetail.getXlDir(); | |
| 992 | + // 进出场班次 | |
| 993 | + if(bcType.equals("in") || bcType.equals("out")){ | |
| 994 | + // 进出班次的计划里程,算空驶里程 | |
| 995 | + emptyLc = ttInfoDetail.getJhlc(); | |
| 996 | + // 总里程需要加上空驶里程 | |
| 997 | + zlc += emptyLc; | |
| 982 | 998 | continue; |
| 983 | 999 | } |
| 984 | - if(num++ == 1){ | |
| 985 | - sBufferA = new StringBuffer(); | |
| 986 | - sBufferA.append("<JHZLC>").append(ttInfoDetail.getJhlc()).append("</JHZLC>"); | |
| 987 | - sBufferA.append("<JHYYLC>").append(ttInfoDetail.getJhlc()).append("</JHYYLC>"); | |
| 988 | - sBuffer.append(sBufferA).append(sBufferB); | |
| 989 | - } | |
| 990 | 1000 | // 如果发车时间格式错误,忽略此条 |
| 991 | 1001 | if(changeTimeFormat(ttInfoDetail) == null){ |
| 992 | 1002 | continue; |
| 993 | 1003 | } |
| 994 | - sBuffer.append("<BC>"); | |
| 995 | - sBuffer.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 996 | - sBuffer.append("<SXX>").append(ttInfoDetail.getXlDir()).append("</SXX>"); | |
| 997 | - sBuffer.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 1004 | + sBufferC.append("<BC>"); | |
| 1005 | + sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 1006 | + sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | |
| 1007 | + sBufferC.append("<FCZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 998 | 1008 | +"_"+ttInfoDetail.getQdzCode())).append("</FCZDMC>"); |
| 999 | 1009 | // 起点站的参数 |
| 1000 | 1010 | otherMap.put("stationMark","B"); |
| 1001 | 1011 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 1002 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 1003 | - sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 1004 | - sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 1012 | + sBufferC.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 1013 | + sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 1014 | + sBufferC.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | |
| 1005 | 1015 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 1006 | 1016 | // 起点站的参数 |
| 1007 | 1017 | otherMap.put("stationMark","E"); |
| 1008 | 1018 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 1009 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 1010 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 1011 | - sBuffer.append("</BC>"); | |
| 1019 | + sBufferC.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 1020 | + sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 1021 | + sBufferC.append("</BC>"); | |
| 1022 | + // 0:上行;1:下行 | |
| 1023 | + if("0".equals(sxx)){ | |
| 1024 | + singleLc = lineInformation.getUpMileage(); | |
| 1025 | + }else{ | |
| 1026 | + singleLc = lineInformation.getDownMileage(); | |
| 1027 | + } | |
| 1028 | + zlc += singleLc ; | |
| 1029 | + yylc += singleLc; | |
| 1012 | 1030 | } |
| 1013 | - sBuffer.append("</BCList>"); | |
| 1014 | - sBuffer.append("</SKB>"); | |
| 1031 | + sBufferC.append("</BCList>"); | |
| 1032 | + sBufferC.append("</SKB>"); | |
| 1033 | + sBufferA = new StringBuffer(); | |
| 1034 | + sBufferA.append("<JHZLC>").append(df.format(zlc)).append("</JHZLC>"); | |
| 1035 | + sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>"); | |
| 1036 | + sBuffer.append(sBufferA).append(sBufferB).append(sBufferC); | |
| 1015 | 1037 | } |
| 1016 | 1038 | } |
| 1017 | 1039 | sBuffer.append("</SKBs>"); | ... | ... |
src/main/java/com/bsth/service/oil/LsylbService.java
0 → 100644
| 1 | +package com.bsth.service.oil; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | +import java.util.Map; | |
| 5 | + | |
| 6 | +import com.bsth.entity.oil.Lsylb; | |
| 7 | +import com.bsth.entity.oil.Ylb; | |
| 8 | +import com.bsth.service.BaseService; | |
| 9 | + | |
| 10 | +public interface LsylbService extends BaseService<Lsylb, Integer>{ | |
| 11 | + List<Lsylb> listYlb(Map<String, Object> map); | |
| 12 | + Map<String, Object> sumYlb(Map<String, Object> map); | |
| 13 | +} | ... | ... |
src/main/java/com/bsth/service/oil/impl/LsylbServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.oil.impl; | |
| 2 | + | |
| 3 | +import java.sql.ResultSet; | |
| 4 | +import java.sql.SQLException; | |
| 5 | +import java.text.DecimalFormat; | |
| 6 | +import java.text.ParseException; | |
| 7 | +import java.text.SimpleDateFormat; | |
| 8 | +import java.util.ArrayList; | |
| 9 | +import java.util.Calendar; | |
| 10 | +import java.util.Date; | |
| 11 | +import java.util.HashMap; | |
| 12 | +import java.util.Iterator; | |
| 13 | +import java.util.List; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +import javax.transaction.Transactional; | |
| 17 | + | |
| 18 | +import org.apache.commons.lang3.StringEscapeUtils; | |
| 19 | +import org.apache.commons.lang3.StringUtils; | |
| 20 | +import org.slf4j.Logger; | |
| 21 | +import org.slf4j.LoggerFactory; | |
| 22 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 23 | +import org.springframework.data.domain.Sort; | |
| 24 | +import org.springframework.data.domain.Sort.Direction; | |
| 25 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 26 | +import org.springframework.jdbc.core.RowMapper; | |
| 27 | +import org.springframework.stereotype.Service; | |
| 28 | + | |
| 29 | +import com.alibaba.fastjson.JSONArray; | |
| 30 | +import com.alibaba.fastjson.JSONObject; | |
| 31 | +import com.bsth.common.ResponseCode; | |
| 32 | +import com.bsth.data.BasicData; | |
| 33 | +import com.bsth.entity.Cars; | |
| 34 | +import com.bsth.entity.Line; | |
| 35 | +import com.bsth.entity.mcy_forms.Daily; | |
| 36 | +import com.bsth.entity.oil.Cyl; | |
| 37 | +import com.bsth.entity.oil.Dlb; | |
| 38 | +import com.bsth.entity.oil.Lsylb; | |
| 39 | +import com.bsth.entity.oil.Nylog; | |
| 40 | +import com.bsth.entity.oil.Ylb; | |
| 41 | +import com.bsth.entity.oil.Ylxxb; | |
| 42 | +import com.bsth.entity.search.CustomerSpecs; | |
| 43 | +import com.bsth.entity.sys.SysUser; | |
| 44 | +import com.bsth.repository.CarsRepository; | |
| 45 | +import com.bsth.repository.LineRepository; | |
| 46 | +import com.bsth.repository.oil.CylRepository; | |
| 47 | +import com.bsth.repository.oil.DlbRepository; | |
| 48 | +import com.bsth.repository.oil.LsylbRepository; | |
| 49 | +import com.bsth.repository.oil.NylogRepository; | |
| 50 | +import com.bsth.repository.oil.YlbRepository; | |
| 51 | +import com.bsth.repository.oil.YlxxbRepository; | |
| 52 | +import com.bsth.security.util.SecurityUtils; | |
| 53 | +import com.bsth.service.impl.BaseServiceImpl; | |
| 54 | +import com.bsth.service.oil.DlbService; | |
| 55 | +import com.bsth.service.oil.LsylbService; | |
| 56 | +import com.bsth.service.oil.YlbService; | |
| 57 | +import com.bsth.service.realcontrol.ScheduleRealInfoService; | |
| 58 | +import com.bsth.util.Arith; | |
| 59 | +import com.bsth.util.BatchSaveUtils; | |
| 60 | +import com.bsth.util.ReportUtils; | |
| 61 | +import com.github.abel533.echarts.code.Y; | |
| 62 | + | |
| 63 | +import javassist.bytecode.stackmap.BasicBlock.Catch; | |
| 64 | + | |
| 65 | +@Service | |
| 66 | +public class LsylbServiceImpl extends BaseServiceImpl<Lsylb,Integer> implements LsylbService{ | |
| 67 | + @Autowired | |
| 68 | + LsylbRepository repository; | |
| 69 | + @Override | |
| 70 | + public List<Lsylb> listYlb(Map<String, Object> map) { | |
| 71 | + // TODO Auto-generated method stub | |
| 72 | + List<Lsylb> listYlb=new ArrayList<Lsylb>(); | |
| 73 | + List<String> stringList=new ArrayList<String>(); | |
| 74 | + String rq=map.get("rq").toString(); | |
| 75 | + String gsbm=map.get("ssgsdm_like").toString(); | |
| 76 | + String fgsbm=map.get("fgsdm_like").toString(); | |
| 77 | + String xlbm=map.get("xlbm_like").toString().trim(); | |
| 78 | + String nbbm=map.get("nbbm_eq").toString(); | |
| 79 | + String sxtj=map.get("sxtj").toString(); | |
| 80 | + int nylx=Integer.parseInt(map.get("nylx").toString()); | |
| 81 | + if(nbbm.trim()!=""){ | |
| 82 | + stringList.add(nbbm); | |
| 83 | + List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm,nylx); | |
| 84 | + if(objectLists.size()>0){ | |
| 85 | + int cs=Integer.parseInt(objectLists.get(0)[1].toString()); | |
| 86 | + if(sxtj.equals("1")){ | |
| 87 | + if(cs==1){ | |
| 88 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm,nylx, stringList); | |
| 89 | + } | |
| 90 | + }else if(sxtj.equals("2")){ | |
| 91 | + if(cs>1){ | |
| 92 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm,nylx, stringList); | |
| 93 | + } | |
| 94 | + }else{ | |
| 95 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm,nylx, stringList); | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 99 | + }else{ | |
| 100 | + //全部 | |
| 101 | + if(sxtj.equals("0")){ | |
| 102 | + List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm,nylx); | |
| 103 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 104 | + String clbm=objectLists.get(i)[0].toString(); | |
| 105 | + stringList.add(clbm); | |
| 106 | + } | |
| 107 | + if(stringList.size()>0){ | |
| 108 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm,nylx, stringList); | |
| 109 | + } | |
| 110 | + }else{ | |
| 111 | + List<Object[]> objectLists; | |
| 112 | + if(sxtj.equals("3")){ | |
| 113 | + //有加油没里程 | |
| 114 | + objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm,nylx); | |
| 115 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 116 | + String clbm=objectLists.get(i)[0].toString(); | |
| 117 | + double jzl=Double.parseDouble(objectLists.get(i)[1].toString()); | |
| 118 | + double zlc=Double.parseDouble(objectLists.get(i)[2].toString()); | |
| 119 | + if(jzl>0 && zlc<=0){ | |
| 120 | + stringList.add(clbm); | |
| 121 | + } | |
| 122 | + | |
| 123 | + } | |
| 124 | + | |
| 125 | + }else if(sxtj.equals("4")){ | |
| 126 | + //有里程没加油 | |
| 127 | + objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm,nylx); | |
| 128 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 129 | + String clbm=objectLists.get(i)[0].toString(); | |
| 130 | + double jzl=Double.parseDouble(objectLists.get(i)[1].toString()); | |
| 131 | + double zlc=Double.parseDouble(objectLists.get(i)[2].toString()); | |
| 132 | + if(zlc>0 && jzl<=0){ | |
| 133 | + stringList.add(clbm); | |
| 134 | + } | |
| 135 | + | |
| 136 | + } | |
| 137 | + }else{ | |
| 138 | + objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm,nylx); | |
| 139 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 140 | + String clbm=objectLists.get(i)[0].toString(); | |
| 141 | + int cs=Integer.parseInt(objectLists.get(i)[1].toString()); | |
| 142 | + //一车一单 | |
| 143 | + if(sxtj.equals("1")){ | |
| 144 | + if(cs==1){ | |
| 145 | + stringList.add(clbm); | |
| 146 | + } | |
| 147 | + } | |
| 148 | + //一车多单 | |
| 149 | + if(sxtj.equals("2")){ | |
| 150 | + if(cs>1){ | |
| 151 | + stringList.add(clbm); | |
| 152 | + } | |
| 153 | + } | |
| 154 | + } | |
| 155 | + } | |
| 156 | + | |
| 157 | + if(stringList.size()>0){ | |
| 158 | + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm,nylx, stringList); | |
| 159 | + } | |
| 160 | + } | |
| 161 | + } | |
| 162 | + | |
| 163 | + return listYlb; | |
| 164 | + } | |
| 165 | + | |
| 166 | + | |
| 167 | + @Override | |
| 168 | + public Map<String, Object> sumYlb(Map<String, Object> map) { | |
| 169 | + // TODO Auto-generated method stub | |
| 170 | + List<String> stringList=new ArrayList<String>(); | |
| 171 | + String rq=map.get("rq").toString(); | |
| 172 | + String gsbm=map.get("ssgsdm_like").toString(); | |
| 173 | + String fgsbm=map.get("fgsdm_like").toString(); | |
| 174 | + String xlbm=map.get("xlbm_like").toString().trim(); | |
| 175 | + String nbbm=map.get("nbbm_eq").toString(); | |
| 176 | + String sxtj=map.get("sxtj").toString(); | |
| 177 | + int nylx=Integer.parseInt(map.get("nylx").toString()); | |
| 178 | + if(nbbm.trim()!=""){ | |
| 179 | + stringList.add(nbbm); | |
| 180 | + }else{ | |
| 181 | + if(!sxtj.equals("0")){ | |
| 182 | + List<Object[]> objectLists; | |
| 183 | + if(sxtj.equals("3")){ | |
| 184 | + //有加油没里程 | |
| 185 | + objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm,nylx); | |
| 186 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 187 | + String clbm=objectLists.get(i)[0].toString(); | |
| 188 | + double jzl=Double.parseDouble(objectLists.get(i)[1].toString()); | |
| 189 | + double zlc=Double.parseDouble(objectLists.get(i)[2].toString()); | |
| 190 | + if(jzl>0 && zlc<=0){ | |
| 191 | + stringList.add(clbm); | |
| 192 | + } | |
| 193 | + | |
| 194 | + } | |
| 195 | + | |
| 196 | + }else if(sxtj.equals("4")){ | |
| 197 | + //有里程没加油 | |
| 198 | + objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm,nylx); | |
| 199 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 200 | + String clbm=objectLists.get(i)[0].toString(); | |
| 201 | + double jzl=Double.parseDouble(objectLists.get(i)[1].toString()); | |
| 202 | + double zlc=Double.parseDouble(objectLists.get(i)[2].toString()); | |
| 203 | + if(zlc>0 && jzl<=0){ | |
| 204 | + stringList.add(clbm); | |
| 205 | + } | |
| 206 | + | |
| 207 | + } | |
| 208 | + }else{ | |
| 209 | + objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm,nylx); | |
| 210 | + for (int i = 0; i < objectLists.size(); i++) { | |
| 211 | + String clbm=objectLists.get(i)[0].toString(); | |
| 212 | + int cs=Integer.parseInt(objectLists.get(i)[1].toString()); | |
| 213 | + //一车一单 | |
| 214 | + | |
| 215 | + if(sxtj.equals("1")){ | |
| 216 | + if(cs==1){ | |
| 217 | + stringList.add(clbm); | |
| 218 | + } | |
| 219 | + } | |
| 220 | + //一车多单 | |
| 221 | + if(sxtj.equals("2")){ | |
| 222 | + if(cs>1){ | |
| 223 | + stringList.add(clbm); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + } | |
| 227 | + } | |
| 228 | + } | |
| 229 | + } | |
| 230 | + List<Object[]> sumYlbList=new ArrayList<Object[]>(); | |
| 231 | + if(sxtj.equals("0")){ | |
| 232 | + sumYlbList=repository.sumYlb2(rq, gsbm, fgsbm, xlbm,nbbm,nylx); | |
| 233 | + }else{ | |
| 234 | + if(stringList.size()>0){ | |
| 235 | + | |
| 236 | + sumYlbList=repository.sumYlb(rq, gsbm, fgsbm, xlbm, stringList,nylx); | |
| 237 | + } | |
| 238 | + | |
| 239 | + } | |
| 240 | + | |
| 241 | + Double jzl=0.0,yh=0.0,sh=0.0; | |
| 242 | + for (int i = 0; i < sumYlbList.size(); i++) { | |
| 243 | + jzl = Arith.add(jzl, Double.valueOf(sumYlbList.get(i)[0].toString())); | |
| 244 | + yh = Arith.add(yh, Double.valueOf(sumYlbList.get(i)[1].toString())); | |
| 245 | + sh = Arith.add(sh, Double.valueOf(sumYlbList.get(i)[2].toString())); | |
| 246 | + } | |
| 247 | + | |
| 248 | + Map<String, Object> sumMap=new HashMap<String,Object>(); | |
| 249 | + sumMap.put("jzl", jzl); | |
| 250 | + sumMap.put("yh", yh); | |
| 251 | + sumMap.put("sh", sh); | |
| 252 | + return sumMap; | |
| 253 | + } | |
| 254 | +} | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -811,7 +811,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 811 | 811 | String sql="select * from bsth_c_ylxxb where yyrq='"+rq+"' " |
| 812 | 812 | + " and gsdm ='"+gsbm+"' and nylx ='0' and nbbm " |
| 813 | 813 | + " not in ( select nbbm from bsth_c_ylb " |
| 814 | - + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"' " | |
| 814 | + + " where rq='"+rq+"' " | |
| 815 | 815 | + " and ssgsdm='"+gsbm+"' and fgsdm ='"+fgsbm+"')" |
| 816 | 816 | + " and nbbm in (select inside_code from " |
| 817 | 817 | + " bsth_c_cars where business_code ='"+gsbm+"' " | ... | ... |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| ... | ... | @@ -119,6 +119,9 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 119 | 119 | |
| 120 | 120 | List<Map<String,Object>> statisticsDailyTj(String gsdm,String fgsdm,String line, String date,String date2, String xlName, String type); |
| 121 | 121 | |
| 122 | + //用于实时数据与统计数据合并查询 | |
| 123 | + List<Map<String,Object>> statisticsDailyTjHb(String gsdm,String fgsdm,String line, String date,String date2, String xlName, String type); | |
| 124 | + | |
| 122 | 125 | //List<Object> scheduleDaily(String line,String date); |
| 123 | 126 | |
| 124 | 127 | int countByLineCodeAndDate(String xlBm, String schDate); | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -190,60 +190,57 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 190 | 190 | ScheduleRealInfo sch = dayOfSchedule.get(schId); |
| 191 | 191 | String gsbm = sch.getGsBm(), fgsbm = sch.getFgsBm(); |
| 192 | 192 | |
| 193 | - //校验运营公司 | |
| 194 | - Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh); | |
| 195 | - if (null == jsy) { | |
| 196 | - msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员"; | |
| 197 | - rs.put("msg", msg); | |
| 198 | - return rs; | |
| 199 | - } | |
| 200 | - if (!carExist(gsbm, nbbm)) { | |
| 193 | + if (nbbm != null && !carExist(gsbm, nbbm)) { | |
| 201 | 194 | msg = sch.getGsName() + "没有自编号为" + "[" + nbbm + "]的车辆"; |
| 202 | 195 | rs.put("msg", msg); |
| 203 | 196 | return rs; |
| 204 | 197 | } |
| 205 | 198 | |
| 206 | - if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) { | |
| 199 | + if (nbbm != null && !sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) { | |
| 207 | 200 | rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + nbbm + "】的车辆"); |
| 208 | 201 | return rs; |
| 209 | 202 | } |
| 210 | 203 | |
| 211 | - Personnel spy = null; | |
| 212 | - if (StringUtils.isNotEmpty(sGh)) { | |
| 213 | - spy = BasicData.perMap.get(gsbm + "-" + sGh); | |
| 214 | - if (null == spy) { | |
| 215 | - msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员"; | |
| 216 | - rs.put("msg", msg); | |
| 217 | - return rs; | |
| 218 | - } | |
| 219 | - } | |
| 204 | + if (nbbm != null && !(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) { | |
| 220 | 205 | |
| 206 | + String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm)); | |
| 221 | 207 | |
| 222 | - //校验分公司 | |
| 223 | - if (null != jsy && !fgsbm.equals(jsy.getBrancheCompanyCode())) { | |
| 224 | - msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员"); | |
| 208 | + msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!"); | |
| 225 | 209 | rs.put("msg", msg); |
| 226 | 210 | rs.put("checkStatus", -1); |
| 227 | 211 | return rs; |
| 228 | 212 | } |
| 229 | 213 | |
| 230 | - if (StringUtils.isNotEmpty(sGh)) { | |
| 231 | - if (null != spy && !fgsbm.equals(spy.getBrancheCompanyCode())) { | |
| 232 | - msg = ("【售票员】: " + jGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员"); | |
| 214 | + if(null != jGh && !"/".equals(StringUtils.trim(jGh))){ | |
| 215 | + Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh); | |
| 216 | + | |
| 217 | + if (null == jsy) { | |
| 218 | + msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员"; | |
| 219 | + rs.put("msg", msg); | |
| 220 | + return rs; | |
| 221 | + } | |
| 222 | + else if (!fgsbm.equals(jsy.getBrancheCompanyCode())) { | |
| 223 | + //校验分公司 | |
| 224 | + msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员"); | |
| 233 | 225 | rs.put("msg", msg); |
| 234 | 226 | rs.put("checkStatus", -1); |
| 235 | 227 | return rs; |
| 236 | 228 | } |
| 237 | 229 | } |
| 238 | 230 | |
| 239 | - if (!(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) { | |
| 240 | - | |
| 241 | - String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm)); | |
| 242 | - | |
| 243 | - msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!"); | |
| 244 | - rs.put("msg", msg); | |
| 245 | - rs.put("checkStatus", -1); | |
| 246 | - return rs; | |
| 231 | + if (null != sGh && !"/".equals(StringUtils.trim(sGh))) { | |
| 232 | + Personnel spy = BasicData.perMap.get(gsbm + "-" + sGh); | |
| 233 | + if (null == spy) { | |
| 234 | + msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员"; | |
| 235 | + rs.put("msg", msg); | |
| 236 | + return rs; | |
| 237 | + } | |
| 238 | + else if (!fgsbm.equals(spy.getBrancheCompanyCode())) { | |
| 239 | + msg = ("【售票员】: " + jGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员"); | |
| 240 | + rs.put("msg", msg); | |
| 241 | + rs.put("checkStatus", -1); | |
| 242 | + return rs; | |
| 243 | + } | |
| 247 | 244 | } |
| 248 | 245 | |
| 249 | 246 | rs.put("checkStatus", 1); |
| ... | ... | @@ -1508,10 +1505,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1508 | 1505 | } |
| 1509 | 1506 | } |
| 1510 | 1507 | |
| 1508 | + if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){ | |
| 1509 | + rs.put("status", ResponseCode.ERROR); | |
| 1510 | + rs.put("msg", "无效的参数【驾驶员】"); | |
| 1511 | + return rs; | |
| 1512 | + } | |
| 1513 | + | |
| 1511 | 1514 | /** |
| 1512 | 1515 | * 换驾驶员 |
| 1513 | 1516 | */ |
| 1514 | - if (StringUtils.isNotEmpty(jsy) && jsy.indexOf("/") != -1) { | |
| 1517 | + if (StringUtils.isNotEmpty(jsy)) { | |
| 1515 | 1518 | String jGh = jsy.split("/")[0]; |
| 1516 | 1519 | String jName = getPersonName(sch.getGsBm(), jGh); |
| 1517 | 1520 | if (StringUtils.isEmpty(jName)) { |
| ... | ... | @@ -1528,8 +1531,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1528 | 1531 | * 换售票员 |
| 1529 | 1532 | */ |
| 1530 | 1533 | String spy = map.get("spy"); |
| 1531 | - if (StringUtils.isNotEmpty(spy) && spy.indexOf("/") != -1 && !spy.equals("/")) { | |
| 1534 | + if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) { | |
| 1532 | 1535 | String sGh = spy.split("/")[0]; |
| 1536 | + | |
| 1533 | 1537 | String sName = getPersonName(sch.getGsBm(), sGh); |
| 1534 | 1538 | if (StringUtils.isEmpty(sName)) { |
| 1535 | 1539 | rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); |
| ... | ... | @@ -2662,6 +2666,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2662 | 2666 | } |
| 2663 | 2667 | Map<String, Object> map = new HashMap<String, Object>(); |
| 2664 | 2668 | if (list.size() > 0) { |
| 2669 | + map.put("xlBm", list.get(0).getXlBm()); | |
| 2665 | 2670 | map.put("xlName", list.get(0).getXlName()); |
| 2666 | 2671 | try { |
| 2667 | 2672 | map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE)); |
| ... | ... | @@ -2910,6 +2915,148 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2910 | 2915 | } |
| 2911 | 2916 | |
| 2912 | 2917 | @Override |
| 2918 | + public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2, | |
| 2919 | + String xlName, String type) { | |
| 2920 | + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 2921 | + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 2922 | + List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 2923 | + line = line.trim(); | |
| 2924 | + if (line.equals("")) { | |
| 2925 | + //查询所有线路 | |
| 2926 | + list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | |
| 2927 | + } else { | |
| 2928 | + //查询单条线路 | |
| 2929 | + list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | |
| 2930 | + } | |
| 2931 | + for (int i = 0; i < list.size(); i++) { | |
| 2932 | + ScheduleRealInfo s = list.get(i); | |
| 2933 | + Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 2934 | + if (cts != null && cts.size() > 0) { | |
| 2935 | + list_s.add(s); | |
| 2936 | + } else { | |
| 2937 | + if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 2938 | + list_s.add(s); | |
| 2939 | + } | |
| 2940 | + } | |
| 2941 | + } | |
| 2942 | + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 2943 | + for (int i = 0; i < list.size(); i++) { | |
| 2944 | + if (i < list.size() - 1) { | |
| 2945 | + if (list.get(i + 1).getXlBm().equals(list.get(i).getXlBm())) { | |
| 2946 | + lists.add(list.get(i)); | |
| 2947 | + } else { | |
| 2948 | + lists.add(list.get(i)); | |
| 2949 | + Map<String, Object> map = staticTj(lists); | |
| 2950 | + lMap.add(map); | |
| 2951 | + lists = new ArrayList<ScheduleRealInfo>(); | |
| 2952 | + } | |
| 2953 | + } else { | |
| 2954 | + if (list.get(i).getXlBm().equals(list.get(i - 1).getXlBm())) { | |
| 2955 | + lists.add(list.get(i)); | |
| 2956 | + Map<String, Object> map = staticTj(lists); | |
| 2957 | + lMap.add(map); | |
| 2958 | + } else { | |
| 2959 | + lists = new ArrayList<ScheduleRealInfo>(); | |
| 2960 | + lists.add(list.get(i)); | |
| 2961 | + Map<String, Object> map = staticTj(lists); | |
| 2962 | + lMap.add(map); | |
| 2963 | + } | |
| 2964 | + } | |
| 2965 | + } | |
| 2966 | + | |
| 2967 | + Collections.sort(lMap, new AccountXlbm()); | |
| 2968 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 2969 | + map.put("xlBm", "hj"); | |
| 2970 | + map.put("xlName", "合计"); | |
| 2971 | + double jhyygl = culateService.culateJhgl(list);//计划营运公里 | |
| 2972 | + double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | |
| 2973 | + map.put("jhlc", jhyygl); | |
| 2974 | + map.put("jcclc", jhjcclc); | |
| 2975 | + map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | |
| 2976 | + | |
| 2977 | + double ljgl = culateService.culateLjgl(list_s); | |
| 2978 | + double sjyygl = culateService.culateSjgl(list_s); | |
| 2979 | + double zyygl = Arith.add(sjyygl, ljgl); | |
| 2980 | + | |
| 2981 | + double sjjccgl = culateService.culateJccgl(list_s); | |
| 2982 | + double sjksgl = culateService.culateKsgl(list_s); | |
| 2983 | + double zksgl = Arith.add(sjjccgl, sjksgl); | |
| 2984 | + map.put("sjzgl", Arith.add(zyygl, zksgl)); | |
| 2985 | + map.put("sjgl", zyygl); | |
| 2986 | + map.put("sjksgl", zksgl); | |
| 2987 | + | |
| 2988 | + double ssgl = culateService.culateLbgl(list); | |
| 2989 | + map.put("ssgl", ssgl); | |
| 2990 | + //计划+临加-少驶=实驶 | |
| 2991 | + double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | |
| 2992 | + if (jl == zyygl) { | |
| 2993 | + map.put("zt", 0); | |
| 2994 | + } else { | |
| 2995 | + map.put("zt", 1); | |
| 2996 | + } | |
| 2997 | + map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | |
| 2998 | + map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | |
| 2999 | + map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | |
| 3000 | + map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | |
| 3001 | + map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | |
| 3002 | + map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | |
| 3003 | + map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | |
| 3004 | + map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | |
| 3005 | + map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | |
| 3006 | + map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | |
| 3007 | + double ssgl_pc = culateService.culateCJLC(list, "配车"); | |
| 3008 | + double ssgl_by = culateService.culateCJLC(list, "保养"); | |
| 3009 | + double ssgl_cj = culateService.culateCJLC(list, "抽减"); | |
| 3010 | + double ssgl_qt = culateService.culateCJLC(list, "其他"); | |
| 3011 | + map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | |
| 3012 | + | |
| 3013 | + map.put("ssbc", culateService.culateLbbc(list)); | |
| 3014 | + map.put("ljgl", ljgl); | |
| 3015 | + map.put("jhbc", culateService.culateJhbc(list, "")); | |
| 3016 | + map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | |
| 3017 | + map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | |
| 3018 | + map.put("sjbc", culateService.culateSjbc(list_s, "")); | |
| 3019 | + map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | |
| 3020 | + map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | |
| 3021 | + map.put("ljbc", culateService.culateLjbc(list_s, "")); | |
| 3022 | + map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | |
| 3023 | + map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | |
| 3024 | + map.put("fzbc", culateService.culateFzbc(list_s, "")); | |
| 3025 | + map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | |
| 3026 | + map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | |
| 3027 | + map.put("dtbc", 0); | |
| 3028 | + map.put("dtbc_m", 0); | |
| 3029 | + map.put("dtbc_a", 0); | |
| 3030 | + if (list.size() > 0) { | |
| 3031 | + int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | |
| 3032 | + for (Map<String, Object> m : lMap) { | |
| 3033 | + if (m.containsKey("djg") && m.get("djg") != null) | |
| 3034 | + djg += Integer.valueOf(m.get("djg").toString()); | |
| 3035 | + if (m.containsKey("djg_m") && m.get("djg_m") != null) | |
| 3036 | + djg_m += Integer.valueOf(m.get("djg_m").toString()); | |
| 3037 | + if (m.containsKey("djg_a") && m.get("djg_a") != null) | |
| 3038 | + djg_a += Integer.valueOf(m.get("djg_a").toString()); | |
| 3039 | + if (m.containsKey("djg_time") && m.get("djg_time") != null) { | |
| 3040 | + int t = Integer.valueOf(m.get("djg_time").toString()); | |
| 3041 | + if (t > djg_time) | |
| 3042 | + djg_time = t; | |
| 3043 | + } | |
| 3044 | + } | |
| 3045 | + map.put("djg", djg); | |
| 3046 | + map.put("djg_m", djg_m); | |
| 3047 | + map.put("djg_a", djg_a); | |
| 3048 | + map.put("djg_time", djg_time); | |
| 3049 | + } else { | |
| 3050 | + map.put("djg", "0"); | |
| 3051 | + map.put("djg_m", "0"); | |
| 3052 | + map.put("djg_a", "0"); | |
| 3053 | + map.put("djg_time", "0"); | |
| 3054 | + } | |
| 3055 | + lMap.add(map); | |
| 3056 | + return lMap; | |
| 3057 | + } | |
| 3058 | + | |
| 3059 | + @Override | |
| 2913 | 3060 | public Map<String, Object> scheduleDaily(String line, String date) { |
| 2914 | 3061 | Map<String, String> tempMap = null; |
| 2915 | 3062 | List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); |
| ... | ... | @@ -3305,11 +3452,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3305 | 3452 | Set<ScheduleRealInfo> set = new HashSet<>(); |
| 3306 | 3453 | |
| 3307 | 3454 | ScheduleRealInfo sch; |
| 3308 | - //StringBuilder sb = new StringBuilder(); | |
| 3309 | 3455 | |
| 3310 | 3456 | String jGh = null, jName, sGh, sName; |
| 3311 | 3457 | for (ChangePersonCar cpc : cpcs) { |
| 3312 | - //sb = new StringBuilder(); | |
| 3313 | 3458 | |
| 3314 | 3459 | sch = dayOfSchedule.get(cpc.getSchId()); |
| 3315 | 3460 | if (sch == null) |
| ... | ... | @@ -3337,6 +3482,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3337 | 3482 | } |
| 3338 | 3483 | } |
| 3339 | 3484 | |
| 3485 | + | |
| 3340 | 3486 | //为换人换车情况表写入数据 |
| 3341 | 3487 | schModifyLog.saveChangetochange(sch, cpc, userId); |
| 3342 | 3488 | //日志记录 |
| ... | ... | @@ -3344,8 +3490,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3344 | 3490 | |
| 3345 | 3491 | //换驾驶员 |
| 3346 | 3492 | if (StringUtils.isNotEmpty(cpc.getJsy())) { |
| 3347 | - /*if(!jGh.equals(sch.getjGh())) | |
| 3348 | - sb.append(sch.getjGh() + " 换 " + jGh + ";");*/ | |
| 3349 | 3493 | //换驾驶员 |
| 3350 | 3494 | if (persoChange(sch, jGh)) |
| 3351 | 3495 | set.add(sch); |
| ... | ... | @@ -3353,8 +3497,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3353 | 3497 | |
| 3354 | 3498 | //换售票员 |
| 3355 | 3499 | if (StringUtils.isNotEmpty(cpc.getSpy()) |
| 3356 | - && cpc.getSpy().indexOf("/") != -1 | |
| 3357 | - && cpc.getSpy().length() > 1) { | |
| 3500 | + && !"/".equals(StringUtils.trim(cpc.getSpy()))) { | |
| 3501 | + | |
| 3358 | 3502 | sGh = cpc.getSpy().split("/")[0]; |
| 3359 | 3503 | sName = getPersonName(sch.getGsBm(), sGh); |
| 3360 | 3504 | if (StringUtils.isEmpty(sName)) { | ... | ... |
src/main/java/com/bsth/service/schedule/datatools/Excel2003PoiOperator.java
| 1 | -package com.bsth.service.schedule.datatools; | |
| 2 | - | |
| 3 | -import org.apache.poi.hssf.usermodel.*; | |
| 4 | -import org.apache.poi.ss.usermodel.*; | |
| 5 | -import org.apache.poi.ss.util.WorkbookUtil; | |
| 6 | -import org.apache.poi.xssf.usermodel.XSSFColor; | |
| 7 | - | |
| 8 | -import java.awt.Color; | |
| 9 | -import java.io.File; | |
| 10 | -import java.io.FileOutputStream; | |
| 11 | -import java.util.Date; | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * Excel2003表格Poi操作类。 | |
| 15 | - * TODO:2003里面还有很多和2007不通的样式设定方式,以后再改 | |
| 16 | - */ | |
| 17 | -public class Excel2003PoiOperator implements ExcelPoiOperator { | |
| 18 | - @Override | |
| 19 | - public Cell createCell( | |
| 20 | - Workbook workbook, Row row, short columnIndex, | |
| 21 | - Object value, int valueType, | |
| 22 | - HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, | |
| 23 | - BorderStyle borderStyle, Color borderColor, | |
| 24 | - short fontSize, Color fontColor, String fontName, | |
| 25 | - Color backgroudColor, FillPatternType fillPatternType) { | |
| 26 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 27 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 28 | - | |
| 29 | - CreationHelper creationHelper = hssfWorkbook.getCreationHelper(); | |
| 30 | - | |
| 31 | - // 1、创建单元格对象 | |
| 32 | - HSSFCell hssfCell = hssfRow.createCell((int) columnIndex); | |
| 33 | - | |
| 34 | - // 2、设定样式 | |
| 35 | - HSSFCellStyle hssfCellStyle = hssfWorkbook.createCellStyle(); | |
| 36 | - | |
| 37 | - // 设定值及数据格式 | |
| 38 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 39 | - if (valueType == HSSFCell.CELL_TYPE_STRING) { | |
| 40 | - hssfCellStyle.setDataFormat(dataFormat.getFormat("@")); | |
| 41 | - hssfCell.setCellValue(creationHelper.createRichTextString(String.valueOf(value))); | |
| 42 | - } else if (valueType == HSSFCell.CELL_TYPE_NUMERIC) { | |
| 43 | - if (value instanceof Date) { // 日期 | |
| 44 | - hssfCellStyle.setDataFormat(dataFormat.getFormat("yyyy-mm-dd")); | |
| 45 | - hssfCell.setCellValue((Date) value); | |
| 46 | - } else if (value instanceof Double) { | |
| 47 | - hssfCellStyle.setDataFormat(dataFormat.getFormat("0.00")); | |
| 48 | - hssfCell.setCellValue((Double) value); | |
| 49 | - } else if (value instanceof Integer) { | |
| 50 | - hssfCellStyle.setDataFormat(dataFormat.getFormat("0")); | |
| 51 | - hssfCell.setCellValue(Double.valueOf(value.toString())); | |
| 52 | - } else { | |
| 53 | - throw new RuntimeException("Excel2003 只支持 String Date Double Integer 单元格类型"); | |
| 54 | - } | |
| 55 | - } else if (valueType == HSSFCell.CELL_TYPE_BLANK) { | |
| 56 | - hssfCell.setCellType(HSSFCell.CELL_TYPE_BLANK); | |
| 57 | - } else { | |
| 58 | - throw new RuntimeException("暂时不支持字符串、日期、数字以外的类型"); | |
| 59 | - } | |
| 60 | - | |
| 61 | - // 对齐方式 | |
| 62 | - hssfCellStyle.setAlignment((short) horizontalAlignment.ordinal()); | |
| 63 | - hssfCellStyle.setVerticalAlignment((short) verticalAlignment.ordinal()); | |
| 64 | - | |
| 65 | - // 边框样式 | |
| 66 | - hssfCellStyle.setBorderTop((short) borderStyle.ordinal()); | |
| 67 | - hssfCellStyle.setTopBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 68 | - hssfCellStyle.setBorderBottom((short) borderStyle.ordinal()); | |
| 69 | - hssfCellStyle.setBottomBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 70 | - hssfCellStyle.setBorderLeft((short) borderStyle.ordinal()); | |
| 71 | - hssfCellStyle.setLeftBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 72 | - hssfCellStyle.setBorderRight((short) borderStyle.ordinal()); | |
| 73 | - hssfCellStyle.setRightBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 74 | - | |
| 75 | - // 字体颜色 | |
| 76 | -// HSSFFont font = hssfWorkbook.createFont(); | |
| 77 | -// font.setColor(new XSSFColor(fontColor).getIndexed()); | |
| 78 | -// font.setFontHeightInPoints(fontSize); | |
| 79 | -// font.setFontName(fontName); | |
| 80 | -// hssfCellStyle.setFont(font); | |
| 81 | - | |
| 82 | - | |
| 83 | - // 单元背景色 | |
| 84 | - hssfCellStyle.setFillForegroundColor(new XSSFColor(backgroudColor).getIndexed()); | |
| 85 | -// hssfCellStyle.setFillPattern((short) fillPatternType.ordinal()); | |
| 86 | - | |
| 87 | - // TODO | |
| 88 | - | |
| 89 | - hssfCell.setCellStyle(hssfCellStyle); | |
| 90 | - return hssfCell; | |
| 91 | - } | |
| 92 | - | |
| 93 | - @Override | |
| 94 | - public Cell createStringCell( | |
| 95 | - Workbook workbook, Row row, short columnIndex, | |
| 96 | - String value) { | |
| 97 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 98 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 99 | - | |
| 100 | - HSSFCell hssfCell = (HSSFCell) createCell( | |
| 101 | - hssfWorkbook, hssfRow, columnIndex, | |
| 102 | - value, HSSFCell.CELL_TYPE_STRING, | |
| 103 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 104 | - BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 105 | - (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 106 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 107 | - ); | |
| 108 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 109 | - hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 110 | - return hssfCell; | |
| 111 | - } | |
| 112 | - | |
| 113 | - @Override | |
| 114 | - public Cell createStringCell( | |
| 115 | - Workbook workbook, Row row, short columnIndex, | |
| 116 | - String value, | |
| 117 | - Color backgroudColor) { | |
| 118 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 119 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 120 | - | |
| 121 | - HSSFCell hssfCell = (HSSFCell) createCell( | |
| 122 | - hssfWorkbook, hssfRow, columnIndex, | |
| 123 | - value, HSSFCell.CELL_TYPE_STRING, | |
| 124 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 125 | - BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 126 | - (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 127 | - backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 128 | - ); | |
| 129 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 130 | - hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 131 | - return hssfCell; | |
| 132 | - } | |
| 133 | - | |
| 134 | - @Override | |
| 135 | - public Cell createIntegerCell( | |
| 136 | - Workbook workbook, Row row, short columnIndex, | |
| 137 | - Integer value) { | |
| 138 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 139 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 140 | - | |
| 141 | - HSSFCell hssfCell = (HSSFCell) createCell( | |
| 142 | - hssfWorkbook, hssfRow, columnIndex, | |
| 143 | - value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 144 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 145 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 146 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 147 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 148 | - ); | |
| 149 | - | |
| 150 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 151 | - hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 152 | - return hssfCell; | |
| 153 | - } | |
| 154 | - | |
| 155 | - @Override | |
| 156 | - public Cell createIntegerCell( | |
| 157 | - Workbook workbook, Row row, short columnIndex, | |
| 158 | - Integer value, | |
| 159 | - Color backgroudColor) { | |
| 160 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 161 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 162 | - | |
| 163 | - HSSFCell hssfCell = (HSSFCell) createCell( | |
| 164 | - hssfWorkbook, hssfRow, columnIndex, | |
| 165 | - value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 166 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 167 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 168 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 169 | - backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 170 | - ); | |
| 171 | - | |
| 172 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 173 | - hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 174 | - return hssfCell; | |
| 175 | - } | |
| 176 | - | |
| 177 | - @Override | |
| 178 | - public Cell createDoubleCell( | |
| 179 | - Workbook workbook, Row row, short columnIndex, | |
| 180 | - Double value) { | |
| 181 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 182 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 183 | - | |
| 184 | - HSSFCell hssfCell = (HSSFCell) createCell( | |
| 185 | - hssfWorkbook, hssfRow, columnIndex, | |
| 186 | - value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 187 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 188 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 189 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 190 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 191 | - ); | |
| 192 | - | |
| 193 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 194 | - hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 195 | - return hssfCell; | |
| 196 | - } | |
| 197 | - | |
| 198 | - @Override | |
| 199 | - public Cell createDoubleCell( | |
| 200 | - Workbook workbook, Row row, short columnIndex, | |
| 201 | - Double value, | |
| 202 | - Color backgroudColor) { | |
| 203 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 204 | - HSSFRow hssfRow = (HSSFRow) row; | |
| 205 | - | |
| 206 | - HSSFCell hssfCell = (HSSFCell) createCell( | |
| 207 | - hssfWorkbook, hssfRow, columnIndex, | |
| 208 | - value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 209 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 210 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 211 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 212 | - backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 213 | - ); | |
| 214 | - | |
| 215 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 216 | - hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 217 | - return hssfCell; | |
| 218 | - } | |
| 219 | - | |
| 220 | - @Override | |
| 221 | - public Cell createBlankCell(Workbook workbook, Row row, short columnIndex) { | |
| 222 | - return createCell( | |
| 223 | - workbook, row, columnIndex, | |
| 224 | - null, HSSFCell.CELL_TYPE_BLANK, | |
| 225 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 226 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 227 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 228 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 229 | - ); | |
| 230 | - } | |
| 231 | - | |
| 232 | - @Override | |
| 233 | - public Cell setCellDataFormat(Workbook workbook, Cell cell, String fmt) { | |
| 234 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 235 | - DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 236 | - cell.getCellStyle().setDataFormat(dataFormat.getFormat("fmt")); | |
| 237 | - return cell; | |
| 238 | - } | |
| 239 | - | |
| 240 | - @Override | |
| 241 | - public Cell setCellBackground(Cell cell, Color color) { | |
| 242 | - HSSFCell hssfCell = (HSSFCell) cell; | |
| 243 | - hssfCell.getCellStyle().setFillForegroundColor(new XSSFColor(color).getIndexed()); | |
| 244 | - return cell; | |
| 245 | - } | |
| 246 | - | |
| 247 | - @Override | |
| 248 | - public Workbook createWorkBook() { | |
| 249 | - return new HSSFWorkbook(); | |
| 250 | - } | |
| 251 | - | |
| 252 | - @Override | |
| 253 | - public Sheet createWorkBookSheet(Workbook workbook, String sheetName) { | |
| 254 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 255 | - return hssfWorkbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName)); | |
| 256 | - } | |
| 257 | - | |
| 258 | - @Override | |
| 259 | - public Row createSheetRow(Sheet sheet, int rowIndex) { | |
| 260 | - HSSFSheet hssfSheet = (HSSFSheet) sheet; | |
| 261 | - return hssfSheet.createRow(rowIndex); | |
| 262 | - } | |
| 263 | - | |
| 264 | - @Override | |
| 265 | - public void writeExcel(File excelFile, Workbook workbook) { | |
| 266 | - try { | |
| 267 | - HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 268 | - FileOutputStream fileOutputStream = new FileOutputStream(excelFile); | |
| 269 | - hssfWorkbook.write(fileOutputStream); | |
| 270 | - } catch (Exception exp) { | |
| 271 | - throw new RuntimeException(exp); | |
| 272 | - } | |
| 273 | - } | |
| 274 | -} | |
| 1 | +package com.bsth.service.schedule.datatools; | |
| 2 | + | |
| 3 | +import org.apache.poi.hssf.usermodel.*; | |
| 4 | +import org.apache.poi.ss.usermodel.*; | |
| 5 | +import org.apache.poi.ss.util.WorkbookUtil; | |
| 6 | +import org.apache.poi.xssf.usermodel.XSSFColor; | |
| 7 | + | |
| 8 | +import java.awt.Color; | |
| 9 | +import java.io.File; | |
| 10 | +import java.io.FileOutputStream; | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Excel2003表格Poi操作类。 | |
| 15 | + * TODO:2003里面还有很多和2007不通的样式设定方式,以后再改 | |
| 16 | + */ | |
| 17 | +public class Excel2003PoiOperator implements ExcelPoiOperator { | |
| 18 | + @Override | |
| 19 | + public Cell createCell( | |
| 20 | + Workbook workbook, Row row, short columnIndex, | |
| 21 | + Object value, int valueType, | |
| 22 | + HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, | |
| 23 | + BorderStyle borderStyle, Color borderColor, | |
| 24 | + short fontSize, Color fontColor, String fontName, | |
| 25 | + Color backgroudColor, FillPatternType fillPatternType) { | |
| 26 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 27 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 28 | + | |
| 29 | + CreationHelper creationHelper = hssfWorkbook.getCreationHelper(); | |
| 30 | + | |
| 31 | + // 1、创建单元格对象 | |
| 32 | + HSSFCell hssfCell = hssfRow.createCell((int) columnIndex); | |
| 33 | + | |
| 34 | + // 2、设定样式 | |
| 35 | + HSSFCellStyle hssfCellStyle = hssfWorkbook.createCellStyle(); | |
| 36 | + | |
| 37 | + // 设定值及数据格式 | |
| 38 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 39 | + if (valueType == HSSFCell.CELL_TYPE_STRING) { | |
| 40 | + hssfCellStyle.setDataFormat(dataFormat.getFormat("@")); | |
| 41 | + hssfCell.setCellValue(creationHelper.createRichTextString(String.valueOf(value))); | |
| 42 | + } else if (valueType == HSSFCell.CELL_TYPE_NUMERIC) { | |
| 43 | + if (value instanceof Date) { // 日期 | |
| 44 | + hssfCellStyle.setDataFormat(dataFormat.getFormat("yyyy-mm-dd")); | |
| 45 | + hssfCell.setCellValue((Date) value); | |
| 46 | + } else if (value instanceof Double) { | |
| 47 | + hssfCellStyle.setDataFormat(dataFormat.getFormat("0.00")); | |
| 48 | + hssfCell.setCellValue((Double) value); | |
| 49 | + } else if (value instanceof Integer) { | |
| 50 | + hssfCellStyle.setDataFormat(dataFormat.getFormat("0")); | |
| 51 | + hssfCell.setCellValue(Double.valueOf(value.toString())); | |
| 52 | + } else { | |
| 53 | + throw new RuntimeException("Excel2003 只支持 String Date Double Integer 单元格类型"); | |
| 54 | + } | |
| 55 | + } else if (valueType == HSSFCell.CELL_TYPE_BLANK) { | |
| 56 | + hssfCell.setCellType(HSSFCell.CELL_TYPE_BLANK); | |
| 57 | + } else { | |
| 58 | + throw new RuntimeException("暂时不支持字符串、日期、数字以外的类型"); | |
| 59 | + } | |
| 60 | + | |
| 61 | + // 对齐方式 | |
| 62 | + hssfCellStyle.setAlignment((short) horizontalAlignment.ordinal()); | |
| 63 | + hssfCellStyle.setVerticalAlignment((short) verticalAlignment.ordinal()); | |
| 64 | + | |
| 65 | + // 边框样式 | |
| 66 | + hssfCellStyle.setBorderTop((short) borderStyle.ordinal()); | |
| 67 | + hssfCellStyle.setTopBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 68 | + hssfCellStyle.setBorderBottom((short) borderStyle.ordinal()); | |
| 69 | + hssfCellStyle.setBottomBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 70 | + hssfCellStyle.setBorderLeft((short) borderStyle.ordinal()); | |
| 71 | + hssfCellStyle.setLeftBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 72 | + hssfCellStyle.setBorderRight((short) borderStyle.ordinal()); | |
| 73 | + hssfCellStyle.setRightBorderColor(new XSSFColor(borderColor).getIndexed()); | |
| 74 | + | |
| 75 | + // 字体颜色 | |
| 76 | +// HSSFFont font = hssfWorkbook.createFont(); | |
| 77 | +// font.setColor(new XSSFColor(fontColor).getIndexed()); | |
| 78 | +// font.setFontHeightInPoints(fontSize); | |
| 79 | +// font.setFontName(fontName); | |
| 80 | +// hssfCellStyle.setFont(font); | |
| 81 | + | |
| 82 | + | |
| 83 | + // 单元背景色 | |
| 84 | + hssfCellStyle.setFillForegroundColor(new XSSFColor(backgroudColor).getIndexed()); | |
| 85 | +// hssfCellStyle.setFillPattern((short) fillPatternType.ordinal()); | |
| 86 | + | |
| 87 | + // TODO | |
| 88 | + | |
| 89 | + hssfCell.setCellStyle(hssfCellStyle); | |
| 90 | + return hssfCell; | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Override | |
| 94 | + public Cell createStringCell( | |
| 95 | + Workbook workbook, Row row, short columnIndex, | |
| 96 | + String value) { | |
| 97 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 98 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 99 | + | |
| 100 | + HSSFCell hssfCell = (HSSFCell) createCell( | |
| 101 | + hssfWorkbook, hssfRow, columnIndex, | |
| 102 | + value, HSSFCell.CELL_TYPE_STRING, | |
| 103 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 104 | + BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 105 | + (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 106 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 107 | + ); | |
| 108 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 109 | + hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 110 | + return hssfCell; | |
| 111 | + } | |
| 112 | + | |
| 113 | + @Override | |
| 114 | + public Cell createStringCell( | |
| 115 | + Workbook workbook, Row row, short columnIndex, | |
| 116 | + String value, | |
| 117 | + Color backgroudColor) { | |
| 118 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 119 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 120 | + | |
| 121 | + HSSFCell hssfCell = (HSSFCell) createCell( | |
| 122 | + hssfWorkbook, hssfRow, columnIndex, | |
| 123 | + value, HSSFCell.CELL_TYPE_STRING, | |
| 124 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 125 | + BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 126 | + (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 127 | + backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 128 | + ); | |
| 129 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 130 | + hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 131 | + return hssfCell; | |
| 132 | + } | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + public Cell createIntegerCell( | |
| 136 | + Workbook workbook, Row row, short columnIndex, | |
| 137 | + Integer value) { | |
| 138 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 139 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 140 | + | |
| 141 | + HSSFCell hssfCell = (HSSFCell) createCell( | |
| 142 | + hssfWorkbook, hssfRow, columnIndex, | |
| 143 | + value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 144 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 145 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 146 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 147 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 148 | + ); | |
| 149 | + | |
| 150 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 151 | + hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 152 | + return hssfCell; | |
| 153 | + } | |
| 154 | + | |
| 155 | + @Override | |
| 156 | + public Cell createIntegerCell( | |
| 157 | + Workbook workbook, Row row, short columnIndex, | |
| 158 | + Integer value, | |
| 159 | + Color backgroudColor) { | |
| 160 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 161 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 162 | + | |
| 163 | + HSSFCell hssfCell = (HSSFCell) createCell( | |
| 164 | + hssfWorkbook, hssfRow, columnIndex, | |
| 165 | + value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 166 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 167 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 168 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 169 | + backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 170 | + ); | |
| 171 | + | |
| 172 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 173 | + hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 174 | + return hssfCell; | |
| 175 | + } | |
| 176 | + | |
| 177 | + @Override | |
| 178 | + public Cell createDoubleCell( | |
| 179 | + Workbook workbook, Row row, short columnIndex, | |
| 180 | + Double value) { | |
| 181 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 182 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 183 | + | |
| 184 | + HSSFCell hssfCell = (HSSFCell) createCell( | |
| 185 | + hssfWorkbook, hssfRow, columnIndex, | |
| 186 | + value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 187 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 188 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 189 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 190 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 191 | + ); | |
| 192 | + | |
| 193 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 194 | + hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 195 | + return hssfCell; | |
| 196 | + } | |
| 197 | + | |
| 198 | + @Override | |
| 199 | + public Cell createDoubleCell( | |
| 200 | + Workbook workbook, Row row, short columnIndex, | |
| 201 | + Double value, | |
| 202 | + Color backgroudColor) { | |
| 203 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 204 | + HSSFRow hssfRow = (HSSFRow) row; | |
| 205 | + | |
| 206 | + HSSFCell hssfCell = (HSSFCell) createCell( | |
| 207 | + hssfWorkbook, hssfRow, columnIndex, | |
| 208 | + value, HSSFCell.CELL_TYPE_NUMERIC, | |
| 209 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 210 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 211 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 212 | + backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 213 | + ); | |
| 214 | + | |
| 215 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 216 | + hssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 217 | + return hssfCell; | |
| 218 | + } | |
| 219 | + | |
| 220 | + @Override | |
| 221 | + public Cell createBlankCell(Workbook workbook, Row row, short columnIndex) { | |
| 222 | + return createCell( | |
| 223 | + workbook, row, columnIndex, | |
| 224 | + null, HSSFCell.CELL_TYPE_BLANK, | |
| 225 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 226 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 227 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 228 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 229 | + ); | |
| 230 | + } | |
| 231 | + | |
| 232 | + @Override | |
| 233 | + public Cell setCellDataFormat(Workbook workbook, Cell cell, String fmt) { | |
| 234 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 235 | + DataFormat dataFormat = hssfWorkbook.createDataFormat(); | |
| 236 | + cell.getCellStyle().setDataFormat(dataFormat.getFormat("fmt")); | |
| 237 | + return cell; | |
| 238 | + } | |
| 239 | + | |
| 240 | + @Override | |
| 241 | + public Cell setCellBackground(Cell cell, Color color) { | |
| 242 | + HSSFCell hssfCell = (HSSFCell) cell; | |
| 243 | + hssfCell.getCellStyle().setFillForegroundColor(new XSSFColor(color).getIndexed()); | |
| 244 | + return cell; | |
| 245 | + } | |
| 246 | + | |
| 247 | + @Override | |
| 248 | + public Workbook createWorkBook() { | |
| 249 | + return new HSSFWorkbook(); | |
| 250 | + } | |
| 251 | + | |
| 252 | + @Override | |
| 253 | + public Sheet createWorkBookSheet(Workbook workbook, String sheetName) { | |
| 254 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 255 | + return hssfWorkbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName)); | |
| 256 | + } | |
| 257 | + | |
| 258 | + @Override | |
| 259 | + public Row createSheetRow(Sheet sheet, int rowIndex) { | |
| 260 | + HSSFSheet hssfSheet = (HSSFSheet) sheet; | |
| 261 | + return hssfSheet.createRow(rowIndex); | |
| 262 | + } | |
| 263 | + | |
| 264 | + @Override | |
| 265 | + public void writeExcel(File excelFile, Workbook workbook) { | |
| 266 | + try { | |
| 267 | + HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; | |
| 268 | + FileOutputStream fileOutputStream = new FileOutputStream(excelFile); | |
| 269 | + hssfWorkbook.write(fileOutputStream); | |
| 270 | + } catch (Exception exp) { | |
| 271 | + throw new RuntimeException(exp); | |
| 272 | + } | |
| 273 | + } | |
| 274 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/datatools/Excel2007PoiOperator.java
| 1 | -package com.bsth.service.schedule.datatools; | |
| 2 | - | |
| 3 | -import org.apache.poi.ss.usermodel.*; | |
| 4 | -import org.apache.poi.ss.util.WorkbookUtil; | |
| 5 | -import org.apache.poi.xssf.usermodel.*; | |
| 6 | - | |
| 7 | -import java.awt.Color; | |
| 8 | -import java.io.File; | |
| 9 | -import java.io.FileOutputStream; | |
| 10 | -import java.util.Date; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Excel2007表格Poi操作类。 | |
| 14 | - * TODO:以后测style需要重用 | |
| 15 | - */ | |
| 16 | -public class Excel2007PoiOperator implements ExcelPoiOperator { | |
| 17 | - @Override | |
| 18 | - public Cell createCell( | |
| 19 | - Workbook workbook, Row row, short columnIndex, | |
| 20 | - Object value, int valueType, | |
| 21 | - HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, | |
| 22 | - BorderStyle borderStyle, java.awt.Color borderColor, | |
| 23 | - short fontSize, java.awt.Color fontColor, String fontName, | |
| 24 | - java.awt.Color backgroudColor, FillPatternType fillPatternType) { | |
| 25 | - | |
| 26 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 27 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 28 | - | |
| 29 | - CreationHelper creationHelper = xssfWorkbook.getCreationHelper(); | |
| 30 | - | |
| 31 | - // 1、创建单元格对象 | |
| 32 | - XSSFCell xssfCell = xssfRow.createCell(columnIndex); | |
| 33 | - | |
| 34 | - // 2、设定样式 | |
| 35 | - XSSFCellStyle xssfCellStyle = xssfWorkbook.createCellStyle(); | |
| 36 | - | |
| 37 | - // 设定值及数据格式 | |
| 38 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 39 | - if (valueType == XSSFCell.CELL_TYPE_STRING) { | |
| 40 | - xssfCellStyle.setDataFormat(dataFormat.getFormat("@")); | |
| 41 | - xssfCell.setCellValue(creationHelper.createRichTextString(String.valueOf(value))); | |
| 42 | - } else if (valueType == XSSFCell.CELL_TYPE_NUMERIC) { | |
| 43 | - if (value instanceof Date) { // 日期 | |
| 44 | - xssfCellStyle.setDataFormat(dataFormat.getFormat("yyyy-mm-dd")); | |
| 45 | - xssfCell.setCellValue((Date) value); | |
| 46 | - } else if (value instanceof Double) { | |
| 47 | - xssfCellStyle.setDataFormat(dataFormat.getFormat("0.00")); | |
| 48 | - xssfCell.setCellValue((Double) value); | |
| 49 | - } else if (value instanceof Integer) { | |
| 50 | - xssfCellStyle.setDataFormat(dataFormat.getFormat("0")); | |
| 51 | - xssfCell.setCellValue(Double.valueOf(value.toString())); | |
| 52 | - } else { | |
| 53 | - throw new RuntimeException("Excel2007 只支持 String Date Double Integer 单元格类型"); | |
| 54 | - } | |
| 55 | - } else if (valueType == XSSFCell.CELL_TYPE_BLANK) { | |
| 56 | - xssfCell.setCellType(Cell.CELL_TYPE_BLANK); | |
| 57 | - } else { | |
| 58 | - throw new RuntimeException("暂时不支持字符串、日期、数字以外的类型"); | |
| 59 | - } | |
| 60 | - | |
| 61 | - // 对齐方式 | |
| 62 | - xssfCellStyle.setAlignment(horizontalAlignment); | |
| 63 | - xssfCellStyle.setVerticalAlignment(verticalAlignment); | |
| 64 | - | |
| 65 | - // 边框样式 | |
| 66 | - xssfCellStyle.setBorderTop(borderStyle); | |
| 67 | - xssfCellStyle.setTopBorderColor(new XSSFColor(borderColor)); | |
| 68 | - xssfCellStyle.setBorderBottom(borderStyle); | |
| 69 | - xssfCellStyle.setBottomBorderColor(new XSSFColor(borderColor)); | |
| 70 | - xssfCellStyle.setBorderLeft(borderStyle); | |
| 71 | - xssfCellStyle.setLeftBorderColor(new XSSFColor(borderColor)); | |
| 72 | - xssfCellStyle.setBorderRight(borderStyle); | |
| 73 | - xssfCellStyle.setRightBorderColor(new XSSFColor(borderColor)); | |
| 74 | - | |
| 75 | - // 字体颜色 | |
| 76 | - XSSFFont font = xssfWorkbook.createFont(); | |
| 77 | - font.setColor(new XSSFColor(fontColor)); | |
| 78 | - font.setFontHeightInPoints(fontSize); | |
| 79 | - font.setFontName(fontName); | |
| 80 | - xssfCellStyle.setFont(font); | |
| 81 | - | |
| 82 | - | |
| 83 | - // 单元背景色 | |
| 84 | - xssfCellStyle.setFillForegroundColor(new XSSFColor(backgroudColor)); | |
| 85 | - xssfCellStyle.setFillPattern(fillPatternType); | |
| 86 | - | |
| 87 | - // TODO | |
| 88 | - | |
| 89 | - xssfCell.setCellStyle(xssfCellStyle); | |
| 90 | - return xssfCell; | |
| 91 | - } | |
| 92 | - | |
| 93 | - @Override | |
| 94 | - public Cell createStringCell( | |
| 95 | - Workbook workbook, Row row, short columnIndex, | |
| 96 | - String value) { | |
| 97 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 98 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 99 | - | |
| 100 | - XSSFCell xssfCell = (XSSFCell) createCell( | |
| 101 | - xssfWorkbook, xssfRow, columnIndex, | |
| 102 | - value, XSSFCell.CELL_TYPE_STRING, | |
| 103 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 104 | - BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 105 | - (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 106 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 107 | - ); | |
| 108 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 109 | - xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 110 | - return xssfCell; | |
| 111 | - } | |
| 112 | - | |
| 113 | - @Override | |
| 114 | - public Cell createStringCell( | |
| 115 | - Workbook workbook, Row row, short columnIndex, | |
| 116 | - String value, | |
| 117 | - Color backgroudColor) { | |
| 118 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 119 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 120 | - | |
| 121 | - XSSFCell xssfCell = (XSSFCell) createCell( | |
| 122 | - xssfWorkbook, xssfRow, columnIndex, | |
| 123 | - value, XSSFCell.CELL_TYPE_STRING, | |
| 124 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 125 | - BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 126 | - (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 127 | - backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 128 | - ); | |
| 129 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 130 | - xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 131 | - return xssfCell; | |
| 132 | - } | |
| 133 | - | |
| 134 | - @Override | |
| 135 | - public Cell createIntegerCell( | |
| 136 | - Workbook workbook, Row row, short columnIndex, | |
| 137 | - Integer value) { | |
| 138 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 139 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 140 | - | |
| 141 | - XSSFCell xssfCell = (XSSFCell) createCell( | |
| 142 | - xssfWorkbook, xssfRow, columnIndex, | |
| 143 | - value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 144 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 145 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 146 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 147 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 148 | - ); | |
| 149 | - | |
| 150 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 151 | - xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 152 | - return xssfCell; | |
| 153 | - } | |
| 154 | - | |
| 155 | - @Override | |
| 156 | - public Cell createIntegerCell( | |
| 157 | - Workbook workbook, Row row, short columnIndex, | |
| 158 | - Integer value, | |
| 159 | - Color backgroudColor) { | |
| 160 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 161 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 162 | - | |
| 163 | - XSSFCell xssfCell = (XSSFCell) createCell( | |
| 164 | - xssfWorkbook, xssfRow, columnIndex, | |
| 165 | - value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 166 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 167 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 168 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 169 | - backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 170 | - ); | |
| 171 | - | |
| 172 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 173 | - xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 174 | - return xssfCell; | |
| 175 | - } | |
| 176 | - | |
| 177 | - @Override | |
| 178 | - public Cell createDoubleCell( | |
| 179 | - Workbook workbook, Row row, short columnIndex, | |
| 180 | - Double value) { | |
| 181 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 182 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 183 | - | |
| 184 | - XSSFCell xssfCell = (XSSFCell) createCell( | |
| 185 | - xssfWorkbook, xssfRow, columnIndex, | |
| 186 | - value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 187 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 188 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 189 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 190 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 191 | - ); | |
| 192 | - | |
| 193 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 194 | - xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 195 | - return xssfCell; | |
| 196 | - } | |
| 197 | - | |
| 198 | - @Override | |
| 199 | - public Cell createDoubleCell( | |
| 200 | - Workbook workbook, Row row, short columnIndex, | |
| 201 | - Double value, | |
| 202 | - Color backgroudColor) { | |
| 203 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 204 | - XSSFRow xssfRow = (XSSFRow) row; | |
| 205 | - | |
| 206 | - XSSFCell xssfCell = (XSSFCell) createCell( | |
| 207 | - xssfWorkbook, xssfRow, columnIndex, | |
| 208 | - value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 209 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 210 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 211 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 212 | - backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 213 | - ); | |
| 214 | - | |
| 215 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 216 | - xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 217 | - return xssfCell; | |
| 218 | - } | |
| 219 | - | |
| 220 | - @Override | |
| 221 | - public Cell createBlankCell( | |
| 222 | - Workbook workbook, Row row, short columnIndex) { | |
| 223 | - return createCell( | |
| 224 | - workbook, row, columnIndex, | |
| 225 | - null, XSSFCell.CELL_TYPE_BLANK, | |
| 226 | - HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 227 | - BorderStyle.MEDIUM, new Color(0xdedede), | |
| 228 | - (short) 13, new Color(0x2765A7), "宋体", | |
| 229 | - new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 230 | - ); | |
| 231 | - } | |
| 232 | - | |
| 233 | - @Override | |
| 234 | - public Cell setCellDataFormat(Workbook workbook, Cell cell, String fmt) { | |
| 235 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 236 | - DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 237 | - cell.getCellStyle().setDataFormat(dataFormat.getFormat(fmt)); | |
| 238 | - return cell; | |
| 239 | - } | |
| 240 | - | |
| 241 | - @Override | |
| 242 | - public Cell setCellBackground(Cell cell, Color color) { | |
| 243 | - XSSFCell xssfCell = (XSSFCell) cell; | |
| 244 | - xssfCell.getCellStyle().setFillForegroundColor(new XSSFColor(color)); | |
| 245 | - return cell; | |
| 246 | - } | |
| 247 | - | |
| 248 | - @Override | |
| 249 | - public Workbook createWorkBook() { | |
| 250 | - return new XSSFWorkbook(); | |
| 251 | - } | |
| 252 | - | |
| 253 | - @Override | |
| 254 | - public Sheet createWorkBookSheet(Workbook workbook, String sheetName) { | |
| 255 | - return workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName)); | |
| 256 | - } | |
| 257 | - | |
| 258 | - @Override | |
| 259 | - public Row createSheetRow(Sheet sheet, int rowIndex) { | |
| 260 | - XSSFSheet xssfSheet = (XSSFSheet) sheet; | |
| 261 | - return xssfSheet.createRow(rowIndex); | |
| 262 | - } | |
| 263 | - | |
| 264 | - @Override | |
| 265 | - public void writeExcel(File excelFile, Workbook workbook) { | |
| 266 | - try { | |
| 267 | - XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 268 | - FileOutputStream fileOutputStream = new FileOutputStream(excelFile); | |
| 269 | - xssfWorkbook.write(fileOutputStream); | |
| 270 | - } catch (Exception exp) { | |
| 271 | - throw new RuntimeException(exp); | |
| 272 | - } | |
| 273 | - | |
| 274 | - } | |
| 275 | -} | |
| 1 | +package com.bsth.service.schedule.datatools; | |
| 2 | + | |
| 3 | +import org.apache.poi.ss.usermodel.*; | |
| 4 | +import org.apache.poi.ss.util.WorkbookUtil; | |
| 5 | +import org.apache.poi.xssf.usermodel.*; | |
| 6 | + | |
| 7 | +import java.awt.Color; | |
| 8 | +import java.io.File; | |
| 9 | +import java.io.FileOutputStream; | |
| 10 | +import java.util.Date; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Excel2007表格Poi操作类。 | |
| 14 | + * TODO:以后测style需要重用 | |
| 15 | + */ | |
| 16 | +public class Excel2007PoiOperator implements ExcelPoiOperator { | |
| 17 | + @Override | |
| 18 | + public Cell createCell( | |
| 19 | + Workbook workbook, Row row, short columnIndex, | |
| 20 | + Object value, int valueType, | |
| 21 | + HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, | |
| 22 | + BorderStyle borderStyle, java.awt.Color borderColor, | |
| 23 | + short fontSize, java.awt.Color fontColor, String fontName, | |
| 24 | + java.awt.Color backgroudColor, FillPatternType fillPatternType) { | |
| 25 | + | |
| 26 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 27 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 28 | + | |
| 29 | + CreationHelper creationHelper = xssfWorkbook.getCreationHelper(); | |
| 30 | + | |
| 31 | + // 1、创建单元格对象 | |
| 32 | + XSSFCell xssfCell = xssfRow.createCell(columnIndex); | |
| 33 | + | |
| 34 | + // 2、设定样式 | |
| 35 | + XSSFCellStyle xssfCellStyle = xssfWorkbook.createCellStyle(); | |
| 36 | + | |
| 37 | + // 设定值及数据格式 | |
| 38 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 39 | + if (valueType == XSSFCell.CELL_TYPE_STRING) { | |
| 40 | + xssfCellStyle.setDataFormat(dataFormat.getFormat("@")); | |
| 41 | + xssfCell.setCellValue(creationHelper.createRichTextString(String.valueOf(value))); | |
| 42 | + } else if (valueType == XSSFCell.CELL_TYPE_NUMERIC) { | |
| 43 | + if (value instanceof Date) { // 日期 | |
| 44 | + xssfCellStyle.setDataFormat(dataFormat.getFormat("yyyy-mm-dd")); | |
| 45 | + xssfCell.setCellValue((Date) value); | |
| 46 | + } else if (value instanceof Double) { | |
| 47 | + xssfCellStyle.setDataFormat(dataFormat.getFormat("0.00")); | |
| 48 | + xssfCell.setCellValue((Double) value); | |
| 49 | + } else if (value instanceof Integer) { | |
| 50 | + xssfCellStyle.setDataFormat(dataFormat.getFormat("0")); | |
| 51 | + xssfCell.setCellValue(Double.valueOf(value.toString())); | |
| 52 | + } else { | |
| 53 | + throw new RuntimeException("Excel2007 只支持 String Date Double Integer 单元格类型"); | |
| 54 | + } | |
| 55 | + } else if (valueType == XSSFCell.CELL_TYPE_BLANK) { | |
| 56 | + xssfCell.setCellType(Cell.CELL_TYPE_BLANK); | |
| 57 | + } else { | |
| 58 | + throw new RuntimeException("暂时不支持字符串、日期、数字以外的类型"); | |
| 59 | + } | |
| 60 | + | |
| 61 | + // 对齐方式 | |
| 62 | + xssfCellStyle.setAlignment(horizontalAlignment); | |
| 63 | + xssfCellStyle.setVerticalAlignment(verticalAlignment); | |
| 64 | + | |
| 65 | + // 边框样式 | |
| 66 | + xssfCellStyle.setBorderTop(borderStyle); | |
| 67 | + xssfCellStyle.setTopBorderColor(new XSSFColor(borderColor)); | |
| 68 | + xssfCellStyle.setBorderBottom(borderStyle); | |
| 69 | + xssfCellStyle.setBottomBorderColor(new XSSFColor(borderColor)); | |
| 70 | + xssfCellStyle.setBorderLeft(borderStyle); | |
| 71 | + xssfCellStyle.setLeftBorderColor(new XSSFColor(borderColor)); | |
| 72 | + xssfCellStyle.setBorderRight(borderStyle); | |
| 73 | + xssfCellStyle.setRightBorderColor(new XSSFColor(borderColor)); | |
| 74 | + | |
| 75 | + // 字体颜色 | |
| 76 | + XSSFFont font = xssfWorkbook.createFont(); | |
| 77 | + font.setColor(new XSSFColor(fontColor)); | |
| 78 | + font.setFontHeightInPoints(fontSize); | |
| 79 | + font.setFontName(fontName); | |
| 80 | + xssfCellStyle.setFont(font); | |
| 81 | + | |
| 82 | + | |
| 83 | + // 单元背景色 | |
| 84 | + xssfCellStyle.setFillForegroundColor(new XSSFColor(backgroudColor)); | |
| 85 | + xssfCellStyle.setFillPattern(fillPatternType); | |
| 86 | + | |
| 87 | + // TODO | |
| 88 | + | |
| 89 | + xssfCell.setCellStyle(xssfCellStyle); | |
| 90 | + return xssfCell; | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Override | |
| 94 | + public Cell createStringCell( | |
| 95 | + Workbook workbook, Row row, short columnIndex, | |
| 96 | + String value) { | |
| 97 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 98 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 99 | + | |
| 100 | + XSSFCell xssfCell = (XSSFCell) createCell( | |
| 101 | + xssfWorkbook, xssfRow, columnIndex, | |
| 102 | + value, XSSFCell.CELL_TYPE_STRING, | |
| 103 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 104 | + BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 105 | + (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 106 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 107 | + ); | |
| 108 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 109 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 110 | + return xssfCell; | |
| 111 | + } | |
| 112 | + | |
| 113 | + @Override | |
| 114 | + public Cell createStringCell( | |
| 115 | + Workbook workbook, Row row, short columnIndex, | |
| 116 | + String value, | |
| 117 | + Color backgroudColor) { | |
| 118 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 119 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 120 | + | |
| 121 | + XSSFCell xssfCell = (XSSFCell) createCell( | |
| 122 | + xssfWorkbook, xssfRow, columnIndex, | |
| 123 | + value, XSSFCell.CELL_TYPE_STRING, | |
| 124 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 125 | + BorderStyle.MEDIUM, new java.awt.Color(0xdedede), | |
| 126 | + (short) 13, new java.awt.Color(0x2765A7), "宋体", | |
| 127 | + backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 128 | + ); | |
| 129 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 130 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@")); | |
| 131 | + return xssfCell; | |
| 132 | + } | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + public Cell createIntegerCell( | |
| 136 | + Workbook workbook, Row row, short columnIndex, | |
| 137 | + Integer value) { | |
| 138 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 139 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 140 | + | |
| 141 | + XSSFCell xssfCell = (XSSFCell) createCell( | |
| 142 | + xssfWorkbook, xssfRow, columnIndex, | |
| 143 | + value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 144 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 145 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 146 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 147 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 148 | + ); | |
| 149 | + | |
| 150 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 151 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 152 | + return xssfCell; | |
| 153 | + } | |
| 154 | + | |
| 155 | + @Override | |
| 156 | + public Cell createIntegerCell( | |
| 157 | + Workbook workbook, Row row, short columnIndex, | |
| 158 | + Integer value, | |
| 159 | + Color backgroudColor) { | |
| 160 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 161 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 162 | + | |
| 163 | + XSSFCell xssfCell = (XSSFCell) createCell( | |
| 164 | + xssfWorkbook, xssfRow, columnIndex, | |
| 165 | + value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 166 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 167 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 168 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 169 | + backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 170 | + ); | |
| 171 | + | |
| 172 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 173 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0")); | |
| 174 | + return xssfCell; | |
| 175 | + } | |
| 176 | + | |
| 177 | + @Override | |
| 178 | + public Cell createDoubleCell( | |
| 179 | + Workbook workbook, Row row, short columnIndex, | |
| 180 | + Double value) { | |
| 181 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 182 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 183 | + | |
| 184 | + XSSFCell xssfCell = (XSSFCell) createCell( | |
| 185 | + xssfWorkbook, xssfRow, columnIndex, | |
| 186 | + value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 187 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 188 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 189 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 190 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 191 | + ); | |
| 192 | + | |
| 193 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 194 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 195 | + return xssfCell; | |
| 196 | + } | |
| 197 | + | |
| 198 | + @Override | |
| 199 | + public Cell createDoubleCell( | |
| 200 | + Workbook workbook, Row row, short columnIndex, | |
| 201 | + Double value, | |
| 202 | + Color backgroudColor) { | |
| 203 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 204 | + XSSFRow xssfRow = (XSSFRow) row; | |
| 205 | + | |
| 206 | + XSSFCell xssfCell = (XSSFCell) createCell( | |
| 207 | + xssfWorkbook, xssfRow, columnIndex, | |
| 208 | + value, XSSFCell.CELL_TYPE_NUMERIC, | |
| 209 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 210 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 211 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 212 | + backgroudColor, FillPatternType.SOLID_FOREGROUND | |
| 213 | + ); | |
| 214 | + | |
| 215 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 216 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 217 | + return xssfCell; | |
| 218 | + } | |
| 219 | + | |
| 220 | + @Override | |
| 221 | + public Cell createBlankCell( | |
| 222 | + Workbook workbook, Row row, short columnIndex) { | |
| 223 | + return createCell( | |
| 224 | + workbook, row, columnIndex, | |
| 225 | + null, XSSFCell.CELL_TYPE_BLANK, | |
| 226 | + HorizontalAlignment.CENTER, VerticalAlignment.CENTER, | |
| 227 | + BorderStyle.MEDIUM, new Color(0xdedede), | |
| 228 | + (short) 13, new Color(0x2765A7), "宋体", | |
| 229 | + new Color(0xffffff), FillPatternType.SOLID_FOREGROUND | |
| 230 | + ); | |
| 231 | + } | |
| 232 | + | |
| 233 | + @Override | |
| 234 | + public Cell setCellDataFormat(Workbook workbook, Cell cell, String fmt) { | |
| 235 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 236 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 237 | + cell.getCellStyle().setDataFormat(dataFormat.getFormat(fmt)); | |
| 238 | + return cell; | |
| 239 | + } | |
| 240 | + | |
| 241 | + @Override | |
| 242 | + public Cell setCellBackground(Cell cell, Color color) { | |
| 243 | + XSSFCell xssfCell = (XSSFCell) cell; | |
| 244 | + xssfCell.getCellStyle().setFillForegroundColor(new XSSFColor(color)); | |
| 245 | + return cell; | |
| 246 | + } | |
| 247 | + | |
| 248 | + @Override | |
| 249 | + public Workbook createWorkBook() { | |
| 250 | + return new XSSFWorkbook(); | |
| 251 | + } | |
| 252 | + | |
| 253 | + @Override | |
| 254 | + public Sheet createWorkBookSheet(Workbook workbook, String sheetName) { | |
| 255 | + return workbook.createSheet(WorkbookUtil.createSafeSheetName(sheetName)); | |
| 256 | + } | |
| 257 | + | |
| 258 | + @Override | |
| 259 | + public Row createSheetRow(Sheet sheet, int rowIndex) { | |
| 260 | + XSSFSheet xssfSheet = (XSSFSheet) sheet; | |
| 261 | + return xssfSheet.createRow(rowIndex); | |
| 262 | + } | |
| 263 | + | |
| 264 | + @Override | |
| 265 | + public void writeExcel(File excelFile, Workbook workbook) { | |
| 266 | + try { | |
| 267 | + XSSFWorkbook xssfWorkbook = (XSSFWorkbook) workbook; | |
| 268 | + FileOutputStream fileOutputStream = new FileOutputStream(excelFile); | |
| 269 | + xssfWorkbook.write(fileOutputStream); | |
| 270 | + } catch (Exception exp) { | |
| 271 | + throw new RuntimeException(exp); | |
| 272 | + } | |
| 273 | + | |
| 274 | + } | |
| 275 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/datatools/ExcelPoiOperator.java
| 1 | -package com.bsth.service.schedule.datatools; | |
| 2 | - | |
| 3 | -import org.apache.poi.ss.usermodel.*; | |
| 4 | - | |
| 5 | -import java.awt.Color; | |
| 6 | -import java.io.File; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * Excel表格Poi操作接口。 | |
| 10 | - */ | |
| 11 | -public interface ExcelPoiOperator { | |
| 12 | - | |
| 13 | - | |
| 14 | - //---------------- 创建单元格 ---------------// | |
| 15 | - | |
| 16 | - Cell createCell( | |
| 17 | - Workbook workbook, Row row, short columnIndex, | |
| 18 | - Object value, int valueType, | |
| 19 | - HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, | |
| 20 | - BorderStyle borderStyle, java.awt.Color borderColor, | |
| 21 | - short fontSize, java.awt.Color fontColor, String fontName, | |
| 22 | - java.awt.Color backgroudColor, FillPatternType fillPatternType | |
| 23 | - ); | |
| 24 | - | |
| 25 | - Cell createStringCell( | |
| 26 | - Workbook workbook, Row row, short columnIndex, | |
| 27 | - String value | |
| 28 | - ); | |
| 29 | - | |
| 30 | - Cell createStringCell( | |
| 31 | - Workbook workbook, Row row, short columnIndex, | |
| 32 | - String value, | |
| 33 | - java.awt.Color backgroudColor | |
| 34 | - ); | |
| 35 | - | |
| 36 | - Cell createIntegerCell( | |
| 37 | - Workbook workbook, Row row, short columnIndex, | |
| 38 | - Integer value | |
| 39 | - ); | |
| 40 | - | |
| 41 | - Cell createIntegerCell( | |
| 42 | - Workbook workbook, Row row, short columnIndex, | |
| 43 | - Integer value, | |
| 44 | - java.awt.Color backgroudColor | |
| 45 | - ); | |
| 46 | - | |
| 47 | - Cell createDoubleCell( | |
| 48 | - Workbook workbook, Row row, short columnIndex, | |
| 49 | - Double value | |
| 50 | - ); | |
| 51 | - | |
| 52 | - Cell createDoubleCell( | |
| 53 | - Workbook workbook, Row row, short columnIndex, | |
| 54 | - Double value, | |
| 55 | - java.awt.Color backgroudColor | |
| 56 | - ); | |
| 57 | - | |
| 58 | - Cell createBlankCell( | |
| 59 | - Workbook workbook, Row row, short columnIndex | |
| 60 | - ); | |
| 61 | - | |
| 62 | - //---------------- 创建单元格数据格式 ---------------// | |
| 63 | - | |
| 64 | - Cell setCellDataFormat(Workbook workbook, Cell cell, String fmt); | |
| 65 | - | |
| 66 | - Cell setCellBackground(Cell cell, Color color); | |
| 67 | - | |
| 68 | - //---------------- 创建workbook,sheet,row ---------------// | |
| 69 | - Workbook createWorkBook(); | |
| 70 | - Sheet createWorkBookSheet(Workbook workbook, String sheetName); | |
| 71 | - Row createSheetRow(Sheet sheet, int rowIndex); | |
| 72 | - | |
| 73 | - //---------------- 生成文件 ---------------// | |
| 74 | - void writeExcel(File excelFile, Workbook workbook); | |
| 75 | -} | |
| 1 | +package com.bsth.service.schedule.datatools; | |
| 2 | + | |
| 3 | +import org.apache.poi.ss.usermodel.*; | |
| 4 | + | |
| 5 | +import java.awt.Color; | |
| 6 | +import java.io.File; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Excel表格Poi操作接口。 | |
| 10 | + */ | |
| 11 | +public interface ExcelPoiOperator { | |
| 12 | + | |
| 13 | + | |
| 14 | + //---------------- 创建单元格 ---------------// | |
| 15 | + | |
| 16 | + Cell createCell( | |
| 17 | + Workbook workbook, Row row, short columnIndex, | |
| 18 | + Object value, int valueType, | |
| 19 | + HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, | |
| 20 | + BorderStyle borderStyle, java.awt.Color borderColor, | |
| 21 | + short fontSize, java.awt.Color fontColor, String fontName, | |
| 22 | + java.awt.Color backgroudColor, FillPatternType fillPatternType | |
| 23 | + ); | |
| 24 | + | |
| 25 | + Cell createStringCell( | |
| 26 | + Workbook workbook, Row row, short columnIndex, | |
| 27 | + String value | |
| 28 | + ); | |
| 29 | + | |
| 30 | + Cell createStringCell( | |
| 31 | + Workbook workbook, Row row, short columnIndex, | |
| 32 | + String value, | |
| 33 | + java.awt.Color backgroudColor | |
| 34 | + ); | |
| 35 | + | |
| 36 | + Cell createIntegerCell( | |
| 37 | + Workbook workbook, Row row, short columnIndex, | |
| 38 | + Integer value | |
| 39 | + ); | |
| 40 | + | |
| 41 | + Cell createIntegerCell( | |
| 42 | + Workbook workbook, Row row, short columnIndex, | |
| 43 | + Integer value, | |
| 44 | + java.awt.Color backgroudColor | |
| 45 | + ); | |
| 46 | + | |
| 47 | + Cell createDoubleCell( | |
| 48 | + Workbook workbook, Row row, short columnIndex, | |
| 49 | + Double value | |
| 50 | + ); | |
| 51 | + | |
| 52 | + Cell createDoubleCell( | |
| 53 | + Workbook workbook, Row row, short columnIndex, | |
| 54 | + Double value, | |
| 55 | + java.awt.Color backgroudColor | |
| 56 | + ); | |
| 57 | + | |
| 58 | + Cell createBlankCell( | |
| 59 | + Workbook workbook, Row row, short columnIndex | |
| 60 | + ); | |
| 61 | + | |
| 62 | + //---------------- 创建单元格数据格式 ---------------// | |
| 63 | + | |
| 64 | + Cell setCellDataFormat(Workbook workbook, Cell cell, String fmt); | |
| 65 | + | |
| 66 | + Cell setCellBackground(Cell cell, Color color); | |
| 67 | + | |
| 68 | + //---------------- 创建workbook,sheet,row ---------------// | |
| 69 | + Workbook createWorkBook(); | |
| 70 | + Sheet createWorkBookSheet(Workbook workbook, String sheetName); | |
| 71 | + Row createSheetRow(Sheet sheet, int rowIndex); | |
| 72 | + | |
| 73 | + //---------------- 生成文件 ---------------// | |
| 74 | + void writeExcel(File excelFile, Workbook workbook); | |
| 75 | +} | ... | ... |