Commit c34e29c0cd88eef3025766d866b4485aeedf1063
1 parent
cd110d9c
1.冲突文件处理
Showing
3 changed files
with
1 additions
and
7289 deletions
src/main/java/com/bsth/filter/AccessLogFilter.java
| 1 | -<<<<<<< HEAD | |
| 2 | 1 | package com.bsth.filter; |
| 3 | 2 | |
| 4 | 3 | import com.alibaba.fastjson.JSON; |
| ... | ... | @@ -99,105 +98,3 @@ public class AccessLogFilter extends BaseFilter { |
| 99 | 98 | return "[" + msg.toString() + "]"; |
| 100 | 99 | } |
| 101 | 100 | } |
| 102 | -======= | |
| 103 | -package com.bsth.filter; | |
| 104 | - | |
| 105 | -import com.alibaba.fastjson.JSON; | |
| 106 | -import com.bsth.entity.sys.SysUser; | |
| 107 | -import com.bsth.security.util.SecurityUtils; | |
| 108 | -import com.bsth.util.IpUtils; | |
| 109 | -import com.google.common.collect.Lists; | |
| 110 | -import com.google.common.collect.Maps; | |
| 111 | -import org.slf4j.Logger; | |
| 112 | -import org.slf4j.LoggerFactory; | |
| 113 | -import org.springframework.stereotype.Component; | |
| 114 | - | |
| 115 | -import javax.servlet.FilterChain; | |
| 116 | -import javax.servlet.ServletException; | |
| 117 | -import javax.servlet.http.HttpServletRequest; | |
| 118 | -import javax.servlet.http.HttpServletResponse; | |
| 119 | -import java.io.IOException; | |
| 120 | -import java.util.Enumeration; | |
| 121 | -import java.util.List; | |
| 122 | -import java.util.Map; | |
| 123 | - | |
| 124 | -/** | |
| 125 | - * | |
| 126 | - * @ClassName: AccessLogFilter | |
| 127 | - * @Description: TODO(记录访问日志) | |
| 128 | - * @author PanZhao | |
| 129 | - * @date 2016年3月17日 下午4:28:31 | |
| 130 | - * | |
| 131 | - */ | |
| 132 | -@Component | |
| 133 | -public class AccessLogFilter extends BaseFilter { | |
| 134 | - | |
| 135 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 136 | - | |
| 137 | - @Override | |
| 138 | - public void doFilter(HttpServletRequest request, | |
| 139 | - HttpServletResponse response, FilterChain chain) | |
| 140 | - throws IOException, ServletException { | |
| 141 | - | |
| 142 | - SysUser user = null; | |
| 143 | - if (request.getParameter("token") != null) { | |
| 144 | - user = new SysUser(); | |
| 145 | - user.setUserName("admin"); | |
| 146 | - } else { | |
| 147 | - user = SecurityUtils.getCurrentUser(); | |
| 148 | - } | |
| 149 | - String username = user.getUserName(); | |
| 150 | - String name = user.getName(); | |
| 151 | - String jsessionId = request.getRequestedSessionId(); | |
| 152 | - String ip = IpUtils.getIpAddr(request); | |
| 153 | - String userAgent = request.getHeader("User-Agent"); | |
| 154 | - String url = request.getRequestURI(); | |
| 155 | - String params = getParams(request); | |
| 156 | - String headers = getHeaders(request); | |
| 157 | - String method = request.getMethod(); | |
| 158 | - | |
| 159 | - StringBuilder s = new StringBuilder(); | |
| 160 | - s.append(getBlock(username + " -" + name)); | |
| 161 | - s.append(getBlock(jsessionId)); | |
| 162 | - s.append(getBlock(ip)); | |
| 163 | - s.append(getBlock(userAgent)); | |
| 164 | - s.append(getBlock(url)); | |
| 165 | - s.append(getBlock(method)); | |
| 166 | - s.append(getBlock(params)); | |
| 167 | - s.append(getBlock(headers)); | |
| 168 | - s.append(getBlock(request.getHeader("Referer"))); | |
| 169 | - | |
| 170 | - long now = System.currentTimeMillis(); | |
| 171 | - chain.doFilter(request, response); | |
| 172 | - s.append("<cost time:").append(System.currentTimeMillis() - now).append(">"); | |
| 173 | - logger.info(s.toString()); | |
| 174 | - } | |
| 175 | - | |
| 176 | - private static String getParams(HttpServletRequest request) { | |
| 177 | - Map<String, String[]> params = request.getParameterMap(); | |
| 178 | - return JSON.toJSONString(params); | |
| 179 | - } | |
| 180 | - | |
| 181 | - private static String getHeaders(HttpServletRequest request) { | |
| 182 | - Map<String, List<String>> headers = Maps.newHashMap(); | |
| 183 | - Enumeration<String> namesEnumeration = request.getHeaderNames(); | |
| 184 | - while (namesEnumeration.hasMoreElements()) { | |
| 185 | - String name = namesEnumeration.nextElement(); | |
| 186 | - Enumeration<String> valueEnumeration = request.getHeaders(name); | |
| 187 | - List<String> values = Lists.newArrayList(); | |
| 188 | - while (valueEnumeration.hasMoreElements()) { | |
| 189 | - values.add(valueEnumeration.nextElement()); | |
| 190 | - } | |
| 191 | - headers.put(name, values); | |
| 192 | - } | |
| 193 | - return JSON.toJSONString(headers); | |
| 194 | - } | |
| 195 | - | |
| 196 | - public static String getBlock(Object msg) { | |
| 197 | - if (msg == null) { | |
| 198 | - msg = ""; | |
| 199 | - } | |
| 200 | - return "[" + msg.toString() + "]"; | |
| 201 | - } | |
| 202 | -} | |
| 203 | ->>>>>>> 2021.05.11 历史版本 选择版本 查看历史版本修改当前版本和待更新版本 | ... | ... |
src/main/java/com/bsth/service/oil/impl/CwjyServiceImpl.java
| 1 | -<<<<<<< HEAD | |
| 2 | -package com.bsth.service.oil.impl; | |
| 3 | - | |
| 4 | -import java.io.File; | |
| 5 | -import java.io.FileInputStream; | |
| 6 | -import java.sql.ResultSet; | |
| 7 | -import java.sql.SQLException; | |
| 8 | -import java.text.DecimalFormat; | |
| 9 | -import java.text.ParseException; | |
| 10 | -import java.text.SimpleDateFormat; | |
| 11 | -import java.util.ArrayList; | |
| 12 | -import java.util.Arrays; | |
| 13 | -import java.util.Date; | |
| 14 | -import java.util.HashMap; | |
| 15 | -import java.util.List; | |
| 16 | -import java.util.Map; | |
| 17 | - | |
| 18 | -import javax.transaction.Transactional; | |
| 19 | - | |
| 20 | -import org.apache.commons.lang3.StringEscapeUtils; | |
| 21 | -import org.apache.poi.hssf.usermodel.HSSFCell; | |
| 22 | -import org.apache.poi.hssf.usermodel.HSSFRow; | |
| 23 | -import org.apache.poi.hssf.usermodel.HSSFSheet; | |
| 24 | -import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |
| 25 | -import org.apache.poi.poifs.filesystem.POIFSFileSystem; | |
| 26 | -import org.apache.poi.ss.usermodel.Cell; | |
| 27 | -import org.slf4j.Logger; | |
| 28 | -import org.slf4j.LoggerFactory; | |
| 29 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 30 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 31 | -import org.springframework.jdbc.core.RowMapper; | |
| 32 | -import org.springframework.stereotype.Service; | |
| 33 | - | |
| 34 | -import com.alibaba.fastjson.JSONArray; | |
| 35 | -import com.alibaba.fastjson.JSONObject; | |
| 36 | -import com.bsth.common.ResponseCode; | |
| 37 | -import com.bsth.data.BasicData; | |
| 38 | -import com.bsth.entity.oil.Cwjy; | |
| 39 | -import com.bsth.entity.oil.Cyl; | |
| 40 | -import com.bsth.entity.oil.Ylb; | |
| 41 | -import com.bsth.entity.oil.Ylxxb; | |
| 42 | -import com.bsth.repository.oil.CwjyRepository; | |
| 43 | -import com.bsth.repository.oil.YlxxbRepository; | |
| 44 | -import com.bsth.service.impl.BaseServiceImpl; | |
| 45 | -import com.bsth.service.oil.CwjyService; | |
| 46 | -import com.bsth.util.Arith; | |
| 47 | -import com.bsth.util.PageHelper; | |
| 48 | -import com.bsth.util.PageObject; | |
| 49 | - | |
| 50 | -@Service | |
| 51 | -public class CwjyServiceImpl extends BaseServiceImpl<Cwjy,Integer> implements CwjyService | |
| 52 | -{ | |
| 53 | - @Autowired | |
| 54 | - CwjyRepository repository; | |
| 55 | - @Autowired | |
| 56 | - YlxxbRepository ylxxbRepository; | |
| 57 | - | |
| 58 | - @Autowired | |
| 59 | - JdbcTemplate jdbcTemplate; | |
| 60 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 61 | - /*@SuppressWarnings("unchecked") | |
| 62 | - public PageObject<Ylxxb> Pagequery(Map<String, Object> map) { | |
| 63 | - int page=Integer.parseInt(map.get("page").toString()); | |
| 64 | - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); | |
| 65 | - | |
| 66 | - String rq=map.get("rq").toString(); | |
| 67 | - String nbbm=""; | |
| 68 | - if(map.get("nbbh")!=null){ | |
| 69 | - nbbm=map.get("nbbh").toString(); | |
| 70 | - } | |
| 71 | - | |
| 72 | - Object gsdmIn=map.get("gsdm_in"); | |
| 73 | - Object fgsdmIn=map.get("fgsdm_in"); | |
| 74 | - String addSql=""; | |
| 75 | - String gsdmLike=""; | |
| 76 | - String fgsdmLike=""; | |
| 77 | - | |
| 78 | - //选择了公司 | |
| 79 | - if(gsdmIn==null){ | |
| 80 | - gsdmLike=map.get("gsdm_like").toString(); | |
| 81 | - addSql += " and a.gsdm = '"+gsdmLike+ "' "; | |
| 82 | - | |
| 83 | - //选择了分公司 | |
| 84 | - if(fgsdmIn==null){ | |
| 85 | - fgsdmLike=map.get("fgsdm_like").toString();; | |
| 86 | - addSql += " and a.fgsdm = '"+fgsdmLike+ "' "; | |
| 87 | - }else{ | |
| 88 | - String fgsdmIns[]= fgsdmIn.toString().split(","); | |
| 89 | - addSql +=" and a.fgsdm in ("; | |
| 90 | - for(int i=0;i<fgsdmIns.length;i++){ | |
| 91 | - addSql +="'"+fgsdmIns[i]+"'"; | |
| 92 | - if(i<fgsdmIns.length-1){ | |
| 93 | - addSql +=","; | |
| 94 | - } | |
| 95 | - } | |
| 96 | - addSql +=")"; | |
| 97 | - } | |
| 98 | - }else{ | |
| 99 | - //没有选择公司 (分公司也没有选择) | |
| 100 | - String gsdmIns[]=gsdmIn.toString().split(","); | |
| 101 | - addSql += " and a.gsdm in ("; | |
| 102 | - for(int i=0;i<gsdmIns.length;i++){ | |
| 103 | - addSql +="'" +gsdmIns[i]+"'"; | |
| 104 | - if(i<gsdmIns.length-1){ | |
| 105 | - addSql+=","; | |
| 106 | - } | |
| 107 | - } | |
| 108 | - addSql +=")"; | |
| 109 | - String fgsdmIns[]= fgsdmIn.toString().split(","); | |
| 110 | - addSql +=" and a.fgsdm in ("; | |
| 111 | - for(int i=0;i<fgsdmIns.length;i++){ | |
| 112 | - addSql +="'"+fgsdmIns[i]+"'"; | |
| 113 | - if(i<fgsdmIns.length-1){ | |
| 114 | - addSql +=","; | |
| 115 | - } | |
| 116 | - } | |
| 117 | - addSql +=")"; | |
| 118 | - | |
| 119 | - | |
| 120 | - } | |
| 121 | - String countSql="SELECT ifnull(count(*),0) as countTs FROM bsth_c_cwjy a "+ | |
| 122 | - " left join ( select * from bsth_c_ylxxb b where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " + | |
| 123 | - " on a.nbbm=b.nbbm left join (select nbbm,group_concat(jsy) as jsy " | |
| 124 | - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+ | |
| 125 | - " ) c on a.nbbm=c.nbbm where a.nbbm like '%"+nbbm+"%' " +addSql ; | |
| 126 | - int listsize=jdbcTemplate.queryForObject(countSql, Integer.class); | |
| 127 | - // TODO Auto-generated method stub | |
| 128 | - String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm,b.jsy as jsy,b.jzl as jzl ,b.stationid as stationid," | |
| 129 | - + "b.nylx as nylx,b.yj as yj,b.bz as bz,c.jsy as ldgh FROM bsth_c_cwjy a "+ | |
| 130 | - " left join ( select * from bsth_c_ylxxb b where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " + | |
| 131 | - " on a.nbbm=b.nbbm left join (select nbbm,group_concat(jsy) as jsy " | |
| 132 | - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+ | |
| 133 | - " ) c on a.nbbm=c.nbbm where a.nbbm like '%"+nbbm+"%' " +addSql+ " limit "+page*10+","+10; | |
| 134 | - | |
| 135 | - | |
| 136 | - List<Ylxxb> yList= jdbcTemplate.query(sql, | |
| 137 | - new RowMapper<Ylxxb>(){ | |
| 138 | - @Override | |
| 139 | - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 140 | - Ylxxb t=new Ylxxb(); | |
| 141 | - t.setGsdm(rs.getString("gsdm")); | |
| 142 | - t.setFgsdm(rs.getString("fgsdm")); | |
| 143 | - t.setNbbm(rs.getString("nbbm")); | |
| 144 | - t.setJsy(rs.getString("jsy")); | |
| 145 | - t.setJzl(rs.getDouble("jzl")); | |
| 146 | - t.setStationid(rs.getString("stationid")); | |
| 147 | - t.setNylx(rs.getInt("nylx")); | |
| 148 | - t.setYj(rs.getDouble("yj")); | |
| 149 | - t.setBz(rs.getString("bz")); | |
| 150 | - t.setLdgh(rs.getString("ldgh")); | |
| 151 | - return t; | |
| 152 | - } | |
| 153 | - }); | |
| 154 | - List<Object[]> list=repository.obtainCwjycl(rq,nbbm); | |
| 155 | - for (int i = 0; i < list.size(); i++) { | |
| 156 | - Ylxxb y=new Ylxxb(); | |
| 157 | - y.setGsdm(list.get(i)[0]==null?"":list.get(i)[0].toString()); | |
| 158 | - y.setNbbm(list.get(i)[1]==null?"":list.get(i)[1].toString()); | |
| 159 | - y.setJsy(list.get(i)[2]==null?"":list.get(i)[2].toString()); | |
| 160 | - y.setJzl(list.get(i)[3]==null?0.0:Double.parseDouble(list.get(i)[3].toString())); | |
| 161 | - y.setStationid(list.get(i)[4]==null?"":list.get(i)[4].toString()); | |
| 162 | - y.setNylx(list.get(i)[5]==null?0:Integer.parseInt(list.get(i)[5].toString())); | |
| 163 | - y.setYj(list.get(i)[6]==null?0.0:Double.parseDouble(list.get(i)[6].toString())); | |
| 164 | - y.setBz(list.get(i)[7]==null?"":list.get(i)[7].toString()); | |
| 165 | - y.setLdgh(list.get(i)[8]==null?"":list.get(i)[8].toString()); | |
| 166 | - try { | |
| 167 | - y.setYyrq(sdf.parse(rq)); | |
| 168 | - } catch (ParseException e) { | |
| 169 | - // TODO Auto-generated catch block | |
| 170 | - e.printStackTrace(); | |
| 171 | - } | |
| 172 | - yList.add(y); | |
| 173 | - } | |
| 174 | - PageHelper pageHelper = new PageHelper(listsize, map); | |
| 175 | - pageHelper.getMap(); | |
| 176 | - PageObject<Ylxxb> pageObject=pageHelper.getPageObject(); | |
| 177 | - pageObject.setDataList(yList); | |
| 178 | - return pageObject; | |
| 179 | - }*/ | |
| 180 | - | |
| 181 | - @Override | |
| 182 | - public Ylxxb bynbbm(Map<String, Object> map) { | |
| 183 | - // TODO Auto-generated method stub | |
| 184 | - // TODO Auto-generated method stub | |
| 185 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 186 | - String rq = map.get("rq").toString(); | |
| 187 | - String nbbm = ""; | |
| 188 | - if (map.get("nbbm") != null) { | |
| 189 | - nbbm = map.get("nbbm").toString(); | |
| 190 | - } | |
| 191 | - List<Object[]> list = repository.obtainCwjycl(rq, nbbm); | |
| 192 | - Ylxxb y = new Ylxxb(); | |
| 193 | - if (list.size() > 0) { | |
| 194 | - y.setGsdm(list.get(0)[0] == null ? "" : list.get(0)[0].toString()); | |
| 195 | - y.setNbbm(list.get(0)[1] == null ? "" : list.get(0)[1].toString()); | |
| 196 | - y.setJsy(list.get(0)[2] == null ? "" : list.get(0)[2].toString()); | |
| 197 | - y.setJzl(list.get(0)[3] == null ? 0.0 : Double.parseDouble(list.get(0)[3].toString())); | |
| 198 | - y.setStationid(list.get(0)[4] == null ? "" : list.get(0)[4].toString()); | |
| 199 | - y.setNylx(list.get(0)[5] == null ? 0 : Integer.parseInt(list.get(0)[5].toString())); | |
| 200 | - y.setYj(list.get(0)[6] == null ? 0.0 : Double.parseDouble(list.get(0)[6].toString())); | |
| 201 | - y.setBz(list.get(0)[7] == null ? "" : list.get(0)[7].toString()); | |
| 202 | - y.setLdgh(list.get(0)[8] == null ? "" : list.get(0)[8].toString()); | |
| 203 | - try { | |
| 204 | - y.setYyrq(sdf.parse(rq)); | |
| 205 | - } catch (ParseException e) { | |
| 206 | - // TODO Auto-generated catch block | |
| 207 | - e.printStackTrace(); | |
| 208 | - } | |
| 209 | - } | |
| 210 | - return y; | |
| 211 | - } | |
| 212 | - | |
| 213 | - @Transactional | |
| 214 | - @Override | |
| 215 | - public Map<String, Object> savejzl(Map<String, Object> maps) throws Exception { | |
| 216 | - // TODO Auto-generated method stub | |
| 217 | - Map<String, Object> map=new HashMap<String,Object>(); | |
| 218 | - try { | |
| 219 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 220 | -// String rq = sdf.format(t.getYyrq()); | |
| 221 | -// String nbbm=t.getNbbm(); | |
| 222 | -// List<Ylxxb> yList=ylxxbRepository.obtainYlxx2(rq,nbbm); | |
| 223 | -// if(yList.size()>0){ | |
| 224 | -// t.setId(yList.get(0).getId()); | |
| 225 | -// ylxxbRepository.save(t); | |
| 226 | -// }else{ | |
| 227 | -// ylxxbRepository.save(t); | |
| 228 | -// } | |
| 229 | - String gsbm=maps.get("gsbm").toString(); | |
| 230 | - String fgsbm=maps.get("fgsbm").toString(); | |
| 231 | - String rq=maps.get("rq").toString(); | |
| 232 | - Date date=sdf.parse(rq); | |
| 233 | - String json =StringEscapeUtils.unescapeHtml4(maps.get("ylbList").toString()); | |
| 234 | - JSONArray jsonArray=JSONArray.parseArray(json); | |
| 235 | - JSONObject jsonObject; | |
| 236 | - // 获取车辆存油信息 | |
| 237 | - for (int i = 0; i < jsonArray.size(); i++) { | |
| 238 | - jsonObject=jsonArray.getJSONObject(i); | |
| 239 | - Integer id =jsonObject.getInteger("id"); | |
| 240 | - String jsy=jsonObject.getString("jsy"); | |
| 241 | - double jzl=jsonObject.getDoubleValue("jzl"); | |
| 242 | - String stationid=jsonObject.getString("stationid"); | |
| 243 | - String nbbm=jsonObject.getString("nbbm"); | |
| 244 | - int nylx=jsonObject.getIntValue("nylx"); | |
| 245 | - String jyggh=jsonObject.getString("jyggh"); | |
| 246 | - String bz=jsonObject.getString("bz"); | |
| 247 | - Ylxxb y; | |
| 248 | - if(id>0){ | |
| 249 | - y=ylxxbRepository.findById(id).get(); | |
| 250 | - y.setJsy(jsy); | |
| 251 | - y.setJzl(jzl); | |
| 252 | - y.setStationid(stationid); | |
| 253 | - y.setJyggh(jyggh); | |
| 254 | - y.setBz(bz); | |
| 255 | - y.setCreatetime(new Date()); | |
| 256 | - y.setYyrq(date); | |
| 257 | - ylxxbRepository.save(y); | |
| 258 | - }else{ | |
| 259 | - if(jsy!="" && jzl>0){ | |
| 260 | - y=new Ylxxb(); | |
| 261 | - y.setGsdm(gsbm); | |
| 262 | - y.setJsy(jsy); | |
| 263 | - y.setNbbm(nbbm); | |
| 264 | - y.setJzl(jzl); | |
| 265 | - y.setStationid(stationid); | |
| 266 | - y.setJyggh(jyggh); | |
| 267 | - y.setBz(bz); | |
| 268 | - y.setCreatetime(new Date()); | |
| 269 | - y.setYyrq(date); | |
| 270 | - y.setJylx(1); | |
| 271 | - y.setNylx(0); | |
| 272 | - ylxxbRepository.save(y); | |
| 273 | - } | |
| 274 | - } | |
| 275 | - } | |
| 276 | - map.put("status", ResponseCode.SUCCESS); | |
| 277 | - | |
| 278 | - } catch (Exception e) { | |
| 279 | - map.put("status", ResponseCode.ERROR); | |
| 280 | - logger.error("save erro.", e); | |
| 281 | - throw e; | |
| 282 | - // TODO: handle exception | |
| 283 | - } | |
| 284 | - return map; | |
| 285 | - } | |
| 286 | - | |
| 287 | - | |
| 288 | - | |
| 289 | - @Override | |
| 290 | - public List<Ylxxb> Pagequery(Map<String, Object> map) { | |
| 291 | - // TODO Auto-generated method stub | |
| 292 | - String rq=map.get("rq").toString(); | |
| 293 | - String nbbm=map.get("nbbh").toString(); | |
| 294 | - String gsdm=map.get("gsdm_like").toString(); | |
| 295 | - | |
| 296 | - String fgsdm=map.get("fgsdm_like").toString(); | |
| 297 | - String line =map.get("line_like").toString().trim(); | |
| 298 | - /*String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm," | |
| 299 | - + "b.jyggh as jyggh,b.jzl as jzl ,b.stationid as stationid,b.jsy as jsy," | |
| 300 | - + "b.nylx as nylx,b.yj as yj,b.bz as bz,b.id as id ,c.jsy as ldgh FROM bsth_c_cwjy a "+ | |
| 301 | - " left join (" | |
| 302 | - + " select * from bsth_c_ylxxb b " | |
| 303 | - + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1 " | |
| 304 | - + " and gsdm = '"+gsdm+"') b " + | |
| 305 | - " on a.nbbm=b.nbbm " | |
| 306 | - + "left join (select nbbm,group_concat(jsy) as jsy " | |
| 307 | - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) " | |
| 308 | - + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' group by nbbm "+ | |
| 309 | - " ) c on a.nbbm=c.nbbm " | |
| 310 | - + "where a.nbbm like '%"+nbbm+"%' and a.gsdm='"+gsdm+"' and a.fgsdm ='"+fgsdm+"'" | |
| 311 | - + " order by a.nbbm";*/ | |
| 312 | - String sql= " select * from bsth_c_ylxxb b " | |
| 313 | - + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1 " | |
| 314 | - + " and gsdm = '"+gsdm+"'"; | |
| 315 | - | |
| 316 | - List<Ylxxb> yList= jdbcTemplate.query(sql, | |
| 317 | - new RowMapper<Ylxxb>(){ | |
| 318 | - @Override | |
| 319 | - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 320 | - Ylxxb t=new Ylxxb(); | |
| 321 | - t.setId(rs.getInt("id")); | |
| 322 | - t.setGsdm(rs.getString("gsdm")); | |
| 323 | - t.setFgsdm(rs.getString("fgsdm")); | |
| 324 | - t.setNbbm(rs.getString("nbbm")); | |
| 325 | - t.setJyggh(rs.getString("jyggh")); | |
| 326 | - t.setJsy(rs.getString("jsy")); | |
| 327 | - t.setJzl(rs.getDouble("jzl")); | |
| 328 | - t.setStationid(rs.getString("stationid")); | |
| 329 | - t.setNylx(rs.getInt("nylx")); | |
| 330 | - t.setYj(rs.getDouble("yj")); | |
| 331 | - t.setBz(rs.getString("bz")); | |
| 332 | - return t; | |
| 333 | - } | |
| 334 | - }); | |
| 335 | - List<Cwjy> cwList=null; | |
| 336 | - if(line.equals("")){ | |
| 337 | - cwList = repository.selectAll(nbbm, gsdm, fgsdm); | |
| 338 | - }else{ | |
| 339 | - cwList = repository.selectAll_s(nbbm, gsdm, fgsdm, line); | |
| 340 | - } | |
| 341 | - | |
| 342 | - String sql_ylb="SELECT nbbm,group_concat(jsy) AS jsy FROM bsth_c_ylb WHERE " | |
| 343 | - + " rq = '"+rq+"' AND ssgsdm = '"+gsdm+"' AND " | |
| 344 | - + " fgsdm = '"+fgsdm+"' GROUP BY nbbm"; | |
| 345 | - | |
| 346 | - List<Map<String, String>> ylbList= jdbcTemplate.query(sql_ylb, | |
| 347 | - new RowMapper<Map<String, String>>(){ | |
| 348 | - @Override | |
| 349 | - public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 350 | - Map<String, String> maps =new HashMap<String, String>(); | |
| 351 | - maps.put("nbbm", rs.getString("nbbm")); | |
| 352 | - maps.put("ldgh", rs.getString("jsy")); | |
| 353 | - return maps; | |
| 354 | - } | |
| 355 | - }); | |
| 356 | - | |
| 357 | - List<Ylxxb> ylxxbList= new ArrayList<Ylxxb>(); | |
| 358 | - Ylxxb y=null; | |
| 359 | - for (int i = 0; i < cwList.size(); i++) { | |
| 360 | - Cwjy cwjy=cwList.get(i); | |
| 361 | - y=new Ylxxb(); | |
| 362 | - y.setNylx(0); | |
| 363 | - y.setId(0); | |
| 364 | - y.setJzl(0.0); | |
| 365 | - y.setGsdm(cwjy.getGsdm()); | |
| 366 | - y.setFgsdm(cwjy.getFgsdm()); | |
| 367 | - y.setNbbm(cwjy.getNbbm()); | |
| 368 | - y.setLinename(cwjy.getLinename()); | |
| 369 | - for (int j = 0; j < yList.size(); j++) { | |
| 370 | - Ylxxb ylxxb=yList.get(j); | |
| 371 | - if(y.getNbbm().equals(ylxxb.getNbbm())){ | |
| 372 | - y.setId(ylxxb.getId()); | |
| 373 | - y.setJyggh(ylxxb.getJyggh()); | |
| 374 | - y.setJsy(ylxxb.getJsy()); | |
| 375 | - y.setJzl(ylxxb.getJzl()); | |
| 376 | - y.setStationid(ylxxb.getStationid()); | |
| 377 | - y.setNylx(ylxxb.getNylx()); | |
| 378 | - y.setYj(ylxxb.getYj()); | |
| 379 | - y.setBz(ylxxb.getBz()); | |
| 380 | - break; | |
| 381 | - } | |
| 382 | - } | |
| 383 | - for (int j = 0; j < ylbList.size(); j++) { | |
| 384 | - Map<String, String> m=ylbList.get(j); | |
| 385 | - if(m.get("nbbm").toString().equals(cwjy.getNbbm())){ | |
| 386 | - y.setLdgh(m.get("ldgh").toString()); | |
| 387 | - break; | |
| 388 | - } | |
| 389 | - | |
| 390 | - } | |
| 391 | - | |
| 392 | - ylxxbList.add(y); | |
| 393 | - | |
| 394 | - } | |
| 395 | - | |
| 396 | - return ylxxbList; | |
| 397 | - } | |
| 398 | - | |
| 399 | - @Override | |
| 400 | - public int checkNbbm(Cwjy t) { | |
| 401 | - // TODO Auto-generated method stub | |
| 402 | - String sql="select count(*) from bsth_c_cwjy where nbbm ='"+t.getNbbm()+"'" | |
| 403 | - + " and gsdm ='"+t.getFgsdm()+"' and fgsdm ='"+t.getFgsdm()+"'"; | |
| 404 | - int cs=jdbcTemplate.queryForObject(sql, Integer.class); | |
| 405 | - | |
| 406 | - return cs; | |
| 407 | - } | |
| 408 | - | |
| 409 | - @Override | |
| 410 | - public List<Ylxxb> cwjyList(Map<String, Object> map) { | |
| 411 | - String rq=map.get("rq").toString(); | |
| 412 | - String nbbm=map.get("nbbh").toString(); | |
| 413 | - String gsdm=map.get("gsdm_like").toString(); | |
| 414 | - | |
| 415 | - String fgsdm=map.get("fgsdm_like").toString(); | |
| 416 | - String line =map.get("line_like").toString().trim(); | |
| 417 | - boolean type=false; | |
| 418 | - if(map.get("type")!=null){ | |
| 419 | - type=true; | |
| 420 | - } | |
| 421 | - String sql="select a.nbbm,a.gsdm,a.fgsdm,IFNULL(b.id,0) as id,IFNULL(b.jzl,0) as jzl," | |
| 422 | - + " IFNULL(b.jyggh,0) as jyggh,IFNULL(b.jsy,0) as jsy,IFNULL(b.stationid,0) as stationid ," | |
| 423 | - + " IFNULL(b.yj,0) as yj,IFNULL(b.nylx,0) as nylx,IFNULL(b.bz,'') as bz,IFNULL(c.jsy,'') as ldgh ," | |
| 424 | - + " IFNULL(c.xlname,c.linename) as xlname from " | |
| 425 | - + " (select * from bsth_c_cwjy where gsdm='"+gsdm+"' and fgsdm='"+fgsdm+"') a " | |
| 426 | - + " left join (select * from bsth_c_ylxxb where yyrq='"+rq+"' and gsdm='"+gsdm+"' and jylx=1) b" | |
| 427 | - + " on a.nbbm=b.nbbm LEFT JOIN (select u.nbbm,u.jsy,v.linename,v.xlname,v.xlbm from(select a.nbbm,GROUP_CONCAT(a.jsy) as jsy " | |
| 428 | - + " from (select nbbm,jsy from bsth_c_ylb x where x.rq='"+rq+"' " | |
| 429 | - + " and x.ssgsdm='"+gsdm+"' and x.fgsdm='"+fgsdm+"' group by nbbm,jsy ) a group by a.nbbm) u" | |
| 430 | - + " LEFT JOIN(select o.nbbm,GROUP_CONCAT(o.xlbm) xlbm ,GROUP_CONCAT(o.linename) as xlname," | |
| 431 | - + " GROUP_CONCAT(p.`name`) as linename from (select nbbm,xlbm,linename from bsth_c_ylb " | |
| 432 | - + " where rq='"+rq+"' and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"' group by nbbm,xlbm,linename) o " | |
| 433 | - + " LEFT JOIN bsth_c_line p on o.xlbm=p.line_code group by o.nbbm ) v on u.nbbm=v.nbbm) c " | |
| 434 | - + " on a.nbbm=c.nbbm where 1=1 "; | |
| 435 | - if(!nbbm.equals("")){ | |
| 436 | - sql +=" and a.nbbm like '%"+nbbm+"%'"; | |
| 437 | - } | |
| 438 | - if(!line.equals("")){ | |
| 439 | - sql += " and c.xlbm ='"+line+"'"; | |
| 440 | - } | |
| 441 | - if(type){ | |
| 442 | - sql +=" and c.xlbm is not null"; | |
| 443 | - } | |
| 444 | - sql +=" order by xlname desc"; | |
| 445 | - List<Ylxxb> yList= jdbcTemplate.query(sql, | |
| 446 | - new RowMapper<Ylxxb>(){ | |
| 447 | - @Override | |
| 448 | - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 449 | - Ylxxb t=new Ylxxb(); | |
| 450 | - t.setId(rs.getInt("id")); | |
| 451 | - t.setGsdm(rs.getString("gsdm")); | |
| 452 | - t.setFgsdm(rs.getString("fgsdm")); | |
| 453 | - t.setNbbm(rs.getString("nbbm")); | |
| 454 | - t.setJyggh(rs.getString("jyggh")); | |
| 455 | - t.setJsy(rs.getString("jsy")); | |
| 456 | - t.setJzl(rs.getDouble("jzl")); | |
| 457 | - t.setStationid(rs.getString("stationid")); | |
| 458 | - t.setNylx(rs.getInt("nylx")); | |
| 459 | - t.setYj(rs.getDouble("yj")); | |
| 460 | - t.setBz(rs.getString("bz")); | |
| 461 | - t.setLdgh(rs.getString("ldgh")); | |
| 462 | - t.setLinename(rs.getString("xlname")); | |
| 463 | - return t; | |
| 464 | - } | |
| 465 | - }); | |
| 466 | - return yList; | |
| 467 | - } | |
| 468 | - | |
| 469 | - | |
| 470 | - @Override | |
| 471 | - public String importExcel(File file, String gsbm, String gsName) { | |
| 472 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 473 | - SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 474 | - DecimalFormat df = new DecimalFormat("######0.00"); | |
| 475 | - List<String> textList = new ArrayList<String>(); | |
| 476 | - try { | |
| 477 | - POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); | |
| 478 | - HSSFWorkbook wb = new HSSFWorkbook(fs); | |
| 479 | - HSSFSheet sheet = wb.getSheetAt(0); | |
| 480 | - // 取得总行数 | |
| 481 | - int rowNum = sheet.getLastRowNum() + 1; | |
| 482 | - // 取得总列数 | |
| 483 | - int cellNum = sheet.getRow(0).getLastCellNum(); | |
| 484 | - HSSFRow row = null; | |
| 485 | - HSSFCell cell = null; | |
| 486 | - for(int i = 2; i < rowNum; i++){ | |
| 487 | - row = sheet.getRow(i); | |
| 488 | - if (row == null){ | |
| 489 | - continue; | |
| 490 | - } | |
| 491 | - String text = ""; | |
| 492 | - for(int j = 0; j < cellNum; j++){ | |
| 493 | - cell = row.getCell(j); | |
| 494 | - if(cell == null){ | |
| 495 | - text += ","; | |
| 496 | - continue; | |
| 497 | - } | |
| 498 | - text += String.valueOf(cell) + ","; | |
| 499 | - } | |
| 500 | - String[] split = (text+";").split(","); | |
| 501 | - String str = ""; | |
| 502 | - for(int j = 0; j < split.length && j < 5; j++){ | |
| 503 | - str += split[j]; | |
| 504 | - } | |
| 505 | - if(str.trim().length() == 0){ | |
| 506 | - continue; | |
| 507 | - } | |
| 508 | - textList.add(text + ";"); | |
| 509 | - } | |
| 510 | - for(int i = 0; i < textList.size(); i++){ | |
| 511 | - String text = textList.get(i); | |
| 512 | - System.out.println(text); | |
| 513 | - String[] split = text.split(","); | |
| 514 | - String rq = split[0].trim(); | |
| 515 | - String nbbm = split[1].trim(); | |
| 516 | - String jsy = split[2].trim(); | |
| 517 | - double jzl = Double.valueOf(split[3].trim().length()!=0?split[3]:"0"); | |
| 518 | - String jyz = split[4].trim(); | |
| 519 | - String remarks = split[5].trim(); | |
| 520 | - if(rq.trim().length() == 0){ | |
| 521 | - rq = sdf.format(new Date()); | |
| 522 | - } | |
| 523 | - | |
| 524 | - List<Double> jzl_ = repository.import_queryBySame(gsbm, rq, nbbm); | |
| 525 | -// | |
| 526 | - if(jzl_.size() == 0){ | |
| 527 | - repository.import_insertData(gsbm, rq, nbbm, jsy, | |
| 528 | - df.format(jzl), jyz, remarks, sd.format(new Date())); | |
| 529 | - }else{ | |
| 530 | - repository.import_UpdateJzl(df.format(jzl), jsy, jyz, remarks, gsbm, rq, nbbm); | |
| 531 | - } | |
| 532 | - } | |
| 533 | - | |
| 534 | - /** 以下为测试导入ylxxb用 */ | |
| 535 | -// Date date = new Date(); | |
| 536 | -// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 537 | -// for(int i = 1; i < rowNum; i++){ | |
| 538 | -// row = sheet.getRow(i); | |
| 539 | -// if (row == null){ | |
| 540 | -// continue; | |
| 541 | -// } | |
| 542 | -// String text = ""; | |
| 543 | -// for(int j = 0; j < cellNum; j++){ | |
| 544 | -// cell = row.getCell(j); | |
| 545 | -// if(cell == null){ | |
| 546 | -// text += ","; | |
| 547 | -// continue; | |
| 548 | -// } | |
| 549 | -// if(j == 1 && cell.getCellType() == Cell.CELL_TYPE_NUMERIC){ | |
| 550 | -// text += dateFormat.format(cell.getDateCellValue()) + ","; | |
| 551 | -// } else if(j == 4 || j == 7){ | |
| 552 | -// text += "0,"; | |
| 553 | -//// } else if(j == 6 && String.valueOf(cell).contains("-")){ | |
| 554 | -//// String str = String.valueOf(cell); | |
| 555 | -//// text += str.split("-")[1] + ","; | |
| 556 | -// } else { | |
| 557 | -// text += String.valueOf(cell) + ","; | |
| 558 | -// } | |
| 559 | -// } | |
| 560 | -// System.out.println(text); | |
| 561 | -// Ylxxb ylxxb = new Ylxxb(); | |
| 562 | -// String[] split = text.split(","); | |
| 563 | -// ylxxb.setCreatetime(date); | |
| 564 | -// ylxxb.setYyrq(sdf.parse(split[0].trim())); | |
| 565 | -// ylxxb.setJlrq(dateFormat.parse(split[1])); | |
| 566 | -// ylxxb.setFromgsdm("22"); | |
| 567 | -// ylxxb.setNbbm(split[2]); | |
| 568 | -// ylxxb.setJzl(Double.valueOf(split[3])); | |
| 569 | -// ylxxb.setNylx(Integer.valueOf(split[4])); | |
| 570 | -// ylxxb.setStationid(split[5]); | |
| 571 | -// if(split[6].contains("-")){ | |
| 572 | -// ylxxb.setJsy(split[6].split("-")[1]); | |
| 573 | -// } | |
| 574 | -// ylxxb.setBz(split[6]); | |
| 575 | -// ylxxb.setJylx(Integer.valueOf(split[7])); | |
| 576 | -// ylxxbRepository.save(ylxxb); | |
| 577 | -// } | |
| 578 | - wb.close(); | |
| 579 | - fs.close(); | |
| 580 | - } catch (Exception e) { | |
| 581 | - // TODO Auto-generated catch block | |
| 582 | - e.printStackTrace(); | |
| 583 | - return "文件导入失败"; | |
| 584 | - } finally { | |
| 585 | - file.delete(); | |
| 586 | - } | |
| 587 | - return "文件导入成功"; | |
| 588 | - } | |
| 589 | - | |
| 590 | - | |
| 591 | -} | |
| 592 | -======= | |
| 593 | 1 | package com.bsth.service.oil.impl; |
| 594 | 2 | |
| 595 | 3 | import java.io.File; |
| ... | ... | @@ -1179,5 +587,4 @@ public class CwjyServiceImpl extends BaseServiceImpl<Cwjy,Integer> implements Cw |
| 1179 | 587 | } |
| 1180 | 588 | |
| 1181 | 589 | |
| 1182 | -} | |
| 1183 | ->>>>>>> 2021.05.11 历史版本 选择版本 查看历史版本修改当前版本和待更新版本 | |
| 590 | +} | |
| 1184 | 591 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| 1 | -<<<<<<< HEAD | |
| 2 | 1 | package com.bsth.service.realcontrol.impl; |
| 3 | 2 | |
| 4 | 3 | import java.io.*; |
| ... | ... | @@ -6588,6594 +6587,3 @@ class compareFcsjType implements Comparator<ScheduleRealInfo> { |
| 6588 | 6587 | } |
| 6589 | 6588 | |
| 6590 | 6589 | } |
| 6591 | -======= | |
| 6592 | -package com.bsth.service.realcontrol.impl; | |
| 6593 | - | |
| 6594 | -import java.io.*; | |
| 6595 | -import java.net.HttpURLConnection; | |
| 6596 | -import java.net.MalformedURLException; | |
| 6597 | -import java.net.URL; | |
| 6598 | -import java.net.URLEncoder; | |
| 6599 | -import java.sql.ResultSet; | |
| 6600 | -import java.sql.SQLException; | |
| 6601 | -import java.text.DecimalFormat; | |
| 6602 | -import java.text.ParseException; | |
| 6603 | -import java.text.SimpleDateFormat; | |
| 6604 | -import java.util.ArrayList; | |
| 6605 | -import java.util.Calendar; | |
| 6606 | -import java.util.Collection; | |
| 6607 | -import java.util.Collections; | |
| 6608 | -import java.util.Comparator; | |
| 6609 | -import java.util.Date; | |
| 6610 | -import java.util.GregorianCalendar; | |
| 6611 | -import java.util.HashMap; | |
| 6612 | -import java.util.HashSet; | |
| 6613 | -import java.util.Iterator; | |
| 6614 | -import java.util.List; | |
| 6615 | -import java.util.Map; | |
| 6616 | -import java.util.Queue; | |
| 6617 | -import java.util.Set; | |
| 6618 | -import java.util.concurrent.ConcurrentLinkedQueue; | |
| 6619 | -import java.util.concurrent.Executors; | |
| 6620 | -import java.util.concurrent.ScheduledExecutorService; | |
| 6621 | -import java.util.concurrent.ThreadFactory; | |
| 6622 | -import java.util.concurrent.TimeUnit; | |
| 6623 | -import java.util.regex.Pattern; | |
| 6624 | - | |
| 6625 | -import org.apache.commons.io.IOUtils; | |
| 6626 | -import org.apache.commons.lang3.StringEscapeUtils; | |
| 6627 | -import org.apache.commons.lang3.StringUtils; | |
| 6628 | -import org.joda.time.format.DateTimeFormat; | |
| 6629 | -import org.joda.time.format.DateTimeFormatter; | |
| 6630 | -import org.slf4j.Logger; | |
| 6631 | -import org.slf4j.LoggerFactory; | |
| 6632 | -import org.springframework.beans.factory.DisposableBean; | |
| 6633 | -import org.springframework.beans.factory.InitializingBean; | |
| 6634 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 6635 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 6636 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 6637 | -import org.springframework.jdbc.core.RowMapper; | |
| 6638 | -import org.springframework.stereotype.Service; | |
| 6639 | -import org.springframework.transaction.annotation.Transactional; | |
| 6640 | - | |
| 6641 | -import com.alibaba.fastjson.JSON; | |
| 6642 | -import com.alibaba.fastjson.JSONArray; | |
| 6643 | -import com.alibaba.fastjson.JSONObject; | |
| 6644 | -import com.bsth.common.Constants; | |
| 6645 | -import com.bsth.common.ResponseCode; | |
| 6646 | -import com.bsth.controller.realcontrol.dto.ChangePersonCar; | |
| 6647 | -import com.bsth.controller.realcontrol.dto.DfsjChange; | |
| 6648 | -import com.bsth.controller.realcontrol.dto.LpData; | |
| 6649 | -import com.bsth.data.BasicData; | |
| 6650 | -import com.bsth.data.LineConfigData; | |
| 6651 | -import com.bsth.data.Station2ParkBuffer; | |
| 6652 | -import com.bsth.data.schedule.DayOfSchedule; | |
| 6653 | -import com.bsth.data.schedule.SchAttrCalculator; | |
| 6654 | -import com.bsth.data.schedule.ScheduleComparator; | |
| 6655 | -import com.bsth.data.schedule.edit_logs.FormLogger; | |
| 6656 | -import com.bsth.data.schedule.edit_logs.ScheduleModifyLogger; | |
| 6657 | -import com.bsth.data.schedule.edit_logs.loggers.AfterwardsLogger; | |
| 6658 | -import com.bsth.data.schedule.edit_logs.loggers.FcxxwtLogger; | |
| 6659 | -import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; | |
| 6660 | -import com.bsth.data.schedule.late_adjust.LateAdjustHandle; | |
| 6661 | -import com.bsth.data.utils.CustomStringUtils; | |
| 6662 | -import com.bsth.entity.CarDevice; | |
| 6663 | -import com.bsth.entity.Cars; | |
| 6664 | -import com.bsth.entity.Line; | |
| 6665 | -import com.bsth.entity.Personnel; | |
| 6666 | -import com.bsth.entity.calc.CalcInterval; | |
| 6667 | -import com.bsth.entity.oil.Dlb; | |
| 6668 | -import com.bsth.entity.oil.Ylb; | |
| 6669 | -import com.bsth.entity.oil.Ylxxb; | |
| 6670 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 6671 | -import com.bsth.entity.realcontrol.LineConfig; | |
| 6672 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 6673 | -import com.bsth.entity.realcontrol.SvgAttribute; | |
| 6674 | -import com.bsth.entity.report.MileageReport; | |
| 6675 | -import com.bsth.entity.report.RepairReport; | |
| 6676 | -import com.bsth.entity.report.ScheduleCorrectionReport; | |
| 6677 | -import com.bsth.entity.schedule.CarConfigInfo; | |
| 6678 | -import com.bsth.entity.schedule.EmployeeConfigInfo; | |
| 6679 | -import com.bsth.entity.schedule.GuideboardInfo; | |
| 6680 | -import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 6681 | -import com.bsth.entity.sys.Dictionary; | |
| 6682 | -import com.bsth.entity.sys.DutyEmployee; | |
| 6683 | -import com.bsth.entity.sys.SysUser; | |
| 6684 | -import com.bsth.repository.CarDeviceRepository; | |
| 6685 | -import com.bsth.repository.CarsRepository; | |
| 6686 | -import com.bsth.repository.LineRepository; | |
| 6687 | -import com.bsth.repository.RepairReportRepository; | |
| 6688 | -import com.bsth.repository.calc.CalcIntervalRepository; | |
| 6689 | -import com.bsth.repository.oil.DlbRepository; | |
| 6690 | -import com.bsth.repository.oil.YlbRepository; | |
| 6691 | -import com.bsth.repository.oil.YlxxbRepository; | |
| 6692 | -import com.bsth.repository.realcontrol.ChildTaskPlanRepository; | |
| 6693 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 6694 | -import com.bsth.repository.realcontrol.SvgAttributeRepository; | |
| 6695 | -import com.bsth.repository.schedule.CarConfigInfoRepository; | |
| 6696 | -import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | |
| 6697 | -import com.bsth.repository.schedule.GuideboardInfoRepository; | |
| 6698 | -import com.bsth.security.util.SecurityUtils; | |
| 6699 | -import com.bsth.service.LineService; | |
| 6700 | -import com.bsth.service.SectionRouteService; | |
| 6701 | -import com.bsth.service.directive.DirectiveService; | |
| 6702 | -import com.bsth.service.impl.BaseServiceImpl; | |
| 6703 | -import com.bsth.service.realcontrol.ScheduleRealInfoService; | |
| 6704 | -import com.bsth.service.report.CulateMileageService; | |
| 6705 | -import com.bsth.service.report.ReportService; | |
| 6706 | -import com.bsth.service.schedule.SchedulePlanInfoService; | |
| 6707 | -import com.bsth.service.sys.DictionaryService; | |
| 6708 | -import com.bsth.service.sys.DutyEmployeeService; | |
| 6709 | -import com.bsth.util.Arith; | |
| 6710 | -import com.bsth.util.ComparableChild; | |
| 6711 | -import com.bsth.util.ComparableLp; | |
| 6712 | -import com.bsth.util.ComparableReal; | |
| 6713 | -import com.bsth.util.ConfigUtil; | |
| 6714 | -import com.bsth.util.DateUtils; | |
| 6715 | -import com.bsth.util.ReportRelatedUtils; | |
| 6716 | -import com.bsth.util.ReportUtils; | |
| 6717 | -import com.bsth.util.TimeUtils; | |
| 6718 | -import com.bsth.util.TransGPS; | |
| 6719 | -import com.bsth.websocket.handler.SendUtils; | |
| 6720 | -import com.fasterxml.jackson.databind.ObjectMapper; | |
| 6721 | -import com.github.stuxuhai.jpinyin.PinyinException; | |
| 6722 | -import com.github.stuxuhai.jpinyin.PinyinFormat; | |
| 6723 | -import com.github.stuxuhai.jpinyin.PinyinHelper; | |
| 6724 | -import com.google.common.base.Splitter; | |
| 6725 | -import com.google.common.collect.Lists; | |
| 6726 | - | |
| 6727 | -import javax.ws.rs.HEAD; | |
| 6728 | - | |
| 6729 | -@Service | |
| 6730 | -public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> | |
| 6731 | - implements ScheduleRealInfoService, InitializingBean, DisposableBean { | |
| 6732 | - @Autowired | |
| 6733 | - JdbcTemplate jdbcTemplate; | |
| 6734 | - @Autowired | |
| 6735 | - ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 6736 | - | |
| 6737 | - @Autowired | |
| 6738 | - EmployeeConfigInfoRepository employeeConfigInfoRepository; | |
| 6739 | - | |
| 6740 | - @Autowired | |
| 6741 | - CarConfigInfoRepository carConfigInfoRepository; | |
| 6742 | - | |
| 6743 | - @Autowired | |
| 6744 | - SectionRouteService sectionRouteService; | |
| 6745 | - | |
| 6746 | - @Autowired | |
| 6747 | - CulateMileageService culateMieageService; | |
| 6748 | - | |
| 6749 | - @Autowired | |
| 6750 | - DictionaryService dictionaryService; | |
| 6751 | - | |
| 6752 | - @Autowired | |
| 6753 | - CalcIntervalRepository calcIntervalRepository; | |
| 6754 | - /*@Autowired | |
| 6755 | - BorrowCenter borrowCenter;*/ | |
| 6756 | - | |
| 6757 | - @Autowired | |
| 6758 | - LineRepository lineRepository; | |
| 6759 | - @Autowired | |
| 6760 | - LineService lineService; | |
| 6761 | - @Autowired | |
| 6762 | - GuideboardInfoRepository guideboardInfoRepository; | |
| 6763 | - | |
| 6764 | - @Autowired | |
| 6765 | - ChildTaskPlanRepository cTaskPlanRepository; | |
| 6766 | - | |
| 6767 | - @Autowired | |
| 6768 | - SendUtils sendUtils; | |
| 6769 | - | |
| 6770 | - @Autowired | |
| 6771 | - DayOfSchedule dayOfSchedule; | |
| 6772 | - | |
| 6773 | - @Autowired | |
| 6774 | - SchAttrCalculator schAttrCalculator; | |
| 6775 | - | |
| 6776 | - @Autowired | |
| 6777 | - LineConfigData lineConfigData; | |
| 6778 | - | |
| 6779 | - @Autowired | |
| 6780 | - DutyEmployeeService dutyEmployeeService; | |
| 6781 | - | |
| 6782 | - @Autowired | |
| 6783 | - YlxxbRepository ylxxbRepository; | |
| 6784 | - | |
| 6785 | - @Autowired | |
| 6786 | - YlbRepository ylbRepository; | |
| 6787 | - | |
| 6788 | - @Autowired | |
| 6789 | - DlbRepository dlbRepository; | |
| 6790 | - | |
| 6791 | - @Autowired | |
| 6792 | - ReportService reposrService; | |
| 6793 | - | |
| 6794 | - @Autowired | |
| 6795 | - CulateMileageService culateService; | |
| 6796 | - | |
| 6797 | - @Autowired | |
| 6798 | - FormLogger schModifyLog; | |
| 6799 | - | |
| 6800 | - @Autowired | |
| 6801 | - DirectiveService directiveService; | |
| 6802 | - | |
| 6803 | - @Autowired | |
| 6804 | - CarDeviceRepository carDeviceRepository; | |
| 6805 | - | |
| 6806 | - @Autowired | |
| 6807 | - CarsRepository carsRepository; | |
| 6808 | - | |
| 6809 | - @Autowired | |
| 6810 | - RepairReportRepository repairReportRepository; | |
| 6811 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 6812 | - | |
| 6813 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 6814 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 6815 | - | |
| 6816 | - public static Map<String,String> DIRMAP ; // dvr电话 | |
| 6817 | - private Queue<RepairReport> queue = new ConcurrentLinkedQueue<>(); | |
| 6818 | - | |
| 6819 | - private ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { | |
| 6820 | - | |
| 6821 | - @Override | |
| 6822 | - public Thread newThread(Runnable r) { | |
| 6823 | - // TODO Auto-generated method stub | |
| 6824 | - Thread t = new Thread(r); | |
| 6825 | - t.setName("RepairReportReissuer"); | |
| 6826 | - | |
| 6827 | - return t; | |
| 6828 | - } | |
| 6829 | - }); | |
| 6830 | - | |
| 6831 | - | |
| 6832 | - | |
| 6833 | - private static Map<String, String> report2repair = new HashMap<String, String>(); | |
| 6834 | - | |
| 6835 | - static { | |
| 6836 | - report2repair.put("9101", "9109"); | |
| 6837 | - report2repair.put("9102", "9102"); | |
| 6838 | - report2repair.put("9103", "9103"); | |
| 6839 | - report2repair.put("9104", "9104"); | |
| 6840 | - report2repair.put("9109", "9109"); | |
| 6841 | - report2repair.put("9201", "9201"); | |
| 6842 | - report2repair.put("9202", "9202"); | |
| 6843 | - report2repair.put("9203", "9203"); | |
| 6844 | - report2repair.put("9204", "9204"); | |
| 6845 | - report2repair.put("9209", "9209"); | |
| 6846 | - report2repair.put("9301", "9301"); | |
| 6847 | - report2repair.put("9302", "9302"); | |
| 6848 | - report2repair.put("9303", "9303"); | |
| 6849 | - report2repair.put("9304", "9304"); | |
| 6850 | - report2repair.put("9305", "9305"); | |
| 6851 | - report2repair.put("9306", "9306"); | |
| 6852 | - report2repair.put("9309", "9309"); | |
| 6853 | - } | |
| 6854 | - | |
| 6855 | - | |
| 6856 | - /** | |
| 6857 | - * 校验人车 和 班次的公司和分公司归属 | |
| 6858 | - * | |
| 6859 | - * @param schId | |
| 6860 | - * @param jGh | |
| 6861 | - * @param sGh | |
| 6862 | - * @param nbbm | |
| 6863 | - * @return -2 跨营运公司,校验不过 | |
| 6864 | - * -1 跨分公司,二次确认 | |
| 6865 | - * 1 校验通过 | |
| 6866 | - */ | |
| 6867 | - @Override | |
| 6868 | - public Map<String, Object> checkPCFgsAscription(Long schId, String jGh, String sGh, String nbbm) { | |
| 6869 | - Map<String, Object> rs = new HashMap<>(); | |
| 6870 | - try { | |
| 6871 | - rs.put("status", ResponseCode.SUCCESS); | |
| 6872 | - rs.put("checkStatus", -2); | |
| 6873 | - | |
| 6874 | - String msg = null; | |
| 6875 | - ScheduleRealInfo sch = dayOfSchedule.get(schId); | |
| 6876 | - String gsbm = sch.getGsBm(), fgsbm = sch.getFgsBm(); | |
| 6877 | - | |
| 6878 | - if (nbbm != null && !carExist(gsbm, nbbm)) { | |
| 6879 | - msg = sch.getGsName() + "没有自编号为" + "[" + nbbm + "]的车辆"; | |
| 6880 | - rs.put("msg", msg); | |
| 6881 | - return rs; | |
| 6882 | - } | |
| 6883 | - | |
| 6884 | - if (nbbm != null && !sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(nbbm))) { | |
| 6885 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + nbbm + "】的车辆"); | |
| 6886 | - return rs; | |
| 6887 | - } | |
| 6888 | - | |
| 6889 | - if (nbbm != null && !(fgsbm + "_" + gsbm).equals(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm))) { | |
| 6890 | - | |
| 6891 | - String clFgsName = BasicData.businessFgsCodeNameMap.get(BasicData.nbbm2FgsCompanyCodeMap.get(nbbm)); | |
| 6892 | - | |
| 6893 | - msg = ("【" + nbbm + "】" + "是" + clFgsName + "的车辆!"); | |
| 6894 | - rs.put("msg", msg); | |
| 6895 | - rs.put("checkStatus", -1); | |
| 6896 | - return rs; | |
| 6897 | - } | |
| 6898 | - | |
| 6899 | - if(null != jGh && !"/".equals(StringUtils.trim(jGh))){ | |
| 6900 | - Personnel jsy = BasicData.perMap.get(gsbm + "-" + jGh); | |
| 6901 | - | |
| 6902 | - if (null == jsy) { | |
| 6903 | - msg = "【驾驶员】:" + sch.getGsName() + "暂无工号为" + "【" + jGh + "】的人员"; | |
| 6904 | - rs.put("msg", msg); | |
| 6905 | - return rs; | |
| 6906 | - } | |
| 6907 | - else if (!fgsbm.equals(jsy.getBrancheCompanyCode())) { | |
| 6908 | - //校验分公司 | |
| 6909 | - msg = ("【驾驶员】:" + jGh + "/" + jsy.getPersonnelName() + "是" + jsy.getBrancheCompany() + "的人员"); | |
| 6910 | - rs.put("msg", msg); | |
| 6911 | - rs.put("checkStatus", -1); | |
| 6912 | - return rs; | |
| 6913 | - } | |
| 6914 | - } | |
| 6915 | - | |
| 6916 | - if (null != sGh && !"/".equals(StringUtils.trim(sGh))) { | |
| 6917 | - Personnel spy = BasicData.perMap.get(gsbm + "-" + sGh); | |
| 6918 | - if (null == spy) { | |
| 6919 | - msg = "【售票员】: " + sch.getGsName() + "暂无工号为" + "【" + sGh + "】的人员"; | |
| 6920 | - rs.put("msg", msg); | |
| 6921 | - return rs; | |
| 6922 | - } | |
| 6923 | - else if (!fgsbm.equals(spy.getBrancheCompanyCode())) { | |
| 6924 | - msg = ("【售票员】: " + sGh + "/" + spy.getPersonnelName() + "是" + spy.getBrancheCompany() + "的人员"); | |
| 6925 | - rs.put("msg", msg); | |
| 6926 | - rs.put("checkStatus", -1); | |
| 6927 | - return rs; | |
| 6928 | - } | |
| 6929 | - } | |
| 6930 | - | |
| 6931 | - rs.put("checkStatus", 1); | |
| 6932 | - } catch (Exception e) { | |
| 6933 | - logger.error("", e); | |
| 6934 | - rs.put("status", ResponseCode.ERROR); | |
| 6935 | - } | |
| 6936 | - return rs; | |
| 6937 | - } | |
| 6938 | - | |
| 6939 | - | |
| 6940 | - /** | |
| 6941 | - * 车辆是否存在 | |
| 6942 | - * | |
| 6943 | - * @param gsbm 公司编码 | |
| 6944 | - * @param nbbm 车辆自编号 | |
| 6945 | - * @return | |
| 6946 | - */ | |
| 6947 | - private boolean carExist(String gsbm, String nbbm) { | |
| 6948 | - return BasicData.nbbm2CompanyCodeMap.containsKey(nbbm); | |
| 6949 | - } | |
| 6950 | - | |
| 6951 | - /** | |
| 6952 | - * 获取人员姓名 | |
| 6953 | - * | |
| 6954 | - * @param gsbm 公司编码 | |
| 6955 | - * @param gh 人员工号 | |
| 6956 | - * @return | |
| 6957 | - */ | |
| 6958 | - private String getPersonName(String gsbm, String gh) { | |
| 6959 | - return BasicData.allPerson.get(gsbm + '-' + gh); | |
| 6960 | - } | |
| 6961 | - | |
| 6962 | - @Override | |
| 6963 | - public Iterable<ScheduleRealInfo> list(Map<String, Object> map) { | |
| 6964 | - Iterator<ScheduleRealInfo> iterator = super.list(map).iterator(); | |
| 6965 | - Set<ScheduleRealInfo> set = new HashSet<>(100); | |
| 6966 | - | |
| 6967 | - DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | |
| 6968 | - //计算时间戳 | |
| 6969 | - ScheduleRealInfo sch; | |
| 6970 | - while (iterator.hasNext()) { | |
| 6971 | - sch = iterator.next(); | |
| 6972 | - //待发时间戳 | |
| 6973 | - sch.setDfsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getDfsj())); | |
| 6974 | - //实发时间戳 | |
| 6975 | - if (StringUtils.isNotEmpty(sch.getFcsjActual())) { | |
| 6976 | - sch.setFcsjActualTime(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsjActual())); | |
| 6977 | - } | |
| 6978 | - set.add(sch); | |
| 6979 | - } | |
| 6980 | - return set; | |
| 6981 | - } | |
| 6982 | - | |
| 6983 | - @Override | |
| 6984 | - public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) { | |
| 6985 | - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines)); | |
| 6986 | - | |
| 6987 | - /*Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | |
| 6988 | - | |
| 6989 | - for (String lineCode : lineList) { | |
| 6990 | - mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode)); | |
| 6991 | - }*/ | |
| 6992 | - return dayOfSchedule.findByLineCodes(lineList); | |
| 6993 | - } | |
| 6994 | - | |
| 6995 | - private final static long DAY_TIME = 1000 * 60 * 60 * 24L; | |
| 6996 | - | |
| 6997 | - private static int BUF_SIZE = 1024; | |
| 6998 | - | |
| 6999 | - private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | |
| 7000 | - private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 7001 | - | |
| 7002 | - @Override | |
| 7003 | - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType, String opType, String userId) { | |
| 7004 | - Map<String, Object> map = new HashMap<>(); | |
| 7005 | - try { | |
| 7006 | - | |
| 7007 | - ScheduleRealInfo schedule = dayOfSchedule.get(id); | |
| 7008 | - | |
| 7009 | - if (schedule.getStatus() > 0) { | |
| 7010 | - map.put("status", ResponseCode.SUCCESS); | |
| 7011 | - map.put("flag", "4008"); | |
| 7012 | - map.put("t", schedule); | |
| 7013 | - return map; | |
| 7014 | - } | |
| 7015 | - | |
| 7016 | - LineConfig config = lineConfigData.get(schedule.getXlBm()); | |
| 7017 | - //小于线路开始运营时间,则默认跨过24点 | |
| 7018 | - if (dfsj.compareTo(config.getStartOpt()) < 0) { | |
| 7019 | - schedule.setRealExecDate(fmtyyyyMMdd.print(schedule.getScheduleDate().getTime() + DAY_TIME)); | |
| 7020 | - } else { | |
| 7021 | - schedule.setRealExecDate(schedule.getScheduleDateStr()); | |
| 7022 | - } | |
| 7023 | - | |
| 7024 | - //记录日志 | |
| 7025 | - ScheduleModifyLogger.dftz(schedule, opType, schedule.getDfsj(), dfsj, remarks, userId); | |
| 7026 | - | |
| 7027 | - schedule.setDfsjAll(dfsj); | |
| 7028 | - schedule.setDfAuto(false); | |
| 7029 | - if ("1".equals(opType)) | |
| 7030 | - schedule.setRemarks(remarks); | |
| 7031 | - | |
| 7032 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | |
| 7033 | - ts.add(schedule); | |
| 7034 | - //调整终点时间和下一个班次的应到时间 | |
| 7035 | - //schedule.calcEndTime(); | |
| 7036 | - /*ScheduleRealInfo nextSch = dayOfSchedule.nextByLp2(schedule); | |
| 7037 | - if (null != nextSch) { | |
| 7038 | - nextSch.setQdzArrDatejh(schedule.getZdsj()); | |
| 7039 | - ts.add(nextSch); | |
| 7040 | - }*/ | |
| 7041 | - | |
| 7042 | - //调整班次类型 | |
| 7043 | - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(schedule.getBcType())) { | |
| 7044 | - if ((schedule.getBcType().equals("major") | |
| 7045 | - || schedule.getBcType().equals("venting")) | |
| 7046 | - && bcType.equals("normal")) { | |
| 7047 | - //清空备注 | |
| 7048 | - schedule.setRemarks(""); | |
| 7049 | - } | |
| 7050 | - schedule.setBcType(bcType); | |
| 7051 | - } | |
| 7052 | - | |
| 7053 | - //如果正在执行该班次 | |
| 7054 | - //ScheduleRealInfo exec = dayOfSchedule.executeCurr(schedule.getClZbh()); | |
| 7055 | - //if(exec != null && exec == schedule){ | |
| 7056 | - //重新计算正在执行班次 | |
| 7057 | - dayOfSchedule.reCalcExecPlan(schedule.getClZbh()); | |
| 7058 | - //} | |
| 7059 | - | |
| 7060 | - //重新计算是否误点 | |
| 7061 | - schedule.reCalcLate(); | |
| 7062 | - //取消应发未到标记,不再自动调整待发 | |
| 7063 | - //if(schedule.isLate2()){ | |
| 7064 | - // schedule.setLate2(false); | |
| 7065 | - //LateAdjustHandle.remove(schedule); | |
| 7066 | - //} | |
| 7067 | - | |
| 7068 | - try { | |
| 7069 | - if (!schedule.getDirectiveState().equals(-1) && schedule.getStatus() == 0) { | |
| 7070 | - //重新下发调度指令 | |
| 7071 | - directiveService.send60Dispatch(schedule.getId(), "待发@系统"); | |
| 7072 | - } | |
| 7073 | - } catch (Exception e) { | |
| 7074 | - logger.error("", e); | |
| 7075 | - } | |
| 7076 | - | |
| 7077 | - // 持久化到数据库 | |
| 7078 | - dayOfSchedule.save(schedule); | |
| 7079 | - | |
| 7080 | - map.put("status", ResponseCode.SUCCESS); | |
| 7081 | - map.put("ts", ts); | |
| 7082 | - } catch (Exception e) { | |
| 7083 | - logger.error("", e); | |
| 7084 | - map.put("status", ResponseCode.ERROR); | |
| 7085 | - } | |
| 7086 | - return map; | |
| 7087 | - } | |
| 7088 | - | |
| 7089 | - @Override | |
| 7090 | - public Map<String, Object> destroy(String idsStr, String remarks, String reason, String userId) { | |
| 7091 | - | |
| 7092 | - Map<String, Object> map = new HashMap<>(); | |
| 7093 | - List<ScheduleRealInfo> rsList = new ArrayList<>(); | |
| 7094 | - map.put("ts", rsList); | |
| 7095 | - try { | |
| 7096 | - List<String> idList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(idsStr)); | |
| 7097 | - | |
| 7098 | - ScheduleRealInfo schedule = null; | |
| 7099 | - for (String id : idList) { | |
| 7100 | - schedule = dayOfSchedule.get(Long.parseLong(id)); | |
| 7101 | - if (schedule.isDestroy()) { | |
| 7102 | - map.put("status", ResponseCode.ERROR); | |
| 7103 | - map.put("msg", "不必要的重复烂班!"); | |
| 7104 | - return map; | |
| 7105 | - } | |
| 7106 | - //记录日志 | |
| 7107 | - ScheduleModifyLogger.jhlb(schedule, remarks, userId); | |
| 7108 | - | |
| 7109 | - schedule.setAdjustExps(reason); | |
| 7110 | - schedule.destroy(); | |
| 7111 | - schedule.addRemarks(remarks); | |
| 7112 | - | |
| 7113 | - dayOfSchedule.save(schedule); | |
| 7114 | - rsList.add(schedule); | |
| 7115 | - } | |
| 7116 | - | |
| 7117 | - //重新计算当前执行班次 | |
| 7118 | - dayOfSchedule.reCalcExecPlan(schedule.getClZbh()); | |
| 7119 | - | |
| 7120 | - map.put("status", ResponseCode.SUCCESS); | |
| 7121 | - } catch (Exception e) { | |
| 7122 | - logger.error("", e); | |
| 7123 | - map.put("status", ResponseCode.ERROR); | |
| 7124 | - } | |
| 7125 | - return map; | |
| 7126 | - } | |
| 7127 | - | |
| 7128 | - // 线路id获取驾驶员 | |
| 7129 | - @Override | |
| 7130 | - public List<Map<String, String>> findDriverByLine(String lineCode) { | |
| 7131 | - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode); | |
| 7132 | - | |
| 7133 | - List<Map<String, String>> rsList = new ArrayList<>(); | |
| 7134 | - Map<String, String> map = null; | |
| 7135 | - Personnel driver = null; | |
| 7136 | - String code = null; | |
| 7137 | - | |
| 7138 | - for (EmployeeConfigInfo employee : list) { | |
| 7139 | - driver = employee.getJsy(); | |
| 7140 | - if (driver != null) { | |
| 7141 | - map = new HashMap<>(); | |
| 7142 | - code = driver.getJobCode(); | |
| 7143 | - map.put("id", code + "/" + driver.getPersonnelName()); | |
| 7144 | - map.put("text", code + "/" + driver.getPersonnelName()); | |
| 7145 | - rsList.add(map); | |
| 7146 | - } | |
| 7147 | - } | |
| 7148 | - return rsList; | |
| 7149 | - } | |
| 7150 | - | |
| 7151 | - // 线路id获取售票员 | |
| 7152 | - @Override | |
| 7153 | - public List<Map<String, String>> findConductorByLine(String lineCode) { | |
| 7154 | - List<EmployeeConfigInfo> list = employeeConfigInfoRepository.findBylineCode(lineCode); | |
| 7155 | - | |
| 7156 | - List<Map<String, String>> rsList = new ArrayList<>(); | |
| 7157 | - Map<String, String> map = null; | |
| 7158 | - Personnel conductor = null; | |
| 7159 | - String code = null; | |
| 7160 | - | |
| 7161 | - for (EmployeeConfigInfo employee : list) { | |
| 7162 | - conductor = employee.getSpy(); | |
| 7163 | - if (conductor != null) { | |
| 7164 | - code = conductor.getJobCode(); | |
| 7165 | - map = new HashMap<>(); | |
| 7166 | - map.put("id", code + "/" + conductor.getPersonnelName()); | |
| 7167 | - map.put("text", code + "/" + conductor.getPersonnelName()); | |
| 7168 | - rsList.add(map); | |
| 7169 | - } | |
| 7170 | - } | |
| 7171 | - return rsList; | |
| 7172 | - } | |
| 7173 | - | |
| 7174 | - @Override | |
| 7175 | - public List<Map<String, String>> findCarByLine(String lineCode) { | |
| 7176 | - | |
| 7177 | - List<CarConfigInfo> list = carConfigInfoRepository.findBylineCode(lineCode); | |
| 7178 | - | |
| 7179 | - List<Map<String, String>> rsList = new ArrayList<>(); | |
| 7180 | - Map<String, String> map = null; | |
| 7181 | - Cars car = null; | |
| 7182 | - String code = null; | |
| 7183 | - | |
| 7184 | - for (CarConfigInfo cci : list) { | |
| 7185 | - car = cci.getCl(); | |
| 7186 | - if (car != null) { | |
| 7187 | - code = car.getInsideCode(); | |
| 7188 | - map = new HashMap<>(); | |
| 7189 | - map.put("id", code); | |
| 7190 | - map.put("text", code); | |
| 7191 | - rsList.add(map); | |
| 7192 | - } | |
| 7193 | - } | |
| 7194 | - return rsList; | |
| 7195 | - } | |
| 7196 | - | |
| 7197 | - /** | |
| 7198 | - * 添加到历史库 | |
| 7199 | - * | |
| 7200 | - * @param t | |
| 7201 | - * @return | |
| 7202 | - */ | |
| 7203 | - @Override | |
| 7204 | - public Map<String, Object> addToHistory(ScheduleRealInfo t) { | |
| 7205 | - Map<String, Object> rs = new HashMap<>(); | |
| 7206 | - try { | |
| 7207 | - if (!carExist(t.getGsBm(), t.getClZbh())) { | |
| 7208 | - rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | |
| 7209 | - rs.put("status", ResponseCode.ERROR); | |
| 7210 | - return rs; | |
| 7211 | - } | |
| 7212 | - | |
| 7213 | - SysUser user = SecurityUtils.getCurrentUser(); | |
| 7214 | - //String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm()); | |
| 7215 | - | |
| 7216 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 7217 | - | |
| 7218 | - if (StringUtils.isEmpty(t.getjGh())) { | |
| 7219 | - rs.put("status", ResponseCode.ERROR); | |
| 7220 | - rs.put("msg", "驾驶员工号不能为空!"); | |
| 7221 | - return rs; | |
| 7222 | - } | |
| 7223 | - //截取驾驶员工号 | |
| 7224 | - if (t.getjGh().indexOf("-") != -1) { | |
| 7225 | - t.setjGh(t.getjGh().split("-")[1]); | |
| 7226 | - } | |
| 7227 | - //检查驾驶员工号 | |
| 7228 | - String jName = getPersonName(t.getGsBm(), t.getjGh()); | |
| 7229 | - if (StringUtils.isEmpty(jName)) { | |
| 7230 | - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员"); | |
| 7231 | - rs.put("status", ResponseCode.ERROR); | |
| 7232 | - return rs; | |
| 7233 | - } else if (StringUtils.isEmpty(t.getjName())) { | |
| 7234 | - t.setjName(jName);//补上驾驶员名称 | |
| 7235 | - } | |
| 7236 | - | |
| 7237 | - //有售票员 | |
| 7238 | - if (StringUtils.isNotEmpty(t.getsGh())) { | |
| 7239 | - String sName = getPersonName(t.getGsBm(), t.getsGh()); | |
| 7240 | - if (StringUtils.isEmpty(sName)) { | |
| 7241 | - rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员"); | |
| 7242 | - rs.put("status", ResponseCode.ERROR); | |
| 7243 | - return rs; | |
| 7244 | - } else if (StringUtils.isEmpty(t.getsName())) { | |
| 7245 | - t.setsName(sName);//补上售票员名称 | |
| 7246 | - } | |
| 7247 | - } else { | |
| 7248 | - t.setsGh(""); | |
| 7249 | - t.setsName(""); | |
| 7250 | - } | |
| 7251 | - | |
| 7252 | - //公司 和 分公司名称 | |
| 7253 | - t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm())); | |
| 7254 | - t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getFgsBm()+ "_" + t.getGsBm() )); | |
| 7255 | - | |
| 7256 | - //t.setScheduleDateStr(schDate); | |
| 7257 | - t.setScheduleDate(sdfyyyyMMdd.parse(t.getScheduleDateStr())); | |
| 7258 | - t.setRealExecDate(t.getScheduleDateStr()); | |
| 7259 | - t.setCreateBy(user); | |
| 7260 | - t.setSflj(true); | |
| 7261 | - t.setLate(false); | |
| 7262 | - t.setDfsj(t.getFcsj()); | |
| 7263 | - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime()); | |
| 7264 | - t.setJhlcOrig(t.getJhlc()); | |
| 7265 | - | |
| 7266 | - //班次历时 | |
| 7267 | - t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60); | |
| 7268 | - | |
| 7269 | - //起终点名称 | |
| 7270 | - String prefix = t.getXlBm() + "_" + t.getXlDir() + "_"; | |
| 7271 | - t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix)); | |
| 7272 | - t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix)); | |
| 7273 | - | |
| 7274 | - //计算班次实际执行时间 | |
| 7275 | - schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t); | |
| 7276 | - //处理计达跨24点 | |
| 7277 | - LineConfig conf = lineConfigData.get(t.getXlBm()); | |
| 7278 | - if (t.getZdsj().compareTo(conf.getStartOpt()) < 0) { | |
| 7279 | - t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime() + (1000 * 60 * 60 * 24)); | |
| 7280 | - } | |
| 7281 | - if (t.getZdsjT() < t.getFcsjT()) { | |
| 7282 | - rs.put("status", ResponseCode.ERROR); | |
| 7283 | - rs.put("msg", "起终点时间异常!"); | |
| 7284 | - return rs; | |
| 7285 | - } | |
| 7286 | - | |
| 7287 | - t.setId(dayOfSchedule.getId()); | |
| 7288 | - //实时入库 | |
| 7289 | - rs = super.save(t); | |
| 7290 | - } catch (Exception e) { | |
| 7291 | - logger.error("", e); | |
| 7292 | - rs.put("status", ResponseCode.ERROR); | |
| 7293 | - } | |
| 7294 | - return rs; | |
| 7295 | - } | |
| 7296 | - | |
| 7297 | - | |
| 7298 | - /** | |
| 7299 | - * 临加班次 | |
| 7300 | - */ | |
| 7301 | - @Override | |
| 7302 | - public Map<String, Object> save(ScheduleRealInfo sch) { | |
| 7303 | - Map<String, Object> rs = new HashMap<>(); | |
| 7304 | - try { | |
| 7305 | - String clZbh = sch.getClZbh(); | |
| 7306 | - if (StringUtils.isNotEmpty(clZbh)) { | |
| 7307 | - //检测 | |
| 7308 | - if (!carExist(sch.getGsBm(), clZbh)) { | |
| 7309 | - rs.put("status", ResponseCode.ERROR); | |
| 7310 | - rs.put("msg", "车辆 " + clZbh + " 不存在!"); | |
| 7311 | - return rs; | |
| 7312 | - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) { | |
| 7313 | - rs.put("status", ResponseCode.ERROR); | |
| 7314 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆"); | |
| 7315 | - return rs; | |
| 7316 | - } | |
| 7317 | - } | |
| 7318 | - | |
| 7319 | - SysUser user = SecurityUtils.getCurrentUser(); | |
| 7320 | - String schDate = DayOfSchedule.currSchDateMap.get(sch.getXlBm()); | |
| 7321 | - | |
| 7322 | - SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 7323 | - | |
| 7324 | - if (StringUtils.isEmpty(sch.getjGh())) { | |
| 7325 | - rs.put("status", ResponseCode.ERROR); | |
| 7326 | - rs.put("msg", "驾驶员工号不能为空!"); | |
| 7327 | - return rs; | |
| 7328 | - } | |
| 7329 | - //截取驾驶员工号 | |
| 7330 | - if (sch.getjGh().indexOf("-") != -1) { | |
| 7331 | - sch.setjGh(sch.getjGh().split("-")[1]); | |
| 7332 | - } | |
| 7333 | - //检查驾驶员工号 | |
| 7334 | - String jName = getPersonName(sch.getGsBm(), sch.getjGh()); | |
| 7335 | - if (StringUtils.isEmpty(jName)) { | |
| 7336 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | |
| 7337 | - rs.put("status", ResponseCode.ERROR); | |
| 7338 | - return rs; | |
| 7339 | - } else if (StringUtils.isEmpty(sch.getjName())) { | |
| 7340 | - sch.setjName(jName);//补上驾驶员名称 | |
| 7341 | - } | |
| 7342 | - | |
| 7343 | - //有售票员 | |
| 7344 | - if (StringUtils.isNotEmpty(sch.getsGh())) { | |
| 7345 | - String sName = getPersonName(sch.getGsBm(), sch.getsGh()); | |
| 7346 | - if (StringUtils.isEmpty(sName)) { | |
| 7347 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的售票员"); | |
| 7348 | - rs.put("status", ResponseCode.ERROR); | |
| 7349 | - return rs; | |
| 7350 | - } else if (StringUtils.isEmpty(sch.getsName())) { | |
| 7351 | - sch.setsName(sName);//补上售票员名称 | |
| 7352 | - } | |
| 7353 | - } else { | |
| 7354 | - sch.setsGh(""); | |
| 7355 | - sch.setsName(""); | |
| 7356 | - } | |
| 7357 | - | |
| 7358 | - //公司 和 分公司名称 | |
| 7359 | - sch.setGsName(BasicData.businessCodeNameMap.get(sch.getGsBm())); | |
| 7360 | - sch.setFgsName(BasicData.businessFgsCodeNameMap.get(sch.getFgsBm() + "_" + sch.getGsBm())); | |
| 7361 | - sch.setCreateDate(new Date()); | |
| 7362 | - sch.setScheduleDateStr(schDate); | |
| 7363 | - sch.setScheduleDate(sdfyyyyMMdd.parse(schDate)); | |
| 7364 | - sch.setRealExecDate(schDate); | |
| 7365 | - | |
| 7366 | - sch.setCreateBy(user); | |
| 7367 | - sch.setSflj(true); | |
| 7368 | - sch.setLate(false); | |
| 7369 | - sch.setDfsj(sch.getFcsj()); | |
| 7370 | - sch.setZdsjT(sdfyyyyMMddHHmm.parse(schDate + sch.getZdsj()).getTime()); | |
| 7371 | - sch.setJhlcOrig(sch.getJhlc()); | |
| 7372 | - sch.setCreateDate(new Date()); | |
| 7373 | - sch.setUpdateDate(new Date()); | |
| 7374 | - sch.setSpId(-1L); | |
| 7375 | - //起终点名称 | |
| 7376 | - String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | |
| 7377 | - sch.setQdzName(BasicData.getStationNameByCode(sch.getQdzCode(), prefix)); | |
| 7378 | - sch.setZdzName(BasicData.getStationNameByCode(sch.getZdzCode(), prefix)); | |
| 7379 | - | |
| 7380 | - //计算班次实际执行时间 | |
| 7381 | - schAttrCalculator.calcRealDate(sch).calcAllTimeByFcsj(sch); | |
| 7382 | - | |
| 7383 | - //处理计达跨24点 | |
| 7384 | - LineConfig conf = lineConfigData.get(sch.getXlBm()); | |
| 7385 | - if (sch.getZdsj().compareTo(conf.getStartOpt()) < 0) { | |
| 7386 | - sch.setZdsjT(sdfyyyyMMddHHmm.parse(sch.getScheduleDateStr() + sch.getZdsj()).getTime() + (1000 * 60 * 60 * 24)); | |
| 7387 | - } | |
| 7388 | - | |
| 7389 | - //班次历时 | |
| 7390 | - sch.setBcsj((int) ((sch.getZdsjT() - sch.getDfsjT()) / 1000 / 60)); | |
| 7391 | - if (sch.getZdsjT() < sch.getFcsjT()) { | |
| 7392 | - rs.put("status", ResponseCode.ERROR); | |
| 7393 | - rs.put("msg", "起终点时间异常!"); | |
| 7394 | - return rs; | |
| 7395 | - } | |
| 7396 | - | |
| 7397 | - sch.setId(dayOfSchedule.getId()); | |
| 7398 | - //实时入库 | |
| 7399 | - super.save(sch); | |
| 7400 | - | |
| 7401 | - // 加入缓存 | |
| 7402 | - dayOfSchedule.put(sch); | |
| 7403 | - | |
| 7404 | - //更新起点应到时间 | |
| 7405 | - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); | |
| 7406 | - | |
| 7407 | - //重新计算车辆当前执行班次 | |
| 7408 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | |
| 7409 | - | |
| 7410 | - //记录站到场历时数据 | |
| 7411 | - Station2ParkBuffer.put(sch); | |
| 7412 | - | |
| 7413 | - rs.put("ts", ts); | |
| 7414 | - rs.put("t", sch); | |
| 7415 | - } catch (Exception e) { | |
| 7416 | - logger.error("", e); | |
| 7417 | - rs.put("status", ResponseCode.ERROR); | |
| 7418 | - } | |
| 7419 | - return rs; | |
| 7420 | - } | |
| 7421 | - | |
| 7422 | - /** | |
| 7423 | - * 删除历史表临加班次 | |
| 7424 | - * | |
| 7425 | - * @param id | |
| 7426 | - * @return | |
| 7427 | - */ | |
| 7428 | - @Override | |
| 7429 | - public Map<String, Object> deleteToHistory(Long id) { | |
| 7430 | - Map<String, Object> rs = new HashMap<>(); | |
| 7431 | - rs.put("status", ResponseCode.ERROR); | |
| 7432 | - | |
| 7433 | - try { | |
| 7434 | - ScheduleRealInfo sch = super.findById(id); | |
| 7435 | - if (sch == null) { | |
| 7436 | - rs.put("msg", "无效的id号"); | |
| 7437 | - return rs; | |
| 7438 | - } | |
| 7439 | - | |
| 7440 | - if (!sch.isSflj()) { | |
| 7441 | - rs.put("msg", "你只能删除临加班次"); | |
| 7442 | - return rs; | |
| 7443 | - } | |
| 7444 | - | |
| 7445 | - //解除和调度指令的外键约束 | |
| 7446 | - jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | |
| 7447 | - | |
| 7448 | - //数据库删除 | |
| 7449 | - rs = super.delete(id); | |
| 7450 | - } catch (Exception e) { | |
| 7451 | - logger.error("", e); | |
| 7452 | - rs.put("msg", e.getMessage()); | |
| 7453 | - } | |
| 7454 | - | |
| 7455 | - return rs; | |
| 7456 | - } | |
| 7457 | - | |
| 7458 | - @Override | |
| 7459 | - public Map<String, Object> delete(Long id) { | |
| 7460 | - Map<String, Object> rs = new HashMap<>(); | |
| 7461 | - rs.put("status", ResponseCode.ERROR); | |
| 7462 | - | |
| 7463 | - ScheduleRealInfo sch = null; | |
| 7464 | - try { | |
| 7465 | - sch = dayOfSchedule.get(id); | |
| 7466 | - if (sch == null) { | |
| 7467 | - rs.put("msg", "无效的id号"); | |
| 7468 | - return rs; | |
| 7469 | - } | |
| 7470 | - | |
| 7471 | - if (!sch.isSflj()) { | |
| 7472 | - rs.put("msg", "你只能删除临加班次"); | |
| 7473 | - return rs; | |
| 7474 | - } | |
| 7475 | - | |
| 7476 | - sch.setDeleted(true); | |
| 7477 | - //解除和调度指令的外键约束 | |
| 7478 | - jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | |
| 7479 | - | |
| 7480 | - //数据库删除 | |
| 7481 | - rs = super.delete(id); | |
| 7482 | - if (rs.get("status").equals(ResponseCode.SUCCESS)) { | |
| 7483 | - dayOfSchedule.delete(sch); | |
| 7484 | - //更新起点应到时间 | |
| 7485 | - List<ScheduleRealInfo> ts = dayOfSchedule.updateQdzTimePlan(sch); | |
| 7486 | - rs.put("ts", ts); | |
| 7487 | - rs.put("delete", sch); | |
| 7488 | - } else | |
| 7489 | - sch.setDeleted(false); | |
| 7490 | - } catch (Exception e) { | |
| 7491 | - logger.error("", e); | |
| 7492 | - rs.put("msg", e.getMessage()); | |
| 7493 | - sch.setDeleted(false); | |
| 7494 | - } | |
| 7495 | - | |
| 7496 | - return rs; | |
| 7497 | - } | |
| 7498 | - | |
| 7499 | - @Override | |
| 7500 | - public List<Map<String, String>> sreachVehic(String nbbm) { | |
| 7501 | - // 转大写 | |
| 7502 | - nbbm = nbbm.toUpperCase(); | |
| 7503 | - | |
| 7504 | - List<Map<String, String>> list = new ArrayList<>(); | |
| 7505 | - Map<String, String> map; | |
| 7506 | - Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet(); | |
| 7507 | - | |
| 7508 | - Line line; | |
| 7509 | - for (String k : allSet) { | |
| 7510 | - if (k.indexOf(nbbm) != -1) { | |
| 7511 | - // 所属线路 | |
| 7512 | - map = new HashMap<>(); | |
| 7513 | - line = BasicData.nbbm2LineMap.get(k); | |
| 7514 | - map.put("id", k); | |
| 7515 | - map.put("text", k); | |
| 7516 | - if (null != line) { | |
| 7517 | - map.put("lineName", line.getName()); | |
| 7518 | - map.put("lineCode", line.getLineCode()); | |
| 7519 | - } | |
| 7520 | - | |
| 7521 | - list.add(map); | |
| 7522 | - } | |
| 7523 | - | |
| 7524 | - if (list.size() > 20) | |
| 7525 | - break; | |
| 7526 | - } | |
| 7527 | - return list; | |
| 7528 | - } | |
| 7529 | - | |
| 7530 | - @Override | |
| 7531 | - public void adjustCar(ScheduleRealInfo schedule, String car) { | |
| 7532 | - schedule.setClZbh(car); | |
| 7533 | - } | |
| 7534 | - | |
| 7535 | - @Override | |
| 7536 | - public void adjustDriver(ScheduleRealInfo schedule, String driver, String driverName) { | |
| 7537 | - if (driver.indexOf("-") != -1) | |
| 7538 | - driver = driver.split("-")[1]; | |
| 7539 | - schedule.setjGh(driver); | |
| 7540 | - schedule.setjName(driverName); | |
| 7541 | - } | |
| 7542 | - | |
| 7543 | - @Override | |
| 7544 | - public void adjustConductor(ScheduleRealInfo schedule, String conductor, String conductorName) { | |
| 7545 | - if (conductor.indexOf("-") != -1) | |
| 7546 | - conductor = conductor.split("-")[1]; | |
| 7547 | - schedule.setsGh(conductor); | |
| 7548 | - schedule.setsName(conductorName); | |
| 7549 | - } | |
| 7550 | - | |
| 7551 | - @Override | |
| 7552 | - public List<ScheduleRealInfo> queryUserInfo(String line, String date, String state) { | |
| 7553 | - List<ScheduleRealInfo> scheduleRealInfos = new ArrayList<>(); | |
| 7554 | - List<Object[]> objects = null; | |
| 7555 | - if (state.equals("2")) { | |
| 7556 | - objects = scheduleRealInfoRepository.queryUserInfo2(line, date); | |
| 7557 | - for (Object[] objs : objects) { | |
| 7558 | - ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo(); | |
| 7559 | - scheduleRealInfo.setId((Long)objs[0]); | |
| 7560 | - scheduleRealInfo.setjGh((String)objs[1]); | |
| 7561 | - scheduleRealInfo.setClZbh((String)objs[2]); | |
| 7562 | - scheduleRealInfo.setLpName((String)objs[3]); | |
| 7563 | - scheduleRealInfo.setjName((String)objs[4]); | |
| 7564 | - | |
| 7565 | - scheduleRealInfos.add(scheduleRealInfo); | |
| 7566 | - } | |
| 7567 | - } else { | |
| 7568 | - objects = scheduleRealInfoRepository.queryUserInfo3(line, date); | |
| 7569 | - for (Object[] objs : objects) { | |
| 7570 | - ScheduleRealInfo scheduleRealInfo = new ScheduleRealInfo(); | |
| 7571 | - scheduleRealInfo.setId((Long)objs[0]); | |
| 7572 | - scheduleRealInfo.setClZbh((String)objs[1]); | |
| 7573 | - | |
| 7574 | - scheduleRealInfos.add(scheduleRealInfo); | |
| 7575 | - } | |
| 7576 | - } | |
| 7577 | - | |
| 7578 | - return scheduleRealInfos; | |
| 7579 | - } | |
| 7580 | - | |
| 7581 | - @Override | |
| 7582 | - public List<ScheduleRealInfo> queryUserInfoPx(String line, String date, String state, String type) { | |
| 7583 | -// List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | |
| 7584 | - state = state + ""; | |
| 7585 | - String lpname = state; | |
| 7586 | - String px = type; | |
| 7587 | - if (state.equals("lpName")) { | |
| 7588 | - state = state + "+1"; | |
| 7589 | - type = "ASC"; | |
| 7590 | - } | |
| 7591 | - String minfcsj = "02:00"; | |
| 7592 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 7593 | - if (lineList.size() > 0) { | |
| 7594 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 7595 | - + " id = (" | |
| 7596 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 7597 | - + ")"; | |
| 7598 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 7599 | - } | |
| 7600 | - String sqlPlan = "select * from (select * from (" | |
| 7601 | - + " select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, " | |
| 7602 | - + " s.lp_Name as lpName,min(s.j_Name) as jName,max(s.schedule_date_str) as dateStr ," | |
| 7603 | - + " min(s.fcsj) as fcsj,1 as px from bsth_c_s_sp_info_real s where " | |
| 7604 | - + " s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'" | |
| 7605 | - + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name) x where x.fcsj >'" + minfcsj + "'" | |
| 7606 | - + " UNION " | |
| 7607 | - + " select * from ( select min(s.id) as id,s.j_Gh as jGh,s.cl_Zbh as clZbh, " | |
| 7608 | - + " s.lp_Name as lpName,min(s.j_Name) as jName, max(s.schedule_date_str) as dateStr," | |
| 7609 | - + " min(s.fcsj) as fcsj,2 as px from bsth_c_s_sp_info_real s " | |
| 7610 | - + " where s.xl_Bm = '" + line + "' and s.schedule_date_str ='" + date + "'" | |
| 7611 | - + " GROUP BY s.j_Gh,s.cl_Zbh,s.lp_Name" | |
| 7612 | - + " ) y where y.fcsj <='" + minfcsj + "') z order by (" + state + "),dateStr,px,fcsj " + type; | |
| 7613 | - List<ScheduleRealInfo> list = jdbcTemplate.query(sqlPlan, | |
| 7614 | - new RowMapper<ScheduleRealInfo>() { | |
| 7615 | - @Override | |
| 7616 | - public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 7617 | - ScheduleRealInfo t = new ScheduleRealInfo(); | |
| 7618 | - t.setId(rs.getLong("id")); | |
| 7619 | - t.setjGh(rs.getString("jGh")); | |
| 7620 | - t.setClZbh(rs.getString("clZbh")); | |
| 7621 | - t.setLpName(rs.getString("lpName")); | |
| 7622 | - t.setjName(rs.getString("jName")); | |
| 7623 | - t.setFcsj(rs.getString("fcsj")); | |
| 7624 | - return t; | |
| 7625 | - } | |
| 7626 | - }); | |
| 7627 | - if (lpname.equals("lpName")) { | |
| 7628 | - | |
| 7629 | - List<ScheduleRealInfo> listNew = new ArrayList<ScheduleRealInfo>(); | |
| 7630 | - Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); | |
| 7631 | -// if (px.equals("desc")) { | |
| 7632 | - int zt = 0; | |
| 7633 | - for (int l = 0; l < 2; l++) { | |
| 7634 | - for (int i = 0; i < list.size(); i++) { | |
| 7635 | - ScheduleRealInfo t = list.get(i); | |
| 7636 | - if (t.getLpName().indexOf("+") != -1) { | |
| 7637 | - if (zt == 0) { | |
| 7638 | - listNew.add(t); | |
| 7639 | - } | |
| 7640 | - } else if (pattern.matcher(t.getLpName()).matches()) { | |
| 7641 | - if (zt == 1) { | |
| 7642 | - listNew.add(t); | |
| 7643 | - } | |
| 7644 | - } else { | |
| 7645 | - continue; | |
| 7646 | - } | |
| 7647 | - } | |
| 7648 | - zt++; | |
| 7649 | - } | |
| 7650 | - | |
| 7651 | - Collections.sort(list, new ComparableLp()); | |
| 7652 | - for (int i = 0; i < list.size(); i++) { | |
| 7653 | - ScheduleRealInfo t = list.get(i); | |
| 7654 | - if (t.getLpName().indexOf("+") != -1) { | |
| 7655 | - continue; | |
| 7656 | - } else if (pattern.matcher(t.getLpName()).matches()) { | |
| 7657 | - continue; | |
| 7658 | - } else { | |
| 7659 | - listNew.add(t); | |
| 7660 | - } | |
| 7661 | - } | |
| 7662 | - return listNew; | |
| 7663 | - } else { | |
| 7664 | - return list; | |
| 7665 | - } | |
| 7666 | - | |
| 7667 | - } | |
| 7668 | - | |
| 7669 | - /** | |
| 7670 | - * | |
| 7671 | - */ | |
| 7672 | - @Override | |
| 7673 | - public List<ScheduleRealInfo> exportWaybill(String jName,String jGh, String clZbh, String lpName, String date, String line) { | |
| 7674 | - ReportUtils ee = new ReportUtils(); | |
| 7675 | - ReportRelatedUtils rru = new ReportRelatedUtils(); | |
| 7676 | - List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | |
| 7677 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | |
| 7678 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
| 7679 | -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line); | |
| 7680 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 7681 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 7682 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | |
| 7683 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 7684 | - if (cts != null && cts.size() > 0) { | |
| 7685 | - lists.add(s); | |
| 7686 | - } else { | |
| 7687 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 7688 | - lists.add(s); | |
| 7689 | - } | |
| 7690 | - } | |
| 7691 | - } | |
| 7692 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 7693 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | |
| 7694 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | |
| 7695 | - //计算里程和班次数,并放入Map里 | |
| 7696 | - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); | |
| 7697 | - | |
| 7698 | - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos))); | |
| 7699 | - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos)); | |
| 7700 | - map.put("addMileage", culateMieageService.culateLjgl(lists)); | |
| 7701 | - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists)); | |
| 7702 | - map.put("yygl", yygl); | |
| 7703 | - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists)); | |
| 7704 | - map.put("ksgl", ksgl); | |
| 7705 | - map.put("realMileage", Arith.add(yygl, ksgl)); | |
| 7706 | - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, "")); | |
| 7707 | - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos)); | |
| 7708 | - map.put("ljbc", culateMieageService.culateLjbc(lists, "")); | |
| 7709 | - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, ""); | |
| 7710 | - map.put("sjbc", sjbc); | |
| 7711 | -// map=new HashMap<String,Object>(); | |
| 7712 | - | |
| 7713 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 7714 | - String minfcsj = "02:00"; | |
| 7715 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 7716 | - if (lineList.size() > 0) { | |
| 7717 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 7718 | - + " id = (" | |
| 7719 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 7720 | - + ")"; | |
| 7721 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 7722 | - } | |
| 7723 | - String[] minSjs = minfcsj.split(":"); | |
| 7724 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | |
| 7725 | - | |
| 7726 | - | |
| 7727 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 7728 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | |
| 7729 | - String[] fcsj = s.getFcsj().split(":"); | |
| 7730 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 7731 | - | |
| 7732 | - Long fscjT = 0L; | |
| 7733 | - if (fcsjL < minSj) { | |
| 7734 | - Calendar calendar = new GregorianCalendar(); | |
| 7735 | - calendar.setTime(s.getScheduleDate()); | |
| 7736 | - calendar.add(calendar.DATE, 1); | |
| 7737 | - s.setScheduleDate(calendar.getTime()); | |
| 7738 | - try { | |
| 7739 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | |
| 7740 | - } catch (ParseException e) { | |
| 7741 | - // TODO Auto-generated catch block | |
| 7742 | - e.printStackTrace(); | |
| 7743 | - } | |
| 7744 | - | |
| 7745 | - } else { | |
| 7746 | - try { | |
| 7747 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 7748 | - } catch (ParseException e) { | |
| 7749 | - // TODO Auto-generated catch block | |
| 7750 | - e.printStackTrace(); | |
| 7751 | - } | |
| 7752 | - ; | |
| 7753 | - } | |
| 7754 | - s.setFcsjT(fscjT); | |
| 7755 | - } | |
| 7756 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | |
| 7757 | - Collections.sort(scheduleRealInfos, new ComparableReal()); | |
| 7758 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 7759 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | |
| 7760 | - s.setAdjustExps(i + 1 + ""); | |
| 7761 | - String remarks = ""; | |
| 7762 | - if (s.getRemarks() != null) { | |
| 7763 | - remarks += s.getRemarks(); | |
| 7764 | - } | |
| 7765 | - | |
| 7766 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | |
| 7767 | - if (!childTaskPlans.isEmpty()) { | |
| 7768 | - s.setFcsjActual(""); | |
| 7769 | - s.setZdsjActual(""); | |
| 7770 | - s.setJhlc(0.0); | |
| 7771 | - } | |
| 7772 | - | |
| 7773 | - if (s.isDestroy()) { | |
| 7774 | - s.setFcsjActual(""); | |
| 7775 | - s.setZdsjActual(""); | |
| 7776 | - s.setJhlc(0.0); | |
| 7777 | - remarks += "(烂班)"; | |
| 7778 | - s.setRemarks(remarks); | |
| 7779 | - } | |
| 7780 | - | |
| 7781 | - listSchedule.add(s); | |
| 7782 | - //计算营运里程,空驶里程 | |
| 7783 | - if (!childTaskPlans.isEmpty()) { | |
| 7784 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 7785 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | |
| 7786 | - Collections.sort(listit, new ComparableChild()); | |
| 7787 | - for (int j = 0; j < listit.size(); j++) { | |
| 7788 | - ScheduleRealInfo t = new ScheduleRealInfo(); | |
| 7789 | - ChildTaskPlan childTaskPlan = listit.get(j); | |
| 7790 | - if (childTaskPlan.isDestroy()) { | |
| 7791 | - t.setFcsjActual(""); | |
| 7792 | - t.setZdsjActual(""); | |
| 7793 | - t.setJhlc(0.0); | |
| 7794 | - } else { | |
| 7795 | - t.setFcsjActual(childTaskPlan.getStartDate()); | |
| 7796 | - t.setZdsjActual(childTaskPlan.getEndDate()); | |
| 7797 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | |
| 7798 | - } | |
| 7799 | - t.setQdzName(childTaskPlan.getStartStationName()); | |
| 7800 | - t.setZdzName(childTaskPlan.getEndStationName()); | |
| 7801 | - t.setRemarks(childTaskPlan.getRemarks()); | |
| 7802 | - t.setAdjustExps("子"); | |
| 7803 | - t.setjGh(""); | |
| 7804 | - t.setjName(""); | |
| 7805 | - t.setsGh(""); | |
| 7806 | - t.setsName(""); | |
| 7807 | - listSchedule.add(t); | |
| 7808 | - } | |
| 7809 | - } | |
| 7810 | - } | |
| 7811 | - Map<String, Object> maps; | |
| 7812 | - for (ScheduleRealInfo scheduleRealInfo : listSchedule) { | |
| 7813 | - maps = new HashMap<String, Object>(); | |
| 7814 | - try { | |
| 7815 | - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | |
| 7816 | - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | |
| 7817 | - maps = rru.getMapValue(scheduleRealInfo); | |
| 7818 | - maps.put("bcs", scheduleRealInfo.getAdjustExps()); | |
| 7819 | - String zdsj = scheduleRealInfo.getZdsj(); | |
| 7820 | - String zdsjActual = scheduleRealInfo.getZdsjActual(); | |
| 7821 | - if (zdsj != null && zdsjActual != null && | |
| 7822 | - !zdsj.equals(zdsjActual) && | |
| 7823 | - !zdsj.equals("") && | |
| 7824 | - !zdsjActual.equals("")) { | |
| 7825 | - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | |
| 7826 | - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | |
| 7827 | - if (zdsj.compareTo(zdsjActual) > 0) { | |
| 7828 | - if (zdsjT - zdsjAT > 1000) { | |
| 7829 | - maps.put("fast", ""); | |
| 7830 | - maps.put("slow", zdsjAT - zdsjT + 1440); | |
| 7831 | - } else { | |
| 7832 | - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | |
| 7833 | - maps.put("slow", ""); | |
| 7834 | - } | |
| 7835 | - } else { | |
| 7836 | - if (zdsjAT - zdsjT > 1000) { | |
| 7837 | - maps.put("fast", zdsjT - zdsjAT + 1440); | |
| 7838 | - maps.put("slow", ""); | |
| 7839 | - } else { | |
| 7840 | - maps.put("fast", ""); | |
| 7841 | - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | |
| 7842 | - } | |
| 7843 | - } | |
| 7844 | - } else { | |
| 7845 | - maps.put("fast", ""); | |
| 7846 | - maps.put("slow", ""); | |
| 7847 | - } | |
| 7848 | - listMap.add(maps); | |
| 7849 | - } catch (Exception e) { | |
| 7850 | - e.printStackTrace(); | |
| 7851 | - } | |
| 7852 | - } | |
| 7853 | - | |
| 7854 | - String xls = ""; | |
| 7855 | - if (map.get("type").toString().equals("0")) { | |
| 7856 | - xls = "waybill_minhang.xls"; | |
| 7857 | - } else { | |
| 7858 | - xls = "waybill_minhang_dl.xls"; | |
| 7859 | - } | |
| 7860 | - | |
| 7861 | - | |
| 7862 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 7863 | - | |
| 7864 | - list.add(listMap.iterator()); | |
| 7865 | - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/" + xls, | |
| 7866 | - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | |
| 7867 | - return scheduleRealInfos; | |
| 7868 | - } | |
| 7869 | - | |
| 7870 | - @Override | |
| 7871 | - public List<Map<String, Object>> dailyInfo(String line, String date, String type) { | |
| 7872 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 7873 | - ReportUtils ee = new ReportUtils(); | |
| 7874 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 7875 | - List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date); | |
| 7876 | - | |
| 7877 | - double totalZGL = 0, totalKSGL = 0, totalYH = 0; | |
| 7878 | - int totalBCS = 0; | |
| 7879 | - for (int i = 0; i < list.size(); i++) { | |
| 7880 | - String zgl = format.format(Double.parseDouble(list.get(i).get("zgl") == null ? "0" : list.get(i).get("zgl").toString())); | |
| 7881 | - String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl") == null ? "0" : list.get(i).get("ksgl").toString())); | |
| 7882 | - if (type.equals("export")) { | |
| 7883 | - totalZGL += Double.parseDouble(zgl); | |
| 7884 | - totalKSGL += Double.parseDouble(ksgl); | |
| 7885 | - totalBCS += Integer.parseInt(list.get(i).get("bcs").toString()); | |
| 7886 | - } | |
| 7887 | - list.get(i).put("zgl", zgl); | |
| 7888 | - list.get(i).put("ksgl", ksgl); | |
| 7889 | - } | |
| 7890 | - if (type.equals("export")) { | |
| 7891 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 7892 | - map.put("line", line); | |
| 7893 | - map.put("date", date); | |
| 7894 | - map.put("totalZGL", totalZGL); | |
| 7895 | - map.put("totalKSGL", totalKSGL); | |
| 7896 | - map.put("totalYH", totalYH); | |
| 7897 | - map.put("totalBCS", totalBCS); | |
| 7898 | - | |
| 7899 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 7900 | - | |
| 7901 | - listI.add(list.iterator()); | |
| 7902 | - try { | |
| 7903 | - ee.excelReplace(listI, new Object[]{map}, path + "mould/daily.xls", | |
| 7904 | - path + "export/班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | |
| 7905 | - } catch (ParseException e) { | |
| 7906 | - e.printStackTrace(); | |
| 7907 | - } | |
| 7908 | - } | |
| 7909 | - return list; | |
| 7910 | - } | |
| 7911 | - | |
| 7912 | - @Override | |
| 7913 | - public List<Object[]> historyMessage(String line, String date, String code, String type) { | |
| 7914 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 7915 | - | |
| 7916 | - long d = 0; | |
| 7917 | - long t = 0; | |
| 7918 | - if (date.length() > 0) { | |
| 7919 | - try { | |
| 7920 | - d = sdf.parse(date + " 00:00:00").getTime(); | |
| 7921 | - t = sdf.parse(date + " 23:59:59").getTime(); | |
| 7922 | - } catch (ParseException e) { | |
| 7923 | - // TODO Auto-generated catch block | |
| 7924 | - e.printStackTrace(); | |
| 7925 | - } | |
| 7926 | - | |
| 7927 | - } | |
| 7928 | - String device = ""; | |
| 7929 | - String device2 =""; | |
| 7930 | - long qyrqTime=0l; | |
| 7931 | - if (!code.equals("")) { | |
| 7932 | - try { | |
| 7933 | - List<CarDevice> deviceList=carDeviceRepository.findCarCode(code, sdf.parse(date+ " 00:00:00")); | |
| 7934 | - if(deviceList.size()>0){ | |
| 7935 | - device=deviceList.get(0).getOldDeviceNo(); | |
| 7936 | - Date qyrq=deviceList.get(0).getQyrq(); | |
| 7937 | - qyrqTime=qyrq.getTime(); | |
| 7938 | - if(qyrqTime<t){ | |
| 7939 | - device2=deviceList.get(0).getNewDeviceNo(); | |
| 7940 | - } | |
| 7941 | - }else{ | |
| 7942 | - device = BasicData.deviceId2NbbmMap.inverse().get(code); | |
| 7943 | - } | |
| 7944 | - } catch (ParseException e) { | |
| 7945 | - // TODO Auto-generated catch block | |
| 7946 | - e.printStackTrace(); | |
| 7947 | - } | |
| 7948 | - } | |
| 7949 | - List<Object[]> list=new ArrayList<Object[]>(); | |
| 7950 | - | |
| 7951 | - List<Object[]> list0 =scheduleRealInfoRepository.historyMessage(line, d, t, device); | |
| 7952 | - for (Object[] obj : list0) { | |
| 7953 | - if (obj != null) { | |
| 7954 | - if(code.equals("")){ | |
| 7955 | - if (BasicData.deviceId2NbbmMap.get(obj[0].toString()) == null) { | |
| 7956 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | |
| 7957 | - try { | |
| 7958 | - carDeviceList = carDeviceRepository.findCarDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | |
| 7959 | - //启用日期大于营运日期 还是根据旧设备号查询 | |
| 7960 | - if(carDeviceList.size()==0){ | |
| 7961 | - carDeviceList = carDeviceRepository.findCarOldDevice(obj[0].toString(), new Date(Long.parseLong(obj[3].toString()))); | |
| 7962 | - } | |
| 7963 | - } catch (Exception e) { | |
| 7964 | - // TODO Auto-generated catch block | |
| 7965 | - e.printStackTrace(); | |
| 7966 | - } | |
| 7967 | - if (carDeviceList.size() > 0) { | |
| 7968 | - obj[0] = carDeviceList.get(0).getClZbh(); | |
| 7969 | - } else { | |
| 7970 | - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | |
| 7971 | - } | |
| 7972 | - } else { | |
| 7973 | - obj[0] = BasicData.deviceId2NbbmMap.get(obj[0].toString()); | |
| 7974 | - } | |
| 7975 | - }else{ | |
| 7976 | - obj[0]=code; | |
| 7977 | - } | |
| 7978 | - | |
| 7979 | - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | |
| 7980 | - obj[4] = BasicData.lineCode2NameMap.get(line); | |
| 7981 | - } | |
| 7982 | - } | |
| 7983 | - list.addAll(list0); | |
| 7984 | - if(!device2.equals("")){ | |
| 7985 | - List<Object[]> list1 =scheduleRealInfoRepository.historyMessage(line, d, t, device2); | |
| 7986 | - for (Object[] obj : list1) { | |
| 7987 | - if (obj != null) { | |
| 7988 | - obj[0] =code; | |
| 7989 | - obj[3] = sdf.format(new Date(Long.parseLong(obj[3].toString()))); | |
| 7990 | - obj[4] = BasicData.lineCode2NameMap.get(line); | |
| 7991 | - } | |
| 7992 | - } | |
| 7993 | - list.addAll(list1); | |
| 7994 | - } | |
| 7995 | - | |
| 7996 | - if (type != null && type.length() != 0 && type.equals("export")) { | |
| 7997 | - String lineName = BasicData.lineCode2NameMap.get(line); | |
| 7998 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 7999 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 8000 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 8001 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 8002 | - ReportUtils ee = new ReportUtils(); | |
| 8003 | - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | |
| 8004 | - for (int i = 0; i < list.size(); i++) { | |
| 8005 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 8006 | - Object[] obj = list.get(i); | |
| 8007 | - map.put("num", i + 1); | |
| 8008 | - map.put("line", obj[4]); | |
| 8009 | - map.put("clZbh", obj[0]); | |
| 8010 | - map.put("sender", obj[1]); | |
| 8011 | - map.put("date", obj[3]); | |
| 8012 | - map.put("text", obj[2]); | |
| 8013 | - newList.add(map); | |
| 8014 | - } | |
| 8015 | - try { | |
| 8016 | - listI.add(newList.iterator()); | |
| 8017 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 8018 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/historyMessage.xls", | |
| 8019 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | |
| 8020 | - + "-" + lineName + "-调度历史消息.xls"); | |
| 8021 | - } catch (Exception e) { | |
| 8022 | - // TODO: handle exception | |
| 8023 | - e.printStackTrace(); | |
| 8024 | - } | |
| 8025 | - } | |
| 8026 | - | |
| 8027 | - if (type != null && type.length() != 0 && type.equals("export_msg")) { | |
| 8028 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 8029 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 8030 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 8031 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 8032 | - ReportUtils ee = new ReportUtils(); | |
| 8033 | - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | |
| 8034 | - for (int i = 0; i < list.size(); i++) { | |
| 8035 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 8036 | - Object[] obj = list.get(i); | |
| 8037 | - map.put("num", i + 1); | |
| 8038 | - map.put("line", obj[4]); | |
| 8039 | - map.put("clZbh", obj[0]); | |
| 8040 | - map.put("sender", obj[1]); | |
| 8041 | - map.put("date", obj[3]); | |
| 8042 | - map.put("text", obj[2]); | |
| 8043 | - newList.add(map); | |
| 8044 | - } | |
| 8045 | - try { | |
| 8046 | - listI.add(newList.iterator()); | |
| 8047 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 8048 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/message.xls", | |
| 8049 | - path + "export/调度消息分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | |
| 8050 | - } catch (Exception e) { | |
| 8051 | - // TODO: handle exception | |
| 8052 | - e.printStackTrace(); | |
| 8053 | - } | |
| 8054 | - } | |
| 8055 | - return list; | |
| 8056 | - } | |
| 8057 | - | |
| 8058 | - @Override | |
| 8059 | - public Map<Integer, Integer> trustStatus(String lineStr) { | |
| 8060 | - List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lineStr)); | |
| 8061 | - | |
| 8062 | - Map<Integer, Integer> map = new HashMap<>(); | |
| 8063 | - return map; | |
| 8064 | - } | |
| 8065 | - | |
| 8066 | - @Override | |
| 8067 | - public Map<String, Object> realOutAdjust(Map<String, String> map) { | |
| 8068 | - Map<String, Object> rs = new HashMap<>(); | |
| 8069 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | |
| 8070 | - try { | |
| 8071 | - // 维修上报 | |
| 8072 | - if (StringUtils.isNotBlank(map.get("reportTypes"))) { | |
| 8073 | - Map<String, Object> param = new HashMap<String, Object>(); | |
| 8074 | - param.putAll(map); | |
| 8075 | - rs = repairReport(param, false); | |
| 8076 | - } | |
| 8077 | - | |
| 8078 | - Long id = Long.parseLong(map.get("id")); | |
| 8079 | - String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual"); | |
| 8080 | - | |
| 8081 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 8082 | - | |
| 8083 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | |
| 8084 | - //小于线路开始运营时间,则默认跨过24点 | |
| 8085 | - if (fcsjActual.compareTo(config.getStartOpt()) < 0) { | |
| 8086 | - sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)); | |
| 8087 | - } else { | |
| 8088 | - sch.setRealExecDate(sch.getScheduleDateStr()); | |
| 8089 | - } | |
| 8090 | - | |
| 8091 | - //日志记录 | |
| 8092 | - ScheduleModifyLogger.sftz(sch, fcsjActual, remarks); | |
| 8093 | - | |
| 8094 | - sch.setFcsjActualAll(fcsjActual); | |
| 8095 | - sch.setRemarks(remarks); | |
| 8096 | - sch.calcStatus(); | |
| 8097 | - //if(sch.isLate2()){ | |
| 8098 | - //取消应发未到标记 | |
| 8099 | - // sch.setLate2(false); | |
| 8100 | - LateAdjustHandle.remove(sch); | |
| 8101 | - //} | |
| 8102 | - | |
| 8103 | - dayOfSchedule.save(sch); | |
| 8104 | - | |
| 8105 | - ts.add(sch); | |
| 8106 | - | |
| 8107 | - rs.put("status", ResponseCode.SUCCESS); | |
| 8108 | - rs.put("ts", ts); | |
| 8109 | - | |
| 8110 | - //通知页面刷新 | |
| 8111 | - sendUtils.refreshSch(ts); | |
| 8112 | - } catch (Exception e) { | |
| 8113 | - logger.error("", e); | |
| 8114 | - rs.put("status", ResponseCode.ERROR); | |
| 8115 | - } | |
| 8116 | - | |
| 8117 | - return rs; | |
| 8118 | - } | |
| 8119 | - | |
| 8120 | - @Override | |
| 8121 | - public Map<String, Object> revokeDestroy(Long id) { | |
| 8122 | - Map<String, Object> rs = new HashMap<>(); | |
| 8123 | - try { | |
| 8124 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 8125 | - if (sch.getStatus() != -1) { | |
| 8126 | - rs.put("status", ResponseCode.ERROR); | |
| 8127 | - rs.put("msg", "未烂班,无法撤销!"); | |
| 8128 | - } else { | |
| 8129 | - //日志记录 | |
| 8130 | - ScheduleModifyLogger.cxlb(sch); | |
| 8131 | - | |
| 8132 | - sch.setStatus(0); | |
| 8133 | - sch.setRemarks("");//清空备注 | |
| 8134 | - sch.setJhlc(sch.getJhlcOrig()); | |
| 8135 | - | |
| 8136 | - //入库 | |
| 8137 | - dayOfSchedule.save(sch); | |
| 8138 | - //重新计算当前执行班次 | |
| 8139 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | |
| 8140 | - rs.put("status", ResponseCode.SUCCESS); | |
| 8141 | - rs.put("t", sch); | |
| 8142 | - | |
| 8143 | - } | |
| 8144 | - } catch (Exception e) { | |
| 8145 | - logger.error("", e); | |
| 8146 | - rs.put("status", ResponseCode.ERROR); | |
| 8147 | - } | |
| 8148 | - return rs; | |
| 8149 | - } | |
| 8150 | - | |
| 8151 | - @Override | |
| 8152 | - public Map<String, Object> revokeRealOutgo(Long id) { | |
| 8153 | - Map<String, Object> rs = new HashMap<>(); | |
| 8154 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | |
| 8155 | - | |
| 8156 | - try { | |
| 8157 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 8158 | - if (sch.getFcsjActual() == null) { | |
| 8159 | - rs.put("status", ResponseCode.ERROR); | |
| 8160 | - rs.put("msg", "无实发时间,无法撤销!"); | |
| 8161 | - } else { | |
| 8162 | - //日志记录 | |
| 8163 | - ScheduleModifyLogger.cxsf(sch); | |
| 8164 | - | |
| 8165 | - sch.clearFcsjActual(); | |
| 8166 | - rs.put("status", ResponseCode.SUCCESS); | |
| 8167 | - | |
| 8168 | - ts.add(sch); | |
| 8169 | - rs.put("ts", ts); | |
| 8170 | - | |
| 8171 | - dayOfSchedule.save(sch); | |
| 8172 | - | |
| 8173 | - } | |
| 8174 | - } catch (Exception e) { | |
| 8175 | - logger.error("", e); | |
| 8176 | - rs.put("status", ResponseCode.ERROR); | |
| 8177 | - } | |
| 8178 | - return rs; | |
| 8179 | - } | |
| 8180 | - | |
| 8181 | - @Override | |
| 8182 | - public Map<String, Object> spaceAdjust(Long[] ids, Integer space) { | |
| 8183 | - | |
| 8184 | - List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null; | |
| 8185 | - Map<String, Object> rs = new HashMap<>(), tempRs = new HashMap<>(); | |
| 8186 | - try { | |
| 8187 | - ScheduleRealInfo sch, next; | |
| 8188 | - for (Long id : ids) { | |
| 8189 | - sch = dayOfSchedule.get(id); | |
| 8190 | - if (null != sch) | |
| 8191 | - list.add(sch); | |
| 8192 | - } | |
| 8193 | - | |
| 8194 | - int size = list.size(); | |
| 8195 | - if (size == 0) { | |
| 8196 | - rs.put("status", ResponseCode.ERROR); | |
| 8197 | - } else { | |
| 8198 | - // 按发车时间排序 | |
| 8199 | - Collections.sort(list, new ScheduleComparator.FCSJ()); | |
| 8200 | - | |
| 8201 | - // 以第一个实际发车/待发时间为起点,调整间隔 | |
| 8202 | - sch = list.get(0); | |
| 8203 | - Long st = sch.getFcsjActualTime() == null ? sch.getDfsjT() : sch.getFcsjActualTime(), plus = space * 60 * 1000L; | |
| 8204 | - | |
| 8205 | - for (int i = 1; i < size; i++) { | |
| 8206 | - st += plus; | |
| 8207 | - sch = list.get(i); | |
| 8208 | - | |
| 8209 | - //调整待发 | |
| 8210 | - tempRs = outgoAdjust(sch.getId(), null, fmtHHmm.print(st), null, "3", null); | |
| 8211 | - | |
| 8212 | - if (null != tempRs && tempRs.get("ts") != null) | |
| 8213 | - tempTs = (List<ScheduleRealInfo>) tempRs.get("ts"); | |
| 8214 | - | |
| 8215 | - ts.addAll(tempTs); | |
| 8216 | - } | |
| 8217 | - | |
| 8218 | - rs.put("status", ResponseCode.SUCCESS); | |
| 8219 | - //返回最后一个班次,页面会全量刷新 | |
| 8220 | - rs.put("ts", ts); | |
| 8221 | - } | |
| 8222 | - | |
| 8223 | - } catch (Exception e) { | |
| 8224 | - logger.error("", e); | |
| 8225 | - rs.put("status", ResponseCode.ERROR); | |
| 8226 | - } | |
| 8227 | - return rs; | |
| 8228 | - } | |
| 8229 | - | |
| 8230 | - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | |
| 8231 | - | |
| 8232 | - @Transactional | |
| 8233 | - @Override | |
| 8234 | - public Map<String, Object> schInfoFineTune(Map<String, String> map) { | |
| 8235 | - Map<String, Object> rs = new HashMap<>(); | |
| 8236 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | |
| 8237 | - try { | |
| 8238 | - // 维修上报 | |
| 8239 | - if (StringUtils.isNotBlank(map.get("reportTypes"))) { | |
| 8240 | - Map<String, Object> param = new HashMap<String, Object>(); | |
| 8241 | - param.putAll(map); | |
| 8242 | - rs = repairReport(param, false); | |
| 8243 | - } | |
| 8244 | - | |
| 8245 | - Long id = Long.parseLong(map.get("id")); | |
| 8246 | - String remarks = map.get("remarks"); | |
| 8247 | - | |
| 8248 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 8249 | - | |
| 8250 | - if (null == sch) { | |
| 8251 | - rs.put("status", ResponseCode.ERROR); | |
| 8252 | - rs.put("msg", "不存在的班次!"); | |
| 8253 | - return rs; | |
| 8254 | - } | |
| 8255 | - | |
| 8256 | - //日志记录器 | |
| 8257 | - FcxxwtLogger fLog = FcxxwtLogger.start(sch, remarks); | |
| 8258 | - | |
| 8259 | - String clZbh = map.get("clZbh"); | |
| 8260 | - String jsy = map.get("jsy"); | |
| 8261 | - if (!clZbh.equals(sch.getClZbh()) | |
| 8262 | - || !jsy.equals(sch.getjGh() + "/" + sch.getjName())) | |
| 8263 | - schModifyLog.saveChangetochange(sch, clZbh, jsy);//为换人换车情况表写入数据 | |
| 8264 | - /** | |
| 8265 | - * 换车 | |
| 8266 | - */ | |
| 8267 | - if (StringUtils.isNotEmpty(clZbh) && !clZbh.equals(sch.getClZbh())) { | |
| 8268 | - //换车 | |
| 8269 | - if (!carExist(sch.getGsBm(), clZbh)) { | |
| 8270 | - rs.put("status", ResponseCode.ERROR); | |
| 8271 | - rs.put("msg", "车辆 " + clZbh + " 不存在!"); | |
| 8272 | - return rs; | |
| 8273 | - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(clZbh))) { | |
| 8274 | - rs.put("status", ResponseCode.ERROR); | |
| 8275 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + clZbh + "】的车辆"); | |
| 8276 | - return rs; | |
| 8277 | - } else { | |
| 8278 | - fLog.log("换车", sch.getClZbh(), clZbh); | |
| 8279 | - dayOfSchedule.changeCar(sch, clZbh); | |
| 8280 | - } | |
| 8281 | - } | |
| 8282 | - | |
| 8283 | - if(StringUtils.isBlank(jsy) || "/".equals(StringUtils.trim(jsy))){ | |
| 8284 | - rs.put("status", ResponseCode.ERROR); | |
| 8285 | - rs.put("msg", "无效的参数【驾驶员】"); | |
| 8286 | - return rs; | |
| 8287 | - } | |
| 8288 | - | |
| 8289 | - /** | |
| 8290 | - * 换驾驶员 | |
| 8291 | - */ | |
| 8292 | - if (StringUtils.isNotEmpty(jsy)) { | |
| 8293 | - String jGh = jsy.split("/")[0]; | |
| 8294 | - String jName = getPersonName(sch.getGsBm(), jGh); | |
| 8295 | - if (StringUtils.isEmpty(jName)) { | |
| 8296 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | |
| 8297 | - rs.put("status", ResponseCode.ERROR); | |
| 8298 | - return rs; | |
| 8299 | - } else if (!jGh.equals(sch.getjGh())) { | |
| 8300 | - fLog.log("换驾驶员", sch.getjGh() + "/" + sch.getjName(), jsy); | |
| 8301 | - persoChange(sch, jGh); | |
| 8302 | - } | |
| 8303 | - } | |
| 8304 | - | |
| 8305 | - /** | |
| 8306 | - * 换售票员 | |
| 8307 | - */ | |
| 8308 | - String spy = map.get("spy"); | |
| 8309 | - if (StringUtils.isNotEmpty(spy) && !StringUtils.trim(spy).equals("/")) { | |
| 8310 | - String sGh = spy.split("/")[0]; | |
| 8311 | - | |
| 8312 | - String sName = getPersonName(sch.getGsBm(), sGh); | |
| 8313 | - if (StringUtils.isEmpty(sName)) { | |
| 8314 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | |
| 8315 | - rs.put("status", ResponseCode.ERROR); | |
| 8316 | - return rs; | |
| 8317 | - } else if (!sGh.equals(sch.getsGh())) { | |
| 8318 | - fLog.log("换售票员", sch.getsGh() + "/" + sch.getsName(), spy); | |
| 8319 | - persoChangeSPY(sch, sGh); | |
| 8320 | - } | |
| 8321 | - } else if (StringUtils.isNotEmpty(sch.getsGh())) { | |
| 8322 | - fLog.log("撤销售票员"); | |
| 8323 | - sch.setsGh(""); | |
| 8324 | - sch.setsName(""); | |
| 8325 | - } | |
| 8326 | - | |
| 8327 | - LineConfig config = lineConfigData.get(sch.getXlBm()); | |
| 8328 | - /** | |
| 8329 | - * 调整实发 | |
| 8330 | - */ | |
| 8331 | - String fcsjActual = map.get("fcsjActual"); | |
| 8332 | - if (StringUtils.isNotBlank(fcsjActual) | |
| 8333 | - && !fcsjActual.equals(sch.getFcsjActual())) { | |
| 8334 | - | |
| 8335 | - //long t = 0L; | |
| 8336 | - //小于线路开始运营时间,则默认跨过24点 | |
| 8337 | - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), fcsjActual, config); | |
| 8338 | - /* if (fcsjActual.compareTo(config.getStartOpt()) < 0) | |
| 8339 | - t = fmtyyyyMMddHHmm.parseMillis(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME) + fcsjActual); | |
| 8340 | - else | |
| 8341 | - t = fmtyyyyMMddHHmm.parseMillis(sch.getScheduleDateStr() + fcsjActual);*/ | |
| 8342 | - | |
| 8343 | - fLog.log("调整实发时间", sch.getFcsjActual(), fcsjActual); | |
| 8344 | - sch.setFcsjActualAll(t); | |
| 8345 | - //取消应发未到标记 | |
| 8346 | - //if(sch.isLate2()){ | |
| 8347 | - // sch.setLate2(false); | |
| 8348 | - LateAdjustHandle.remove(sch); | |
| 8349 | - //} | |
| 8350 | - } else if (StringUtils.isNotEmpty(sch.getFcsjActual()) && StringUtils.isEmpty(fcsjActual)) { | |
| 8351 | - fLog.log("撤销实发时间", sch.getFcsjActual(), ""); | |
| 8352 | - //撤销实发 | |
| 8353 | - revokeRealOutgo(sch.getId()); | |
| 8354 | - } | |
| 8355 | - | |
| 8356 | - /** | |
| 8357 | - * 调整实达 | |
| 8358 | - */ | |
| 8359 | - String zdsjActual = map.get("zdsjActual"); | |
| 8360 | - if (StringUtils.isNotBlank(zdsjActual) | |
| 8361 | - && !zdsjActual.equals(sch.getZdsjActual())) { | |
| 8362 | - | |
| 8363 | - //调整实达 | |
| 8364 | - fLog.log("调整实达时间", sch.getZdsjActual(), zdsjActual); | |
| 8365 | - | |
| 8366 | - long t = schAttrCalculator.getTime(sch.getScheduleDateStr(), zdsjActual, config); | |
| 8367 | - sch.setZdsjActualAll(t); | |
| 8368 | - //路牌下一班起点到达时间 | |
| 8369 | - ScheduleRealInfo next = dayOfSchedule.nextByLp2(sch); | |
| 8370 | - if (null != next) { | |
| 8371 | - next.setQdzArrDatesj(zdsjActual); | |
| 8372 | - next.setLate2(false); | |
| 8373 | - ts.add(next); | |
| 8374 | - } | |
| 8375 | - | |
| 8376 | - //重新计算车辆执行班次 | |
| 8377 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | |
| 8378 | - //取消应发未到标记 | |
| 8379 | - LateAdjustHandle.remove(sch); | |
| 8380 | - } else if (StringUtils.isNotEmpty(sch.getZdsjActual()) && StringUtils.isEmpty(zdsjActual)) { | |
| 8381 | - //清除实达时间 | |
| 8382 | - fLog.log("撤销实达时间", sch.getZdsjActual(), ""); | |
| 8383 | - sch.clearZdsjActual(); | |
| 8384 | - //清除路牌下一班起点到达时间 | |
| 8385 | - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch); | |
| 8386 | - if (null != next) { | |
| 8387 | - next.setQdzArrDatesj(null); | |
| 8388 | - ts.add(next); | |
| 8389 | - } | |
| 8390 | - //重新计算车辆执行班次 | |
| 8391 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | |
| 8392 | - } | |
| 8393 | - | |
| 8394 | - /** | |
| 8395 | - * 备注 | |
| 8396 | - */ | |
| 8397 | - sch.setRemarks(remarks); | |
| 8398 | - | |
| 8399 | - /** | |
| 8400 | - * 烂班 | |
| 8401 | - */ | |
| 8402 | - if (map.get("status") != null | |
| 8403 | - && Integer.parseInt(map.get("status").toString()) == -1) { | |
| 8404 | - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null); | |
| 8405 | - fLog.log("烂班"); | |
| 8406 | - } | |
| 8407 | - | |
| 8408 | - /** | |
| 8409 | - * 修改班次里程 | |
| 8410 | - */ | |
| 8411 | - String jhlc = map.get("jhlc"); | |
| 8412 | - if (StringUtils.isNotEmpty(jhlc)) { | |
| 8413 | - double jhlcNum = Double.parseDouble(jhlc); | |
| 8414 | - //烂班 | |
| 8415 | - if (jhlcNum == 0 && sch.getJhlcOrig() != 0 && !sch._isInout() && !sch.isDestroy()) { | |
| 8416 | - destroy(sch.getId() + "", "", map.get("adjustExps").toString(), null); | |
| 8417 | - fLog.log("里程设置为0,自动烂班"); | |
| 8418 | - } else if (jhlcNum != sch.getJhlc()) { | |
| 8419 | - fLog.log("设置里程", sch.getJhlc(), jhlcNum); | |
| 8420 | - sch.setJhlc(jhlcNum); | |
| 8421 | - //临加班次,实际计划一起改 | |
| 8422 | - if (sch.isSflj()) | |
| 8423 | - sch.setJhlcOrig(jhlcNum); | |
| 8424 | - } | |
| 8425 | - } | |
| 8426 | - | |
| 8427 | - /** | |
| 8428 | - * 修改班次类型 | |
| 8429 | - */ | |
| 8430 | - String bcType = map.get("bcType"); | |
| 8431 | - if (StringUtils.isNotEmpty(bcType) && !bcType.equals(sch.getBcType())) { | |
| 8432 | - fLog.log("修改班次类型", sch.getBcType(), bcType); | |
| 8433 | - sch.setBcType(bcType); | |
| 8434 | - } | |
| 8435 | - | |
| 8436 | - //重新计算班次状态 | |
| 8437 | - sch.calcStatus(); | |
| 8438 | - dayOfSchedule.save(sch); | |
| 8439 | - //页面需要更新的班次信息 | |
| 8440 | - ts.add(sch); | |
| 8441 | - | |
| 8442 | - rs.put("status", ResponseCode.SUCCESS); | |
| 8443 | - rs.put("ts", ts); | |
| 8444 | - | |
| 8445 | - //日志记录结束 | |
| 8446 | - fLog.end(); | |
| 8447 | - } catch (Exception e) { | |
| 8448 | - logger.error("", e); | |
| 8449 | - rs.put("status", ResponseCode.ERROR); | |
| 8450 | - } | |
| 8451 | - return rs; | |
| 8452 | - } | |
| 8453 | - | |
| 8454 | - @Override | |
| 8455 | - public Map<String, Object> outgoAdjustAll(String params) { | |
| 8456 | - Map<String, Object> rs = new HashMap<>(); | |
| 8457 | - try { | |
| 8458 | - JSONArray jsonArray = JSONArray.parseArray(params); | |
| 8459 | - | |
| 8460 | - ScheduleRealInfo schedule = null; | |
| 8461 | - JSONObject jsonObj; | |
| 8462 | - String dfsj; | |
| 8463 | - long id; | |
| 8464 | - for (int i = 0; i < jsonArray.size(); i++) { | |
| 8465 | - jsonObj = jsonArray.getJSONObject(i); | |
| 8466 | - dfsj = jsonObj.getString("t"); | |
| 8467 | - id = jsonObj.getLong("id"); | |
| 8468 | - schedule = dayOfSchedule.get(id); | |
| 8469 | - | |
| 8470 | - if (schedule != null) | |
| 8471 | - outgoAdjust(id, null, dfsj, null, "2", null); | |
| 8472 | - } | |
| 8473 | - | |
| 8474 | - rs.put("status", ResponseCode.SUCCESS); | |
| 8475 | - //将更新的最后一个班次返回,页面会做全量刷新 | |
| 8476 | - rs.put("t", schedule); | |
| 8477 | - } catch (Exception e) { | |
| 8478 | - logger.error("", e); | |
| 8479 | - rs.put("status", ResponseCode.ERROR); | |
| 8480 | - } | |
| 8481 | - return rs; | |
| 8482 | - } | |
| 8483 | - | |
| 8484 | - @Override | |
| 8485 | - public Map<String, Object> findRouteByLine(String lineCode) { | |
| 8486 | - Map<String, Object> map = new HashMap<>(); | |
| 8487 | - //上行 | |
| 8488 | - Integer lineId = BasicData.lineId2CodeMap.inverse().get(lineCode); | |
| 8489 | - map.put("line.id_eq", lineId); | |
| 8490 | - map.put("directions_eq", 0); | |
| 8491 | - List<Map<String, Object>> upList = sectionRouteService.getSectionRoute(map); | |
| 8492 | - | |
| 8493 | - //下行 | |
| 8494 | - map.put("directions_eq", 1); | |
| 8495 | - List<Map<String, Object>> downList = sectionRouteService.getSectionRoute(map); | |
| 8496 | - | |
| 8497 | - Map<String, Object> rs = new HashMap<>(); | |
| 8498 | - | |
| 8499 | - String upVectors = "", vec; | |
| 8500 | - //拼接上行路段 | |
| 8501 | - for (Map<String, Object> temp : upList) { | |
| 8502 | - vec = temp.get("sectionBsectionVector").toString(); | |
| 8503 | - upVectors += vec.subSequence(11, vec.length() - 2) + " "; | |
| 8504 | - } | |
| 8505 | - | |
| 8506 | - //拼接下行路段 | |
| 8507 | - String downVectors = ""; | |
| 8508 | - for (Map<String, Object> temp : downList) {//LINESTRING( | |
| 8509 | - vec = temp.get("sectionBsectionVector").toString(); | |
| 8510 | - downVectors += vec.subSequence(11, vec.length() - 2) + " "; | |
| 8511 | - } | |
| 8512 | - | |
| 8513 | - | |
| 8514 | - rs.put("up", upVectors); | |
| 8515 | - //上行gcj | |
| 8516 | - rs.put("up_gcj", BdToGcjString(upVectors)); | |
| 8517 | - rs.put("down", downVectors); | |
| 8518 | - //下行gcj | |
| 8519 | - rs.put("down_gcj", BdToGcjString(downVectors)); | |
| 8520 | - rs.put("lineId", lineId); | |
| 8521 | - | |
| 8522 | - return rs; | |
| 8523 | - } | |
| 8524 | - | |
| 8525 | - /** | |
| 8526 | - * @param @param bdStr | |
| 8527 | - * @throws | |
| 8528 | - * @Title: BdToGcjString | |
| 8529 | - * @Description: TODO(将百度路由字符串 转 成GCJ 字符串) | |
| 8530 | - */ | |
| 8531 | - public String BdToGcjString(String bdStr) { | |
| 8532 | - String[] array = bdStr.split(","), subArray; | |
| 8533 | - if (array.length == 0 || bdStr.length() < 2) | |
| 8534 | - return ""; | |
| 8535 | - | |
| 8536 | - String gcjStr = ""; | |
| 8537 | - TransGPS.Location location; | |
| 8538 | - for (String crd : array) { | |
| 8539 | - subArray = crd.split(" "); | |
| 8540 | - if (subArray.length != 2) | |
| 8541 | - continue; | |
| 8542 | - location = TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(subArray[0]), Double.parseDouble(subArray[1]))); | |
| 8543 | - | |
| 8544 | - gcjStr += location.getLng() + " " + location.getLat() + ","; | |
| 8545 | - } | |
| 8546 | - | |
| 8547 | - return gcjStr.substring(0, gcjStr.length() - 1); | |
| 8548 | - } | |
| 8549 | - | |
| 8550 | - public List<Map<String, String>> findLine(String line) { | |
| 8551 | - List<Line> listLine = lineRepository.findLine("%" + line + "%"); | |
| 8552 | - List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | |
| 8553 | - Map<String, String> map; | |
| 8554 | - for (Line temp : listLine) { | |
| 8555 | - if (temp != null) { | |
| 8556 | - String xlName = temp.getName(); | |
| 8557 | - if (xlName.indexOf(line) != -1) { | |
| 8558 | - map = new HashMap<String, String>(); | |
| 8559 | - map.put("id", temp.getLineCode()); | |
| 8560 | - map.put("text", xlName); | |
| 8561 | - list.add(map); | |
| 8562 | - } | |
| 8563 | - } | |
| 8564 | - } | |
| 8565 | - return list; | |
| 8566 | - } | |
| 8567 | - | |
| 8568 | - public List<Map<String, String>> findLpName(String lpName) { | |
| 8569 | - List<GuideboardInfo> listLpName = guideboardInfoRepository.findLpName("%" + lpName + "%"); | |
| 8570 | - List<Map<String, String>> list = new ArrayList<Map<String, String>>(); | |
| 8571 | - Map<String, String> map; | |
| 8572 | - for (GuideboardInfo temp : listLpName) { | |
| 8573 | - if (temp != null) { | |
| 8574 | - String lp = temp.getLpName(); | |
| 8575 | - if (lp.indexOf(lpName) != -1) { | |
| 8576 | - map = new HashMap<String, String>(); | |
| 8577 | - map.put("id", lp); | |
| 8578 | - map.put("text", lp); | |
| 8579 | - list.add(map); | |
| 8580 | - } | |
| 8581 | - } | |
| 8582 | - } | |
| 8583 | - return list; | |
| 8584 | - } | |
| 8585 | - | |
| 8586 | - @Override | |
| 8587 | - public Map<String, Object> findKMBC2(String jName, String clZbh, String date) { | |
| 8588 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill3(jName, clZbh, date, "", ""); | |
| 8589 | - | |
| 8590 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 8591 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | |
| 8592 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | |
| 8593 | - int jhbc = 0, cjbc = 0, ljbc = 0; | |
| 8594 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0; | |
| 8595 | - float addMileage = 0l, remMileage = 0l; | |
| 8596 | - String j_Name = ""; | |
| 8597 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 8598 | - for (ScheduleRealInfo scheduleRealInfo : list) { | |
| 8599 | - if (scheduleRealInfo != null) { | |
| 8600 | - j_Name = scheduleRealInfo.getjName(); | |
| 8601 | - //计划里程(主任务过滤掉临加班次), | |
| 8602 | - //烂班里程(主任务烂班), | |
| 8603 | - //临加里程(主任务临加), | |
| 8604 | - //计划班次,烂班班次,增加班次 | |
| 8605 | - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | |
| 8606 | - if (scheduleRealInfo.isSflj()) { | |
| 8607 | - addMileage += tempJhlc; | |
| 8608 | - ljbc++; | |
| 8609 | - } else { | |
| 8610 | - jhlc += tempJhlc; | |
| 8611 | - jhbc++; | |
| 8612 | - if (scheduleRealInfo.getStatus() == -1) { | |
| 8613 | - remMileage += tempJhlc; | |
| 8614 | - cjbc++; | |
| 8615 | - } | |
| 8616 | - } | |
| 8617 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 8618 | - //计算营运里程,空驶里程 | |
| 8619 | - if (childTaskPlans.isEmpty()) { | |
| 8620 | - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 8621 | - || scheduleRealInfo.getBcType().equals("venting")) { | |
| 8622 | - ksgl += tempJhlc; | |
| 8623 | - } else { | |
| 8624 | - yygl += tempJhlc; | |
| 8625 | - } | |
| 8626 | - } else { | |
| 8627 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 8628 | - while (it.hasNext()) { | |
| 8629 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 8630 | - if (childTaskPlan.getMileageType().equals("empty")) { | |
| 8631 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 8632 | - } else { | |
| 8633 | - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 8634 | - } | |
| 8635 | - } | |
| 8636 | - } | |
| 8637 | - } | |
| 8638 | - } | |
| 8639 | - map.put("j_name", j_Name); | |
| 8640 | - map.put("jhlc", format.format(jhlc)); | |
| 8641 | - map.put("remMileage", format.format(remMileage)); | |
| 8642 | - map.put("addMileage", format.format(addMileage)); | |
| 8643 | - map.put("yygl", format.format(yygl)); | |
| 8644 | - map.put("ksgl", format.format(ksgl)); | |
| 8645 | - map.put("realMileage", format.format(yygl + ksgl)); | |
| 8646 | - map.put("jhbc", jhbc); | |
| 8647 | - map.put("cjbc", cjbc); | |
| 8648 | - map.put("ljbc", ljbc); | |
| 8649 | - map.put("sjbc", jhbc - cjbc + ljbc); | |
| 8650 | - return map; | |
| 8651 | - } | |
| 8652 | - | |
| 8653 | - | |
| 8654 | - public Map<String, Object> findKMBC(String jGh, String clZbh, | |
| 8655 | - String lpName, String date, String line) { | |
| 8656 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 8657 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | |
| 8658 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 8659 | - for (int i = 0; i < list.size(); i++) { | |
| 8660 | - ScheduleRealInfo s = list.get(i); | |
| 8661 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 8662 | - if (cts != null && cts.size() > 0) { | |
| 8663 | - lists.add(s); | |
| 8664 | - } else { | |
| 8665 | - if (s.getFcsjActual() != null && s.getZdsjActual() != null) { | |
| 8666 | - lists.add(s); | |
| 8667 | - } | |
| 8668 | - } | |
| 8669 | - } | |
| 8670 | - map.put("jhbc", culateService.culateJhbc(list, ""));//计划班次 | |
| 8671 | - map.put("jhlc", Arith.add(culateService.culateJhgl(list), | |
| 8672 | - culateService.culateJhJccgl(list))); //计划总里程 | |
| 8673 | - map.put("cjbc", culateService.culateLbbc(list));//烂班班次 | |
| 8674 | - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里 | |
| 8675 | - map.put("ljbc", culateService.culateLjbc(lists, ""));//临加班次 | |
| 8676 | - double ljgl = culateService.culateLjgl(lists); | |
| 8677 | - map.put("addMileage", ljgl); //临加公里 | |
| 8678 | - map.put("sjbc", culateService.culateSjbc(lists, "") + culateService.culateLjbc(lists, "")); | |
| 8679 | - double ksgl = culateService.culateKsgl(list);//子任务空驶公里 | |
| 8680 | - double jccgl = culateService.culateJccgl(lists);//空驶班次公里 | |
| 8681 | - map.put("ksgl", ksgl);//空驶公里 | |
| 8682 | - double sjgl = culateService.culateSjgl(lists);//实际营运公里 | |
| 8683 | - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl)));//总公里 | |
| 8684 | - map.put("zkslc", Arith.add(ksgl, jccgl)); | |
| 8685 | - map.put("jcclc", jccgl); | |
| 8686 | - map.put("yygl", Arith.add(sjgl, ljgl)); //总营运公里 | |
| 8687 | - return map; | |
| 8688 | - } | |
| 8689 | - | |
| 8690 | - public Map<String, Object> findKMBC_mh_2(String jGh, String clZbh, | |
| 8691 | - String lpName, String date, String line) { | |
| 8692 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 8693 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | |
| 8694 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 8695 | - for (int i = 0; i < list.size(); i++) { | |
| 8696 | - ScheduleRealInfo s = list.get(i); | |
| 8697 | - if (s.isDestroy() && s.isReissue()) { | |
| 8698 | - s.setRemark(""); | |
| 8699 | - s.setFcsjActual(s.getDfsj()); | |
| 8700 | - s.setZdsjActual(s.getZdsj()); | |
| 8701 | - s.setStatus(2); | |
| 8702 | - s.setJhlc(s.getJhlcOrig()); | |
| 8703 | - } | |
| 8704 | - | |
| 8705 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 8706 | - if (cts != null && cts.size() > 0) { | |
| 8707 | - lists.add(s); | |
| 8708 | - } else { | |
| 8709 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 8710 | - lists.add(s); | |
| 8711 | - } | |
| 8712 | - } | |
| 8713 | - } | |
| 8714 | - double ksgl = culateService.culateKsgl(list); | |
| 8715 | - double sjgl = culateService.culateSjgl(lists); | |
| 8716 | - double jccgl = culateService.culateJccgl(lists); | |
| 8717 | - double ljgl = culateService.culateLjgl(lists); | |
| 8718 | - | |
| 8719 | - map.put("jhlc", Arith.add(culateService.culateJhgl(list), culateService.culateJhJccgl(list))); //计划里程 | |
| 8720 | - map.put("remMileage", culateService.culateLbgl(list)); //烂班公里 | |
| 8721 | - map.put("addMileage", ljgl); //临加公里 | |
| 8722 | - map.put("yygl", Arith.add(sjgl, ljgl)); //实际公里 | |
| 8723 | - map.put("ksgl", ksgl);//空驶公里 | |
| 8724 | - map.put("realMileage", Arith.add(Arith.add(ksgl, jccgl), Arith.add(sjgl, ljgl))); | |
| 8725 | -// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage)); | |
| 8726 | - map.put("jhbc", culateService.culateJhbc(list, "")); | |
| 8727 | - map.put("cjbc", culateService.culateLbbc(list)); | |
| 8728 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | |
| 8729 | - map.put("sjbc", culateService.culateJhbc(lists, "") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists, "")); | |
| 8730 | - map.put("jcclc", jccgl); | |
| 8731 | - map.put("zkslc", Arith.add(ksgl, jccgl)); | |
| 8732 | -// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc)); | |
| 8733 | - return map; | |
| 8734 | - } | |
| 8735 | - | |
| 8736 | - | |
| 8737 | - @Override | |
| 8738 | - public List<Map<String, Object>> accountPx(String line, String date, | |
| 8739 | - String code, String xlName, String px) { | |
| 8740 | -// List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px); | |
| 8741 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 8742 | - if (!code.trim().equals("")) { | |
| 8743 | - code = BasicData.deviceId2NbbmMap.inverse().get(code); | |
| 8744 | - } | |
| 8745 | - String fgs = ""; | |
| 8746 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 8747 | - if (lineList.size() > 0) { | |
| 8748 | - Line l = lineList.get(0); | |
| 8749 | - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany()); | |
| 8750 | - } | |
| 8751 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
| 8752 | - String sql = "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ," | |
| 8753 | - + " device_id FROM bsth_v_report_80 WHERE " | |
| 8754 | - + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '" + date + "' AND" | |
| 8755 | - + " line_id = '" + line + "' and device_id like '%" + code + "%'"; | |
| 8756 | - Map<String, Object> map; | |
| 8757 | - List<Object[]> lsitObj = jdbcTemplate.query(sql, | |
| 8758 | - new RowMapper<Object[]>() { | |
| 8759 | - @Override | |
| 8760 | - public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 8761 | - Object[] t = new Object[3]; | |
| 8762 | - t[0] = rs.getString("request_code"); | |
| 8763 | - t[1] = rs.getString("TIMESTAMP"); | |
| 8764 | - t[2] = rs.getString("device_id"); | |
| 8765 | - return t; | |
| 8766 | - } | |
| 8767 | - }); | |
| 8768 | - int i = 1; | |
| 8769 | - for (Object[] obj : lsitObj) { | |
| 8770 | - if (obj != null) { | |
| 8771 | - map = new HashMap<String, Object>(); | |
| 8772 | - map.put("num", i++); | |
| 8773 | - map.put("xlName", xlName); | |
| 8774 | - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) { | |
| 8775 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | |
| 8776 | - try { | |
| 8777 | - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString())); | |
| 8778 | - } catch (Exception e) { | |
| 8779 | - // TODO Auto-generated catch block | |
| 8780 | - e.printStackTrace(); | |
| 8781 | - } | |
| 8782 | - if (carDeviceList.size() > 0) { | |
| 8783 | - map.put("clZbh", carDeviceList.get(0).getClZbh()); | |
| 8784 | - | |
| 8785 | - } else { | |
| 8786 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | |
| 8787 | - } | |
| 8788 | - } else { | |
| 8789 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | |
| 8790 | - | |
| 8791 | - } | |
| 8792 | - map.put("company", fgs); | |
| 8793 | - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase()); | |
| 8794 | - map.put("requestTime", obj[1]); | |
| 8795 | - listMap.add(map); | |
| 8796 | - } | |
| 8797 | - } | |
| 8798 | - if (listMap.size() > 1) { | |
| 8799 | - if (px.equals("asc")) { | |
| 8800 | - Collections.sort(listMap, new AccountMap()); | |
| 8801 | - } else { | |
| 8802 | - Collections.sort(listMap, new AccountMap2()); | |
| 8803 | - } | |
| 8804 | - } | |
| 8805 | - return listMap; | |
| 8806 | - } | |
| 8807 | - | |
| 8808 | - @Override | |
| 8809 | - public List<Map<String, Object>> account(String line, String date, | |
| 8810 | - String code, String xlName, String type) { | |
| 8811 | - if (!code.trim().equals("")) { | |
| 8812 | - code = BasicData.deviceId2NbbmMap.inverse().get(code); | |
| 8813 | - } | |
| 8814 | - String fgs = ""; | |
| 8815 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 8816 | - if (lineList.size() > 0) { | |
| 8817 | - Line l = lineList.get(0); | |
| 8818 | - fgs = BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany() + "_" + l.getCompany()); | |
| 8819 | - } | |
| 8820 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 8821 | - List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code); | |
| 8822 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
| 8823 | - Map<String, Object> map; | |
| 8824 | - int i = 1; | |
| 8825 | - for (Object[] obj : lsitObj) { | |
| 8826 | - if (obj != null) { | |
| 8827 | - map = new HashMap<String, Object>(); | |
| 8828 | - map.put("num", i++); | |
| 8829 | - map.put("xlName", xlName); | |
| 8830 | - if (BasicData.deviceId2NbbmMap.get(obj[2]) == null) { | |
| 8831 | - List<CarDevice> carDeviceList = new ArrayList<CarDevice>(); | |
| 8832 | - try { | |
| 8833 | - carDeviceList = carDeviceRepository.findCarDevice(obj[2].toString(), sdf.parse(obj[1].toString())); | |
| 8834 | - } catch (Exception e) { | |
| 8835 | - // TODO Auto-generated catch block | |
| 8836 | - e.printStackTrace(); | |
| 8837 | - } | |
| 8838 | - if (carDeviceList.size() > 0) { | |
| 8839 | - map.put("clZbh", carDeviceList.get(0).getClZbh()); | |
| 8840 | - | |
| 8841 | - } else { | |
| 8842 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | |
| 8843 | - } | |
| 8844 | - } else { | |
| 8845 | - map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2])); | |
| 8846 | - | |
| 8847 | - } | |
| 8848 | - map.put("company", fgs); | |
| 8849 | - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase()); | |
| 8850 | - map.put("requestTime", obj[1]); | |
| 8851 | - listMap.add(map); | |
| 8852 | - } | |
| 8853 | - } | |
| 8854 | - | |
| 8855 | - if (type != null && type.length() != 0 && type.equals("export")) { | |
| 8856 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 8857 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 8858 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 8859 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 8860 | - ReportUtils ee = new ReportUtils(); | |
| 8861 | - Map<String, Object> typeMap = new HashMap<String, Object>(); | |
| 8862 | - typeMap.put("0xA1", "请求恢复运营"); | |
| 8863 | - typeMap.put("0xA2", "申请调档"); | |
| 8864 | - typeMap.put("0xA3", "出场请求"); | |
| 8865 | - typeMap.put("0xA5", "进场请求"); | |
| 8866 | - typeMap.put("0xA7", "加油请求"); | |
| 8867 | - typeMap.put("0x50", "车辆故障"); | |
| 8868 | - typeMap.put("0x70", "路阻报告"); | |
| 8869 | - typeMap.put("0x60", "事故报告"); | |
| 8870 | - typeMap.put("0x11", "扣证纠纷"); | |
| 8871 | - typeMap.put("0x12", "报警"); | |
| 8872 | - for (Map<String, Object> map1 : listMap) { | |
| 8873 | - map1.put("requestText", typeMap.get(map1.get("requestType"))); | |
| 8874 | - } | |
| 8875 | - try { | |
| 8876 | - listI.add(listMap.iterator()); | |
| 8877 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 8878 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/account.xls", | |
| 8879 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | |
| 8880 | - + "-" + xlName + "-驾驶员请求台账.xls"); | |
| 8881 | - } catch (Exception e) { | |
| 8882 | - // TODO: handle exception | |
| 8883 | - e.printStackTrace(); | |
| 8884 | - } | |
| 8885 | - } | |
| 8886 | - | |
| 8887 | - return listMap; | |
| 8888 | - } | |
| 8889 | - | |
| 8890 | - @Override | |
| 8891 | - public List<SchEditInfoDto> correctForm(String line, String date, String endDate, | |
| 8892 | - String lpName, String code, String type, String changType) { | |
| 8893 | - | |
| 8894 | -// var types = {'DFTZ': '待发调整', 'FCXXWT':'发车信息微调', 'JHLB': '计划烂班', 'CXLB': '撤销烂班', | |
| 8895 | -// 'CXZX': '撤销执行', 'CXSF': '撤销实发', 'SFTZ': '实发调整', 'TZRC': '调整人车'}; | |
| 8896 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 8897 | - map.put("DFTZ", "待发调整"); | |
| 8898 | - map.put("FCXXWT", "发车信息微调"); | |
| 8899 | - map.put("JHLB", "计划烂班"); | |
| 8900 | - map.put("CXLB", "撤销烂班"); | |
| 8901 | - map.put("CXZX", "撤销执行"); | |
| 8902 | - map.put("CXSF", "撤销实发"); | |
| 8903 | - map.put("SFTZ", "实发调整"); | |
| 8904 | - map.put("TZRC", "调整人车"); | |
| 8905 | - | |
| 8906 | - SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm"); | |
| 8907 | - SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 8908 | - String cont = ""; | |
| 8909 | - cont = " and xl_bm ='" + line + "'"; | |
| 8910 | - if (!lpName.equals("")) { | |
| 8911 | - cont += " and lp_name = '" + lpName + "'"; | |
| 8912 | - } | |
| 8913 | - if (!code.equals("")) { | |
| 8914 | - cont += " and cl_zbh ='" + code + "'"; | |
| 8915 | - } | |
| 8916 | - String sql = "select t1.*, t2.real_exec_date," | |
| 8917 | - + "t2.fcsj,t2.lp_name,t2.cl_zbh,t2.j_gh,t2.j_name," | |
| 8918 | - + "t2.xl_dir,t2.real_exec_date from (select * from " | |
| 8919 | - + "logger_sch_modify where rq BETWEEN ? and ? and line_code=? )" | |
| 8920 | - + " t1 INNER JOIN bsth_c_s_sp_info_real t2 on " | |
| 8921 | - + "t1.sch_id=t2.id where 1=1 " + cont; | |
| 8922 | - | |
| 8923 | - List<SchEditInfoDto> list = jdbcTemplate.query(sql, | |
| 8924 | - new BeanPropertyRowMapper(SchEditInfoDto.class), date, endDate, line); | |
| 8925 | - List<SchEditInfoDto> lists = new ArrayList<SchEditInfoDto>(); | |
| 8926 | - for (int i = 0; i < list.size(); i++) { | |
| 8927 | - Long fcsjs = 0l; | |
| 8928 | - Long updsj = 0l; | |
| 8929 | - SchEditInfoDto t = list.get(i); | |
| 8930 | - if (map.get(t.getType()) != null) { | |
| 8931 | - | |
| 8932 | - if (changType.equals("")) { | |
| 8933 | - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | |
| 8934 | - } else { | |
| 8935 | - String fcsj = ""; | |
| 8936 | - String updtime = ""; | |
| 8937 | - try { | |
| 8938 | - fcsj = sdf1.format(sdf1.parse(t.getFcsj())); | |
| 8939 | - updtime = sdf1.format(sdf1.parse(t.getTimeStr())); | |
| 8940 | - fcsjs = sdf2.parse(t.getRealExecDate() + " " + fcsj).getTime(); | |
| 8941 | - updsj = sdf2.parse(t.getRq() + " " + updtime).getTime(); | |
| 8942 | - } catch (ParseException e) { | |
| 8943 | - // TODO Auto-generated catch block | |
| 8944 | - e.printStackTrace(); | |
| 8945 | - } | |
| 8946 | - if (changType.equals("1")) { | |
| 8947 | - if (fcsjs > updsj) { | |
| 8948 | - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | |
| 8949 | - } else { | |
| 8950 | - t.setType2(""); | |
| 8951 | - } | |
| 8952 | - } else if (changType.equals("2")) { | |
| 8953 | - if (fcsjs < updsj) { | |
| 8954 | - t.setType2(t.getUser() + "于" + t.getTimeStr() + "进行" + map.get(t.getType()).toString() + ";"); | |
| 8955 | - } else { | |
| 8956 | - t.setType2(""); | |
| 8957 | - } | |
| 8958 | - } | |
| 8959 | - } | |
| 8960 | - } else { | |
| 8961 | - t.setType2(""); | |
| 8962 | - } | |
| 8963 | - boolean fage = true; | |
| 8964 | - for (int j = 0; j < lists.size(); j++) { | |
| 8965 | - SchEditInfoDto s = lists.get(j); | |
| 8966 | - if (s.getSchId() == t.getSchId()) { | |
| 8967 | - s.setType2(s.getType2() + " " + t.getType2()); | |
| 8968 | - fage = false; | |
| 8969 | - } | |
| 8970 | - } | |
| 8971 | - | |
| 8972 | - if (fage) { | |
| 8973 | - if (changType.equals("")) { | |
| 8974 | - lists.add(t); | |
| 8975 | - } else { | |
| 8976 | - if (changType.equals("1")) { | |
| 8977 | - if (fcsjs > updsj) { | |
| 8978 | - lists.add(t); | |
| 8979 | - } | |
| 8980 | - } else if (changType.equals("2")) { | |
| 8981 | - if (fcsjs < updsj) { | |
| 8982 | - lists.add(t); | |
| 8983 | - } | |
| 8984 | - } | |
| 8985 | - } | |
| 8986 | - } | |
| 8987 | - } | |
| 8988 | - | |
| 8989 | - if (type != null && type.length() != 0 && type.equals("export")) { | |
| 8990 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 8991 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 8992 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 8993 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 8994 | - m.put("dates", date); | |
| 8995 | - ReportUtils ee = new ReportUtils(); | |
| 8996 | - List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | |
| 8997 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 8998 | - for (SchEditInfoDto d : lists) { | |
| 8999 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 9000 | - tempMap.put("lpName", d.getLpName()); | |
| 9001 | - tempMap.put("rq", d.getRq()); | |
| 9002 | - tempMap.put("clZbh", d.getClZbh()); | |
| 9003 | - tempMap.put("jName", d.getjName() + "/" + d.getjGh()); | |
| 9004 | - tempMap.put("fcsj", d.getFcsj()); | |
| 9005 | - tempMap.put("type", d.getType2()); | |
| 9006 | - tempList.add(tempMap); | |
| 9007 | - } | |
| 9008 | - try { | |
| 9009 | - String dateTime = sdfSimple.format(sdfMonth.parse(date)); | |
| 9010 | - if(!endDate.equals(date)){ | |
| 9011 | - dateTime += "-" + sdfSimple.format(sdfMonth.parse(endDate)); | |
| 9012 | - } | |
| 9013 | - String lineName = BasicData.lineCode2NameMap.get(line); | |
| 9014 | - listI.add(tempList.iterator()); | |
| 9015 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 9016 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/correctForm.xls", | |
| 9017 | - path + "export/" + dateTime + "-" + lineName + "-修正报表.xls"); | |
| 9018 | - } catch (Exception e) { | |
| 9019 | - // TODO: handle exception | |
| 9020 | - e.printStackTrace(); | |
| 9021 | - } | |
| 9022 | -// Map<String, Object> maps = tempList.get(tempList.size() - 1); | |
| 9023 | - } | |
| 9024 | - return lists; | |
| 9025 | - } | |
| 9026 | - | |
| 9027 | - @Override | |
| 9028 | - public List<ScheduleRealInfo> queryListWaybill(String jGh, String clZbh, | |
| 9029 | - String lpName, String date, String line) { | |
| 9030 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | |
| 9031 | - List<ScheduleRealInfo> list = null; | |
| 9032 | - list = scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line); | |
| 9033 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 9034 | - String minfcsj = "02:00"; | |
| 9035 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 9036 | - if (lineList.size() > 0) { | |
| 9037 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 9038 | - + " id = (" | |
| 9039 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 9040 | - + ")"; | |
| 9041 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 9042 | - } | |
| 9043 | - String[] minSjs = minfcsj.split(":"); | |
| 9044 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | |
| 9045 | - | |
| 9046 | - for (int i = 0; i < list.size(); i++) { | |
| 9047 | - ScheduleRealInfo s = list.get(i); | |
| 9048 | - if (s.getBcType().equals("out")) { | |
| 9049 | - s.setRemark("1"); | |
| 9050 | - } else if (s.getBcType().equals("in")) { | |
| 9051 | - s.setRemark("3"); | |
| 9052 | - } else { | |
| 9053 | - s.setRemark("2"); | |
| 9054 | - } | |
| 9055 | - String[] fcsj = s.getFcsj().split(":"); | |
| 9056 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 9057 | - | |
| 9058 | - Long fscjT = 0L; | |
| 9059 | - if (fcsjL < minSj) { | |
| 9060 | - Calendar calendar = new GregorianCalendar(); | |
| 9061 | - calendar.setTime(s.getScheduleDate()); | |
| 9062 | - calendar.add(calendar.DATE, 1); | |
| 9063 | - s.setScheduleDate(calendar.getTime()); | |
| 9064 | - try { | |
| 9065 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | |
| 9066 | - } catch (ParseException e) { | |
| 9067 | - // TODO Auto-generated catch block | |
| 9068 | - e.printStackTrace(); | |
| 9069 | - } | |
| 9070 | - | |
| 9071 | - } else { | |
| 9072 | - try { | |
| 9073 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 9074 | - } catch (ParseException e) { | |
| 9075 | - // TODO Auto-generated catch block | |
| 9076 | - e.printStackTrace(); | |
| 9077 | - } | |
| 9078 | - ; | |
| 9079 | - } | |
| 9080 | - s.setFcsjT(fscjT); | |
| 9081 | - } | |
| 9082 | - Collections.sort(list, new compareFcsjType()); | |
| 9083 | - for (int i = 0; i < list.size(); i++) { | |
| 9084 | - ScheduleRealInfo s = list.get(i); | |
| 9085 | - s.setAdjustExps(i + 1 + ""); | |
| 9086 | - String remarks = ""; | |
| 9087 | - if (s.getRemarks() != null) { | |
| 9088 | - remarks += s.getRemarks(); | |
| 9089 | - } | |
| 9090 | - | |
| 9091 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | |
| 9092 | - if (!childTaskPlans.isEmpty()) { | |
| 9093 | - s.setFcsjActual(""); | |
| 9094 | - s.setZdsjActual(""); | |
| 9095 | - s.setJhlc(0.0); | |
| 9096 | - } | |
| 9097 | - | |
| 9098 | - if (s.isDestroy()) { | |
| 9099 | - s.setFcsjActual(""); | |
| 9100 | - s.setZdsjActual(""); | |
| 9101 | - s.setJhlc(0.0); | |
| 9102 | - remarks += "(烂班)"; | |
| 9103 | - s.setRemarks(remarks); | |
| 9104 | - } | |
| 9105 | - | |
| 9106 | - listSchedule.add(s); | |
| 9107 | - //计算营运里程,空驶里程 | |
| 9108 | - if (!childTaskPlans.isEmpty()) { | |
| 9109 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 9110 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | |
| 9111 | - Collections.sort(listit, new ComparableChild()); | |
| 9112 | - for (int j = 0; j < listit.size(); j++) { | |
| 9113 | - ScheduleRealInfo t = new ScheduleRealInfo(); | |
| 9114 | - ChildTaskPlan childTaskPlan = listit.get(j); | |
| 9115 | - if (childTaskPlan.getCcId() == null) { | |
| 9116 | - if (childTaskPlan.isDestroy()) { | |
| 9117 | - t.setFcsjActual(""); | |
| 9118 | - t.setZdsjActual(""); | |
| 9119 | - t.setJhlc(0.0); | |
| 9120 | - } else { | |
| 9121 | - t.setFcsjActual(childTaskPlan.getStartDate()); | |
| 9122 | - t.setZdsjActual(childTaskPlan.getEndDate()); | |
| 9123 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | |
| 9124 | - } | |
| 9125 | - t.setFcsj(childTaskPlan.getStartDate()); | |
| 9126 | - t.setZdsj(childTaskPlan.getEndDate()); | |
| 9127 | - t.setQdzName(childTaskPlan.getStartStationName()); | |
| 9128 | - t.setZdzName(childTaskPlan.getEndStationName()); | |
| 9129 | - t.setRemarks(childTaskPlan.getRemarks()); | |
| 9130 | - t.setAdjustExps("子"); | |
| 9131 | - listSchedule.add(t); | |
| 9132 | - } | |
| 9133 | - } | |
| 9134 | - } | |
| 9135 | - } | |
| 9136 | - | |
| 9137 | - return listSchedule; | |
| 9138 | - } | |
| 9139 | - | |
| 9140 | - @Override | |
| 9141 | - public List<ScheduleRealInfo> queryListWaybill2(String jName, String clZbh, | |
| 9142 | - String lpName, String date, String line) { | |
| 9143 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | |
| 9144 | - List<ScheduleRealInfo> list = null; | |
| 9145 | - list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line); | |
| 9146 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 9147 | - String minfcsj = "02:00"; | |
| 9148 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 9149 | - if (lineList.size() > 0) { | |
| 9150 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 9151 | - + " id = (" | |
| 9152 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 9153 | - + ")"; | |
| 9154 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 9155 | - } | |
| 9156 | - String[] minSjs = minfcsj.split(":"); | |
| 9157 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | |
| 9158 | - | |
| 9159 | - for (int i = 0; i < list.size(); i++) { | |
| 9160 | - ScheduleRealInfo s = list.get(i); | |
| 9161 | - String[] fcsj = s.getFcsj().split(":"); | |
| 9162 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 9163 | - | |
| 9164 | - Long fscjT = 0L; | |
| 9165 | - if (fcsjL < minSj) { | |
| 9166 | - Calendar calendar = new GregorianCalendar(); | |
| 9167 | - calendar.setTime(s.getScheduleDate()); | |
| 9168 | - calendar.add(calendar.DATE, 1); | |
| 9169 | - s.setScheduleDate(calendar.getTime()); | |
| 9170 | - try { | |
| 9171 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | |
| 9172 | - } catch (ParseException e) { | |
| 9173 | - // TODO Auto-generated catch block | |
| 9174 | - e.printStackTrace(); | |
| 9175 | - } | |
| 9176 | - | |
| 9177 | - } else { | |
| 9178 | - try { | |
| 9179 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 9180 | - } catch (ParseException e) { | |
| 9181 | - // TODO Auto-generated catch block | |
| 9182 | - e.printStackTrace(); | |
| 9183 | - } | |
| 9184 | - ; | |
| 9185 | - } | |
| 9186 | - s.setFcsjT(fscjT); | |
| 9187 | - } | |
| 9188 | - Collections.sort(list, new ComparableReal()); | |
| 9189 | - for (int i = 0; i < list.size(); i++) { | |
| 9190 | - ScheduleRealInfo s = list.get(i); | |
| 9191 | - s.setAdjustExps(i + 1 + ""); | |
| 9192 | - String remarks = ""; | |
| 9193 | - if (s.getRemarks() != null) { | |
| 9194 | - remarks += s.getRemarks(); | |
| 9195 | - } | |
| 9196 | - | |
| 9197 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | |
| 9198 | - if (!childTaskPlans.isEmpty()) { | |
| 9199 | - s.setFcsjActual(""); | |
| 9200 | - s.setZdsjActual(""); | |
| 9201 | - s.setJhlc(0.0); | |
| 9202 | - } | |
| 9203 | - | |
| 9204 | - if (s.isDestroy()) { | |
| 9205 | - if (s.isReissue()) { | |
| 9206 | - s.setFcsjActual(s.getDfsj()); | |
| 9207 | - s.setZdsjActual(s.getZdsj()); | |
| 9208 | - s.setRemarks(""); | |
| 9209 | - s.setStatus(2); | |
| 9210 | - s.setJhlc(s.getJhlcOrig()); | |
| 9211 | - } else { | |
| 9212 | - s.setFcsjActual(""); | |
| 9213 | - s.setZdsjActual(""); | |
| 9214 | - s.setJhlc(0.0); | |
| 9215 | - remarks += "(烂班)"; | |
| 9216 | - s.setRemarks(remarks); | |
| 9217 | - } | |
| 9218 | - } | |
| 9219 | - | |
| 9220 | - listSchedule.add(s); | |
| 9221 | - //计算营运里程,空驶里程 | |
| 9222 | - if (!childTaskPlans.isEmpty()) { | |
| 9223 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 9224 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | |
| 9225 | - Collections.sort(listit, new ComparableChild()); | |
| 9226 | - for (int j = 0; j < listit.size(); j++) { | |
| 9227 | - ScheduleRealInfo t = new ScheduleRealInfo(); | |
| 9228 | - ChildTaskPlan childTaskPlan = listit.get(j); | |
| 9229 | - if (childTaskPlan.isDestroy()) { | |
| 9230 | - t.setFcsjActual(""); | |
| 9231 | - t.setZdsjActual(""); | |
| 9232 | - t.setJhlc(0.0); | |
| 9233 | - } else { | |
| 9234 | - t.setFcsjActual(childTaskPlan.getStartDate()); | |
| 9235 | - t.setZdsjActual(childTaskPlan.getEndDate()); | |
| 9236 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | |
| 9237 | - } | |
| 9238 | - t.setQdzName(childTaskPlan.getStartStationName()); | |
| 9239 | - t.setZdzName(childTaskPlan.getEndStationName()); | |
| 9240 | - t.setRemarks(childTaskPlan.getRemarks()); | |
| 9241 | - t.setAdjustExps("子"); | |
| 9242 | - listSchedule.add(t); | |
| 9243 | - } | |
| 9244 | - } | |
| 9245 | - } | |
| 9246 | - | |
| 9247 | - return listSchedule; | |
| 9248 | - } | |
| 9249 | - | |
| 9250 | - @Override | |
| 9251 | - public Map<String, Object> removeChildTask(Long taskId) { | |
| 9252 | - Map<String, Object> rs = new HashMap<>(); | |
| 9253 | - ChildTaskPlan chTask = cTaskPlanRepository.findById(taskId).get(); | |
| 9254 | - | |
| 9255 | - ScheduleRealInfo sch = dayOfSchedule.get(chTask.getSchedule().getId()); | |
| 9256 | - try { | |
| 9257 | - | |
| 9258 | - sch.getcTasks().remove(chTask); | |
| 9259 | - scheduleRealInfoRepository.save(sch); | |
| 9260 | - rs.put("status", ResponseCode.SUCCESS); | |
| 9261 | - } catch (Exception e) { | |
| 9262 | - logger.error("", e); | |
| 9263 | - rs.put("status", ResponseCode.ERROR); | |
| 9264 | - } | |
| 9265 | - return rs; | |
| 9266 | - } | |
| 9267 | - | |
| 9268 | - @Override | |
| 9269 | - public List<Map<String, Object>> statisticsDaily(String line, String date, | |
| 9270 | - String xlName, String type) { | |
| 9271 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 9272 | - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | |
| 9273 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 9274 | - for (int i = 0; i < list_s.size(); i++) { | |
| 9275 | - ScheduleRealInfo s = list_s.get(i); | |
| 9276 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 9277 | - if (cts != null && cts.size() > 0) { | |
| 9278 | - lists.add(s); | |
| 9279 | - } else { | |
| 9280 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 9281 | - lists.add(s); | |
| 9282 | - } | |
| 9283 | - } | |
| 9284 | - } | |
| 9285 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 9286 | - map.put("xlName", xlName); | |
| 9287 | - double jhlc = culateService.culateJhgl(list_s); | |
| 9288 | - map.put("jhlc", jhlc); | |
| 9289 | - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists))); | |
| 9290 | - double lbgl = culateService.culateLbgl(list_s); | |
| 9291 | - map.put("ssgl", lbgl); | |
| 9292 | - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); | |
| 9293 | - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | |
| 9294 | - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | |
| 9295 | - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | |
| 9296 | - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | |
| 9297 | - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | |
| 9298 | - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | |
| 9299 | - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | |
| 9300 | - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | |
| 9301 | - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | |
| 9302 | - double ssgl_pc = culateService.culateCJLC(list_s, "配车"); | |
| 9303 | - double ssgl_by = culateService.culateCJLC(list_s, "保养"); | |
| 9304 | - double ssgl_cj = culateService.culateCJLC(list_s, "抽减"); | |
| 9305 | - double ssgl_qt = culateService.culateCJLC(list_s, "其他"); | |
| 9306 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | |
| 9307 | - map.put("ssbc", culateService.culateLbbc(list_s)); | |
| 9308 | - double ljgl = culateService.culateLjgl(lists); | |
| 9309 | - map.put("ljgl", ljgl); | |
| 9310 | - map.put("jhbc", culateService.culateJhbc(list_s, "")); | |
| 9311 | - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | |
| 9312 | - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | |
| 9313 | - map.put("sjbc", culateService.culateSjbc(lists, "")); | |
| 9314 | - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | |
| 9315 | - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | |
| 9316 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | |
| 9317 | - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | |
| 9318 | - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | |
| 9319 | - map.put("fzbc", culateService.culateFzbc(lists, "")); | |
| 9320 | - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | |
| 9321 | - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | |
| 9322 | - map.put("dtbc", 0); | |
| 9323 | - map.put("dtbc_m", 0); | |
| 9324 | - map.put("dtbc_a", 0); | |
| 9325 | - List<CalcInterval> intervalList=calcIntervalRepository.selectByDateAndLine(line, date,""); | |
| 9326 | - if(intervalList.size()>0){ | |
| 9327 | - CalcInterval c=intervalList.get(0); | |
| 9328 | - map.put("djg",c.getDjgAll()); | |
| 9329 | - map.put("djg_m", c.getDjgZgf()); | |
| 9330 | - map.put("djg_a", c.getDjgWgf()); | |
| 9331 | - map.put("djg_time", c.getDjgTime()); | |
| 9332 | - }else{ | |
| 9333 | - Map<String, Object> m = culateService.culateDjg(list_s, line); | |
| 9334 | - map.put("djg", m.get("djgcsq")); | |
| 9335 | - map.put("djg_m", m.get("djgcsz")); | |
| 9336 | - map.put("djg_a", m.get("djgcsw")); | |
| 9337 | - map.put("djg_time", m.get("djgsj")); | |
| 9338 | - } | |
| 9339 | - | |
| 9340 | - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl)); | |
| 9341 | - lMap.add(map); | |
| 9342 | - | |
| 9343 | - if (date.length() == 10) { | |
| 9344 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59"); | |
| 9345 | - String dbdp = ""; | |
| 9346 | - try { | |
| 9347 | - for (int i = 0; i < list.size(); i++) { | |
| 9348 | - DutyEmployee t = list.get(i); | |
| 9349 | - if (dbdp.indexOf(t.getuName()) == -1) { | |
| 9350 | - if (!(dbdp.length() > 0)) { | |
| 9351 | - dbdp = t.getuName(); | |
| 9352 | - } else { | |
| 9353 | - dbdp += "," + t.getuName(); | |
| 9354 | - } | |
| 9355 | - } | |
| 9356 | - } | |
| 9357 | - } catch (Exception e) { | |
| 9358 | - // TODO: handle exception | |
| 9359 | - e.printStackTrace(); | |
| 9360 | - } | |
| 9361 | - map.put("dbdp", dbdp); | |
| 9362 | - } | |
| 9363 | - | |
| 9364 | - return lMap; | |
| 9365 | - } | |
| 9366 | - | |
| 9367 | - @Override | |
| 9368 | - public List<Map<String, Object>> statisticsDaily_mh_2(String line, String date, | |
| 9369 | - String xlName, String type) { | |
| 9370 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 9371 | - List<ScheduleRealInfo> list_s = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); | |
| 9372 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 9373 | - for (int i = 0; i < list_s.size(); i++) { | |
| 9374 | - ScheduleRealInfo s = list_s.get(i); | |
| 9375 | - if (s.isDestroy() && s.isReissue()) { | |
| 9376 | - s.setRemark(""); | |
| 9377 | - s.setFcsjActual(s.getDfsj()); | |
| 9378 | - s.setZdsjActual(s.getZdsj()); | |
| 9379 | - s.setStatus(2); | |
| 9380 | - s.setJhlc(s.getJhlcOrig()); | |
| 9381 | - } | |
| 9382 | - | |
| 9383 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 9384 | - if (cts != null && cts.size() > 0) { | |
| 9385 | - lists.add(s); | |
| 9386 | - } else { | |
| 9387 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 9388 | - lists.add(s); | |
| 9389 | - } | |
| 9390 | - } | |
| 9391 | - } | |
| 9392 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 9393 | - map.put("xlName", xlName); | |
| 9394 | - double jhlc = culateService.culateJhgl(list_s); | |
| 9395 | - map.put("jhlc", jhlc); | |
| 9396 | - map.put("sjgl", Arith.add(culateService.culateSjgl(lists), culateService.culateLjgl(lists))); | |
| 9397 | - double lbgl = culateService.culateLbgl(list_s); | |
| 9398 | - map.put("ssgl", lbgl); | |
| 9399 | - map.put("ssgl_lz", culateService.culateCJLC(list_s, "路阻")); | |
| 9400 | - map.put("ssgl_dm", culateService.culateCJLC(list_s, "吊慢")); | |
| 9401 | - map.put("ssgl_gz", culateService.culateCJLC(list_s, "故障")); | |
| 9402 | - map.put("ssgl_jf", culateService.culateCJLC(list_s, "纠纷")); | |
| 9403 | - map.put("ssgl_zs", culateService.culateCJLC(list_s, "肇事")); | |
| 9404 | - map.put("ssgl_qr", culateService.culateCJLC(list_s, "缺人")); | |
| 9405 | - map.put("ssgl_qc", culateService.culateCJLC(list_s, "缺车")); | |
| 9406 | - map.put("ssgl_kx", culateService.culateCJLC(list_s, "客稀")); | |
| 9407 | - map.put("ssgl_qh", culateService.culateCJLC(list_s, "气候")); | |
| 9408 | - map.put("ssgl_yw", culateService.culateCJLC(list_s, "援外")); | |
| 9409 | - double ssgl_pc = culateService.culateCJLC(list_s, "配车"); | |
| 9410 | - double ssgl_by = culateService.culateCJLC(list_s, "保养"); | |
| 9411 | - double ssgl_cj = culateService.culateCJLC(list_s, "抽减"); | |
| 9412 | - double ssgl_qt = culateService.culateCJLC(list_s, "其他"); | |
| 9413 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | |
| 9414 | - map.put("ssbc", culateService.culateLbbc(list_s)); | |
| 9415 | - double ljgl = culateService.culateLjgl(lists); | |
| 9416 | - map.put("ljgl", ljgl); | |
| 9417 | - map.put("jhbc", culateService.culateJhbc(list_s, "")); | |
| 9418 | - map.put("jhbc_m", culateService.culateJhbc(list_s, "zgf")); | |
| 9419 | - map.put("jhbc_a", culateService.culateJhbc(list_s, "wgf")); | |
| 9420 | - map.put("sjbc", culateService.culateSjbc(lists, "")); | |
| 9421 | - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | |
| 9422 | - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | |
| 9423 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | |
| 9424 | - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | |
| 9425 | - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | |
| 9426 | - map.put("fzbc", culateService.culateFzbc(lists, "")); | |
| 9427 | - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | |
| 9428 | - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | |
| 9429 | - map.put("dtbc", 0); | |
| 9430 | - map.put("dtbc_m", 0); | |
| 9431 | - map.put("dtbc_a", 0); | |
| 9432 | - map.put("djg", 0); | |
| 9433 | - map.put("djg_m", 0); | |
| 9434 | - map.put("djg_a", 0); | |
| 9435 | - map.put("djg_time", 0); | |
| 9436 | - map.put("jls", Arith.sub(Arith.add(jhlc, ljgl), lbgl)); | |
| 9437 | - lMap.add(map); | |
| 9438 | - return lMap; | |
| 9439 | - } | |
| 9440 | - | |
| 9441 | - public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,Map<String, Object> m) { | |
| 9442 | - | |
| 9443 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 9444 | - for (int i = 0; i < list.size(); i++) { | |
| 9445 | - ScheduleRealInfo s = list.get(i); | |
| 9446 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 9447 | - if (cts != null && cts.size() > 0) { | |
| 9448 | - lists.add(s); | |
| 9449 | - } else { | |
| 9450 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 9451 | - lists.add(s); | |
| 9452 | - } | |
| 9453 | - } | |
| 9454 | - } | |
| 9455 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 9456 | - if (list.size() > 0) { | |
| 9457 | - map.put("fgsBm", list.get(0).getFgsBm()); | |
| 9458 | - map.put("xlBm", list.get(0).getXlBm()); | |
| 9459 | - map.put("xlName", list.get(0).getXlName()); | |
| 9460 | - map.put("fgsName", list.get(0).getFgsName()); | |
| 9461 | - try { | |
| 9462 | - map.put("xlNamePy", PinyinHelper.convertToPinyinString(list.get(0).getFgsBm()+list.get(0).getXlName(), "", PinyinFormat.WITHOUT_TONE)); | |
| 9463 | - } catch (PinyinException e) { | |
| 9464 | - // TODO Auto-generated catch block | |
| 9465 | - e.printStackTrace(); | |
| 9466 | - } | |
| 9467 | - double jhyygl = culateService.culateJhgl(list);//计划营运公里 | |
| 9468 | - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | |
| 9469 | - map.put("jhlc", jhyygl); | |
| 9470 | - map.put("jcclc", jhjcclc); | |
| 9471 | - map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | |
| 9472 | - double ljks=culateService.culateLjksgl(lists); | |
| 9473 | - map.put("ljks", ljks); | |
| 9474 | - double ljgl = culateService.culateLjgl(lists); | |
| 9475 | - double sjyygl = culateService.culateSjgl(lists); | |
| 9476 | - double zyygl = Arith.add(sjyygl, ljgl); | |
| 9477 | - | |
| 9478 | - double sjjccgl = culateService.culateJccgl(lists); | |
| 9479 | - double sjksgl = culateService.culateKsgl(lists); | |
| 9480 | - double zksgl = Arith.add(sjjccgl, sjksgl); | |
| 9481 | - map.put("sjzgl", Arith.add(zyygl, zksgl)); | |
| 9482 | - map.put("sjgl", zyygl); | |
| 9483 | - map.put("sjksgl", zksgl); | |
| 9484 | - double ssgl = culateService.culateLbgl(list); | |
| 9485 | - map.put("ssgl", ssgl); | |
| 9486 | - | |
| 9487 | - //计划+临加-少驶=实驶 | |
| 9488 | - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | |
| 9489 | - if (jl == zyygl) { | |
| 9490 | - map.put("zt", 0); | |
| 9491 | - } else { | |
| 9492 | - map.put("zt", 1); | |
| 9493 | - } | |
| 9494 | - | |
| 9495 | - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | |
| 9496 | - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | |
| 9497 | - map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | |
| 9498 | - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | |
| 9499 | - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | |
| 9500 | - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | |
| 9501 | - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | |
| 9502 | - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | |
| 9503 | - map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | |
| 9504 | - map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | |
| 9505 | - double ssgl_pc = culateService.culateCJLC(list, "配车"); | |
| 9506 | - double ssgl_by = culateService.culateCJLC(list, "保养"); | |
| 9507 | - double ssgl_cj = culateService.culateCJLC(list, "抽减"); | |
| 9508 | - double ssgl_qt = culateService.culateCJLC(list, "其他"); | |
| 9509 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | |
| 9510 | - map.put("ssbc", culateService.culateLbbc(list)); | |
| 9511 | - map.put("ljgl", ljgl); | |
| 9512 | - map.put("jhbc", culateService.culateJhbc(list, "")); | |
| 9513 | - map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | |
| 9514 | - map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | |
| 9515 | - map.put("sjbc", culateService.culateSjbc(lists, "")); | |
| 9516 | - map.put("sjbc_m", culateService.culateSjbc(lists, "zgf")); | |
| 9517 | - map.put("sjbc_a", culateService.culateSjbc(lists, "wgf")); | |
| 9518 | - map.put("ljbc", culateService.culateLjbc(lists, "")); | |
| 9519 | - map.put("ljbc_m", culateService.culateLjbc(lists, "zgf")); | |
| 9520 | - map.put("ljbc_a", culateService.culateLjbc(lists, "wgf")); | |
| 9521 | - map.put("fzbc", culateService.culateFzbc(lists, "")); | |
| 9522 | - map.put("fzbc_m", culateService.culateFzbc(lists, "zgf")); | |
| 9523 | - map.put("fzbc_a", culateService.culateFzbc(lists, "wgf")); | |
| 9524 | - map.put("dtbc", 0); | |
| 9525 | - map.put("dtbc_m", 0); | |
| 9526 | - map.put("dtbc_a", 0); | |
| 9527 | - if(m.get("xl")==null){ | |
| 9528 | - Map<String, Object> m_ = culateService.culateDjg(lists, list.get(0).getXlBm()); | |
| 9529 | - map.put("djg", m_.get("djgcsq")); | |
| 9530 | - map.put("djg_m", m_.get("djgcsz")); | |
| 9531 | - map.put("djg_a", m_.get("djgcsw")); | |
| 9532 | - map.put("djg_time", m_.get("djgsj")); | |
| 9533 | - }else{ | |
| 9534 | - map.put("djg", m.get("djgAll")==null?"0":m.get("djgAll")); | |
| 9535 | - map.put("djg_m", m.get("djgZgf")==null?"0":m.get("djgZgf")); | |
| 9536 | - map.put("djg_a", m.get("djgWgf")==null?"0":m.get("djgWgf")); | |
| 9537 | - map.put("djg_time", m.get("djgTime")==null?"0":m.get("djgTime")); | |
| 9538 | - } | |
| 9539 | - } | |
| 9540 | - return map; | |
| 9541 | - } | |
| 9542 | - | |
| 9543 | - @Override | |
| 9544 | - public List<Map<String, Object>> statisticsDailyTj(String gsdm, String fgsdm, String line, String date, String date2, | |
| 9545 | - String xlName, String type,String nature) { | |
| 9546 | - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>(); | |
| 9547 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 9548 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 9549 | - List<Object[]> listInterval=new ArrayList<Object[]>(); | |
| 9550 | - line = line.trim(); | |
| 9551 | - if (line.equals("")) { | |
| 9552 | - //查询所有线路 | |
| 9553 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | |
| 9554 | - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2); | |
| 9555 | - } else { | |
| 9556 | - //查询单条线路 | |
| 9557 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | |
| 9558 | - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2); | |
| 9559 | - } | |
| 9560 | - Map<String, Map<String,Object>> mapInterval=new HashMap<String, Map<String,Object>>(); | |
| 9561 | - for (int i = 0; i < listInterval.size(); i++) { | |
| 9562 | - Object[] interval=listInterval.get(i); | |
| 9563 | - String gs=interval[0].toString(); | |
| 9564 | - String fgs=interval[1].toString(); | |
| 9565 | - String xl=interval[2].toString(); | |
| 9566 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 9567 | - m.put("gs", gs); | |
| 9568 | - m.put("fgs", fgs); | |
| 9569 | - m.put("xl", xl); | |
| 9570 | - m.put("djgAll", interval[3]); | |
| 9571 | - m.put("djgZgf", interval[6]); | |
| 9572 | - m.put("djgWgf", interval[7]); | |
| 9573 | - m.put("djgTime", interval[8]); | |
| 9574 | - mapInterval.put(gs+"-"+fgs+"-"+xl, m); | |
| 9575 | - } | |
| 9576 | - Map<String, Boolean> lineMap=lineService.lineNature(); | |
| 9577 | - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | |
| 9578 | - for (int i = 0; i < listAll.size(); i++) { | |
| 9579 | - ScheduleRealInfo s=listAll.get(i); | |
| 9580 | - if (nature.equals("0")) { | |
| 9581 | - list.add(s); | |
| 9582 | - }else if(nature.equals("1")){ | |
| 9583 | - if(lineMap.get(s.getXlBm())){ | |
| 9584 | - list.add(s); | |
| 9585 | - } | |
| 9586 | - }else{ | |
| 9587 | - if(!lineMap.get(s.getXlBm())){ | |
| 9588 | - list.add(s); | |
| 9589 | - } | |
| 9590 | - } | |
| 9591 | - } | |
| 9592 | - for (int i = 0; i < list.size(); i++) { | |
| 9593 | - ScheduleRealInfo s = list.get(i); | |
| 9594 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 9595 | - if (cts != null && cts.size() > 0) { | |
| 9596 | - list_s.add(s); | |
| 9597 | - } else { | |
| 9598 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 9599 | - list_s.add(s); | |
| 9600 | - } | |
| 9601 | - } | |
| 9602 | - } | |
| 9603 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 9604 | - for (int i = 0; i < list.size(); i++) { | |
| 9605 | - if (i < list.size() - 1) { | |
| 9606 | - if ((list.get(i+1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) { | |
| 9607 | - lists.add(list.get(i)); | |
| 9608 | - } else { | |
| 9609 | - lists.add(list.get(i)); | |
| 9610 | - Map<String, Object> mm=new HashMap<String,Object>(); | |
| 9611 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | |
| 9612 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | |
| 9613 | - } | |
| 9614 | - Map<String, Object> map = staticTj(lists,mm); | |
| 9615 | - lMap.add(map); | |
| 9616 | - lists = new ArrayList<ScheduleRealInfo>(); | |
| 9617 | - } | |
| 9618 | - } else { | |
| 9619 | - if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) { | |
| 9620 | - lists.add(list.get(i)); | |
| 9621 | - Map<String, Object> mm=new HashMap<String,Object>(); | |
| 9622 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | |
| 9623 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | |
| 9624 | - } | |
| 9625 | - Map<String, Object> map = staticTj(lists,mm); | |
| 9626 | - lMap.add(map); | |
| 9627 | - } else { | |
| 9628 | - lists = new ArrayList<ScheduleRealInfo>(); | |
| 9629 | - lists.add(list.get(i)); | |
| 9630 | - Map<String, Object> mm=new HashMap<String,Object>(); | |
| 9631 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | |
| 9632 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | |
| 9633 | - } | |
| 9634 | - Map<String, Object> map = staticTj(lists,mm); | |
| 9635 | - lMap.add(map); | |
| 9636 | - } | |
| 9637 | - } | |
| 9638 | - } | |
| 9639 | - /*if(!line.equals("")){ | |
| 9640 | - List<Line> l=lineRepository.findLineByCode(line); | |
| 9641 | - if(l.size()>0) | |
| 9642 | - lMap.get(0).put("fgsName", BasicData.businessFgsCodeNameMap.get(l.get(0).getBrancheCompany()+"_"+l.get(0).getCompany())); | |
| 9643 | - }*/ | |
| 9644 | - Collections.sort(lMap, new AccountXlbm()); | |
| 9645 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 9646 | - map.put("xlName", "合计"); | |
| 9647 | - map.put("fgsName", ""); | |
| 9648 | - double jhyygl = culateService.culateJhgl(list);//计划营运公里 | |
| 9649 | - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | |
| 9650 | - map.put("jhlc", jhyygl); | |
| 9651 | - map.put("jcclc", jhjcclc); | |
| 9652 | - map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | |
| 9653 | - | |
| 9654 | - double ljgl = culateService.culateLjgl(list_s); | |
| 9655 | - double sjyygl = culateService.culateSjgl(list_s); | |
| 9656 | - double zyygl = Arith.add(sjyygl, ljgl); | |
| 9657 | - double ljks=culateService.culateLjksgl(list_s); | |
| 9658 | - map.put("ljks", ljks); | |
| 9659 | - double sjjccgl = culateService.culateJccgl(list_s); | |
| 9660 | - double sjksgl = culateService.culateKsgl(list_s); | |
| 9661 | - double zksgl = Arith.add(sjjccgl, sjksgl); | |
| 9662 | - map.put("sjzgl", Arith.add(zyygl, zksgl)); | |
| 9663 | - map.put("sjgl", zyygl); | |
| 9664 | - map.put("sjksgl", zksgl); | |
| 9665 | - | |
| 9666 | - double ssgl = culateService.culateLbgl(list); | |
| 9667 | - map.put("ssgl", ssgl); | |
| 9668 | - //计划+临加-少驶=实驶 | |
| 9669 | - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | |
| 9670 | - if (jl == zyygl) { | |
| 9671 | - map.put("zt", 0); | |
| 9672 | - } else { | |
| 9673 | - map.put("zt", 1); | |
| 9674 | - } | |
| 9675 | - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | |
| 9676 | - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | |
| 9677 | - map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | |
| 9678 | - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | |
| 9679 | - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | |
| 9680 | - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | |
| 9681 | - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | |
| 9682 | - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | |
| 9683 | - map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | |
| 9684 | - map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | |
| 9685 | - double ssgl_pc = culateService.culateCJLC(list, "配车"); | |
| 9686 | - double ssgl_by = culateService.culateCJLC(list, "保养"); | |
| 9687 | - double ssgl_cj = culateService.culateCJLC(list, "抽减"); | |
| 9688 | - double ssgl_qt = culateService.culateCJLC(list, "其他"); | |
| 9689 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | |
| 9690 | - | |
| 9691 | - map.put("ssbc", culateService.culateLbbc(list)); | |
| 9692 | - map.put("ljgl", ljgl); | |
| 9693 | - map.put("jhbc", culateService.culateJhbc(list, "")); | |
| 9694 | - map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | |
| 9695 | - map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | |
| 9696 | - map.put("sjbc", culateService.culateSjbc(list_s, "")); | |
| 9697 | - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | |
| 9698 | - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | |
| 9699 | - map.put("ljbc", culateService.culateLjbc(list_s, "")); | |
| 9700 | - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | |
| 9701 | - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | |
| 9702 | - map.put("fzbc", culateService.culateFzbc(list_s, "")); | |
| 9703 | - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | |
| 9704 | - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | |
| 9705 | - map.put("dtbc", 0); | |
| 9706 | - map.put("dtbc_m", 0); | |
| 9707 | - map.put("dtbc_a", 0); | |
| 9708 | - if (list.size() > 0) { | |
| 9709 | - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | |
| 9710 | - for (Map<String, Object> m : lMap) { | |
| 9711 | - if (m.containsKey("djg") && m.get("djg") != null) | |
| 9712 | - djg += Integer.valueOf(m.get("djg").toString()); | |
| 9713 | - if (m.containsKey("djg_m") && m.get("djg_m") != null) | |
| 9714 | - djg_m += Integer.valueOf(m.get("djg_m").toString()); | |
| 9715 | - if (m.containsKey("djg_a") && m.get("djg_a") != null) | |
| 9716 | - djg_a += Integer.valueOf(m.get("djg_a").toString()); | |
| 9717 | - if (m.containsKey("djg_time") && m.get("djg_time") != null) { | |
| 9718 | - int t = Integer.valueOf(m.get("djg_time").toString()); | |
| 9719 | - if (t > djg_time) | |
| 9720 | - djg_time = t; | |
| 9721 | - } | |
| 9722 | - } | |
| 9723 | - map.put("djg", djg); | |
| 9724 | - map.put("djg_m", djg_m); | |
| 9725 | - map.put("djg_a", djg_a); | |
| 9726 | - map.put("djg_time", djg_time); | |
| 9727 | -// Map<String, Object> m_=culateService.culateDjg(list_s, list.get(0).getXlBm()); | |
| 9728 | -// map.put("djg", m_.get("djgcsq")); | |
| 9729 | -// map.put("djg_m", m_.get("djgcsz")); | |
| 9730 | -// map.put("djg_a", m_.get("djgcsw")); | |
| 9731 | -// map.put("djg_time", m_.get("djgsj")); | |
| 9732 | - } else { | |
| 9733 | - map.put("djg", "0"); | |
| 9734 | - map.put("djg_m", "0"); | |
| 9735 | - map.put("djg_a", "0"); | |
| 9736 | - map.put("djg_time", "0"); | |
| 9737 | - } | |
| 9738 | - lMap.add(map); | |
| 9739 | - if (type != null && type.length() != 0 && type.equals("export")) { | |
| 9740 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 9741 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 9742 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 9743 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 9744 | - m.put("date", date + "至" + date2); | |
| 9745 | - ReportUtils ee = new ReportUtils(); | |
| 9746 | - try { | |
| 9747 | - String dateTime = ""; | |
| 9748 | - if (date.equals(date2)) { | |
| 9749 | - dateTime = sdfSimple.format(sdfMonth.parse(date)); | |
| 9750 | - } else { | |
| 9751 | - dateTime = sdfSimple.format(sdfMonth.parse(date)) | |
| 9752 | - + "-" + sdfSimple.format(sdfMonth.parse(date2)); | |
| 9753 | - } | |
| 9754 | - listI.add(lMap.iterator()); | |
| 9755 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 9756 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/statisticsDaily_2.xls", | |
| 9757 | - path + "export/" + dateTime + "-" + xlName + "-统计日报.xls"); | |
| 9758 | - } catch (Exception e) { | |
| 9759 | - // TODO: handle exception | |
| 9760 | - //e.printStackTrace(); | |
| 9761 | - logger.info("", e); | |
| 9762 | - } | |
| 9763 | - } | |
| 9764 | - | |
| 9765 | - return lMap; | |
| 9766 | - } | |
| 9767 | - | |
| 9768 | - @Override | |
| 9769 | - public List<Map<String, Object>> statisticsDailyTjHb(String gsdm, String fgsdm, String line, String date, String date2, | |
| 9770 | - String xlName, String type,String nature) { | |
| 9771 | - List<ScheduleRealInfo> listAll = new ArrayList<ScheduleRealInfo>(); | |
| 9772 | - List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>(); | |
| 9773 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 9774 | - List<Object[]> listInterval=new ArrayList<Object[]>(); | |
| 9775 | - | |
| 9776 | - line = line.trim(); | |
| 9777 | - if (line.equals("")) { | |
| 9778 | - //查询所有线路 | |
| 9779 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date, date2, gsdm, fgsdm); | |
| 9780 | - listInterval = calcIntervalRepository.countByDateAndLine(gsdm, fgsdm, date, date2); | |
| 9781 | - } else { | |
| 9782 | - //查询单条线路 | |
| 9783 | - listAll = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date, date2); | |
| 9784 | - listInterval = calcIntervalRepository.countByDateAndLine(line, date, date2); | |
| 9785 | - } | |
| 9786 | - Map<String, Map<String,Object>> mapInterval=new HashMap<>(); | |
| 9787 | - for (int i = 0; i < listInterval.size(); i++) { | |
| 9788 | - Object[] interval=listInterval.get(i); | |
| 9789 | - String gs=interval[0].toString(); | |
| 9790 | - String fgs=interval[1].toString(); | |
| 9791 | - String xl=interval[2].toString(); | |
| 9792 | - Map<String, Object> m=new HashMap<String,Object>(); | |
| 9793 | - m.put("gs", gs); | |
| 9794 | - m.put("fgs", fgs); | |
| 9795 | - m.put("xl", xl); | |
| 9796 | - m.put("djgAll", interval[3]); | |
| 9797 | - m.put("djgZgf", interval[6]); | |
| 9798 | - m.put("djgWgf", interval[7]); | |
| 9799 | - m.put("djgTime", interval[8]); | |
| 9800 | - mapInterval.put(gs+"-"+fgs+"-"+xl, m); | |
| 9801 | - } | |
| 9802 | - | |
| 9803 | - Map<String, Boolean> lineMap=lineService.lineNature(); | |
| 9804 | - List<ScheduleRealInfo> list=new ArrayList<ScheduleRealInfo>(); | |
| 9805 | - for (int i = 0; i < listAll.size(); i++) { | |
| 9806 | - ScheduleRealInfo s=listAll.get(i); | |
| 9807 | - if (nature.equals("0")) { | |
| 9808 | - list.add(s); | |
| 9809 | - }else if(nature.equals("1")){ | |
| 9810 | - if(lineMap.get(s.getXlBm())){ | |
| 9811 | - list.add(s); | |
| 9812 | - } | |
| 9813 | - }else{ | |
| 9814 | - if(!lineMap.get(s.getXlBm())){ | |
| 9815 | - list.add(s); | |
| 9816 | - } | |
| 9817 | - } | |
| 9818 | - } | |
| 9819 | - for (int i = 0; i < list.size(); i++) { | |
| 9820 | - ScheduleRealInfo s = list.get(i); | |
| 9821 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 9822 | - if (cts != null && cts.size() > 0) { | |
| 9823 | - list_s.add(s); | |
| 9824 | - } else { | |
| 9825 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 9826 | - list_s.add(s); | |
| 9827 | - } | |
| 9828 | - } | |
| 9829 | - } | |
| 9830 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 9831 | - for (int i = 0; i < list.size(); i++) { | |
| 9832 | - if (i < list.size() - 1) { | |
| 9833 | - if ((list.get(i + 1).getFgsBm()+list.get(i + 1).getXlBm()).equals(list.get(i).getFgsBm()+list.get(i).getXlBm())) { | |
| 9834 | - lists.add(list.get(i)); | |
| 9835 | - } else { | |
| 9836 | - lists.add(list.get(i)); | |
| 9837 | - Map<String, Object> mm=new HashMap<String,Object>(); | |
| 9838 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | |
| 9839 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | |
| 9840 | - } | |
| 9841 | - Map<String, Object> map = staticTj(lists,mm); | |
| 9842 | - lMap.add(map); | |
| 9843 | - lists = new ArrayList<ScheduleRealInfo>(); | |
| 9844 | - } | |
| 9845 | - } else { | |
| 9846 | - if ((list.get(i).getFgsBm()+list.get(i).getXlBm()).equals(list.get(i - 1).getFgsBm()+list.get(i - 1).getXlBm())) { | |
| 9847 | - lists.add(list.get(i)); | |
| 9848 | - Map<String, Object> mm=new HashMap<String,Object>(); | |
| 9849 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | |
| 9850 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | |
| 9851 | - } | |
| 9852 | - Map<String, Object> map = staticTj(lists,mm); | |
| 9853 | - lMap.add(map); | |
| 9854 | - } else { | |
| 9855 | - lists = new ArrayList<ScheduleRealInfo>(); | |
| 9856 | - lists.add(list.get(i)); | |
| 9857 | - Map<String, Object> mm=new HashMap<String,Object>(); | |
| 9858 | - if(mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm())!=null){ | |
| 9859 | - mm=mapInterval.get(lists.get(0).getGsBm()+"-"+lists.get(0).getFgsBm()+"-"+lists.get(0).getXlBm()); | |
| 9860 | - } | |
| 9861 | - Map<String, Object> map = staticTj(lists,mm); | |
| 9862 | - lMap.add(map); | |
| 9863 | - } | |
| 9864 | - } | |
| 9865 | - } | |
| 9866 | - | |
| 9867 | - Collections.sort(lMap, new AccountXlbm()); | |
| 9868 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 9869 | - map.put("xlBm", "hj"); | |
| 9870 | - map.put("xlName", "合计"); | |
| 9871 | - map.put("fgsBm", ""); | |
| 9872 | - map.put("fgsName", ""); | |
| 9873 | - map.put("gsBm", ""); | |
| 9874 | - double jhyygl = culateService.culateJhgl(list);//计划营运公里 | |
| 9875 | - double jhjcclc = culateService.culateJhJccgl(list);//计划进出场公里(计划空驶公里) | |
| 9876 | - map.put("jhlc", jhyygl); | |
| 9877 | - map.put("jcclc", jhjcclc); | |
| 9878 | - map.put("jhzlc", Arith.add(jhyygl, jhjcclc)); | |
| 9879 | - | |
| 9880 | - double ljgl = culateService.culateLjgl(list_s); | |
| 9881 | - double sjyygl = culateService.culateSjgl(list_s); | |
| 9882 | - double zyygl = Arith.add(sjyygl, ljgl); | |
| 9883 | - double ljks=culateService.culateLjksgl(list_s); | |
| 9884 | - map.put("ljks", ljks); | |
| 9885 | - double sjjccgl = culateService.culateJccgl(list_s); | |
| 9886 | - double sjksgl = culateService.culateKsgl(list_s); | |
| 9887 | - double zksgl = Arith.add(sjjccgl, sjksgl); | |
| 9888 | - map.put("sjzgl", Arith.add(zyygl, zksgl)); | |
| 9889 | - map.put("sjgl", zyygl); | |
| 9890 | - map.put("sjksgl", zksgl); | |
| 9891 | - | |
| 9892 | - double ssgl = culateService.culateLbgl(list); | |
| 9893 | - map.put("ssgl", ssgl); | |
| 9894 | - //计划+临加-少驶=实驶 | |
| 9895 | - double jl = Arith.sub(Arith.add(jhyygl, ljgl), ssgl); | |
| 9896 | - if (jl == zyygl) { | |
| 9897 | - map.put("zt", 0); | |
| 9898 | - } else { | |
| 9899 | - map.put("zt", 1); | |
| 9900 | - } | |
| 9901 | - map.put("ssgl_lz", culateService.culateCJLC(list, "路阻")); | |
| 9902 | - map.put("ssgl_dm", culateService.culateCJLC(list, "吊慢")); | |
| 9903 | - map.put("ssgl_gz", culateService.culateCJLC(list, "故障")); | |
| 9904 | - map.put("ssgl_jf", culateService.culateCJLC(list, "纠纷")); | |
| 9905 | - map.put("ssgl_zs", culateService.culateCJLC(list, "肇事")); | |
| 9906 | - map.put("ssgl_qr", culateService.culateCJLC(list, "缺人")); | |
| 9907 | - map.put("ssgl_qc", culateService.culateCJLC(list, "缺车")); | |
| 9908 | - map.put("ssgl_kx", culateService.culateCJLC(list, "客稀")); | |
| 9909 | - map.put("ssgl_qh", culateService.culateCJLC(list, "气候")); | |
| 9910 | - map.put("ssgl_yw", culateService.culateCJLC(list, "援外")); | |
| 9911 | - double ssgl_pc = culateService.culateCJLC(list, "配车"); | |
| 9912 | - double ssgl_by = culateService.culateCJLC(list, "保养"); | |
| 9913 | - double ssgl_cj = culateService.culateCJLC(list, "抽减"); | |
| 9914 | - double ssgl_qt = culateService.culateCJLC(list, "其他"); | |
| 9915 | - map.put("ssgl_other", Arith.add(Arith.add(ssgl_pc, ssgl_by), Arith.add(ssgl_cj, ssgl_qt))); | |
| 9916 | - | |
| 9917 | - map.put("ssbc", culateService.culateLbbc(list)); | |
| 9918 | - map.put("ljgl", ljgl); | |
| 9919 | - map.put("jhbc", culateService.culateJhbc(list, "")); | |
| 9920 | - map.put("jhbc_m", culateService.culateJhbc(list, "zgf")); | |
| 9921 | - map.put("jhbc_a", culateService.culateJhbc(list, "wgf")); | |
| 9922 | - map.put("sjbc", culateService.culateSjbc(list_s, "")); | |
| 9923 | - map.put("sjbc_m", culateService.culateSjbc(list_s, "zgf")); | |
| 9924 | - map.put("sjbc_a", culateService.culateSjbc(list_s, "wgf")); | |
| 9925 | - map.put("ljbc", culateService.culateLjbc(list_s, "")); | |
| 9926 | - map.put("ljbc_m", culateService.culateLjbc(list_s, "zgf")); | |
| 9927 | - map.put("ljbc_a", culateService.culateLjbc(list_s, "wgf")); | |
| 9928 | - map.put("fzbc", culateService.culateFzbc(list_s, "")); | |
| 9929 | - map.put("fzbc_m", culateService.culateFzbc(list_s, "zgf")); | |
| 9930 | - map.put("fzbc_a", culateService.culateFzbc(list_s, "wgf")); | |
| 9931 | - map.put("dtbc", 0); | |
| 9932 | - map.put("dtbc_m", 0); | |
| 9933 | - map.put("dtbc_a", 0); | |
| 9934 | - if (list.size() > 0) { | |
| 9935 | - int djg = 0, djg_m = 0, djg_a = 0, djg_time = 0; | |
| 9936 | - for (Map<String, Object> m : lMap) { | |
| 9937 | - if (m.containsKey("djg") && m.get("djg") != null) | |
| 9938 | - djg += Integer.valueOf(m.get("djg").toString()); | |
| 9939 | - if (m.containsKey("djg_m") && m.get("djg_m") != null) | |
| 9940 | - djg_m += Integer.valueOf(m.get("djg_m").toString()); | |
| 9941 | - if (m.containsKey("djg_a") && m.get("djg_a") != null) | |
| 9942 | - djg_a += Integer.valueOf(m.get("djg_a").toString()); | |
| 9943 | - if (m.containsKey("djg_time") && m.get("djg_time") != null) { | |
| 9944 | - int t = Integer.valueOf(m.get("djg_time").toString()); | |
| 9945 | - if (t > djg_time) | |
| 9946 | - djg_time = t; | |
| 9947 | - } | |
| 9948 | - } | |
| 9949 | - map.put("djg", djg); | |
| 9950 | - map.put("djg_m", djg_m); | |
| 9951 | - map.put("djg_a", djg_a); | |
| 9952 | - map.put("djg_time", djg_time); | |
| 9953 | - } else { | |
| 9954 | - map.put("djg", "0"); | |
| 9955 | - map.put("djg_m", "0"); | |
| 9956 | - map.put("djg_a", "0"); | |
| 9957 | - map.put("djg_time", "0"); | |
| 9958 | - } | |
| 9959 | - lMap.add(map); | |
| 9960 | - return lMap; | |
| 9961 | - } | |
| 9962 | - | |
| 9963 | - @Override | |
| 9964 | - public Map<String, Object> scheduleDaily(String line, String date) { | |
| 9965 | - Map<String, String> tempMap = null; | |
| 9966 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); | |
| 9967 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 9968 | - Double jhlc = 0.00; | |
| 9969 | - Float sjgl = 0f, ssgl = 0f, ssgl_lz = 0f, ssgl_dm = 0f, ssgl_gz = 0f, ssgl_jf = 0f, ssgl_zs = 0f, ssgl_qr = 0f, ssgl_qc = 0f, ssgl_kx = 0f, ssgl_qh = 0f, ssgl_yw = 0f, ssgl_other = 0f, ljgl = 0f; | |
| 9970 | - int jhbc = 0; | |
| 9971 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 9972 | - if (scheduleRealInfo != null) { | |
| 9973 | - //计算里程(包括子任务) | |
| 9974 | - jhlc += scheduleRealInfo.getJhlc(); | |
| 9975 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 9976 | - if (!childTaskPlans.isEmpty()) { | |
| 9977 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 9978 | - while (it.hasNext()) { | |
| 9979 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 9980 | - //是否烂班,烂班就是少驶 | |
| 9981 | - if (!childTaskPlan.isDestroy()) { | |
| 9982 | - sjgl += childTaskPlan.getMileage(); | |
| 9983 | - } else { | |
| 9984 | - ssgl += childTaskPlan.getMileage(); | |
| 9985 | - if (childTaskPlan.getDestroyReason().equals("路阻")) { | |
| 9986 | - ssgl_lz += childTaskPlan.getMileage(); | |
| 9987 | - } else if (childTaskPlan.getDestroyReason().equals("吊慢")) { | |
| 9988 | - ssgl_dm += childTaskPlan.getMileage(); | |
| 9989 | - } else if (childTaskPlan.getDestroyReason().equals("故障")) { | |
| 9990 | - ssgl_gz += childTaskPlan.getMileage(); | |
| 9991 | - } else if (childTaskPlan.getDestroyReason().equals("纠纷")) { | |
| 9992 | - ssgl_jf += childTaskPlan.getMileage(); | |
| 9993 | - } else if (childTaskPlan.getDestroyReason().equals("肇事")) { | |
| 9994 | - ssgl_zs += childTaskPlan.getMileage(); | |
| 9995 | - } else if (childTaskPlan.getDestroyReason().equals("缺人")) { | |
| 9996 | - ssgl_qr += childTaskPlan.getMileage(); | |
| 9997 | - } else if (childTaskPlan.getDestroyReason().equals("缺车")) { | |
| 9998 | - ssgl_qc += childTaskPlan.getMileage(); | |
| 9999 | - } else if (childTaskPlan.getDestroyReason().equals("客稀")) { | |
| 10000 | - ssgl_kx += childTaskPlan.getMileage(); | |
| 10001 | - } else if (childTaskPlan.getDestroyReason().equals("气候")) { | |
| 10002 | - ssgl_qh += childTaskPlan.getMileage(); | |
| 10003 | - } else if (childTaskPlan.getDestroyReason().equals("援外")) { | |
| 10004 | - ssgl_yw += childTaskPlan.getMileage(); | |
| 10005 | - } else { | |
| 10006 | - ssgl_other += childTaskPlan.getMileage(); | |
| 10007 | - } | |
| 10008 | - } | |
| 10009 | - //临加公里 | |
| 10010 | - if (childTaskPlan.getType1().equals("临加")) { | |
| 10011 | - ljgl += childTaskPlan.getMileage(); | |
| 10012 | - } | |
| 10013 | - } | |
| 10014 | - } | |
| 10015 | - //班次 | |
| 10016 | - scheduleRealInfo.getFcsjT(); | |
| 10017 | - scheduleRealInfo.getFcsjActualTime(); | |
| 10018 | - } | |
| 10019 | - } | |
| 10020 | - map.put("jhlc", jhlc); | |
| 10021 | - map.put("sjgl", sjgl); | |
| 10022 | - map.put("ssgl", ssgl); | |
| 10023 | - map.put("ssgl_lz", ssgl_lz); | |
| 10024 | - map.put("ssgl_dm", ssgl_dm); | |
| 10025 | - map.put("ssgl_gz", ssgl_gz); | |
| 10026 | - map.put("ssgl_jf", ssgl_jf); | |
| 10027 | - map.put("ssgl_zs", ssgl_zs); | |
| 10028 | - map.put("ssgl_qr", ssgl_qr); | |
| 10029 | - map.put("ssgl_qc", ssgl_qc); | |
| 10030 | - map.put("ssgl_kx", ssgl_kx); | |
| 10031 | - map.put("ssgl_qh", ssgl_qh); | |
| 10032 | - map.put("ssgl_yw", ssgl_yw); | |
| 10033 | - map.put("ssgl_other", ssgl_other); | |
| 10034 | - map.put("ljgl", ljgl); | |
| 10035 | - | |
| 10036 | - map.put("jhbc", scheduleRealInfos.size()); | |
| 10037 | - return null; | |
| 10038 | - } | |
| 10039 | - | |
| 10040 | - @Override | |
| 10041 | - public int countByLineCodeAndDate(String xlBm, String schDate) { | |
| 10042 | - return scheduleRealInfoRepository.countByLineCodeAndDate(xlBm + "", schDate); | |
| 10043 | - } | |
| 10044 | - | |
| 10045 | - @Override | |
| 10046 | - public List<ScheduleRealInfo> findByLineCodeAndDate(String xlBm, String schDate) { | |
| 10047 | - return scheduleRealInfoRepository.findByLineCodeAndDate(xlBm + "", schDate); | |
| 10048 | - } | |
| 10049 | - | |
| 10050 | - @Override | |
| 10051 | - public void deleteByLineCodeAndDate(String xlBm, String schDate) { | |
| 10052 | - scheduleRealInfoRepository.deleteByLineCodeAndDate(xlBm + "", schDate); | |
| 10053 | - } | |
| 10054 | - | |
| 10055 | - @Override | |
| 10056 | - public Long getMaxId() { | |
| 10057 | - return scheduleRealInfoRepository.getMaxId(); | |
| 10058 | - } | |
| 10059 | - | |
| 10060 | - @Override | |
| 10061 | - public List<ScheduleRealInfo> realScheduleList(String line, String date) { | |
| 10062 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 10063 | - String lpName = "lpName"; | |
| 10064 | - String zdsj = ""; | |
| 10065 | - String zdsjActual = ""; | |
| 10066 | - String zdsj1 = ""; | |
| 10067 | - String zdsjActual1 = ""; | |
| 10068 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date); | |
| 10069 | - | |
| 10070 | - /* | |
| 10071 | - * 对计划发车时间相同的班次进行排序 out最前 in最后 | |
| 10072 | - */ | |
| 10073 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 10074 | - SimpleDateFormat sdfnyr =new SimpleDateFormat("yyyy-MM-dd"); | |
| 10075 | - String minfcsj = "02:00"; | |
| 10076 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 10077 | - if (lineList.size() > 0) { | |
| 10078 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 10079 | - + " id = (" | |
| 10080 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 10081 | - + ")"; | |
| 10082 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 10083 | - } | |
| 10084 | - String[] minSjs = minfcsj.split(":"); | |
| 10085 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | |
| 10086 | - for (int i = 0; i < listInfo.size(); i++) { | |
| 10087 | - ScheduleRealInfo s = listInfo.get(i); | |
| 10088 | - if (s.getBcType().equals("out")) { | |
| 10089 | - s.setRemark("1"); | |
| 10090 | - } else if (s.getBcType().equals("in")) { | |
| 10091 | - s.setRemark("3"); | |
| 10092 | - } else { | |
| 10093 | - s.setRemark("2"); | |
| 10094 | - } | |
| 10095 | - String[] fcsj = s.getFcsj().split(":"); | |
| 10096 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 10097 | - | |
| 10098 | - Long fscjT = 0L; | |
| 10099 | - if (fcsjL < minSj) { | |
| 10100 | - Calendar calendar = new GregorianCalendar(); | |
| 10101 | - calendar.setTime(s.getScheduleDate()); | |
| 10102 | - calendar.add(calendar.DATE, 1); | |
| 10103 | - Date date_sch= calendar.getTime(); | |
| 10104 | - try { | |
| 10105 | - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime(); | |
| 10106 | - } catch (ParseException e) { | |
| 10107 | - // TODO Auto-generated catch block | |
| 10108 | - e.printStackTrace(); | |
| 10109 | - } | |
| 10110 | - | |
| 10111 | - } else { | |
| 10112 | - try { | |
| 10113 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 10114 | - } catch (ParseException e) { | |
| 10115 | - // TODO Auto-generated catch block | |
| 10116 | - e.printStackTrace(); | |
| 10117 | - }; | |
| 10118 | - } | |
| 10119 | - s.setFcsjT(fscjT); | |
| 10120 | - } | |
| 10121 | - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); | |
| 10122 | - listInfo2.addAll(listInfo); | |
| 10123 | - Collections.sort(listInfo, new compareLpFcsjType()); | |
| 10124 | - Collections.sort(listInfo2,new compareDirLpFcsjType()); | |
| 10125 | - for (int i = 0; i < listInfo.size(); i++) { | |
| 10126 | - ScheduleRealInfo t = listInfo.get(i); | |
| 10127 | - if (!lpName.equals(t.getLpName())) { | |
| 10128 | - zdsjActual = t.getZdsjActual(); | |
| 10129 | - zdsj = t.getZdsj(); | |
| 10130 | - t.setZdsjActual(""); | |
| 10131 | - t.setZdsj(""); | |
| 10132 | - } else { | |
| 10133 | - zdsj1 = t.getZdsj(); | |
| 10134 | - zdsjActual1 = t.getZdsjActual(); | |
| 10135 | - t.setZdsjActual(zdsjActual); | |
| 10136 | - t.setZdsj(zdsj); | |
| 10137 | - zdsj = zdsj1; | |
| 10138 | - zdsjActual = zdsjActual1; | |
| 10139 | - } | |
| 10140 | - lpName = t.getLpName(); | |
| 10141 | - list.add(t); | |
| 10142 | - } | |
| 10143 | -/* | |
| 10144 | - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleDdrb2(line, date); | |
| 10145 | - for (int i = 0; i < listInfo2.size(); i++) { | |
| 10146 | - ScheduleRealInfo s = listInfo2.get(i); | |
| 10147 | - if (s.getBcType().equals("out")) { | |
| 10148 | - s.setRemark("1"); | |
| 10149 | - } else if (s.getBcType().equals("in")) { | |
| 10150 | - s.setRemark("3"); | |
| 10151 | - } else { | |
| 10152 | - s.setRemark("2"); | |
| 10153 | - } | |
| 10154 | - String[] fcsj = s.getFcsj().split(":"); | |
| 10155 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 10156 | - | |
| 10157 | - Long fscjT = 0L; | |
| 10158 | - if (fcsjL < minSj) { | |
| 10159 | - Calendar calendar = new GregorianCalendar(); | |
| 10160 | - calendar.setTime(s.getScheduleDate()); | |
| 10161 | - calendar.add(calendar.DATE, 1); | |
| 10162 | - s.setScheduleDate(calendar.getTime()); | |
| 10163 | - try { | |
| 10164 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | |
| 10165 | - } catch (ParseException e) { | |
| 10166 | - // TODO Auto-generated catch block | |
| 10167 | - e.printStackTrace(); | |
| 10168 | - } | |
| 10169 | - | |
| 10170 | - } else { | |
| 10171 | - try { | |
| 10172 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 10173 | - } catch (ParseException e) { | |
| 10174 | - // TODO Auto-generated catch block | |
| 10175 | - e.printStackTrace(); | |
| 10176 | - } | |
| 10177 | - ; | |
| 10178 | - } | |
| 10179 | - s.setFcsjT(fscjT); | |
| 10180 | - }*/ | |
| 10181 | - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | |
| 10182 | - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | |
| 10183 | - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | |
| 10184 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | |
| 10185 | - if (listInfo2.size() > 0) { | |
| 10186 | - int a = listInfo2.size() % 3; | |
| 10187 | - int b = listInfo2.size() / 3; | |
| 10188 | - int x = 0, y = 0; | |
| 10189 | - if (a == 2) { | |
| 10190 | - x = b + 1; | |
| 10191 | - y = x * 2; | |
| 10192 | - } else if (a == 1) { | |
| 10193 | - x = b + 1; | |
| 10194 | - y = x * 2 - 1; | |
| 10195 | - } else { | |
| 10196 | - x = b; | |
| 10197 | - y = 2 * x; | |
| 10198 | - | |
| 10199 | - } | |
| 10200 | - for (int i = 0; i < listInfo2.size(); i++) { | |
| 10201 | - ScheduleRealInfo s = listInfo2.get(i); | |
| 10202 | - if (i + 1 <= x) { | |
| 10203 | - xList.add(s); | |
| 10204 | - } else if ((i + 1) > x && (i + 1) <= y) { | |
| 10205 | - yList.add(s); | |
| 10206 | - } else { | |
| 10207 | - zList.add(s); | |
| 10208 | - } | |
| 10209 | - } | |
| 10210 | - for (int i = 0; i < x; i++) { | |
| 10211 | - newList.add(xList.get(i)); | |
| 10212 | - if (yList.size() > i) { | |
| 10213 | - newList.add(yList.get(i)); | |
| 10214 | - } else { | |
| 10215 | - newList.add(new ScheduleRealInfo()); | |
| 10216 | - } | |
| 10217 | - if (zList.size() > i) { | |
| 10218 | - newList.add(zList.get(i)); | |
| 10219 | - } else { | |
| 10220 | - newList.add(new ScheduleRealInfo()); | |
| 10221 | - } | |
| 10222 | - | |
| 10223 | - } | |
| 10224 | - } | |
| 10225 | - for (int i = 0; i < newList.size(); i++) { | |
| 10226 | - ScheduleRealInfo t1 = newList.get(i); | |
| 10227 | - for (int j = 0; j < list.size(); j++) { | |
| 10228 | - ScheduleRealInfo t2 = list.get(j); | |
| 10229 | - if (t1.getId() == t2.getId()) { | |
| 10230 | - t1 = t2; | |
| 10231 | - } | |
| 10232 | - } | |
| 10233 | - } | |
| 10234 | - | |
| 10235 | - for (int i = 0; i < newList.size(); i++) { | |
| 10236 | - ScheduleRealInfo t1 = newList.get(i); | |
| 10237 | - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks(); | |
| 10238 | - if (reamrks1.length() > 4) { | |
| 10239 | - t1.setRemarks(reamrks1.substring(0, 4)); | |
| 10240 | - t1.setRemark(reamrks1); | |
| 10241 | - } else { | |
| 10242 | - t1.setRemark(reamrks1); | |
| 10243 | - } | |
| 10244 | - } | |
| 10245 | - return newList; | |
| 10246 | - } | |
| 10247 | - | |
| 10248 | - @Override | |
| 10249 | - public List<ScheduleRealInfo> realScheduleList_zrw(String line, String date) { | |
| 10250 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 10251 | - String lpName = "lpName"; | |
| 10252 | - String zdsj = ""; | |
| 10253 | - String zdsjActual = ""; | |
| 10254 | - String zdsj1 = ""; | |
| 10255 | - String zdsjActual1 = ""; | |
| 10256 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleDdrb(line, date); | |
| 10257 | - | |
| 10258 | - /* | |
| 10259 | - * 对计划发车时间相同的班次进行排序 out最前 in最后 | |
| 10260 | - */ | |
| 10261 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 10262 | - SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | |
| 10263 | - | |
| 10264 | - String minfcsj = "02:00"; | |
| 10265 | - List<Line> lineList = lineRepository.findLineByCode(line); | |
| 10266 | - if (lineList.size() > 0) { | |
| 10267 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 10268 | - + " id = (" | |
| 10269 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 10270 | - + ")"; | |
| 10271 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 10272 | - } | |
| 10273 | - String[] minSjs = minfcsj.split(":"); | |
| 10274 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | |
| 10275 | - for (int i = 0; i < listInfo.size(); i++) { | |
| 10276 | - ScheduleRealInfo s = listInfo.get(i); | |
| 10277 | - if (s.getBcType().equals("out")) { | |
| 10278 | - s.setRemark("1"); | |
| 10279 | - } else if (s.getBcType().equals("in")) { | |
| 10280 | - s.setRemark("3"); | |
| 10281 | - } else { | |
| 10282 | - s.setRemark("2"); | |
| 10283 | - } | |
| 10284 | - String[] fcsj = s.getFcsj().split(":"); | |
| 10285 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 10286 | - | |
| 10287 | - Long fscjT = 0L; | |
| 10288 | - if (fcsjL < minSj) { | |
| 10289 | - Calendar calendar = new GregorianCalendar(); | |
| 10290 | - calendar.setTime(s.getScheduleDate()); | |
| 10291 | - calendar.add(calendar.DATE, 1); | |
| 10292 | - Date date_sch=calendar.getTime(); | |
| 10293 | - try { | |
| 10294 | - fscjT = sdf.parse(sdfnyr.format(date_sch) + " " + s.getFcsj()).getTime(); | |
| 10295 | - } catch (ParseException e) { | |
| 10296 | - // TODO Auto-generated catch block | |
| 10297 | - e.printStackTrace(); | |
| 10298 | - } | |
| 10299 | - | |
| 10300 | - } else { | |
| 10301 | - try { | |
| 10302 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 10303 | - } catch (ParseException e) { | |
| 10304 | - // TODO Auto-generated catch block | |
| 10305 | - e.printStackTrace(); | |
| 10306 | - } | |
| 10307 | - ; | |
| 10308 | - } | |
| 10309 | - s.setFcsjT(fscjT); | |
| 10310 | - } | |
| 10311 | - | |
| 10312 | -// Collections.sort(listInfo, new compareLpFcsjType()); | |
| 10313 | - List<ScheduleRealInfo> listInfo2=new ArrayList<ScheduleRealInfo>(); | |
| 10314 | - | |
| 10315 | - Collections.sort(listInfo, new compareLpFcsjType()); | |
| 10316 | - for (int i = 0; i < listInfo.size(); i++) { | |
| 10317 | - ScheduleRealInfo t = listInfo.get(i); | |
| 10318 | - if (!lpName.equals(t.getLpName())) { | |
| 10319 | - zdsjActual = t.getZdsjActual(); | |
| 10320 | - zdsj = t.getZdsj(); | |
| 10321 | - t.setZdsjActual(""); | |
| 10322 | - t.setZdsj(""); | |
| 10323 | - } else { | |
| 10324 | - zdsj1 = t.getZdsj(); | |
| 10325 | - zdsjActual1 = t.getZdsjActual(); | |
| 10326 | - t.setZdsjActual(zdsjActual); | |
| 10327 | - t.setZdsj(zdsj); | |
| 10328 | - zdsj = zdsj1; | |
| 10329 | - zdsjActual = zdsjActual1; | |
| 10330 | - } | |
| 10331 | - | |
| 10332 | - | |
| 10333 | - | |
| 10334 | - lpName = t.getLpName(); | |
| 10335 | - listInfo2.add(t); | |
| 10336 | - | |
| 10337 | - } | |
| 10338 | - | |
| 10339 | - Collections.sort(listInfo2,new compareDirLpFcsjType()); | |
| 10340 | - for (int i = 0; i < listInfo2.size(); i++) { | |
| 10341 | - ScheduleRealInfo t=listInfo2.get(i); | |
| 10342 | - list.add(t); | |
| 10343 | - Set<ChildTaskPlan> childTaskPlans = t.getcTasks(); | |
| 10344 | - //计算营运里程,空驶里程 | |
| 10345 | - if (!childTaskPlans.isEmpty()) { | |
| 10346 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | |
| 10347 | - Collections.sort(listit, new ComparableChild()); | |
| 10348 | - for (int j = 0; j < listit.size(); j++) { | |
| 10349 | - ScheduleRealInfo s = new ScheduleRealInfo(); | |
| 10350 | - ChildTaskPlan childTaskPlan = listit.get(j); | |
| 10351 | - if (childTaskPlan.getCcId() == null) { | |
| 10352 | - if (childTaskPlan.isDestroy()) { | |
| 10353 | - s.setFcsjActual(""); | |
| 10354 | - s.setZdsjActual(""); | |
| 10355 | - } else { | |
| 10356 | - s.setFcsjActual(childTaskPlan.getStartDate()); | |
| 10357 | - s.setZdsjActual(""); | |
| 10358 | - s.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | |
| 10359 | - } | |
| 10360 | - s.setFcsj(childTaskPlan.getStartDate()); | |
| 10361 | - s.setZdsj(""); | |
| 10362 | - s.setQdzName(childTaskPlan.getStartStationName()); | |
| 10363 | - s.setZdzName(childTaskPlan.getEndStationName()); | |
| 10364 | - s.setRemarks(childTaskPlan.getRemarks()); | |
| 10365 | - s.setAdjustExps("子"); | |
| 10366 | - s.setLpName(""); | |
| 10367 | - list.add(s); | |
| 10368 | - } | |
| 10369 | - } | |
| 10370 | - } | |
| 10371 | - } | |
| 10372 | - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | |
| 10373 | - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | |
| 10374 | - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | |
| 10375 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | |
| 10376 | - if (list.size() > 0) { | |
| 10377 | - int a = list.size() % 3; | |
| 10378 | - int b = list.size() / 3; | |
| 10379 | - int x = 0, y = 0; | |
| 10380 | - if (a == 2) { | |
| 10381 | - x = b + 1; | |
| 10382 | - y = x * 2; | |
| 10383 | - } else if (a == 1) { | |
| 10384 | - x = b + 1; | |
| 10385 | - y = x * 2 - 1; | |
| 10386 | - } else { | |
| 10387 | - x = b; | |
| 10388 | - y = 2 * x; | |
| 10389 | - | |
| 10390 | - } | |
| 10391 | - for (int i = 0; i < list.size(); i++) { | |
| 10392 | - ScheduleRealInfo s = list.get(i); | |
| 10393 | - if (i + 1 <= x) { | |
| 10394 | - xList.add(s); | |
| 10395 | - } else if ((i + 1) > x && (i + 1) <= y) { | |
| 10396 | - yList.add(s); | |
| 10397 | - } else { | |
| 10398 | - zList.add(s); | |
| 10399 | - } | |
| 10400 | - } | |
| 10401 | - for (int i = 0; i < x; i++) { | |
| 10402 | - newList.add(xList.get(i)); | |
| 10403 | - if (yList.size() > i) { | |
| 10404 | - newList.add(yList.get(i)); | |
| 10405 | - } else { | |
| 10406 | - newList.add(new ScheduleRealInfo()); | |
| 10407 | - } | |
| 10408 | - if (zList.size() > i) { | |
| 10409 | - newList.add(zList.get(i)); | |
| 10410 | - } else { | |
| 10411 | - newList.add(new ScheduleRealInfo()); | |
| 10412 | - } | |
| 10413 | - | |
| 10414 | - } | |
| 10415 | - } | |
| 10416 | - /* for (int i = 0; i < newList.size(); i++) { | |
| 10417 | - ScheduleRealInfo t1 = newList.get(i); | |
| 10418 | - for (int j = 0; j < list.size(); j++) { | |
| 10419 | - ScheduleRealInfo t2 = list.get(j); | |
| 10420 | - if (t1.getId() == t2.getId()) { | |
| 10421 | - t1 = t2; | |
| 10422 | - } | |
| 10423 | - } | |
| 10424 | - }*/ | |
| 10425 | - | |
| 10426 | - for (int i = 0; i < newList.size(); i++) { | |
| 10427 | - ScheduleRealInfo t1 = newList.get(i); | |
| 10428 | - String reamrks1 = t1.getRemarks() == null ? "" : t1.getRemarks(); | |
| 10429 | - if (reamrks1.length() > 4) { | |
| 10430 | - t1.setRemarks(reamrks1.substring(0, 4)); | |
| 10431 | - t1.setRemark(reamrks1); | |
| 10432 | - } else { | |
| 10433 | - t1.setRemark(reamrks1); | |
| 10434 | - } | |
| 10435 | - } | |
| 10436 | - return newList; | |
| 10437 | - } | |
| 10438 | - | |
| 10439 | - @Override | |
| 10440 | - public List<ScheduleRealInfo> realScheduleList_mh_2(String line, String date) { | |
| 10441 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 10442 | - String lpName = "lpName"; | |
| 10443 | - String zdsj = ""; | |
| 10444 | - String zdsjActual = ""; | |
| 10445 | - String zdsj1 = ""; | |
| 10446 | - String zdsjActual1 = ""; | |
| 10447 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | |
| 10448 | - | |
| 10449 | - for (ScheduleRealInfo s : listInfo) { | |
| 10450 | - if (s.isDestroy() && s.isReissue()) { | |
| 10451 | - s.setRemark(""); | |
| 10452 | - s.setFcsjActual(s.getDfsj()); | |
| 10453 | - s.setZdsjActual(s.getZdsj()); | |
| 10454 | - s.setStatus(2); | |
| 10455 | - s.setJhlc(s.getJhlcOrig()); | |
| 10456 | - } | |
| 10457 | - } | |
| 10458 | - | |
| 10459 | - for (int i = 0; i < listInfo.size(); i++) { | |
| 10460 | - ScheduleRealInfo t = listInfo.get(i); | |
| 10461 | - if (!lpName.equals(t.getLpName())) { | |
| 10462 | - zdsjActual = t.getZdsjActual(); | |
| 10463 | - zdsj = t.getZdsj(); | |
| 10464 | - t.setZdsjActual(""); | |
| 10465 | - t.setZdsj(""); | |
| 10466 | - } else { | |
| 10467 | - zdsj1 = t.getZdsj(); | |
| 10468 | - zdsjActual1 = t.getZdsjActual(); | |
| 10469 | - t.setZdsjActual(zdsjActual); | |
| 10470 | - t.setZdsj(zdsj); | |
| 10471 | - zdsj = zdsj1; | |
| 10472 | - zdsjActual = zdsjActual1; | |
| 10473 | - } | |
| 10474 | - lpName = t.getLpName(); | |
| 10475 | - list.add(t); | |
| 10476 | - } | |
| 10477 | - | |
| 10478 | - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp2(line, date); | |
| 10479 | - List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); | |
| 10480 | - List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); | |
| 10481 | - List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); | |
| 10482 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | |
| 10483 | - if (listInfo2.size() > 0) { | |
| 10484 | - int a = listInfo2.size() % 3; | |
| 10485 | - int b = listInfo2.size() / 3; | |
| 10486 | - int x = 0, y = 0; | |
| 10487 | - if (a == 2) { | |
| 10488 | - x = b + 1; | |
| 10489 | - y = x * 2; | |
| 10490 | - } else if (b == 1) { | |
| 10491 | - x = b + 1; | |
| 10492 | - y = x * 2 - 1; | |
| 10493 | - } else { | |
| 10494 | - x = b; | |
| 10495 | - y = 2 * x; | |
| 10496 | - | |
| 10497 | - } | |
| 10498 | - for (int i = 0; i < listInfo2.size(); i++) { | |
| 10499 | - ScheduleRealInfo s = listInfo2.get(i); | |
| 10500 | - if (i + 1 <= x) { | |
| 10501 | - xList.add(s); | |
| 10502 | - } else if ((i + 1) > x && (i + 1) <= y) { | |
| 10503 | - yList.add(s); | |
| 10504 | - } else { | |
| 10505 | - zList.add(s); | |
| 10506 | - } | |
| 10507 | - } | |
| 10508 | - for (int i = 0; i < x; i++) { | |
| 10509 | - newList.add(xList.get(i)); | |
| 10510 | - if (yList.size() > i) { | |
| 10511 | - newList.add(yList.get(i)); | |
| 10512 | - } else { | |
| 10513 | - newList.add(new ScheduleRealInfo()); | |
| 10514 | - } | |
| 10515 | - if (zList.size() > i) { | |
| 10516 | - newList.add(zList.get(i)); | |
| 10517 | - } else { | |
| 10518 | - newList.add(new ScheduleRealInfo()); | |
| 10519 | - } | |
| 10520 | - | |
| 10521 | - } | |
| 10522 | - } | |
| 10523 | - for (int i = 0; i < newList.size(); i++) { | |
| 10524 | - ScheduleRealInfo t1 = newList.get(i); | |
| 10525 | - for (int j = 0; j < list.size(); j++) { | |
| 10526 | - ScheduleRealInfo t2 = list.get(j); | |
| 10527 | - if (t1.getId() == t2.getId()) { | |
| 10528 | - t1 = t2; | |
| 10529 | - } | |
| 10530 | - } | |
| 10531 | - } | |
| 10532 | - return newList; | |
| 10533 | - } | |
| 10534 | - | |
| 10535 | - @Override | |
| 10536 | - public List<ScheduleRealInfo> realScheduleListQp(String line, String date) { | |
| 10537 | - List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); | |
| 10538 | - String lpName = "lpName"; | |
| 10539 | - String zdsj = ""; | |
| 10540 | - String zdsjActual = ""; | |
| 10541 | - String zdsj1 = ""; | |
| 10542 | - String zdsjActual1 = ""; | |
| 10543 | - List<ScheduleRealInfo> listInfo = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | |
| 10544 | - for (int i = 0; i < listInfo.size(); i++) { | |
| 10545 | - ScheduleRealInfo t = listInfo.get(i); | |
| 10546 | - if (!lpName.equals(t.getLpName())) { | |
| 10547 | - zdsjActual = t.getZdsjActual(); | |
| 10548 | - zdsj = t.getZdsj(); | |
| 10549 | - t.setZdsjActual(""); | |
| 10550 | - t.setZdsj(""); | |
| 10551 | - } else { | |
| 10552 | - zdsj1 = t.getZdsj(); | |
| 10553 | - zdsjActual1 = t.getZdsjActual(); | |
| 10554 | - t.setZdsjActual(zdsjActual); | |
| 10555 | - t.setZdsj(zdsj); | |
| 10556 | - zdsj = zdsj1; | |
| 10557 | - zdsjActual = zdsjActual1; | |
| 10558 | - } | |
| 10559 | - | |
| 10560 | - lpName = t.getLpName(); | |
| 10561 | - list.add(t); | |
| 10562 | - } | |
| 10563 | - return list; | |
| 10564 | - } | |
| 10565 | - | |
| 10566 | - public List<Map<String, Object>> yesterdayDataList(String line, String date, String gsbm, String fgsbm, String jGh, String nbbm) { | |
| 10567 | - List<Map<String, Object>> yesterdayDataList = new ArrayList<Map<String, Object>>(); | |
| 10568 | - if (line.equals("")) { | |
| 10569 | - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date, gsbm, fgsbm, nbbm); | |
| 10570 | - } else { | |
| 10571 | - yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList_eq(line, date, gsbm, fgsbm, nbbm); | |
| 10572 | - } | |
| 10573 | - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date, gsbm, fgsbm); | |
| 10574 | - for (int x = 0; x < yesterdayDataList.size(); x++) { | |
| 10575 | - String jsy = yesterdayDataList.get(x).get("jGh").toString(); | |
| 10576 | - String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); | |
| 10577 | - String xlbm = yesterdayDataList.get(x).get("xlBm").toString(); | |
| 10578 | - String lp = yesterdayDataList.get(x).get("lpName").toString(); | |
| 10579 | - String realExecDate=yesterdayDataList.get(x).get("realExecDate").toString(); | |
| 10580 | - String fcsj[] =realExecDate.split(" "); | |
| 10581 | - //取出最小计划发车时间 | |
| 10582 | - yesterdayDataList.get(x).put("fcsj", fcsj[1]); | |
| 10583 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 10584 | - boolean fage = true; | |
| 10585 | - String company = ""; | |
| 10586 | - String bCompany = ""; | |
| 10587 | - String lineName=""; | |
| 10588 | - String jName=""; | |
| 10589 | - List<ScheduleRealInfo> listS = new ArrayList<ScheduleRealInfo>(); | |
| 10590 | - for (ScheduleRealInfo scheduleRealInfo : lists) { | |
| 10591 | - if (scheduleRealInfo.getjGh().equals(jsy) | |
| 10592 | - && scheduleRealInfo.getClZbh().equals(clZbh) | |
| 10593 | - && scheduleRealInfo.getXlBm().equals(xlbm) | |
| 10594 | - && scheduleRealInfo.getLpName().equals(lp)) { | |
| 10595 | - if (fage) { | |
| 10596 | - //根据线路代码获取公司 | |
| 10597 | - company = scheduleRealInfo.getGsBm(); | |
| 10598 | - bCompany = scheduleRealInfo.getFgsBm(); | |
| 10599 | - lineName = scheduleRealInfo.getXlName(); | |
| 10600 | - jName= scheduleRealInfo.getjName(); | |
| 10601 | - fage = false; | |
| 10602 | - } | |
| 10603 | - Set<ChildTaskPlan> cts = scheduleRealInfo.getcTasks(); | |
| 10604 | - if (cts != null && cts.size() > 0) { | |
| 10605 | - listS.add(scheduleRealInfo); | |
| 10606 | - } else { | |
| 10607 | - if (scheduleRealInfo.getZdsjActual() != null && scheduleRealInfo.getFcsjActual() != null) { | |
| 10608 | - listS.add(scheduleRealInfo); | |
| 10609 | - } | |
| 10610 | - } | |
| 10611 | - } | |
| 10612 | - } | |
| 10613 | - yesterdayDataList.get(x).put("company", company); | |
| 10614 | - yesterdayDataList.get(x).put("bCompany", bCompany); | |
| 10615 | - yesterdayDataList.get(x).put("lineName", lineName); | |
| 10616 | - yesterdayDataList.get(x).put("jName", jName); | |
| 10617 | - Double ljgl = culateMieageService.culateLjgl(listS); | |
| 10618 | - Double sjgl = culateMieageService.culateSjgl(listS); | |
| 10619 | - Double ksgl = culateMieageService.culateKsgl(listS); | |
| 10620 | - Double jccgl = culateMieageService.culateJccgl(listS); | |
| 10621 | - Double zyygl = Arith.add(sjgl, ljgl); | |
| 10622 | - Double zksgl = Arith.add(ksgl, jccgl); | |
| 10623 | - Double zlc = Arith.add(zyygl, zksgl); | |
| 10624 | - yesterdayDataList.get(x).put("totalKilometers", zlc); | |
| 10625 | - | |
| 10626 | - } | |
| 10627 | - //增加顺序号 | |
| 10628 | - for (int i = 0; i < yesterdayDataList.size(); i++) { | |
| 10629 | - if (i == 0) { | |
| 10630 | - yesterdayDataList.get(i).put("seqNumber", 1); | |
| 10631 | - } else { | |
| 10632 | - if (yesterdayDataList.get(i - 1).get("clZbh").equals(yesterdayDataList.get(i).get("clZbh"))) { | |
| 10633 | - yesterdayDataList.get(i).put("seqNumber", 1 + (int) yesterdayDataList.get(i - 1).get("seqNumber")); | |
| 10634 | - } else { | |
| 10635 | - yesterdayDataList.get(i).put("seqNumber", 1); | |
| 10636 | - } | |
| 10637 | - } | |
| 10638 | - } | |
| 10639 | - | |
| 10640 | - return yesterdayDataList; | |
| 10641 | - } | |
| 10642 | - | |
| 10643 | - /** | |
| 10644 | - * 批量调整人车 | |
| 10645 | - */ | |
| 10646 | - @Override | |
| 10647 | - public Map<String, Object> multi_tzrc(List<ChangePersonCar> cpcs, String userId) { | |
| 10648 | - Map<String, Object> rs = new HashMap<>(); | |
| 10649 | - Set<ScheduleRealInfo> set = new HashSet<>(); | |
| 10650 | - | |
| 10651 | - ScheduleRealInfo sch; | |
| 10652 | - | |
| 10653 | - String jGh = null, jName, sGh, sName; | |
| 10654 | - for (ChangePersonCar cpc : cpcs) { | |
| 10655 | - | |
| 10656 | - sch = dayOfSchedule.get(cpc.getSchId()); | |
| 10657 | - if (sch == null) | |
| 10658 | - continue; | |
| 10659 | - | |
| 10660 | - if (cpc.getClZbh() != null) { | |
| 10661 | - if (!carExist(sch.getGsBm(), cpc.getClZbh())) { | |
| 10662 | - rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | |
| 10663 | - rs.put("status", ResponseCode.ERROR); | |
| 10664 | - return rs; | |
| 10665 | - } else if (!sch.getGsBm().equals(BasicData.nbbm2CompanyCodeMap.get(cpc.getClZbh()))) { | |
| 10666 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到自编号为【" + cpc.getClZbh() + "】的车辆"); | |
| 10667 | - rs.put("status", ResponseCode.ERROR); | |
| 10668 | - return rs; | |
| 10669 | - } | |
| 10670 | - } | |
| 10671 | - | |
| 10672 | - if (StringUtils.isNotEmpty(cpc.getJsy())) { | |
| 10673 | - try{ | |
| 10674 | - jGh = cpc.getJsy().split("/")[0]; | |
| 10675 | - }catch (Exception e){ | |
| 10676 | - logger.error("", e); | |
| 10677 | - rs.put("msg", "驾驶员参数异常!!"); | |
| 10678 | - rs.put("status", ResponseCode.ERROR); | |
| 10679 | - return rs; | |
| 10680 | - } | |
| 10681 | - | |
| 10682 | - jName = getPersonName(sch.getGsBm(), jGh); | |
| 10683 | - if (StringUtils.isEmpty(jName)) { | |
| 10684 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | |
| 10685 | - rs.put("status", ResponseCode.ERROR); | |
| 10686 | - return rs; | |
| 10687 | - } | |
| 10688 | - } | |
| 10689 | - | |
| 10690 | - | |
| 10691 | - //为换人换车情况表写入数据 | |
| 10692 | - schModifyLog.saveChangetochange(sch, cpc, userId); | |
| 10693 | - //日志记录 | |
| 10694 | - ScheduleModifyLogger.tzrc(sch, cpc, userId); | |
| 10695 | - | |
| 10696 | - //换驾驶员 | |
| 10697 | - if (StringUtils.isNotEmpty(cpc.getJsy())) { | |
| 10698 | - //换驾驶员 | |
| 10699 | - if (persoChange(sch, jGh)) | |
| 10700 | - set.add(sch); | |
| 10701 | - } | |
| 10702 | - | |
| 10703 | - //换售票员 | |
| 10704 | - if (StringUtils.isNotEmpty(cpc.getSpy()) | |
| 10705 | - && !"/".equals(StringUtils.trim(cpc.getSpy()))) { | |
| 10706 | - | |
| 10707 | - sGh = cpc.getSpy().split("/")[0]; | |
| 10708 | - sName = getPersonName(sch.getGsBm(), sGh); | |
| 10709 | - if (StringUtils.isEmpty(sName)) { | |
| 10710 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | |
| 10711 | - rs.put("status", ResponseCode.ERROR); | |
| 10712 | - return rs; | |
| 10713 | - } | |
| 10714 | - | |
| 10715 | - /*if(!sGh.equals(sch.getsGh())) | |
| 10716 | - sb.append(sch.getsGh() + " 换 " + sGh + ";");*/ | |
| 10717 | - if (persoChangeSPY(sch, sGh)) | |
| 10718 | - set.add(sch); | |
| 10719 | - } else if (StringUtils.isNotEmpty(sch.getsGh())) { | |
| 10720 | - sch.setsGh(""); | |
| 10721 | - sch.setsName(""); | |
| 10722 | - } | |
| 10723 | - | |
| 10724 | - //换车 | |
| 10725 | - if (StringUtils.isNotEmpty(cpc.getClZbh()) && !cpc.getClZbh().equals(sch.getClZbh())) { | |
| 10726 | - //sb.append(sch.getClZbh() + " 换 " + cpc.getClZbh() + ";"); | |
| 10727 | - set.add(sch); | |
| 10728 | - set.addAll(dayOfSchedule.changeCar(sch, cpc.getClZbh())); | |
| 10729 | - } | |
| 10730 | - | |
| 10731 | - /*if(sb.length() > 0) | |
| 10732 | - sch.setRemarks(sb.toString());*/ | |
| 10733 | - | |
| 10734 | - dayOfSchedule.save(sch); | |
| 10735 | - set.add(sch); | |
| 10736 | - | |
| 10737 | - } | |
| 10738 | - rs.put("ts", set); | |
| 10739 | - rs.put("status", ResponseCode.SUCCESS); | |
| 10740 | - return rs; | |
| 10741 | - } | |
| 10742 | - | |
| 10743 | - /** | |
| 10744 | - * @Title: persoChange | |
| 10745 | - * @Description: TODO(班次换驾驶员) | |
| 10746 | - */ | |
| 10747 | - public boolean persoChange(ScheduleRealInfo sch, String jGh) { | |
| 10748 | - if (sch.getjGh().equals(jGh)) | |
| 10749 | - return false; | |
| 10750 | - String jName = getPersonName(sch.getGsBm(), jGh); | |
| 10751 | - if (StringUtils.isNotEmpty(jName)) { | |
| 10752 | - | |
| 10753 | - if (jGh.indexOf("-") != -1) | |
| 10754 | - sch.setjGh(jGh.substring(jGh.indexOf("-") + 1)); | |
| 10755 | - else | |
| 10756 | - sch.setjGh(jGh); | |
| 10757 | - | |
| 10758 | - sch.setjName(jName); | |
| 10759 | - return true; | |
| 10760 | - } | |
| 10761 | - return false; | |
| 10762 | - } | |
| 10763 | - | |
| 10764 | - /** | |
| 10765 | - * @Title: persoChange | |
| 10766 | - * @Description: TODO(班次换售票员) | |
| 10767 | - */ | |
| 10768 | - public boolean persoChangeSPY(ScheduleRealInfo sch, String sGh) { | |
| 10769 | - if (sch.getsGh().equals(sGh)) | |
| 10770 | - return false; | |
| 10771 | - String sName = getPersonName(sch.getGsBm(), sGh); | |
| 10772 | - if (StringUtils.isNotEmpty(sName)) { | |
| 10773 | - if (sGh.indexOf("-") != -1) | |
| 10774 | - sch.setsGh(sGh.substring(sGh.indexOf("-") + 1)); | |
| 10775 | - else | |
| 10776 | - sch.setsGh(sGh); | |
| 10777 | - sch.setsName(sName); | |
| 10778 | - return true; | |
| 10779 | - } | |
| 10780 | - return false; | |
| 10781 | - } | |
| 10782 | - | |
| 10783 | - /** | |
| 10784 | - * 批量待发调整 | |
| 10785 | - */ | |
| 10786 | - @Override | |
| 10787 | - public Map<String, Object> multi_dftz(List<DfsjChange> dfsjcs) { | |
| 10788 | - Map<String, Object> rs = new HashMap<>(), tempMap = new HashMap<>(); | |
| 10789 | - List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 10790 | - | |
| 10791 | - for (DfsjChange dc : dfsjcs) { | |
| 10792 | - if (StringUtils.isEmpty(dc.getOld_dfsj()) || StringUtils.isEmpty(dc.getNew_dfsj())) | |
| 10793 | - continue; | |
| 10794 | - | |
| 10795 | - tempMap = outgoAdjust(dc.getSchId(), "", dc.getNew_dfsj(), null, "2", null); | |
| 10796 | - | |
| 10797 | - if (tempMap.get("status").equals(ResponseCode.SUCCESS)) { | |
| 10798 | - list.addAll((Collection<? extends ScheduleRealInfo>) tempMap.get("ts")); | |
| 10799 | - } | |
| 10800 | - } | |
| 10801 | - | |
| 10802 | - rs.put("status", ResponseCode.SUCCESS); | |
| 10803 | - rs.put("ts", list); | |
| 10804 | - return rs; | |
| 10805 | - } | |
| 10806 | - | |
| 10807 | - | |
| 10808 | - @Override | |
| 10809 | - public Map<String, Object> findKMBC1(String jName, String clZbh, | |
| 10810 | - String date, String enddate) { | |
| 10811 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill4(jName, clZbh, date, enddate); | |
| 10812 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 10813 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | |
| 10814 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | |
| 10815 | - int jhbc = 0, cjbc = 0, ljbc = 0; | |
| 10816 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0; | |
| 10817 | - float addMileage = 0l, remMileage = 0l; | |
| 10818 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 10819 | - for (ScheduleRealInfo scheduleRealInfo : list) { | |
| 10820 | - if (scheduleRealInfo != null) { | |
| 10821 | - //计划里程(主任务过滤掉临加班次), | |
| 10822 | - //烂班里程(主任务烂班), | |
| 10823 | - //临加里程(主任务临加), | |
| 10824 | - //计划班次,烂班班次,增加班次 | |
| 10825 | - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | |
| 10826 | - if (scheduleRealInfo.isSflj()) { | |
| 10827 | - addMileage += tempJhlc; | |
| 10828 | - ljbc++; | |
| 10829 | - } else { | |
| 10830 | - jhlc += tempJhlc; | |
| 10831 | - jhbc++; | |
| 10832 | - if (scheduleRealInfo.getStatus() == -1) { | |
| 10833 | - remMileage += tempJhlc; | |
| 10834 | - cjbc++; | |
| 10835 | - } | |
| 10836 | - } | |
| 10837 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 10838 | - //计算营运里程,空驶里程 | |
| 10839 | - if (childTaskPlans.isEmpty()) { | |
| 10840 | - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 10841 | - || scheduleRealInfo.getBcType().equals("venting")) { | |
| 10842 | - ksgl += tempJhlc; | |
| 10843 | - } else { | |
| 10844 | - yygl += tempJhlc; | |
| 10845 | - } | |
| 10846 | - } else { | |
| 10847 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 10848 | - while (it.hasNext()) { | |
| 10849 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 10850 | - if (childTaskPlan.getMileageType().equals("empty")) { | |
| 10851 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 10852 | - } else { | |
| 10853 | - yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 10854 | - } | |
| 10855 | - } | |
| 10856 | - } | |
| 10857 | - } | |
| 10858 | - } | |
| 10859 | - map.put("jhlc", format.format(jhlc)); | |
| 10860 | - map.put("remMileage", format.format(remMileage)); | |
| 10861 | - map.put("addMileage", format.format(addMileage)); | |
| 10862 | - map.put("yygl", format.format(yygl)); | |
| 10863 | - map.put("ksgl", format.format(ksgl)); | |
| 10864 | - map.put("realMileage", format.format(yygl + ksgl)); | |
| 10865 | - map.put("jhbc", jhbc); | |
| 10866 | - map.put("cjbc", cjbc); | |
| 10867 | - map.put("ljbc", ljbc); | |
| 10868 | - map.put("sjbc", jhbc - cjbc + ljbc); | |
| 10869 | - return map; | |
| 10870 | - } | |
| 10871 | - | |
| 10872 | - /** | |
| 10873 | - * 调整班次类型 | |
| 10874 | - * | |
| 10875 | - * @param id | |
| 10876 | - * @param bcType | |
| 10877 | - * @param remarks | |
| 10878 | - * @return | |
| 10879 | - */ | |
| 10880 | - @Override | |
| 10881 | - public Map<String, Object> changeBcType(Long id, String bcType, String remarks, String majorStationName) { | |
| 10882 | - Map<String, Object> rs = new HashMap<>(); | |
| 10883 | - | |
| 10884 | - try { | |
| 10885 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 10886 | - if (sch != null) { | |
| 10887 | - sch.setBcType(bcType); | |
| 10888 | - sch.setRemarks(remarks); | |
| 10889 | - rs.put("status", ResponseCode.SUCCESS); | |
| 10890 | - rs.put("t", sch); | |
| 10891 | - | |
| 10892 | - if ("major".equals(bcType)) { | |
| 10893 | - sch.setMajorStationName(majorStationName); | |
| 10894 | - } | |
| 10895 | - | |
| 10896 | - dayOfSchedule.save(sch); | |
| 10897 | - } | |
| 10898 | - } catch (Exception e) { | |
| 10899 | - logger.error("", e); | |
| 10900 | - rs.put("status", ResponseCode.ERROR); | |
| 10901 | - } | |
| 10902 | - | |
| 10903 | - return rs; | |
| 10904 | - } | |
| 10905 | - | |
| 10906 | - @Override | |
| 10907 | - public Map<String, Object> historySave(ScheduleRealInfo sch) { | |
| 10908 | - Map<String, Object> rs = new HashMap<>(); | |
| 10909 | - rs.put("status", ResponseCode.ERROR); | |
| 10910 | - | |
| 10911 | - ScheduleRealInfo oldSch = super.findById(sch.getId()); | |
| 10912 | - //事后日志记录 | |
| 10913 | - AfterwardsLogger aflog = AfterwardsLogger.start(oldSch, "事后调整"); | |
| 10914 | - | |
| 10915 | - //换车 | |
| 10916 | - if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) { | |
| 10917 | - if (!carExist(oldSch.getGsBm(), sch.getClZbh())) { | |
| 10918 | - rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!"); | |
| 10919 | - return rs; | |
| 10920 | - } else { | |
| 10921 | - aflog.log("换车", oldSch.getClZbh(), sch.getClZbh()); | |
| 10922 | - oldSch.setClZbh(sch.getClZbh()); | |
| 10923 | - } | |
| 10924 | - } | |
| 10925 | - | |
| 10926 | - //换驾驶员 | |
| 10927 | - if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) { | |
| 10928 | - String jName = getPersonName(oldSch.getGsBm(), sch.getjGh()); | |
| 10929 | - if (StringUtils.isEmpty(jName)) { | |
| 10930 | - rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | |
| 10931 | - return rs; | |
| 10932 | - } | |
| 10933 | - aflog.log("换驾驶员", oldSch.getjGh() + "/" + oldSch.getjName(), sch.getjGh() + "/" + sch.getjName()); | |
| 10934 | - persoChange(oldSch, sch.getjGh()); | |
| 10935 | - } | |
| 10936 | - | |
| 10937 | - //换售票员 | |
| 10938 | - if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) { | |
| 10939 | - String sName = getPersonName(oldSch.getGsBm(), sch.getsGh()); | |
| 10940 | - if (StringUtils.isEmpty(sName)) { | |
| 10941 | - rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员"); | |
| 10942 | - return rs; | |
| 10943 | - } | |
| 10944 | - aflog.log("换售票员", oldSch.getsGh() + "/" + oldSch.getsName(), sch.getsGh() + "/" + sch.getsName()); | |
| 10945 | - persoChangeSPY(oldSch, sch.getsGh()); | |
| 10946 | - } | |
| 10947 | - | |
| 10948 | - //烂班 | |
| 10949 | - boolean dest1 = oldSch.getStatus() == -1; | |
| 10950 | - boolean dest2 = sch.getStatus() == -1; | |
| 10951 | - if (!dest1 && dest2) { | |
| 10952 | - oldSch.destroy(); | |
| 10953 | - aflog.log("烂班"); | |
| 10954 | - } else if (dest1 && !dest2) { | |
| 10955 | - //撤销烂班 | |
| 10956 | - oldSch.setJhlc(oldSch.getJhlcOrig()); | |
| 10957 | - oldSch.setStatus(0); | |
| 10958 | - oldSch.calcStatus(); | |
| 10959 | - oldSch.setAdjustExps(null); | |
| 10960 | - aflog.log("撤销烂班"); | |
| 10961 | - } | |
| 10962 | - | |
| 10963 | - oldSch.setAdjustExps(sch.getAdjustExps()); | |
| 10964 | - | |
| 10965 | - /** | |
| 10966 | - * 修改班次里程 | |
| 10967 | - */ | |
| 10968 | - if (!oldSch.getJhlc().equals(sch.getJhlc())) { | |
| 10969 | - double jhlcNum = sch.getJhlc(); | |
| 10970 | - aflog.log("修改班次里程", oldSch.getJhlc(), jhlcNum); | |
| 10971 | - //烂班 | |
| 10972 | - if (jhlcNum == 0 && oldSch.getJhlcOrig() != 0) | |
| 10973 | - oldSch.destroy(); | |
| 10974 | - else { | |
| 10975 | - oldSch.setJhlc(jhlcNum); | |
| 10976 | - //临加班次,实际计划一起改 | |
| 10977 | - if (oldSch.isSflj()) | |
| 10978 | - oldSch.setJhlcOrig(jhlcNum); | |
| 10979 | - } | |
| 10980 | - } | |
| 10981 | - | |
| 10982 | - //待发时间 | |
| 10983 | - if (!CustomStringUtils.equals(oldSch.getDfsj(), sch.getDfsj())) { | |
| 10984 | - aflog.log("修改待发时间", oldSch.getDfsj(), sch.getDfsj()); | |
| 10985 | - oldSch.setDfsj(sch.getDfsj()); | |
| 10986 | - } | |
| 10987 | - //实发时间 | |
| 10988 | - if (!CustomStringUtils.equals(oldSch.getFcsjActual(), sch.getFcsjActual())) { | |
| 10989 | - aflog.log("修改实发时间", oldSch.getFcsjActual(), sch.getFcsjActual()); | |
| 10990 | - oldSch.setFcsjActual(sch.getFcsjActual()); | |
| 10991 | - } | |
| 10992 | - //实际终点 | |
| 10993 | - if (!CustomStringUtils.equals(oldSch.getZdsjActual(), sch.getZdsjActual())) { | |
| 10994 | - aflog.log("修改实达时间", oldSch.getZdsjActual(), sch.getZdsjActual()); | |
| 10995 | - oldSch.setZdsjActual(sch.getZdsjActual()); | |
| 10996 | - } | |
| 10997 | - | |
| 10998 | - //备注 | |
| 10999 | - if (!CustomStringUtils.equals(oldSch.getRemarks(), sch.getRemarks())) { | |
| 11000 | - aflog.log("修改备注", oldSch.getRemarks(), sch.getRemarks()); | |
| 11001 | - oldSch.setRemarks(sch.getRemarks()); | |
| 11002 | - } | |
| 11003 | - | |
| 11004 | - scheduleRealInfoRepository.save(oldSch); | |
| 11005 | - | |
| 11006 | - aflog.end(); | |
| 11007 | - rs.put("status", ResponseCode.SUCCESS); | |
| 11008 | - return rs; | |
| 11009 | - } | |
| 11010 | - | |
| 11011 | - @Autowired | |
| 11012 | - SvgAttributeRepository svgAttributeRepository; | |
| 11013 | - | |
| 11014 | - @Override | |
| 11015 | - public Map<String, Object> svgAttr(String jsonStr) { | |
| 11016 | - Map<String, Object> rs = new HashMap<>(); | |
| 11017 | - | |
| 11018 | - try { | |
| 11019 | - JSONObject jObj = JSONObject.parseObject(StringEscapeUtils.unescapeHtml4(jsonStr)); | |
| 11020 | - | |
| 11021 | - SvgAttribute svgAttribute = new SvgAttribute(); | |
| 11022 | - svgAttribute.setLineCode(jObj.getString("lineCode")); | |
| 11023 | - svgAttribute.setHideStations(jObj.getString("hideStations")); | |
| 11024 | - svgAttribute.setNicknames(jObj.getString("nicknames")); | |
| 11025 | - svgAttributeRepository.save(svgAttribute); | |
| 11026 | - | |
| 11027 | - rs.put("t", svgAttribute); | |
| 11028 | - rs.put("status", ResponseCode.SUCCESS); | |
| 11029 | - } catch (Exception e) { | |
| 11030 | - logger.error("", e); | |
| 11031 | - rs.put("status", ResponseCode.ERROR); | |
| 11032 | - } | |
| 11033 | - return rs; | |
| 11034 | - } | |
| 11035 | - | |
| 11036 | - @Override | |
| 11037 | - public Map<String, Object> findSvgAttr(String idx) { | |
| 11038 | - Map<String, Object> rs = new HashMap<>(); | |
| 11039 | - try { | |
| 11040 | - List<String> lineCodes = Splitter.on(",").splitToList(idx); | |
| 11041 | - List<SvgAttribute> list = svgAttributeRepository.findSvgAttr(lineCodes); | |
| 11042 | - | |
| 11043 | - rs.put("status", ResponseCode.SUCCESS); | |
| 11044 | - rs.put("list", list); | |
| 11045 | - } catch (Exception e) { | |
| 11046 | - logger.error("", e); | |
| 11047 | - rs.put("status", ResponseCode.ERROR); | |
| 11048 | - } | |
| 11049 | - return rs; | |
| 11050 | - } | |
| 11051 | - | |
| 11052 | - @Override | |
| 11053 | - public Map<String, Object> addRemarks(Long id, String remarks) { | |
| 11054 | - Map<String, Object> rs = new HashMap<>(); | |
| 11055 | - try { | |
| 11056 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 11057 | - sch.addRemarks(remarks); | |
| 11058 | - | |
| 11059 | - rs.put("status", ResponseCode.SUCCESS); | |
| 11060 | - rs.put("t", sch); | |
| 11061 | - } catch (Exception e) { | |
| 11062 | - logger.error("", e); | |
| 11063 | - rs.put("status", ResponseCode.ERROR); | |
| 11064 | - } | |
| 11065 | - return rs; | |
| 11066 | - } | |
| 11067 | - | |
| 11068 | - @Override | |
| 11069 | - public List<Map<String, Object>> yesterdayDataList(String line) { | |
| 11070 | - // TODO Auto-generated method stub | |
| 11071 | - return null; | |
| 11072 | - } | |
| 11073 | - | |
| 11074 | - @Override | |
| 11075 | - public List<ScheduleRealInfo> exportWaybillQp(String clZbh, String date, String line) { | |
| 11076 | - // TODO Auto-generated method stub | |
| 11077 | - ReportUtils ee = new ReportUtils(); | |
| 11078 | - ReportRelatedUtils rru = new ReportRelatedUtils(); | |
| 11079 | - List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | |
| 11080 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | |
| 11081 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
| 11082 | - | |
| 11083 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 11084 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | |
| 11085 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | |
| 11086 | - int jhbc = 0, cjbc = 0, ljbc = 0; | |
| 11087 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; | |
| 11088 | - float addMileage = 0l, remMileage = 0l, addgl = 0, remgl = 0; | |
| 11089 | - int xyz = 1; | |
| 11090 | - Map<String, Object> map; | |
| 11091 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 11092 | - if (scheduleRealInfo != null) { | |
| 11093 | - //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次 | |
| 11094 | - //计划里程(主任务过滤掉临加班次), | |
| 11095 | - //烂班里程(主任务烂班), | |
| 11096 | - //临加里程(主任务临加), | |
| 11097 | - //计划班次,烂班班次,增加班次 | |
| 11098 | - double jh = 0, sj = 0; | |
| 11099 | - tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); | |
| 11100 | - if (scheduleRealInfo.isSflj()) { | |
| 11101 | - ljbc++; | |
| 11102 | - } else { | |
| 11103 | - if (!(scheduleRealInfo.getBcType().equals("in") | |
| 11104 | - || scheduleRealInfo.getBcType().equals("out"))) { | |
| 11105 | - jhbc++; | |
| 11106 | - jh += tempJhlc; | |
| 11107 | - } | |
| 11108 | - if (scheduleRealInfo.getStatus() == -1) { | |
| 11109 | - remMileage += tempJhlc; | |
| 11110 | - cjbc++; | |
| 11111 | - } | |
| 11112 | - } | |
| 11113 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 11114 | - //计算营运里程,空驶里程 | |
| 11115 | - if (childTaskPlans.isEmpty()) { | |
| 11116 | - if (scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 11117 | - ) { | |
| 11118 | - jcclc += tempJhlc; | |
| 11119 | - } else { | |
| 11120 | - if (scheduleRealInfo.getStatus() != -1) { | |
| 11121 | - if (scheduleRealInfo.isSflj()) { | |
| 11122 | - addMileage += tempJhlc; | |
| 11123 | - } | |
| 11124 | - sj += tempJhlc; | |
| 11125 | - } | |
| 11126 | - } | |
| 11127 | - } else { | |
| 11128 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 11129 | - while (it.hasNext()) { | |
| 11130 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 11131 | - if (childTaskPlan.getMileageType().equals("empty")) { | |
| 11132 | - if (childTaskPlan.isDestroy()) { | |
| 11133 | - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 11134 | - } else { | |
| 11135 | - if (scheduleRealInfo.isSflj()) { | |
| 11136 | - addMileage += tempJhlc; | |
| 11137 | - } | |
| 11138 | - ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 11139 | - } | |
| 11140 | - } else { | |
| 11141 | - if (childTaskPlan.isDestroy()) { | |
| 11142 | - remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 11143 | -// cjbc++; | |
| 11144 | - } else { | |
| 11145 | - if (scheduleRealInfo.isSflj()) { | |
| 11146 | - addMileage += tempJhlc; | |
| 11147 | - } | |
| 11148 | - sj += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); | |
| 11149 | - } | |
| 11150 | - } | |
| 11151 | - } | |
| 11152 | - } | |
| 11153 | - | |
| 11154 | - if (!(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out"))) { | |
| 11155 | - map = new HashMap<String, Object>(); | |
| 11156 | - try { | |
| 11157 | - scheduleRealInfo.setBcs(xyz); | |
| 11158 | - xyz++; | |
| 11159 | - Set<ChildTaskPlan> cs = scheduleRealInfo.getcTasks(); | |
| 11160 | - Double sjlc = 0.0; | |
| 11161 | - if (!cs.isEmpty()) { | |
| 11162 | - Iterator<ChildTaskPlan> it = cs.iterator(); | |
| 11163 | - while (it.hasNext()) { | |
| 11164 | - ChildTaskPlan c = it.next(); | |
| 11165 | - if (!c.isDestroy()) { | |
| 11166 | - sjlc += c.getMileage() == null ? 0 : c.getMileage(); | |
| 11167 | - } | |
| 11168 | - | |
| 11169 | - } | |
| 11170 | - } else { | |
| 11171 | - if (scheduleRealInfo.getStatus() != -1) { | |
| 11172 | - sjlc = scheduleRealInfo.getJhlc(); | |
| 11173 | - } | |
| 11174 | - } | |
| 11175 | - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | |
| 11176 | - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | |
| 11177 | - scheduleRealInfo.setSjlc(format.format(sjlc)); | |
| 11178 | - map = rru.getMapValue(scheduleRealInfo); | |
| 11179 | - String zdsj = scheduleRealInfo.getZdsj(); | |
| 11180 | - String zdsjActual = scheduleRealInfo.getZdsjActual(); | |
| 11181 | - if (zdsj != null && zdsjActual != null && | |
| 11182 | - !zdsj.equals(zdsjActual)) { | |
| 11183 | - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | |
| 11184 | - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | |
| 11185 | - if (zdsj.compareTo(zdsjActual) > 0) { | |
| 11186 | - if (zdsjT - zdsjAT > 1000) { | |
| 11187 | - map.put("fast", ""); | |
| 11188 | - map.put("slow", zdsjAT - zdsjT + 1440); | |
| 11189 | - } else { | |
| 11190 | - map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | |
| 11191 | - map.put("slow", ""); | |
| 11192 | - } | |
| 11193 | - } else { | |
| 11194 | - if (zdsjAT - zdsjT > 1000) { | |
| 11195 | - map.put("fast", zdsjT - zdsjAT + 1440); | |
| 11196 | - map.put("slow", ""); | |
| 11197 | - } else { | |
| 11198 | - map.put("fast", ""); | |
| 11199 | - map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | |
| 11200 | - } | |
| 11201 | - } | |
| 11202 | - } else { | |
| 11203 | - map.put("fast", ""); | |
| 11204 | - map.put("slow", ""); | |
| 11205 | - } | |
| 11206 | - listMap.add(map); | |
| 11207 | - } catch (Exception e) { | |
| 11208 | - e.printStackTrace(); | |
| 11209 | - } | |
| 11210 | - } | |
| 11211 | - jhlc += jh; | |
| 11212 | - yygl += sj; | |
| 11213 | - if (jh > sj) { | |
| 11214 | - remgl += jh - sj; | |
| 11215 | - } else { | |
| 11216 | - addgl += sj - jh; | |
| 11217 | - } | |
| 11218 | - } | |
| 11219 | - } | |
| 11220 | - | |
| 11221 | - | |
| 11222 | - List<Ylxxb> listYlxxb = ylxxbRepository.queryListYlxxb(clZbh, date); | |
| 11223 | - Double jzl = 0.0; | |
| 11224 | - for (int t = 0; t < listYlxxb.size(); t++) { | |
| 11225 | - Ylxxb y = listYlxxb.get(t); | |
| 11226 | - jzl += y.getJzl(); | |
| 11227 | - } | |
| 11228 | - | |
| 11229 | - //计算里程和班次数,并放入Map里 | |
| 11230 | - map = findKMBCQp(clZbh, date, line); | |
| 11231 | - map.put("jzl", jzl); | |
| 11232 | -// map.put("jhlc", format.format(jhlc + jcclc)); | |
| 11233 | -// map.put("yygljh", format.format(jhlc)); | |
| 11234 | -// map.put("ssgl", format.format(remMileage)); | |
| 11235 | -// map.put("ksgl", format.format(ksgl)); | |
| 11236 | -// map.put("yyglsj", format.format(yygl)); | |
| 11237 | -// map.put("jhbc", jhbc); | |
| 11238 | -// map.put("jcclc", jcclc); | |
| 11239 | -// | |
| 11240 | -// map.put("ljgl", format.format(addMileage)); | |
| 11241 | -// map.put("ssbc", cjbc); | |
| 11242 | -// map.put("ysgl", format.format(yygl)); | |
| 11243 | -// map.put("sjbc", jhbc - cjbc + ljbc); | |
| 11244 | -// map.put("zgl", format.format(yygl + ksgl + jcclc)); | |
| 11245 | -// map.put("ljbc", ljbc); | |
| 11246 | - | |
| 11247 | - String zdp = "", zwdp = "", wdp = ""; | |
| 11248 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 11249 | - List<DutyEmployee> listDtuy = dutyEmployeeService.getDutyEmployee(line, date + "00:00", date + "23:59"); | |
| 11250 | - try { | |
| 11251 | - Long fcsj1 = sdf.parse(date + " 03:00").getTime(); | |
| 11252 | - Long fcsj2 = sdf.parse(date + " 11:00").getTime(); | |
| 11253 | - Long fcsj3 = sdf.parse(date + " 22:00").getTime(); | |
| 11254 | - for (int i = 0; i < listDtuy.size(); i++) { | |
| 11255 | - DutyEmployee t = listDtuy.get(i); | |
| 11256 | - Long ts = t.getTs(); | |
| 11257 | - if (ts > fcsj1 && ts < fcsj2) { | |
| 11258 | - if (zdp.indexOf(t.getuName()) == -1) { | |
| 11259 | - zdp += t.getuName() + ","; | |
| 11260 | - | |
| 11261 | - } | |
| 11262 | - } else if (ts > fcsj2 && ts < fcsj3) { | |
| 11263 | - if (zwdp.indexOf(t.getuName()) == -1) { | |
| 11264 | - zwdp += t.getuName() + ","; | |
| 11265 | - } | |
| 11266 | - } else { | |
| 11267 | - if (wdp.indexOf(t.getuName()) == -1) { | |
| 11268 | - wdp += t.getuName() + ","; | |
| 11269 | - } | |
| 11270 | - } | |
| 11271 | - } | |
| 11272 | - } catch (ParseException e) { | |
| 11273 | - // TODO Auto-generated catch block | |
| 11274 | - e.printStackTrace(); | |
| 11275 | - } | |
| 11276 | - map.put("zdp", zdp); | |
| 11277 | - map.put("zwdp", zwdp); | |
| 11278 | - map.put("wdp", wdp); | |
| 11279 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 11280 | - list.add(listMap.iterator()); | |
| 11281 | - ee.excelReplace(list, new Object[]{scheduleRealInfos.get(0), map}, path + "mould/waybill_qingpu.xls", | |
| 11282 | - path + "export/" + date + "-" + clZbh + "-行车路单.xls"); | |
| 11283 | - | |
| 11284 | - return scheduleRealInfos; | |
| 11285 | - } | |
| 11286 | - | |
| 11287 | - @Override | |
| 11288 | - public Map<String, Object> findKMBCQp(String clZbh, String date, String line) { | |
| 11289 | - // TODO Auto-generated method stub | |
| 11290 | - List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | |
| 11291 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 11292 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | |
| 11293 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | |
| 11294 | - int jhbc = 0, cjbc = 0, ljbc = 0, sjbc = 0; | |
| 11295 | - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0, ljjcclc = 0, jhjcclc = 0; | |
| 11296 | - double addMileage = 0, remMileage = 0, addgl = 0, remgl = 0; | |
| 11297 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 11298 | - jhlc = culateMieageService.culateJhgl(lists); | |
| 11299 | - jcclc = culateMieageService.culateJccgl(lists); | |
| 11300 | - jhjcclc = culateMieageService.culateJhJccgl(lists); | |
| 11301 | - remMileage = culateMieageService.culateLbgl(lists); | |
| 11302 | - ksgl = culateMieageService.culateKsgl(lists); | |
| 11303 | - yygl = culateMieageService.culateSjgl(lists); | |
| 11304 | - jhbc = culateMieageService.culateJhbc(lists, ""); | |
| 11305 | - addMileage = culateMieageService.culateLjgl(lists); | |
| 11306 | - cjbc = culateMieageService.culateLbbc(lists); | |
| 11307 | - sjbc = culateMieageService.culateSjbc(lists, ""); | |
| 11308 | - ljbc = culateMieageService.culateLjbc(lists, ""); | |
| 11309 | - double zyygl = Arith.add(yygl, addMileage); | |
| 11310 | - double zksgl = Arith.add(ksgl, jcclc); | |
| 11311 | - map.put("jhlc", Arith.add(jhlc, jhjcclc)); | |
| 11312 | - map.put("yygljh", jhlc); | |
| 11313 | - map.put("ssgl", remMileage); | |
| 11314 | - map.put("ksgl", ksgl); | |
| 11315 | - map.put("yyglsj", Arith.add(yygl, addMileage)); | |
| 11316 | - map.put("jcclc", jcclc); | |
| 11317 | - map.put("jhbc", jhbc); | |
| 11318 | - map.put("ljgl", addMileage); | |
| 11319 | - map.put("ssbc", cjbc); | |
| 11320 | - map.put("ysgl", Arith.add(yygl, addMileage)); | |
| 11321 | - map.put("sjbc", sjbc); | |
| 11322 | - map.put("zgl", Arith.add(zyygl, zksgl)); | |
| 11323 | - map.put("ljbc", ljbc); | |
| 11324 | - | |
| 11325 | - return map; | |
| 11326 | - } | |
| 11327 | - | |
| 11328 | - @Override | |
| 11329 | - public List<ScheduleRealInfo> queryListWaybillQp(String clZbh, String date, String line) { | |
| 11330 | - // TODO Auto-generated method stub | |
| 11331 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 11332 | - List<ScheduleRealInfo> list = null; | |
| 11333 | - list = scheduleRealInfoRepository.queryListWaybill2(clZbh, date, line); | |
| 11334 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | |
| 11335 | - for (int i = 0; i < list.size(); i++) { | |
| 11336 | - ScheduleRealInfo s = list.get(i); | |
| 11337 | - if (!(s.getBcType().equals("in") || s.getBcType().equals("out"))) { | |
| 11338 | - String remarks = ""; | |
| 11339 | - Double sjlc = 0.0; | |
| 11340 | - if (s.getRemarks() != null) { | |
| 11341 | - remarks += s.getRemarks(); | |
| 11342 | - } | |
| 11343 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | |
| 11344 | - if (!childTaskPlans.isEmpty()) { | |
| 11345 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 11346 | - while (it.hasNext()) { | |
| 11347 | - ChildTaskPlan c = it.next(); | |
| 11348 | - if (c.getRemarks() != null && c.getRemarks().length() > 0) { | |
| 11349 | - if (remarks.indexOf(c.getRemarks()) == -1) { | |
| 11350 | - remarks += c.getRemarks(); | |
| 11351 | - } | |
| 11352 | - } | |
| 11353 | - | |
| 11354 | - if (!c.isDestroy()) { | |
| 11355 | - if (c.getMileageType().equals("service")) { | |
| 11356 | - sjlc += c.getMileage() == null ? 0 : c.getMileage(); | |
| 11357 | - } | |
| 11358 | - } | |
| 11359 | - | |
| 11360 | - } | |
| 11361 | - } else { | |
| 11362 | - if (s.getStatus() != -1) { | |
| 11363 | - sjlc = s.getJhlc(); | |
| 11364 | - } | |
| 11365 | - } | |
| 11366 | - s.setSjlc(format.format(sjlc)); | |
| 11367 | - s.setRemarks(remarks); | |
| 11368 | - newList.add(s); | |
| 11369 | - } | |
| 11370 | - | |
| 11371 | - } | |
| 11372 | - | |
| 11373 | - return newList; | |
| 11374 | - } | |
| 11375 | - | |
| 11376 | - @Override | |
| 11377 | - public Map<String, Object> MapById(Long id) { | |
| 11378 | - // TODO Auto-generated method stub | |
| 11379 | - Map<String, Object> dMap=new HashMap<>(); | |
| 11380 | - dMap.put("dGroup_eq", "oilType"); | |
| 11381 | - Iterator<Dictionary> it= dictionaryService.list(dMap).iterator(); | |
| 11382 | - while (it.hasNext()) { | |
| 11383 | - Dictionary d=it.next(); | |
| 11384 | - dMap.put(d.getdCode(), d.getdName()); | |
| 11385 | - } | |
| 11386 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 11387 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 11388 | - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id); | |
| 11389 | - String xlbm = s.getXlBm(); | |
| 11390 | - String fcrq = s.getScheduleDateStr(); | |
| 11391 | - | |
| 11392 | - int type = 2; | |
| 11393 | - Double ccyl = 0.0; | |
| 11394 | - Double jcyl = 0.0; | |
| 11395 | - Double yh = 0.0; | |
| 11396 | - Double jzl = 0.0; | |
| 11397 | - Double zlc = 0.0; | |
| 11398 | - String rylx=""; | |
| 11399 | - List<Cars> listCars = carsRepository.findCarsByCode(s.getClZbh()); | |
| 11400 | - if (listCars.size() > 0) { | |
| 11401 | - if (listCars.get(0).getSfdc() != null) { | |
| 11402 | - if (listCars.get(0).getSfdc()) { | |
| 11403 | - List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | |
| 11404 | - type = 1; | |
| 11405 | - for (int i = 0; i < listDlb.size(); i++) { | |
| 11406 | - Dlb d = listDlb.get(i); | |
| 11407 | - if (d.getLp() == null) { | |
| 11408 | - ccyl = Arith.add(ccyl, d.getCzcd()); | |
| 11409 | - jcyl = Arith.add(jcyl, d.getJzcd()); | |
| 11410 | - yh = Arith.add(yh, d.getHd()); | |
| 11411 | - jzl = Arith.add(jzl, d.getCdl()); | |
| 11412 | - zlc = Arith.add(zlc, d.getZlc()); | |
| 11413 | - } else { | |
| 11414 | - if (d.getLp().equals(s.getLpName())) { | |
| 11415 | - ccyl = Arith.add(ccyl, d.getCzcd()); | |
| 11416 | - jcyl = Arith.add(jcyl, d.getJzcd()); | |
| 11417 | - yh = Arith.add(yh, d.getHd()); | |
| 11418 | - jzl = Arith.add(jzl, d.getCdl()); | |
| 11419 | - zlc = Arith.add(zlc, d.getZlc()); | |
| 11420 | - } | |
| 11421 | - } | |
| 11422 | - | |
| 11423 | - } | |
| 11424 | - } else { | |
| 11425 | - List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(), xlbm); | |
| 11426 | - type = 0; | |
| 11427 | - for (int i = 0; i < listYlb.size(); i++) { | |
| 11428 | - Ylb y = listYlb.get(i); | |
| 11429 | - if (y.getLp() == null) { | |
| 11430 | - ccyl = Arith.add(ccyl, y.getCzyl()); | |
| 11431 | - jcyl = Arith.add(jcyl, y.getJzyl()); | |
| 11432 | - yh = Arith.add(yh, y.getYh()); | |
| 11433 | - jzl = Arith.add(jzl, y.getJzl()); | |
| 11434 | - zlc = Arith.add(zlc, y.getZlc()); | |
| 11435 | - if(dMap.get(y.getRylx())!=null) | |
| 11436 | - rylx =dMap.get(y.getRylx()).toString(); | |
| 11437 | - } else { | |
| 11438 | - if (y.getLp().equals(s.getLpName())) { | |
| 11439 | - ccyl = Arith.add(ccyl, y.getCzyl()); | |
| 11440 | - jcyl = Arith.add(jcyl, y.getJzyl()); | |
| 11441 | - yh = Arith.add(yh, y.getYh()); | |
| 11442 | - jzl = Arith.add(jzl, y.getJzl()); | |
| 11443 | - zlc = Arith.add(zlc, y.getZlc()); | |
| 11444 | - if(dMap.get(y.getRylx())!=null) | |
| 11445 | - rylx =dMap.get(y.getRylx()).toString(); | |
| 11446 | - } | |
| 11447 | - } | |
| 11448 | - } | |
| 11449 | - } | |
| 11450 | - } | |
| 11451 | - } | |
| 11452 | - | |
| 11453 | - map.put("rylx", "加注类别:"+rylx); | |
| 11454 | - map.put("jzl", jzl); | |
| 11455 | - map.put("yh", yh); | |
| 11456 | - map.put("ccyl", ccyl); | |
| 11457 | - map.put("jcyl", jcyl); | |
| 11458 | - map.put("type", type); | |
| 11459 | - map.put("zlc", zlc); | |
| 11460 | - map.put("xlName", s.getXlName()); | |
| 11461 | - map.put("clZbh", s.getClZbh()); | |
| 11462 | - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); | |
| 11463 | - map.put("fcsjActual", s.getFcsjActual()); | |
| 11464 | - map.put("zdzName", s.getZdzName()); | |
| 11465 | - map.put("scheduleDate", s.getScheduleDateStr()); | |
| 11466 | - map.put("lpName", s.getLpName()); | |
| 11467 | - String zdp = "", zwdp = "", wdp = ""; | |
| 11468 | - String zdpT = "", zwdpT = "", wdpT = ""; | |
| 11469 | - String dbdp = ""; | |
| 11470 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59"); | |
| 11471 | - try { | |
| 11472 | - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime(); | |
| 11473 | - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime(); | |
| 11474 | - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime(); | |
| 11475 | - for (int i = 0; i < list.size(); i++) { | |
| 11476 | - DutyEmployee t = list.get(i); | |
| 11477 | - if (dbdp.indexOf(t.getuName()) == -1) { | |
| 11478 | - if (!(dbdp.length() > 0)) { | |
| 11479 | - dbdp = t.getuName(); | |
| 11480 | - } else { | |
| 11481 | - dbdp += "," + t.getuName(); | |
| 11482 | - } | |
| 11483 | - } | |
| 11484 | - Long ts = t.getTs(); | |
| 11485 | - if (ts > fcsj1 && ts < fcsj2) { | |
| 11486 | - if (zdp.indexOf(t.getuName()) == -1) { | |
| 11487 | - if (!(zdp.length() > 0)) { | |
| 11488 | - zdpT = t.getuName() + "..."; | |
| 11489 | - } | |
| 11490 | - zdp += t.getuName() + ","; | |
| 11491 | - | |
| 11492 | - } | |
| 11493 | - } else if (ts > fcsj2 && ts < fcsj3) { | |
| 11494 | - if (zwdp.indexOf(t.getuName()) == -1) { | |
| 11495 | - if (!(zwdp.length() > 0)) { | |
| 11496 | - zwdpT = t.getuName() + "..."; | |
| 11497 | - } | |
| 11498 | - zwdp += t.getuName() + ","; | |
| 11499 | - } | |
| 11500 | - } else { | |
| 11501 | - if (wdp.indexOf(t.getuName()) == -1) { | |
| 11502 | - if (!(wdp.length() > 0)) { | |
| 11503 | - wdpT = t.getuName() + "..."; | |
| 11504 | - } | |
| 11505 | - wdp += t.getuName() + ","; | |
| 11506 | - } | |
| 11507 | - } | |
| 11508 | - } | |
| 11509 | - } catch (ParseException e) { | |
| 11510 | - // TODO Auto-generated catch block | |
| 11511 | - e.printStackTrace(); | |
| 11512 | - } | |
| 11513 | - map.put("zdp", zdp); | |
| 11514 | - map.put("zwdp", zwdp); | |
| 11515 | - map.put("wdp", wdp); | |
| 11516 | - map.put("zdpT", zdpT); | |
| 11517 | - map.put("zwdpT", zwdpT); | |
| 11518 | - map.put("wdpT", wdpT); | |
| 11519 | - map.put("dbdp", dbdp); | |
| 11520 | - return map; | |
| 11521 | - } | |
| 11522 | - | |
| 11523 | - @Override | |
| 11524 | - public Map<String, Object> MapByIdQp(Long id) { | |
| 11525 | - // TODO Auto-generated method stub | |
| 11526 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 11527 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 11528 | - ScheduleRealInfo s = scheduleRealInfoRepository.scheduleById(id); | |
| 11529 | - String xlbm = s.getXlBm(); | |
| 11530 | - String fcrq = s.getScheduleDateStr(); | |
| 11531 | - | |
| 11532 | - int type = 0; | |
| 11533 | - Double ccyl = 0.0; | |
| 11534 | - Double jcyl = 0.0; | |
| 11535 | - Double yh = 0.0; | |
| 11536 | - Double jzl = 0.0; | |
| 11537 | - Double zlc = 0.0; | |
| 11538 | -// List<Ylb> listYlb = ylbRepository.queryListYlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); | |
| 11539 | -// List<Dlb> listDlb = dlbRepository.queryListDlb(fcrq, s.getClZbh(), s.getjGh(),xlbm); | |
| 11540 | -// if(listYlb.size()>0){ | |
| 11541 | -// type=0; | |
| 11542 | -// for (int i = 0; i < listYlb.size(); i++) { | |
| 11543 | -// Ylb y = listYlb.get(i); | |
| 11544 | -// if(y.getLp()==null){ | |
| 11545 | -// ccyl=Arith.add(ccyl, y.getCzyl()); | |
| 11546 | -// jcyl=Arith.add(jcyl, y.getJzyl()); | |
| 11547 | -// yh =Arith.add(yh ,y.getYh()); | |
| 11548 | -// jzl =Arith.add(jzl, y.getJzl()); | |
| 11549 | -// zlc =Arith.add(zlc, y.getZlc()); | |
| 11550 | -// }else{ | |
| 11551 | -// if(y.getLp().equals(s.getLpName())){ | |
| 11552 | -// ccyl=Arith.add(ccyl, y.getCzyl()); | |
| 11553 | -// jcyl=Arith.add(jcyl, y.getJzyl()); | |
| 11554 | -// yh =Arith.add(yh ,y.getYh()); | |
| 11555 | -// jzl =Arith.add(jzl, y.getJzl()); | |
| 11556 | -// zlc =Arith.add(zlc, y.getZlc()); | |
| 11557 | -// } | |
| 11558 | -// } | |
| 11559 | -// | |
| 11560 | -// } | |
| 11561 | -// }else{ | |
| 11562 | -// type=1; | |
| 11563 | -// for (int i = 0; i < listDlb.size(); i++) { | |
| 11564 | -// Dlb d=listDlb.get(i); | |
| 11565 | -// if(d.getLp()==null){ | |
| 11566 | -// ccyl=Arith.add(ccyl, d.getCzcd()); | |
| 11567 | -// jcyl=Arith.add(jcyl, d.getJzcd()); | |
| 11568 | -// yh =Arith.add(yh ,d.getHd()); | |
| 11569 | -// jzl =Arith.add(jzl, d.getCdl()); | |
| 11570 | -// zlc =Arith.add(zlc, d.getZlc()); | |
| 11571 | -// }else{ | |
| 11572 | -// if(d.getLp().equals(s.getLpName())){ | |
| 11573 | -// ccyl=Arith.add(ccyl, d.getCzcd()); | |
| 11574 | -// jcyl=Arith.add(jcyl, d.getJzcd()); | |
| 11575 | -// yh =Arith.add(yh ,d.getHd()); | |
| 11576 | -// jzl =Arith.add(jzl, d.getCdl()); | |
| 11577 | -// zlc =Arith.add(zlc, d.getZlc()); | |
| 11578 | -// } | |
| 11579 | -// } | |
| 11580 | -// | |
| 11581 | -// } | |
| 11582 | -// } | |
| 11583 | - | |
| 11584 | - List<Ylxxb> listylxxb = ylxxbRepository.queryListYlxxb(s.getClZbh(), fcrq); | |
| 11585 | - for (int i = 0; i < listylxxb.size(); i++) { | |
| 11586 | - Ylxxb t = listylxxb.get(i); | |
| 11587 | - jzl = Arith.add(jzl, t.getJzl()); | |
| 11588 | - } | |
| 11589 | - map.put("jzl", jzl); | |
| 11590 | - map.put("yh", yh); | |
| 11591 | - map.put("ccyl", ccyl); | |
| 11592 | - map.put("jcyl", jcyl); | |
| 11593 | - map.put("type", type); | |
| 11594 | - map.put("zlc", zlc); | |
| 11595 | - map.put("xlName", s.getXlName()); | |
| 11596 | - map.put("clZbh", s.getClZbh()); | |
| 11597 | - map.put("plate", BasicData.nbbmCompanyPlateMap.get(s.getClZbh())); | |
| 11598 | - map.put("fcsjActual", s.getFcsjActual()); | |
| 11599 | - map.put("zdzName", s.getZdzName()); | |
| 11600 | - map.put("scheduleDate", s.getScheduleDateStr()); | |
| 11601 | - map.put("lpName", s.getLpName()); | |
| 11602 | - String zdp = "", zwdp = "", wdp = ""; | |
| 11603 | - String zdpT = "", zwdpT = "", wdpT = ""; | |
| 11604 | - String dbdp = ""; | |
| 11605 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(xlbm, fcrq + "00:01", fcrq + "23:59"); | |
| 11606 | - try { | |
| 11607 | - Long fcsj1 = sdf.parse(fcrq + " 00:01").getTime(); | |
| 11608 | - Long fcsj2 = sdf.parse(fcrq + " 11:00").getTime(); | |
| 11609 | - Long fcsj3 = sdf.parse(fcrq + " 23:59").getTime(); | |
| 11610 | - for (int i = 0; i < list.size(); i++) { | |
| 11611 | - DutyEmployee t = list.get(i); | |
| 11612 | - if (dbdp.indexOf(t.getuName()) == -1) { | |
| 11613 | - if (!(dbdp.length() > 0)) { | |
| 11614 | - dbdp = t.getuName(); | |
| 11615 | - } else { | |
| 11616 | - dbdp += "," + t.getuName(); | |
| 11617 | - } | |
| 11618 | - } | |
| 11619 | - Long ts = t.getTs(); | |
| 11620 | - if (ts > fcsj1 && ts < fcsj2) { | |
| 11621 | - if (zdp.indexOf(t.getuName()) == -1) { | |
| 11622 | - if (!(zdp.length() > 0)) { | |
| 11623 | - zdpT = t.getuName() + "..."; | |
| 11624 | - } | |
| 11625 | - zdp += t.getuName() + ","; | |
| 11626 | - | |
| 11627 | - } | |
| 11628 | - } else if (ts > fcsj2 && ts < fcsj3) { | |
| 11629 | - if (zwdp.indexOf(t.getuName()) == -1) { | |
| 11630 | - if (!(zwdp.length() > 0)) { | |
| 11631 | - zwdpT = t.getuName() + "..."; | |
| 11632 | - } | |
| 11633 | - zwdp += t.getuName() + ","; | |
| 11634 | - } | |
| 11635 | - } else { | |
| 11636 | - if (wdp.indexOf(t.getuName()) == -1) { | |
| 11637 | - if (!(wdp.length() > 0)) { | |
| 11638 | - wdpT = t.getuName() + "..."; | |
| 11639 | - } | |
| 11640 | - wdp += t.getuName() + ","; | |
| 11641 | - } | |
| 11642 | - } | |
| 11643 | - } | |
| 11644 | - } catch (ParseException e) { | |
| 11645 | - // TODO Auto-generated catch block | |
| 11646 | - e.printStackTrace(); | |
| 11647 | - } | |
| 11648 | - map.put("zdp", zdp); | |
| 11649 | - map.put("zwdp", zwdp); | |
| 11650 | - map.put("wdp", wdp); | |
| 11651 | - map.put("zdpT", zdpT); | |
| 11652 | - map.put("zwdpT", zwdpT); | |
| 11653 | - map.put("wdpT", wdpT); | |
| 11654 | - map.put("dbdp", dbdp); | |
| 11655 | - return map; | |
| 11656 | - } | |
| 11657 | - | |
| 11658 | - @Override | |
| 11659 | - public List<Map<String, Object>> scheduleDailyQp(String line, String date) { | |
| 11660 | - // TODO Auto-generated method stub | |
| 11661 | - List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | |
| 11662 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDailyQp(line, date); | |
| 11663 | - Map<String, Object> map = null; | |
| 11664 | - String lp = "lp"; | |
| 11665 | - String jgh = "jgh"; | |
| 11666 | - String clzbh = "clzbh"; | |
| 11667 | - int bcs = 0; | |
| 11668 | - String thclzbh = ""; | |
| 11669 | - String sgh = "sgh"; | |
| 11670 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 11671 | - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(i); | |
| 11672 | - if (scheduleRealInfo.getLpName().equals(lp)) { | |
| 11673 | - bcs++; | |
| 11674 | - String fcsj = scheduleRealInfo.getFcsj(); | |
| 11675 | - | |
| 11676 | - if (!clzbh.equals(scheduleRealInfo.getClZbh())) { | |
| 11677 | - clzbh = scheduleRealInfo.getClZbh(); | |
| 11678 | - if (thclzbh == "") { | |
| 11679 | - thclzbh += scheduleRealInfo.getClZbh() + ","; | |
| 11680 | - } else { | |
| 11681 | - thclzbh += scheduleRealInfo.getClZbh(); | |
| 11682 | - } | |
| 11683 | - map.put("thclzbh", thclzbh); | |
| 11684 | - } | |
| 11685 | - | |
| 11686 | - if (!jgh.equals(scheduleRealInfo.getjGh())) { | |
| 11687 | - jgh = scheduleRealInfo.getjGh(); | |
| 11688 | - if (map.get("jjb2") != null) { | |
| 11689 | - map.put("jjb3", scheduleRealInfo.getjGh() + "/" + | |
| 11690 | - scheduleRealInfo.getFcsjActual()); | |
| 11691 | - | |
| 11692 | - } else { | |
| 11693 | - map.put("jjb2", scheduleRealInfo.getjGh() + "/" + | |
| 11694 | - scheduleRealInfo.getFcsjActual()); | |
| 11695 | - } | |
| 11696 | - | |
| 11697 | - } | |
| 11698 | - | |
| 11699 | - if (scheduleRealInfo.getsGh() != null) { | |
| 11700 | - if (!scheduleRealInfo.getsGh().equals(sgh)) { | |
| 11701 | - sgh = scheduleRealInfo.getsGh() == null ? "" : scheduleRealInfo.getsGh(); | |
| 11702 | - if (!sgh.equals("")) { | |
| 11703 | - if (map.get("sjb1") != null) { | |
| 11704 | - if (map.get("sjb2") != null) { | |
| 11705 | - map.put("sjb3", scheduleRealInfo.getsGh() + "/" + | |
| 11706 | - scheduleRealInfo.getFcsjActual()); | |
| 11707 | - } else { | |
| 11708 | - map.put("sjb2", scheduleRealInfo.getsGh() + "/" + | |
| 11709 | - scheduleRealInfo.getFcsjActual()); | |
| 11710 | - } | |
| 11711 | - } else { | |
| 11712 | - map.put("sjb1", scheduleRealInfo.getsGh() + "/" + | |
| 11713 | - scheduleRealInfo.getFcsjActual()); | |
| 11714 | - } | |
| 11715 | - } | |
| 11716 | - } | |
| 11717 | - } | |
| 11718 | - if (scheduleRealInfo.getFcsjActual() != null) { | |
| 11719 | - String fcsjs[] = fcsj.split(":"); | |
| 11720 | - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":"); | |
| 11721 | - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]); | |
| 11722 | - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]); | |
| 11723 | - map.put("cz" + bcs, b - a); | |
| 11724 | - } else { | |
| 11725 | - map.put("cz" + bcs, "无"); | |
| 11726 | - } | |
| 11727 | - map.put("lp", scheduleRealInfo.getLpName()); | |
| 11728 | - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual()); | |
| 11729 | - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual()); | |
| 11730 | - | |
| 11731 | - if (i < scheduleRealInfos.size() - 1) { | |
| 11732 | - if (!scheduleRealInfos.get(i + 1).getLpName().equals | |
| 11733 | - (scheduleRealInfos.get(i).getLpName())) { | |
| 11734 | - list.add(map); | |
| 11735 | - lp = "lp"; | |
| 11736 | - jgh = "jgh"; | |
| 11737 | - clzbh = "clzbh"; | |
| 11738 | - bcs = 0; | |
| 11739 | - thclzbh = ""; | |
| 11740 | - sgh = "sgh"; | |
| 11741 | - } | |
| 11742 | - } else { | |
| 11743 | - list.add(map); | |
| 11744 | - } | |
| 11745 | - } else { | |
| 11746 | - bcs = 1; | |
| 11747 | - map = new HashMap<String, Object>(); | |
| 11748 | - lp = scheduleRealInfo.getLpName(); | |
| 11749 | - jgh = scheduleRealInfo.getjGh(); | |
| 11750 | - clzbh = scheduleRealInfo.getClZbh(); | |
| 11751 | - if (scheduleRealInfo.getsGh() != null) { | |
| 11752 | - sgh = scheduleRealInfo.getsGh(); | |
| 11753 | - map.put("sjb1", scheduleRealInfo.getsGh() + "/" + | |
| 11754 | - scheduleRealInfo.getFcsjActual()); | |
| 11755 | - } | |
| 11756 | - String fcsj = scheduleRealInfo.getFcsj(); | |
| 11757 | - scheduleRealInfo.getFcsjActual(); | |
| 11758 | - map.put("jjb1", jgh + "/" + scheduleRealInfo.getFcsjActual()); | |
| 11759 | - map.put("cccl", clzbh); | |
| 11760 | - | |
| 11761 | - if (scheduleRealInfo.getFcsjActual() != null) { | |
| 11762 | - String fcsjs[] = fcsj.split(":"); | |
| 11763 | - String fcsjActuals[] = scheduleRealInfo.getFcsjActual().split(":"); | |
| 11764 | - int a = Integer.parseInt(fcsjActuals[0]) * 60 + Integer.parseInt(fcsjActuals[1]); | |
| 11765 | - int b = Integer.parseInt(fcsjs[0]) * 60 + Integer.parseInt(fcsjs[1]); | |
| 11766 | - map.put("cz" + bcs, b - a); | |
| 11767 | - } else { | |
| 11768 | - map.put("cz" + bcs, "无"); | |
| 11769 | - } | |
| 11770 | - | |
| 11771 | - | |
| 11772 | - map.put("lp", scheduleRealInfo.getLpName()); | |
| 11773 | - map.put("dd" + bcs, scheduleRealInfo.getZdsjActual()); | |
| 11774 | - map.put("kc" + bcs, scheduleRealInfo.getFcsjActual()); | |
| 11775 | - | |
| 11776 | - if (i < scheduleRealInfos.size() - 1) { | |
| 11777 | - if (!scheduleRealInfos.get(i + 1).getLpName().equals | |
| 11778 | - (scheduleRealInfos.get(i).getLpName())) { | |
| 11779 | - list.add(map); | |
| 11780 | - lp = "lp"; | |
| 11781 | - jgh = "jgh"; | |
| 11782 | - clzbh = "clzbh"; | |
| 11783 | - bcs = 0; | |
| 11784 | - thclzbh = ""; | |
| 11785 | - sgh = "sgh"; | |
| 11786 | - } | |
| 11787 | - } else { | |
| 11788 | - list.add(map); | |
| 11789 | - } | |
| 11790 | - } | |
| 11791 | - | |
| 11792 | - } | |
| 11793 | - return list; | |
| 11794 | - } | |
| 11795 | - | |
| 11796 | - | |
| 11797 | - @Override | |
| 11798 | - public List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map) { | |
| 11799 | - String line = map.get("line").toString(); | |
| 11800 | - String date = map.get("date").toString(); | |
| 11801 | - String xlName = map.get("xlName").toString(); | |
| 11802 | - String state = map.get("state").toString(); | |
| 11803 | - String type = map.get("type").toString(); | |
| 11804 | - String genre =map.get("genre").toString(); | |
| 11805 | - String df=""; | |
| 11806 | - if(map.get("df")!=null){ | |
| 11807 | - df=map.get("df").toString(); | |
| 11808 | - } | |
| 11809 | - | |
| 11810 | - List<Map<String, Object>> dataList2 = new ArrayList<Map<String, Object>>(); | |
| 11811 | - List<Map<String, Object>> dataList3 = new ArrayList<Map<String, Object>>(); | |
| 11812 | - List<Map<String, Object>> list1 = this.statisticsDaily(line, date, xlName, null); | |
| 11813 | - List<ScheduleRealInfo> list2 = this.queryUserInfo(line, date, state); | |
| 11814 | - List<ScheduleRealInfo> list3 = new ArrayList<ScheduleRealInfo>(); | |
| 11815 | - if(genre.equals("qp")) | |
| 11816 | - list3=this.realScheduleListQp(line, date); | |
| 11817 | - else if(genre.equals("zrw")) | |
| 11818 | - list3=this.realScheduleList_zrw(line, date); | |
| 11819 | - else | |
| 11820 | - list3=this.realScheduleList(line, date); | |
| 11821 | - Map<String, Object> nMap = new HashMap<String, Object>(); | |
| 11822 | - nMap.put("date", xlName + date); | |
| 11823 | - nMap.put("jls", list1.get(0).get("jls")); | |
| 11824 | - nMap.put("sjgl", list1.get(0).get("sjgl")); | |
| 11825 | - for (Map<String, Object> m : list1) { | |
| 11826 | -// m.put("ssgl", m.get("ssgl")); | |
| 11827 | -// m.put("ssbc", m.get("ssbc")); | |
| 11828 | -// m.put("ssgl_lz", m.get("ssgl_lz") + " / " + m.get("ssbc_lz")); | |
| 11829 | -// m.put("ssgl_dm", m.get("ssgl_dm") + " / " + m.get("ssbc_dm")); | |
| 11830 | -// m.put("ssgl_gz", m.get("ssgl_gz") + " / " + m.get("ssbc_gz")); | |
| 11831 | -// m.put("ssgl_jf", m.get("ssgl_jf") + " / " + m.get("ssbc_jf")); | |
| 11832 | -// m.put("ssgl_zs", m.get("ssgl_zs") + " / " + m.get("ssbc_zs")); | |
| 11833 | -// m.put("ssgl_qr", m.get("ssgl_qr") + " / " + m.get("ssbc_qr")); | |
| 11834 | -// m.put("ssgl_qc", m.get("ssgl_qc") + " / " + m.get("ssbc_qc")); | |
| 11835 | -// m.put("ssgl_kx", m.get("ssgl_kx") + " / " + m.get("ssbc_kx")); | |
| 11836 | -// m.put("ssgl_qh", m.get("ssgl_qh") + " / " + m.get("ssbc_qh")); | |
| 11837 | -// m.put("ssgl_yw", m.get("ssgl_yw") + " / " + m.get("ssbc_yw")); | |
| 11838 | -// m.put("ssgl_other", m.get("ssgl_other") + " / " + m.get("ssbc_other")); | |
| 11839 | - } | |
| 11840 | - | |
| 11841 | - int size = 0; | |
| 11842 | - Map<String, Object> tempMap = new HashMap<String, Object>(); | |
| 11843 | - for (int i = 0; i < list2.size(); i++) { | |
| 11844 | - ScheduleRealInfo s = list2.get(i); | |
| 11845 | - if (size == 5) { | |
| 11846 | - size = 0; | |
| 11847 | - dataList2.add(tempMap); | |
| 11848 | - tempMap = new HashMap<String, Object>(); | |
| 11849 | - } | |
| 11850 | - tempMap.put("lp" + size, s.getLpName()); | |
| 11851 | - tempMap.put("ch" + size, s.getClZbh()); | |
| 11852 | - tempMap.put("jz" + size, s.getjGh() + "/" + s.getjName()); | |
| 11853 | - tempMap.put("sz" + size, ""); | |
| 11854 | - tempMap.put("jw" + size, ""); | |
| 11855 | - tempMap.put("sw" + size, ""); | |
| 11856 | - | |
| 11857 | - size++; | |
| 11858 | - } | |
| 11859 | - if (size < 5) { | |
| 11860 | - for (; size < 5; size++) { | |
| 11861 | - tempMap.put("lp" + size, ""); | |
| 11862 | - tempMap.put("ch" + size, ""); | |
| 11863 | - tempMap.put("jz" + size, ""); | |
| 11864 | - tempMap.put("sz" + size, ""); | |
| 11865 | - tempMap.put("jw" + size, ""); | |
| 11866 | - tempMap.put("sw" + size, ""); | |
| 11867 | - } | |
| 11868 | - } | |
| 11869 | - | |
| 11870 | - dataList2.add(tempMap); | |
| 11871 | -/* | |
| 11872 | - size = 0; | |
| 11873 | - tempMap = new HashMap<String, Object>(); | |
| 11874 | - for (ScheduleRealInfo schedule : list3) { | |
| 11875 | - if (size == 3) { | |
| 11876 | - size = 0; | |
| 11877 | - dataList3.add(tempMap); | |
| 11878 | - tempMap = new HashMap<String, Object>(); | |
| 11879 | - } | |
| 11880 | - tempMap.put("lpName" + size, schedule.getLpName()); | |
| 11881 | - tempMap.put("qdzName" + size, schedule.getQdzName()); | |
| 11882 | - tempMap.put("zdsj" + size, schedule.getZdsj()); | |
| 11883 | - tempMap.put("zdsjActual" + size, schedule.getZdsjActual() != null ? schedule.getZdsjActual() : ""); | |
| 11884 | - tempMap.put("zdsjk" + size, ""); | |
| 11885 | - tempMap.put("zdsjm" + size, ""); | |
| 11886 | - tempMap.put("fcsj" + size, schedule.getFcsj()); | |
| 11887 | - String fcsjActural=schedule.getFcsjActual() != null ? schedule.getFcsjActual() : ""; | |
| 11888 | - String bcType=schedule.getBcType()!=null?schedule.getBcType():""; | |
| 11889 | - if(bcType.equals("in")){ | |
| 11890 | - fcsjActural=fcsjActural+"(进)"; | |
| 11891 | - } | |
| 11892 | - if(bcType.equals("out")){ | |
| 11893 | - fcsjActural=fcsjActural+"(出)"; | |
| 11894 | - } | |
| 11895 | - tempMap.put("fcsjActual" + size, fcsjActural); | |
| 11896 | - tempMap.put("fcsjk" + size, ""); | |
| 11897 | - tempMap.put("fcsjm" + size, ""); | |
| 11898 | - tempMap.put("remarks" + size, schedule.getRemarks() != null ? schedule.getRemarks() : ""); | |
| 11899 | - | |
| 11900 | - size++; | |
| 11901 | - } | |
| 11902 | - if (size < 3) { | |
| 11903 | - for (; size < 3; size++) { | |
| 11904 | - tempMap.put("lpName" + size, ""); | |
| 11905 | - tempMap.put("qdzName" + size, ""); | |
| 11906 | - tempMap.put("zdsj" + size, ""); | |
| 11907 | - tempMap.put("zdsjActual" + size, ""); | |
| 11908 | - tempMap.put("zdsjk" + size, ""); | |
| 11909 | - tempMap.put("zdsjm" + size, ""); | |
| 11910 | - tempMap.put("fcsj" + size, ""); | |
| 11911 | - tempMap.put("fcsjActual" + size, ""); | |
| 11912 | - tempMap.put("fcsjk" + size, ""); | |
| 11913 | - tempMap.put("fcsjm" + size, ""); | |
| 11914 | - tempMap.put("remarks" + size, ""); | |
| 11915 | - } | |
| 11916 | - } | |
| 11917 | -*/ | |
| 11918 | - | |
| 11919 | - size = 0; | |
| 11920 | - tempMap = new HashMap<String, Object>(); | |
| 11921 | - for (ScheduleRealInfo schedule : list3) { | |
| 11922 | - int x = size % 3; | |
| 11923 | - if (x == 0 && size > 0) { | |
| 11924 | - dataList3.add(tempMap); | |
| 11925 | - tempMap = new HashMap<String, Object>(); | |
| 11926 | - } | |
| 11927 | - tempMap.put("lpName" + x, schedule.getLpName()); | |
| 11928 | - tempMap.put("qdzName" + x, schedule.getQdzName()); | |
| 11929 | - tempMap.put("zdsj" + x, schedule.getZdsj()); | |
| 11930 | - String zdsjActual = schedule.getZdsjActual() != null ? schedule.getZdsjActual() : ""; | |
| 11931 | - tempMap.put("zdsjActual" + x, zdsjActual); | |
| 11932 | - | |
| 11933 | - String zdsjk = ""; | |
| 11934 | - String zdsjm = ""; | |
| 11935 | - if (!zdsjActual.equals("")) { | |
| 11936 | - String[] zdsj_s = schedule.getZdsj().split(":"); | |
| 11937 | - String[] zdsjActual_s = zdsjActual.split(":"); | |
| 11938 | - Long zdsj_ = Long.parseLong(zdsj_s[0]) * 60 + Long.parseLong(zdsj_s[1]); | |
| 11939 | - Long zdsjActual_ = Long.parseLong(zdsjActual_s[0]) * 60 + Long.parseLong(zdsjActual_s[1]); | |
| 11940 | - if ((zdsj_ - zdsjActual_) > 0) { | |
| 11941 | - if(zdsj_ - zdsjActual_>1200){ | |
| 11942 | - zdsjm=String.valueOf(1440-(zdsj_-zdsjActual_)); | |
| 11943 | - }else{ | |
| 11944 | - zdsjk = String.valueOf(zdsj_ - zdsjActual_); | |
| 11945 | - } | |
| 11946 | - } else { | |
| 11947 | - if(zdsjActual_ - zdsj_>1200){ | |
| 11948 | - zdsjk =String.valueOf(1440-(zdsjActual_ - zdsj_)); | |
| 11949 | - }else{ | |
| 11950 | - zdsjm = String.valueOf(zdsjActual_ - zdsj_); | |
| 11951 | - } | |
| 11952 | - } | |
| 11953 | - } | |
| 11954 | - tempMap.put("zdsjk" + x, zdsjk); | |
| 11955 | - tempMap.put("zdsjm" + x, zdsjm.equals("0")?"":zdsjm); | |
| 11956 | - tempMap.put("fcsj" + x, schedule.getFcsj()); | |
| 11957 | - String fcsjActural = schedule.getFcsjActual() != null ? schedule.getFcsjActual() : ""; | |
| 11958 | - String bcType = schedule.getBcType() != null ? schedule.getBcType() : ""; | |
| 11959 | - String fcsjActuralstr = ""; | |
| 11960 | - if (bcType.equals("in")) { | |
| 11961 | - fcsjActuralstr = fcsjActural + "(进)"; | |
| 11962 | - } else if (bcType.equals("out")) { | |
| 11963 | - fcsjActuralstr = fcsjActural + "(出)"; | |
| 11964 | - } else { | |
| 11965 | - fcsjActuralstr = fcsjActural; | |
| 11966 | - } | |
| 11967 | - tempMap.put("fcsjActual" + x, fcsjActuralstr); | |
| 11968 | - String fcsjk = ""; | |
| 11969 | - String fcsjm = ""; | |
| 11970 | - String dfsjk =""; | |
| 11971 | - String dfsjm=""; | |
| 11972 | - if (!fcsjActural.equals("")) { | |
| 11973 | - String[] fcsj_s = schedule.getFcsj().split(":"); | |
| 11974 | - String[] fcsjActural_s = fcsjActural.split(":"); | |
| 11975 | - Long fcsj_ = Long.parseLong(fcsj_s[0]) * 60 + Long.parseLong(fcsj_s[1]); | |
| 11976 | - Long fcsjActural_ = Long.parseLong(fcsjActural_s[0]) * 60 + Long.parseLong(fcsjActural_s[1]); | |
| 11977 | - if ((fcsj_ - fcsjActural_) > 0) { | |
| 11978 | - if(fcsj_ - fcsjActural_>1200){ | |
| 11979 | - fcsjm=String.valueOf(1440-(fcsj_ - fcsjActural_)); | |
| 11980 | - }else{ | |
| 11981 | - fcsjk = String.valueOf(fcsj_ - fcsjActural_); | |
| 11982 | - } | |
| 11983 | - } else { | |
| 11984 | - if(fcsjActural_ - fcsj_>1200){ | |
| 11985 | - fcsjk =String.valueOf(1440-(fcsjActural_ - fcsj_)); | |
| 11986 | - } | |
| 11987 | - else{ | |
| 11988 | - fcsjm = String.valueOf(fcsjActural_ - fcsj_); | |
| 11989 | - } | |
| 11990 | - } | |
| 11991 | - if(df.equals("df")){ | |
| 11992 | - String[] dfsj_s =schedule.getDfsj().split(":"); | |
| 11993 | - Long dfsj_ = Long.parseLong(dfsj_s[0]) * 60 + Long.parseLong(dfsj_s[1]); | |
| 11994 | - if ((dfsj_ - fcsjActural_) > 0) { | |
| 11995 | - if(dfsj_ - fcsjActural_>1200){ | |
| 11996 | - dfsjm=String.valueOf(1440-(dfsj_ - fcsjActural_)); | |
| 11997 | - }else{ | |
| 11998 | - dfsjk = String.valueOf(dfsj_ - fcsjActural_); | |
| 11999 | - } | |
| 12000 | - } else { | |
| 12001 | - if(fcsjActural_ - dfsj_>1200){ | |
| 12002 | - dfsjk= String.valueOf(1440-(fcsjActural_ - dfsj_)); | |
| 12003 | - }else{ | |
| 12004 | - dfsjm = String.valueOf(fcsjActural_ - dfsj_); | |
| 12005 | - } | |
| 12006 | - } | |
| 12007 | - } | |
| 12008 | - } | |
| 12009 | - if(df.equals("df")){ | |
| 12010 | - tempMap.put("dfsj"+x,schedule.getDfsj()); | |
| 12011 | - tempMap.put("dfsjk" + x, dfsjk); | |
| 12012 | - tempMap.put("dfsjm" + x, dfsjm.equals("0")?"":dfsjm); | |
| 12013 | - } | |
| 12014 | - tempMap.put("fcsjk" + x, fcsjk); | |
| 12015 | - tempMap.put("fcsjm" + x, fcsjm.equals("0")?"":fcsjm); | |
| 12016 | - tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : ""); | |
| 12017 | - | |
| 12018 | - size++; | |
| 12019 | - } | |
| 12020 | - if (tempMap.get("lpName0") != null) { | |
| 12021 | - if (tempMap.get("lpName1") == null) { | |
| 12022 | - tempMap.put("lpName1", ""); | |
| 12023 | - tempMap.put("qdzName1", ""); | |
| 12024 | - tempMap.put("zdsj1", ""); | |
| 12025 | - tempMap.put("zdsjActual1", ""); | |
| 12026 | - tempMap.put("zdsjk1", ""); | |
| 12027 | - tempMap.put("zdsjm1", ""); | |
| 12028 | - tempMap.put("fcsj1", ""); | |
| 12029 | - tempMap.put("fcsjActual1", ""); | |
| 12030 | - tempMap.put("fcsjk1", ""); | |
| 12031 | - tempMap.put("fcsjm1", ""); | |
| 12032 | - if(df.equals("df")){ | |
| 12033 | - tempMap.put("dfsj1",""); | |
| 12034 | - tempMap.put("dfsjk1" , ""); | |
| 12035 | - tempMap.put("dfsjm1" , ""); | |
| 12036 | - } | |
| 12037 | - tempMap.put("remarks1", ""); | |
| 12038 | - } | |
| 12039 | - if (tempMap.get("lpName2") == null) { | |
| 12040 | - tempMap.put("lpName2", ""); | |
| 12041 | - tempMap.put("qdzName2", ""); | |
| 12042 | - tempMap.put("zdsj2", ""); | |
| 12043 | - tempMap.put("zdsjActual2", ""); | |
| 12044 | - tempMap.put("zdsjk2", ""); | |
| 12045 | - tempMap.put("zdsjm2", ""); | |
| 12046 | - tempMap.put("fcsj2", ""); | |
| 12047 | - tempMap.put("fcsjActual2", ""); | |
| 12048 | - tempMap.put("fcsjk2", ""); | |
| 12049 | - tempMap.put("fcsjm2", ""); | |
| 12050 | - if(df.equals("df")){ | |
| 12051 | - tempMap.put("dfsj2",""); | |
| 12052 | - tempMap.put("dfsjk2" , ""); | |
| 12053 | - tempMap.put("dfsjm2" , ""); | |
| 12054 | - } | |
| 12055 | - tempMap.put("remarks2", ""); | |
| 12056 | - } | |
| 12057 | - dataList3.add(tempMap); | |
| 12058 | - } | |
| 12059 | - | |
| 12060 | - if (date.length() == 10) { | |
| 12061 | - List<DutyEmployee> list = dutyEmployeeService.getDutyEmployee(line, date + "00:01", date + "23:59"); | |
| 12062 | - String dbdp = ""; | |
| 12063 | - try { | |
| 12064 | - for (int i = 0; i < list.size(); i++) { | |
| 12065 | - DutyEmployee t = list.get(i); | |
| 12066 | - if (dbdp.indexOf(t.getuName()) == -1) { | |
| 12067 | - if (!(dbdp.length() > 0)) { | |
| 12068 | - dbdp = t.getuName(); | |
| 12069 | - } else { | |
| 12070 | - dbdp += "," + t.getuName(); | |
| 12071 | - } | |
| 12072 | - } | |
| 12073 | - } | |
| 12074 | - } catch (Exception e) { | |
| 12075 | - // TODO: handle exception | |
| 12076 | - e.printStackTrace(); | |
| 12077 | - } | |
| 12078 | - nMap.put("dbdp", dbdp); | |
| 12079 | - } | |
| 12080 | - | |
| 12081 | - if (type.equals("export")) { | |
| 12082 | - String lineName = ""; | |
| 12083 | - if (map.containsKey("lineName")) | |
| 12084 | - lineName = "-" + map.get("lineName").toString() + "-"; | |
| 12085 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 12086 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 12087 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 12088 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 12089 | - ReportUtils ee = new ReportUtils(); | |
| 12090 | - try { | |
| 12091 | - listI.add(list1.iterator()); | |
| 12092 | - listI.add(dataList2.iterator()); | |
| 12093 | - listI.add(dataList3.iterator()); | |
| 12094 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 12095 | - String sourcePath = path + "mould/scheduleDaily.xls"; | |
| 12096 | - if (date.length() == 7) { | |
| 12097 | - sdfMonth = new SimpleDateFormat("yyyy-MM"); | |
| 12098 | - sdfSimple = new SimpleDateFormat("yyyyMM"); | |
| 12099 | - sourcePath = path + "mould/scheduleDaily_m.xls"; | |
| 12100 | - } | |
| 12101 | - if(df.equals("df")){ | |
| 12102 | - sourcePath =path + "mould/scheduleDaily_df.xls"; | |
| 12103 | - } | |
| 12104 | - ee.excelReplace(listI, new Object[]{nMap}, sourcePath, | |
| 12105 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) + lineName + "调度日报.xls"); | |
| 12106 | - } catch (Exception e) { | |
| 12107 | - // TODO: handle exception | |
| 12108 | - e.printStackTrace(); | |
| 12109 | - } | |
| 12110 | - } | |
| 12111 | - | |
| 12112 | - return new ArrayList<Map<String, Object>>(); | |
| 12113 | - } | |
| 12114 | - | |
| 12115 | - public void exportWaybill_pl(List<ScheduleRealInfo> listpl, | |
| 12116 | - String date, String jName, String clZbh, String lpName) { | |
| 12117 | - ReportUtils ee = new ReportUtils(); | |
| 12118 | - ReportRelatedUtils rru = new ReportRelatedUtils(); | |
| 12119 | - List<Iterator<?>> list = new ArrayList<Iterator<?>>(); | |
| 12120 | - List<ScheduleRealInfo> scheduleRealInfos = listpl; | |
| 12121 | - List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); | |
| 12122 | -// List<ScheduleRealInfo> scheduleRealInfos=scheduleRealInfoRepository.queryListWaybillXcld(jName, clZbh, lpName, date, line); | |
| 12123 | - List<ScheduleRealInfo> lists = new ArrayList<ScheduleRealInfo>(); | |
| 12124 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 12125 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | |
| 12126 | - Set<ChildTaskPlan> cts = s.getcTasks(); | |
| 12127 | - if (cts != null && cts.size() > 0) { | |
| 12128 | - lists.add(s); | |
| 12129 | - } else { | |
| 12130 | - if (s.getZdsjActual() != null && s.getFcsjActual() != null) { | |
| 12131 | - lists.add(s); | |
| 12132 | - } | |
| 12133 | - } | |
| 12134 | - } | |
| 12135 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 12136 | -// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); | |
| 12137 | -// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); | |
| 12138 | - //计算里程和班次数,并放入Map里 | |
| 12139 | - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); | |
| 12140 | - | |
| 12141 | - map.put("jhlc", Arith.add(culateMieageService.culateJhgl(scheduleRealInfos), culateMieageService.culateJhJccgl(scheduleRealInfos))); | |
| 12142 | - map.put("remMileage", culateMieageService.culateLbgl(scheduleRealInfos)); | |
| 12143 | - map.put("addMileage", culateMieageService.culateLjgl(lists)); | |
| 12144 | - double yygl = Arith.add(culateMieageService.culateSjgl(lists), culateMieageService.culateLjgl(lists)); | |
| 12145 | - map.put("yygl", yygl); | |
| 12146 | - double ksgl = Arith.add(culateMieageService.culateKsgl(scheduleRealInfos), culateMieageService.culateJccgl(lists)); | |
| 12147 | - map.put("ksgl", ksgl); | |
| 12148 | - map.put("realMileage", Arith.add(yygl, ksgl)); | |
| 12149 | - map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos, "")); | |
| 12150 | - map.put("cjbc", culateMieageService.culateLbbc(scheduleRealInfos)); | |
| 12151 | - map.put("ljbc", culateMieageService.culateLjbc(lists, "")); | |
| 12152 | - int sjbc = culateMieageService.culateLjbc(lists, "") + culateMieageService.culateSjbc(lists, ""); | |
| 12153 | - map.put("sjbc", sjbc); | |
| 12154 | -// map=new HashMap<String,Object>(); | |
| 12155 | - | |
| 12156 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | |
| 12157 | - String minfcsj = "02:00"; | |
| 12158 | - List<Line> lineList = lineRepository.findLineByCode(listpl.get(0).getXlBm()); | |
| 12159 | - if (lineList.size() > 0) { | |
| 12160 | - String sqlMinYysj = "select start_opt from bsth_c_line_config where " | |
| 12161 | - + " id = (" | |
| 12162 | - + "select max(id) from bsth_c_line_config where line ='" + lineList.get(0).getId() + "'" | |
| 12163 | - + ")"; | |
| 12164 | - minfcsj = jdbcTemplate.queryForObject(sqlMinYysj, String.class); | |
| 12165 | - } | |
| 12166 | - String[] minSjs = minfcsj.split(":"); | |
| 12167 | - Long minSj = Long.parseLong(minSjs[0]) * 60 + Long.parseLong(minSjs[1]); | |
| 12168 | - | |
| 12169 | - | |
| 12170 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 12171 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | |
| 12172 | - String[] fcsj = s.getFcsj().split(":"); | |
| 12173 | - Long fcsjL = Long.parseLong(fcsj[0]) * 60 + Long.parseLong(fcsj[1]); | |
| 12174 | - | |
| 12175 | - Long fscjT = 0L; | |
| 12176 | - if (fcsjL < minSj) { | |
| 12177 | - Calendar calendar = new GregorianCalendar(); | |
| 12178 | - calendar.setTime(s.getScheduleDate()); | |
| 12179 | - calendar.add(calendar.DATE, 1); | |
| 12180 | - s.setScheduleDate(calendar.getTime()); | |
| 12181 | - try { | |
| 12182 | - fscjT = sdf.parse(sdf.format(s.getScheduleDate()) + " " + s.getFcsj()).getTime(); | |
| 12183 | - } catch (ParseException e) { | |
| 12184 | - // TODO Auto-generated catch block | |
| 12185 | - e.printStackTrace(); | |
| 12186 | - } | |
| 12187 | - | |
| 12188 | - } else { | |
| 12189 | - try { | |
| 12190 | - fscjT = sdf.parse(s.getScheduleDateStr() + " " + s.getFcsj()).getTime(); | |
| 12191 | - } catch (ParseException e) { | |
| 12192 | - // TODO Auto-generated catch block | |
| 12193 | - e.printStackTrace(); | |
| 12194 | - } | |
| 12195 | - ; | |
| 12196 | - } | |
| 12197 | - s.setFcsjT(fscjT); | |
| 12198 | - } | |
| 12199 | - List<ScheduleRealInfo> listSchedule = new ArrayList<ScheduleRealInfo>(); | |
| 12200 | - Collections.sort(scheduleRealInfos, new ComparableReal()); | |
| 12201 | - for (int i = 0; i < scheduleRealInfos.size(); i++) { | |
| 12202 | - ScheduleRealInfo s = scheduleRealInfos.get(i); | |
| 12203 | - s.setAdjustExps(i + 1 + ""); | |
| 12204 | - String remarks = ""; | |
| 12205 | - if (s.getRemarks() != null) { | |
| 12206 | - remarks += s.getRemarks(); | |
| 12207 | - } | |
| 12208 | - | |
| 12209 | - Set<ChildTaskPlan> childTaskPlans = s.getcTasks(); | |
| 12210 | - if (!childTaskPlans.isEmpty()) { | |
| 12211 | - s.setFcsjActual(""); | |
| 12212 | - s.setZdsjActual(""); | |
| 12213 | - s.setJhlc(0.0); | |
| 12214 | - } | |
| 12215 | - | |
| 12216 | - if (s.isDestroy()) { | |
| 12217 | - s.setFcsjActual(""); | |
| 12218 | - s.setZdsjActual(""); | |
| 12219 | - s.setJhlc(0.0); | |
| 12220 | - remarks += "(烂班)"; | |
| 12221 | - s.setRemarks(remarks); | |
| 12222 | - } | |
| 12223 | - | |
| 12224 | - listSchedule.add(s); | |
| 12225 | - //计算营运里程,空驶里程 | |
| 12226 | - if (!childTaskPlans.isEmpty()) { | |
| 12227 | -// Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 12228 | - List<ChildTaskPlan> listit = new ArrayList<ChildTaskPlan>(childTaskPlans); | |
| 12229 | - Collections.sort(listit, new ComparableChild()); | |
| 12230 | - for (int j = 0; j < listit.size(); j++) { | |
| 12231 | - ScheduleRealInfo t = new ScheduleRealInfo(); | |
| 12232 | - ChildTaskPlan childTaskPlan = listit.get(j); | |
| 12233 | - if (childTaskPlan.isDestroy()) { | |
| 12234 | - t.setFcsjActual(""); | |
| 12235 | - t.setZdsjActual(""); | |
| 12236 | - t.setJhlc(0.0); | |
| 12237 | - } else { | |
| 12238 | - t.setFcsjActual(childTaskPlan.getStartDate()); | |
| 12239 | - t.setZdsjActual(childTaskPlan.getEndDate()); | |
| 12240 | - t.setJhlc(Double.parseDouble(String.valueOf(childTaskPlan.getMileage()))); | |
| 12241 | - } | |
| 12242 | - t.setQdzName(childTaskPlan.getStartStationName()); | |
| 12243 | - t.setZdzName(childTaskPlan.getEndStationName()); | |
| 12244 | - t.setRemarks(childTaskPlan.getRemarks()); | |
| 12245 | - t.setAdjustExps("子"); | |
| 12246 | - t.setjGh(""); | |
| 12247 | - t.setjName(""); | |
| 12248 | - t.setsGh(""); | |
| 12249 | - t.setsName(""); | |
| 12250 | - listSchedule.add(t); | |
| 12251 | - } | |
| 12252 | - } | |
| 12253 | - } | |
| 12254 | - Map<String, Object> maps; | |
| 12255 | - for (ScheduleRealInfo scheduleRealInfo : listSchedule) { | |
| 12256 | - maps = new HashMap<String, Object>(); | |
| 12257 | - try { | |
| 12258 | - scheduleRealInfo.setjName(scheduleRealInfo.getjGh() + scheduleRealInfo.getjName()); | |
| 12259 | - scheduleRealInfo.setsName(scheduleRealInfo.getsGh() + scheduleRealInfo.getsName()); | |
| 12260 | - maps = rru.getMapValue(scheduleRealInfo); | |
| 12261 | - maps.put("bcs", scheduleRealInfo.getAdjustExps()); | |
| 12262 | - String zdsj = scheduleRealInfo.getZdsj(); | |
| 12263 | - String zdsjActual = scheduleRealInfo.getZdsjActual(); | |
| 12264 | - if (zdsj != null && zdsjActual != null && | |
| 12265 | - !zdsj.equals(zdsjActual) && | |
| 12266 | - !zdsj.equals("") && | |
| 12267 | - !zdsjActual.equals("")) { | |
| 12268 | - int zdsjT = Integer.valueOf(zdsj.split(":")[0]) * 60 + Integer.valueOf(zdsj.split(":")[1]); | |
| 12269 | - int zdsjAT = Integer.valueOf(zdsjActual.split(":")[0]) * 60 + Integer.valueOf(zdsjActual.split(":")[1]); | |
| 12270 | - if (zdsj.compareTo(zdsjActual) > 0) { | |
| 12271 | - if (zdsjT - zdsjAT > 1000) { | |
| 12272 | - maps.put("fast", ""); | |
| 12273 | - maps.put("slow", zdsjAT - zdsjT + 1440); | |
| 12274 | - } else { | |
| 12275 | - maps.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | |
| 12276 | - maps.put("slow", ""); | |
| 12277 | - } | |
| 12278 | - } else { | |
| 12279 | - if (zdsjAT - zdsjT > 1000) { | |
| 12280 | - maps.put("fast", zdsjT - zdsjAT + 1440); | |
| 12281 | - maps.put("slow", ""); | |
| 12282 | - } else { | |
| 12283 | - maps.put("fast", ""); | |
| 12284 | - maps.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual)); | |
| 12285 | - } | |
| 12286 | - } | |
| 12287 | - } else { | |
| 12288 | - maps.put("fast", ""); | |
| 12289 | - maps.put("slow", ""); | |
| 12290 | - } | |
| 12291 | - listMap.add(maps); | |
| 12292 | - } catch (Exception e) { | |
| 12293 | - e.printStackTrace(); | |
| 12294 | - } | |
| 12295 | - } | |
| 12296 | - | |
| 12297 | - | |
| 12298 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 12299 | - list.add(listMap.iterator()); | |
| 12300 | - String xls = ""; | |
| 12301 | - if (map.get("type").toString().equals("0")) { | |
| 12302 | - xls = "waybill_minhang.xls"; | |
| 12303 | - } else { | |
| 12304 | - xls = "waybill_minhang_dl.xls"; | |
| 12305 | - } | |
| 12306 | - map.put("sheetName", jName + "-" + clZbh + "-" + lpName); | |
| 12307 | - ee.excelReplace(list, new Object[]{map}, path + "mould/" + xls, | |
| 12308 | - path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | |
| 12309 | - } | |
| 12310 | - | |
| 12311 | - @Override | |
| 12312 | - public Map<String, Object> exportWaybillMore(Map<String, Object> map) { | |
| 12313 | - String date = map.get("date").toString(); | |
| 12314 | - String line = map.get("line").toString(); | |
| 12315 | - ReportUtils ee = new ReportUtils(); | |
| 12316 | - List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class); | |
| 12317 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; | |
| 12318 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 12319 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 12320 | - int num = 0; | |
| 12321 | - File file = null; | |
| 12322 | - try { | |
| 12323 | - while (true) { | |
| 12324 | - String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date)); | |
| 12325 | -// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹 | |
| 12326 | - file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件 | |
| 12327 | - if (file.exists()) { //判断是否已存在重名 | |
| 12328 | - num++; | |
| 12329 | - } else { | |
| 12330 | - break; | |
| 12331 | - } | |
| 12332 | - } | |
| 12333 | -// file.mkdirs(); //创建 | |
| 12334 | - List<ScheduleRealInfo> lists_line = scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date); | |
| 12335 | - List<File> files = new ArrayList<File>(); | |
| 12336 | - for (List<String> list : lists) { | |
| 12337 | - List<ScheduleRealInfo> newList = new ArrayList<ScheduleRealInfo>(); | |
| 12338 | - String jName = list.get(0); | |
| 12339 | - String clZbh = list.get(1); | |
| 12340 | - String lpName = list.get(2); | |
| 12341 | - String jGh = list.get(3); | |
| 12342 | - for (int i = 0; i < lists_line.size(); i++) { | |
| 12343 | - ScheduleRealInfo s = lists_line.get(i); | |
| 12344 | - if (s.getjGh().equals(jGh) && s.getClZbh().equals(clZbh) && s.getLpName().equals(lpName)) { | |
| 12345 | - newList.add(s); | |
| 12346 | - } | |
| 12347 | - } | |
| 12348 | - this.exportWaybill_pl(newList, date, jName, clZbh, lpName); | |
| 12349 | - File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); | |
| 12350 | - String fileName = file.getName(); | |
| 12351 | - files.add(temp); | |
| 12352 | - } | |
| 12353 | - for (int i = 1; i < files.size(); i++) { | |
| 12354 | - File file1 = files.get(0); | |
| 12355 | - File file2 = files.get(i); | |
| 12356 | - ee.copySheetByFile(file2, file1, 0, 145); | |
| 12357 | - } | |
| 12358 | - File newFile = files.get(0); | |
| 12359 | - newFile.renameTo(file); | |
| 12360 | -// temp.renameTo(new File(path + fileName + "/" + temp.getName())); | |
| 12361 | -// File[] listFiles = file.listFiles(); | |
| 12362 | -// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip"))); | |
| 12363 | -//// zos.setEncoding("gbk"); | |
| 12364 | -//// zos.putNextEntry(new ZipEntry(fileName + "/")); | |
| 12365 | -// for (int i = 0; i < listFiles.length; i++) { | |
| 12366 | -// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName())); | |
| 12367 | -// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i])); | |
| 12368 | -// BufferedOutputStream bos = new BufferedOutputStream(zos); | |
| 12369 | -// int bytesRead = 0; | |
| 12370 | -// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) { | |
| 12371 | -//// zos.write(buffer, 0, bytesRead); | |
| 12372 | -//// zos.flush(); | |
| 12373 | -// bos.write(buffer, 0, bytesRead); | |
| 12374 | -// bos.flush(); | |
| 12375 | -// } | |
| 12376 | -//// bos.close(); | |
| 12377 | -// bis.close(); | |
| 12378 | -// } | |
| 12379 | -// zos.close(); | |
| 12380 | -// } | |
| 12381 | - | |
| 12382 | - } catch (Exception e) { | |
| 12383 | - // TODO: handle exception | |
| 12384 | - e.printStackTrace(); | |
| 12385 | - } | |
| 12386 | - | |
| 12387 | - map.put("fileName", file.getName()); | |
| 12388 | - return map; | |
| 12389 | - } | |
| 12390 | - | |
| 12391 | - @Autowired | |
| 12392 | - SchedulePlanInfoService schPlanService; | |
| 12393 | - | |
| 12394 | - @Override | |
| 12395 | - public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) { | |
| 12396 | - List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode); | |
| 12397 | - | |
| 12398 | - if (rs == null || rs.size() == 0) { | |
| 12399 | - //尝试刷新内存 | |
| 12400 | - Map<String, Object> data = new HashMap<>(); | |
| 12401 | - data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode)); | |
| 12402 | - data.put("xlBm_eq", lineCode); | |
| 12403 | - List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator()); | |
| 12404 | - | |
| 12405 | - if (planItr.size() > 0) { | |
| 12406 | - dayOfSchedule.schedulePlanMap.put(lineCode, planItr); | |
| 12407 | - return planItr; | |
| 12408 | - } | |
| 12409 | - } | |
| 12410 | - return rs; | |
| 12411 | - } | |
| 12412 | - | |
| 12413 | - | |
| 12414 | - @Override | |
| 12415 | - public Map<String, Object> lpChangeMulti(String leftIdx, String rightIdx, int type) { | |
| 12416 | - Map<String, Object> rs = new HashMap<>(); | |
| 12417 | - Set<ScheduleRealInfo> ts = new HashSet<>(); | |
| 12418 | - try { | |
| 12419 | - List<String> leftList = Splitter.on(",").splitToList(leftIdx); | |
| 12420 | - List<String> rightList = Splitter.on(",").splitToList(rightIdx); | |
| 12421 | - Set<String> lpSet = new HashSet<>(); | |
| 12422 | - Set<String> carSet = new HashSet<>(); | |
| 12423 | - | |
| 12424 | - List<ScheduleRealInfo> largeList, smallList; | |
| 12425 | - if (leftList.size() > rightList.size()) { | |
| 12426 | - largeList = getByIdx(leftList); | |
| 12427 | - smallList = getByIdx(rightList); | |
| 12428 | - } else { | |
| 12429 | - largeList = getByIdx(rightList); | |
| 12430 | - smallList = getByIdx(leftList); | |
| 12431 | - } | |
| 12432 | - | |
| 12433 | - ScheduleRealInfo leftSch, rightSch = null; | |
| 12434 | - for (int i = 0; i < largeList.size(); i++) { | |
| 12435 | - leftSch = largeList.get(i); | |
| 12436 | - leftSch.setLpChange(1); | |
| 12437 | - if (i < smallList.size()) { | |
| 12438 | - rightSch = smallList.get(i); | |
| 12439 | - rightSch.setLpChange(1); | |
| 12440 | - ts.add(rightSch); | |
| 12441 | - } else { | |
| 12442 | - //不对称时多出来的 | |
| 12443 | - lpChangeByLeft(leftSch, largeList.get(i - 1), type); | |
| 12444 | - ts.add(leftSch); | |
| 12445 | - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName()); | |
| 12446 | - continue; | |
| 12447 | - } | |
| 12448 | - | |
| 12449 | - //调换路牌 | |
| 12450 | - lpChange(leftSch, rightSch, type); | |
| 12451 | - ts.add(leftSch); | |
| 12452 | - | |
| 12453 | - lpSet.add(leftSch.getXlBm() + "_" + leftSch.getLpName()); | |
| 12454 | - lpSet.add(rightSch.getXlBm() + "_" + rightSch.getLpName()); | |
| 12455 | - | |
| 12456 | - carSet.add(leftSch.getClZbh()); | |
| 12457 | - carSet.add(rightSch.getClZbh()); | |
| 12458 | - scheduleRealInfoRepository.updateLpChange(leftSch.getId()); | |
| 12459 | - scheduleRealInfoRepository.updateLpChange(rightSch.getId()); | |
| 12460 | - } | |
| 12461 | - | |
| 12462 | - //重新计算路牌的起点应到时间 | |
| 12463 | - for (String lpName : lpSet) { | |
| 12464 | - ts.addAll(dayOfSchedule.updateQdzTimePlan(lpName)); | |
| 12465 | - } | |
| 12466 | - | |
| 12467 | - //重新就算车辆当前执行班次 | |
| 12468 | - for(String nbbm : carSet){ | |
| 12469 | - dayOfSchedule.reCalcExecPlan(nbbm); | |
| 12470 | - } | |
| 12471 | - | |
| 12472 | - | |
| 12473 | - for (ScheduleRealInfo sch : ts) { | |
| 12474 | - dayOfSchedule.save(sch); | |
| 12475 | - } | |
| 12476 | - | |
| 12477 | - rs.put("status", ResponseCode.SUCCESS); | |
| 12478 | - rs.put("ts", ts); | |
| 12479 | - } catch (Exception e) { | |
| 12480 | - logger.error("", e); | |
| 12481 | - rs.put("status", ResponseCode.ERROR); | |
| 12482 | - rs.put("msg", e.getMessage()); | |
| 12483 | - } | |
| 12484 | - | |
| 12485 | - return rs; | |
| 12486 | - } | |
| 12487 | - | |
| 12488 | - private List<ScheduleRealInfo> getByIdx(List<String> idList) { | |
| 12489 | - List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 12490 | - for (String id : idList) { | |
| 12491 | - list.add(dayOfSchedule.get(Long.parseLong(id))); | |
| 12492 | - } | |
| 12493 | - return list; | |
| 12494 | - } | |
| 12495 | - | |
| 12496 | - @Override | |
| 12497 | - public void lpChange(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) { | |
| 12498 | - //释放班次映射 | |
| 12499 | - if (type > 0) { | |
| 12500 | - dayOfSchedule.removeNbbm2SchMapp(leftSch); | |
| 12501 | - dayOfSchedule.removeNbbm2SchMapp(rightSch); | |
| 12502 | - } | |
| 12503 | - | |
| 12504 | - //对调数据 | |
| 12505 | - LpData leftData = new LpData(leftSch); | |
| 12506 | - LpData rightData = new LpData(rightSch); | |
| 12507 | - | |
| 12508 | - leftData.appendTo(rightSch, type); | |
| 12509 | - rightData.appendTo(leftSch, type); | |
| 12510 | - | |
| 12511 | - if (type > 0) { | |
| 12512 | - //重新映射 | |
| 12513 | - dayOfSchedule.addNbbm2SchMapp(leftSch); | |
| 12514 | - dayOfSchedule.addNbbm2SchMapp(rightSch); | |
| 12515 | - } | |
| 12516 | - } | |
| 12517 | - | |
| 12518 | - /** | |
| 12519 | - * 更换左边班次的路牌,右边不变 | |
| 12520 | - * | |
| 12521 | - * @param leftSch | |
| 12522 | - * @param rightSch | |
| 12523 | - * @param type | |
| 12524 | - */ | |
| 12525 | - public void lpChangeByLeft(ScheduleRealInfo leftSch, ScheduleRealInfo rightSch, int type) { | |
| 12526 | - //释放班次映射 | |
| 12527 | - if (type > 0) | |
| 12528 | - dayOfSchedule.removeNbbm2SchMapp(leftSch); | |
| 12529 | - | |
| 12530 | - LpData rightData = new LpData(rightSch); | |
| 12531 | - rightData.appendTo(leftSch, type); | |
| 12532 | - | |
| 12533 | - //重新映射 | |
| 12534 | - if (type > 0) | |
| 12535 | - dayOfSchedule.addNbbm2SchMapp(leftSch); | |
| 12536 | - | |
| 12537 | - } | |
| 12538 | - | |
| 12539 | - @Override | |
| 12540 | - public Map<String, Object> revokeRealArrive(Long id) { | |
| 12541 | - Map<String, Object> rs = new HashMap<>(); | |
| 12542 | - List<ScheduleRealInfo> ts = new ArrayList<>(); | |
| 12543 | - | |
| 12544 | - try { | |
| 12545 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 12546 | - if (sch.getZdsjActual() == null && sch.getFcsjActual() == null) { | |
| 12547 | - rs.put("status", ResponseCode.ERROR); | |
| 12548 | - rs.put("msg", "班次未执行,无法撤销!"); | |
| 12549 | - } else { | |
| 12550 | - //日志记录 | |
| 12551 | - ScheduleModifyLogger.cxzx(sch); | |
| 12552 | - | |
| 12553 | - sch.clearFcsjActual(); | |
| 12554 | - sch.clearZdsjActual(); | |
| 12555 | - //清除路牌下一个班的起点到达时间 | |
| 12556 | - ScheduleRealInfo next = dayOfSchedule.nextByLp(sch); | |
| 12557 | - if (null != next) { | |
| 12558 | - next.setQdzArrDatesj(null); | |
| 12559 | - ts.add(next); | |
| 12560 | - } | |
| 12561 | - | |
| 12562 | - rs.put("status", ResponseCode.SUCCESS); | |
| 12563 | - | |
| 12564 | - ts.add(sch); | |
| 12565 | - rs.put("ts", ts); | |
| 12566 | - | |
| 12567 | - dayOfSchedule.save(sch); | |
| 12568 | - //重新计算当前执行班次 | |
| 12569 | - dayOfSchedule.reCalcExecPlan(sch.getClZbh()); | |
| 12570 | - | |
| 12571 | - } | |
| 12572 | - } catch (Exception e) { | |
| 12573 | - logger.error("", e); | |
| 12574 | - rs.put("status", ResponseCode.ERROR); | |
| 12575 | - } | |
| 12576 | - return rs; | |
| 12577 | - } | |
| 12578 | - | |
| 12579 | - @Override | |
| 12580 | - public Map<String, Object> lateAdjust(String idx, float minute) { | |
| 12581 | - Map<String, Object> rs = new HashMap<>(); | |
| 12582 | - try { | |
| 12583 | - int count = 0; | |
| 12584 | - List<ScheduleRealInfo> list = new ArrayList<>(); | |
| 12585 | - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx); | |
| 12586 | - | |
| 12587 | - ScheduleRealInfo sch; | |
| 12588 | - for (String id : ids) { | |
| 12589 | - sch = dayOfSchedule.get(Long.parseLong(id)); | |
| 12590 | - if (sch != null && sch.getStatus() == 0) { | |
| 12591 | - if (minute > 0) { | |
| 12592 | - sch.setLateMinute(minute); | |
| 12593 | - } else if (minute == 0) { | |
| 12594 | - LateAdjustHandle.remove(sch); | |
| 12595 | - } | |
| 12596 | - count++; | |
| 12597 | - list.add(sch); | |
| 12598 | - } | |
| 12599 | - } | |
| 12600 | - | |
| 12601 | - rs.put("status", ResponseCode.SUCCESS); | |
| 12602 | - rs.put("count", count); | |
| 12603 | - rs.put("ts", list); | |
| 12604 | - } catch (Exception e) { | |
| 12605 | - logger.error("", e); | |
| 12606 | - rs.put("status", ResponseCode.ERROR); | |
| 12607 | - rs.put("msg", e.getMessage()); | |
| 12608 | - } | |
| 12609 | - | |
| 12610 | - return rs; | |
| 12611 | - } | |
| 12612 | - | |
| 12613 | - @Override | |
| 12614 | - public List<ScheduleRealInfo> allLate2(String idx) { | |
| 12615 | - List<ScheduleRealInfo> rs = new ArrayList<>(); | |
| 12616 | - List<String> ids = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(idx); | |
| 12617 | - | |
| 12618 | - Collection<ScheduleRealInfo> all = LateAdjustHandle.allLateSch(); | |
| 12619 | - for (ScheduleRealInfo sch : all) { | |
| 12620 | - if (ids.indexOf(sch.getXlBm()) != -1) { | |
| 12621 | - rs.add(sch); | |
| 12622 | - } | |
| 12623 | - } | |
| 12624 | - return rs; | |
| 12625 | - } | |
| 12626 | - | |
| 12627 | - | |
| 12628 | - @Override | |
| 12629 | - public List<Map<String, Object>> mileageReport(String gsdm, | |
| 12630 | - String fgsdm, String line, String date, String date2) { | |
| 12631 | - | |
| 12632 | - String sql = "select * from calc_mileage where 1=1 "; | |
| 12633 | - if (!line.equals(" ")) { | |
| 12634 | - sql = sql + " and line_code='" + line + "' "; | |
| 12635 | - } | |
| 12636 | - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'"; | |
| 12637 | - if (!gsdm.equals(" ")) { | |
| 12638 | - sql = sql + " and company_id=" + gsdm; | |
| 12639 | - } | |
| 12640 | - if (!gsdm.equals(" ")) { | |
| 12641 | - sql = sql + " and sub_company_id=" + fgsdm; | |
| 12642 | - } | |
| 12643 | - sql = sql + " order by line_code"; | |
| 12644 | - List<MileageReport> list = jdbcTemplate.query(sql, | |
| 12645 | - new RowMapper<MileageReport>() { | |
| 12646 | - @Override | |
| 12647 | - public MileageReport mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 12648 | - MileageReport mr = new MileageReport(); | |
| 12649 | - mr.setCompanyName(rs.getString("company_name")); | |
| 12650 | - mr.setSubCompanyName(rs.getString("sub_company_name")); | |
| 12651 | - mr.setLineName(rs.getString("line_name")); | |
| 12652 | - mr.setSjyygl(rs.getDouble("sjyygl")); | |
| 12653 | - mr.setSjksgl(rs.getDouble("sjksgl")); | |
| 12654 | - mr.setZgl(rs.getDouble("zyygl")); | |
| 12655 | - mr.setZddfgl(rs.getDouble("zddfgl")); | |
| 12656 | - mr.setSddfgl(rs.getDouble("sddfgl")); | |
| 12657 | - mr.setWqwxhgl(rs.getDouble("wqwxhgl")); | |
| 12658 | - mr.setBfwxhgl(rs.getDouble("bfwxhgl")); | |
| 12659 | - mr.setPygl(rs.getDouble("pygl")); | |
| 12660 | - mr.setLjgl(rs.getDouble("ljgl")); | |
| 12661 | - mr.setZrwgl(rs.getDouble("zrwgl")); | |
| 12662 | - mr.setOther(rs.getString("other")); | |
| 12663 | - return mr; | |
| 12664 | - } | |
| 12665 | - }); | |
| 12666 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 12667 | - double sjyygl = 0.0; | |
| 12668 | - double sjksgl = 0.0; | |
| 12669 | - double zgl = 0.0; | |
| 12670 | - double sddfgl = 0.0; | |
| 12671 | - double zddfgl = 0.0; | |
| 12672 | - double wqwxhgl = 0.0; | |
| 12673 | - double bfwxhgl = 0.0; | |
| 12674 | - double pygl = 0.0; | |
| 12675 | - double ljgl = 0.0; | |
| 12676 | - double zrwgl = 0.0; | |
| 12677 | - for (MileageReport mr : list) { | |
| 12678 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 12679 | - resMap.put("gsName", mr.getCompanyName()); | |
| 12680 | - resMap.put("fgsName", mr.getSubCompanyName()); | |
| 12681 | - resMap.put("xlName", mr.getLineName()); | |
| 12682 | - resMap.put("sjyygl", mr.getSjyygl()); | |
| 12683 | - resMap.put("sjksgl", mr.getSjksgl()); | |
| 12684 | - resMap.put("zgl", mr.getZgl()); | |
| 12685 | - resMap.put("sddfgl", mr.getSddfgl()); | |
| 12686 | - resMap.put("zddfgl", mr.getZddfgl()); | |
| 12687 | - resMap.put("wqwxhgl", mr.getWqwxhgl()); | |
| 12688 | - resMap.put("bfwxhgl", mr.getBfwxhgl()); | |
| 12689 | - resMap.put("pygl", mr.getPygl()); | |
| 12690 | - resMap.put("ljgl", mr.getLjgl()); | |
| 12691 | - resMap.put("zrwgl", mr.getZrwgl()); | |
| 12692 | - resMap.put("other", mr.getOther()); | |
| 12693 | - lMap.add(resMap); | |
| 12694 | - sjyygl = Arith.add(sjyygl, mr.getSjyygl()); | |
| 12695 | - sjksgl = Arith.add(sjksgl, mr.getSjksgl()); | |
| 12696 | - zgl = Arith.add(zgl, mr.getZgl()); | |
| 12697 | - sddfgl = Arith.add(sddfgl, mr.getSddfgl()); | |
| 12698 | - zddfgl = Arith.add(zddfgl, mr.getZddfgl()); | |
| 12699 | - wqwxhgl = Arith.add(wqwxhgl, mr.getWqwxhgl()); | |
| 12700 | - bfwxhgl = Arith.add(bfwxhgl, mr.getBfwxhgl()); | |
| 12701 | - pygl = Arith.add(pygl, mr.getPygl()); | |
| 12702 | - ljgl = Arith.add(ljgl, mr.getLjgl()); | |
| 12703 | - zrwgl = Arith.add(zrwgl, mr.getZrwgl()); | |
| 12704 | - } | |
| 12705 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 12706 | - resMap.put("xlName", "合计"); | |
| 12707 | - resMap.put("sjyygl", sjyygl); | |
| 12708 | - resMap.put("sjksgl", sjksgl); | |
| 12709 | - resMap.put("zgl", zgl); | |
| 12710 | - resMap.put("sddfgl", sddfgl); | |
| 12711 | - resMap.put("zddfgl", zddfgl); | |
| 12712 | - resMap.put("wqwxhgl", wqwxhgl); | |
| 12713 | - resMap.put("bfwxhgl", bfwxhgl); | |
| 12714 | - resMap.put("pygl", pygl); | |
| 12715 | - resMap.put("ljgl", ljgl); | |
| 12716 | - resMap.put("zrwgl", zrwgl); | |
| 12717 | - resMap.put("other", null); | |
| 12718 | - lMap.add(resMap); | |
| 12719 | - return lMap; | |
| 12720 | - } | |
| 12721 | - | |
| 12722 | - @Override | |
| 12723 | - public List<Map<String, Object>> scheduleCorrectionReport(String gsdm, | |
| 12724 | - String fgsdm, String line, String date, String date2) { | |
| 12725 | - | |
| 12726 | - String sql = "select * from calc_schedule where 1=1 "; | |
| 12727 | - if (!line.equals(" ")) { | |
| 12728 | - sql = sql + " and line_code='" + line + "' "; | |
| 12729 | - } | |
| 12730 | - sql = sql + " and DATE_FORMAT(rq,'%Y-%m-%d') between '" + date + "' and '" + date2 + "'"; | |
| 12731 | - if (!gsdm.equals(" ")) { | |
| 12732 | - sql = sql + " and company_id=" + gsdm; | |
| 12733 | - } | |
| 12734 | - if (!gsdm.equals(" ")) { | |
| 12735 | - sql = sql + " and sub_company_id=" + fgsdm; | |
| 12736 | - } | |
| 12737 | - sql = sql + " order by line_code"; | |
| 12738 | - List<ScheduleCorrectionReport> list = jdbcTemplate.query(sql, | |
| 12739 | - new RowMapper<ScheduleCorrectionReport>() { | |
| 12740 | - @Override | |
| 12741 | - public ScheduleCorrectionReport mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 12742 | - ScheduleCorrectionReport sReport = new ScheduleCorrectionReport(); | |
| 12743 | - sReport.setCompanyName(rs.getString("company_name")); | |
| 12744 | - sReport.setSubCompanyName(rs.getString("sub_company_name")); | |
| 12745 | - sReport.setLineName(rs.getString("line_name")); | |
| 12746 | - sReport.setSjyybc(rs.getInt("sjyybc")); | |
| 12747 | - sReport.setSjksbc(rs.getInt("sjksbc")); | |
| 12748 | - sReport.setZbc(rs.getInt("zyybc")); | |
| 12749 | - sReport.setZddfbc(rs.getInt("zddfbc")); | |
| 12750 | - sReport.setSddfbc(rs.getInt("sddfbc")); | |
| 12751 | - sReport.setWqwxhbc(rs.getInt("wqwxhbc")); | |
| 12752 | - sReport.setBfwxhbc(rs.getInt("bfwxhbc")); | |
| 12753 | - sReport.setPybc(rs.getInt("pybc")); | |
| 12754 | - sReport.setLjbc(rs.getInt("ljbc")); | |
| 12755 | - sReport.setZrwbc(rs.getInt("zrwbc")); | |
| 12756 | - sReport.setOther(rs.getString("other")); | |
| 12757 | - return sReport; | |
| 12758 | - } | |
| 12759 | - }); | |
| 12760 | - List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | |
| 12761 | - int sjyybc = 0; | |
| 12762 | - int sjksbc = 0; | |
| 12763 | - int zbc = 0; | |
| 12764 | - int sddfbc = 0; | |
| 12765 | - int zddfbc = 0; | |
| 12766 | - int wqwxhbc = 0; | |
| 12767 | - int bfwxhbc = 0; | |
| 12768 | - int pybc = 0; | |
| 12769 | - int ljbc = 0; | |
| 12770 | - int zrwbc = 0; | |
| 12771 | - for (ScheduleCorrectionReport sReport : list) { | |
| 12772 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 12773 | - resMap.put("gsName", sReport.getCompanyName()); | |
| 12774 | - resMap.put("fgsName", sReport.getSubCompanyName()); | |
| 12775 | - resMap.put("xlName", sReport.getLineName()); | |
| 12776 | - resMap.put("sjyybc", sReport.getSjyybc()); | |
| 12777 | - resMap.put("sjksbc", sReport.getSjksbc()); | |
| 12778 | - resMap.put("zbc", sReport.getZbc()); | |
| 12779 | - resMap.put("sddfbc", sReport.getSddfbc()); | |
| 12780 | - resMap.put("zddfbc", sReport.getZddfbc()); | |
| 12781 | - resMap.put("wqwxhbc", sReport.getWqwxhbc()); | |
| 12782 | - resMap.put("bfwxhbc", sReport.getBfwxhbc()); | |
| 12783 | - resMap.put("pybc", sReport.getPybc()); | |
| 12784 | - resMap.put("ljbc", sReport.getLjbc()); | |
| 12785 | - resMap.put("zrwbc", sReport.getZrwbc()); | |
| 12786 | - resMap.put("other", sReport.getOther()); | |
| 12787 | - lMap.add(resMap); | |
| 12788 | - sjyybc = sjyybc + sReport.getSjyybc(); | |
| 12789 | - sjksbc = sjksbc + sReport.getSjksbc(); | |
| 12790 | - zbc = zbc + sReport.getZbc(); | |
| 12791 | - sddfbc = sddfbc + sReport.getSddfbc(); | |
| 12792 | - zddfbc = zddfbc + sReport.getZddfbc(); | |
| 12793 | - wqwxhbc = wqwxhbc + sReport.getWqwxhbc(); | |
| 12794 | - bfwxhbc = bfwxhbc + sReport.getBfwxhbc(); | |
| 12795 | - pybc = pybc + sReport.getPybc(); | |
| 12796 | - ljbc = ljbc + sReport.getLjbc(); | |
| 12797 | - zrwbc = zrwbc + sReport.getZrwbc(); | |
| 12798 | - } | |
| 12799 | - Map<String, Object> resMap = new HashMap<String, Object>(); | |
| 12800 | - resMap.put("xlName", "合计"); | |
| 12801 | - resMap.put("sjyybc", sjyybc); | |
| 12802 | - resMap.put("sjksbc", sjksbc); | |
| 12803 | - resMap.put("zbc", zbc); | |
| 12804 | - resMap.put("sddfbc", sddfbc); | |
| 12805 | - resMap.put("zddfbc", zddfbc); | |
| 12806 | - resMap.put("wqwxhbc", wqwxhbc); | |
| 12807 | - resMap.put("bfwxhbc", bfwxhbc); | |
| 12808 | - resMap.put("pybc", pybc); | |
| 12809 | - resMap.put("ljbc", ljbc); | |
| 12810 | - resMap.put("zrwbc", zrwbc); | |
| 12811 | - resMap.put("other", null); | |
| 12812 | - lMap.add(resMap); | |
| 12813 | - return lMap; | |
| 12814 | - } | |
| 12815 | - | |
| 12816 | - @Override | |
| 12817 | - public Integer isCircleQdz(String clzbh, String sdr, String xlbm, String qdzCode) { | |
| 12818 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | |
| 12819 | - String time =sdf.format(Long.parseLong(sdr)); | |
| 12820 | - | |
| 12821 | - Long num=scheduleRealInfoRepository.isCircleQdz(clzbh, time, xlbm, qdzCode); | |
| 12822 | - Integer num2=num==0L?0:1; | |
| 12823 | - return num2; | |
| 12824 | - } | |
| 12825 | - | |
| 12826 | - @SuppressWarnings("unchecked") | |
| 12827 | - private static Map<String, Object> request(String url) { | |
| 12828 | - Map<String, Object> res = new HashMap<String, Object>(); | |
| 12829 | - res.put("status", ResponseCode.SUCCESS); | |
| 12830 | - InputStream in = null; | |
| 12831 | - HttpURLConnection con = null; | |
| 12832 | - try { | |
| 12833 | - con = (HttpURLConnection)new URL(url).openConnection(); | |
| 12834 | - con.setRequestMethod("POST"); | |
| 12835 | - con.setRequestProperty("keep-alive", "true"); | |
| 12836 | - con.setRequestProperty("accept", "application/json"); | |
| 12837 | - con.setRequestProperty("content-type", "application/json"); | |
| 12838 | - con.setDoInput(true); | |
| 12839 | - con.setReadTimeout(2500); | |
| 12840 | - con.setConnectTimeout(2500); | |
| 12841 | - | |
| 12842 | - con.connect(); | |
| 12843 | - if (con.getResponseCode() == 200) { | |
| 12844 | - in = con.getInputStream(); | |
| 12845 | - ByteArrayOutputStream bout = new ByteArrayOutputStream(); | |
| 12846 | - IOUtils.copy(in, bout); bout.close(); | |
| 12847 | - Map<String, Object> response = new ObjectMapper().readValue(bout.toByteArray(), Map.class); | |
| 12848 | - if (!"报修成功".equals(response.get("msg"))) { | |
| 12849 | - res.put("status", ResponseCode.ERROR); | |
| 12850 | - res.putAll(response); | |
| 12851 | - } | |
| 12852 | - } else { | |
| 12853 | - res.put("status", ResponseCode.ERROR); | |
| 12854 | - res.put("msg", "调用上报接口异常"); | |
| 12855 | - } | |
| 12856 | - } catch (IOException e) { | |
| 12857 | - // TODO Auto-generated catch block | |
| 12858 | - res.put("status", ResponseCode.ERROR); | |
| 12859 | - res.put("msg", "调用上报接口异常"); | |
| 12860 | - } finally { | |
| 12861 | - try { | |
| 12862 | - if (in != null) in.close(); | |
| 12863 | - if (con != null) con.disconnect(); | |
| 12864 | - } catch (IOException e) { | |
| 12865 | - // TODO Auto-generated catch block | |
| 12866 | - e.printStackTrace(); | |
| 12867 | - } | |
| 12868 | - } | |
| 12869 | - | |
| 12870 | - return res; | |
| 12871 | - } | |
| 12872 | - | |
| 12873 | - /** | |
| 12874 | - ** 维修记录上报 | |
| 12875 | - * @param param 参数信息 | |
| 12876 | - * @param isActive 主/被动上报 | |
| 12877 | - */ | |
| 12878 | - @Override | |
| 12879 | - @Transactional | |
| 12880 | - public Map<String, Object> repairReport(Map<String, Object> param, boolean isActive) { | |
| 12881 | - Map<String, Object> res = new HashMap<String, Object>(); | |
| 12882 | - res.put("status", ResponseCode.SUCCESS); | |
| 12883 | - // 获取实际排班信息 | |
| 12884 | - Long id = Long.parseLong((String)param.get("id")); | |
| 12885 | - ScheduleRealInfo sch = dayOfSchedule.get(id); | |
| 12886 | - | |
| 12887 | - if (null == sch) { | |
| 12888 | - res.put("status", ResponseCode.ERROR); | |
| 12889 | - res.put("msg", "不存在的班次!"); | |
| 12890 | - | |
| 12891 | - return res; | |
| 12892 | - } | |
| 12893 | - | |
| 12894 | - int reportState = -1; | |
| 12895 | - SysUser user = SecurityUtils.getCurrentUser(); | |
| 12896 | - String reportUser = user.getUserName(), reportName = user.getName(), incode = (String)param.get("clZbh"), reportTypes = (String)param.get("reportTypes"), repairTypes = reportType2RepairType(reportTypes); | |
| 12897 | - // 分公司保存格式 分公司编码_公司编码 | |
| 12898 | - String val = BasicData.nbbm2FgsCompanyCodeMap.get(incode); | |
| 12899 | - String[] arr = val.split("_"); | |
| 12900 | - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1])); | |
| 12901 | - url.append("?nbbm=").append(incode).append("&bxy=").append(reportUser).append("&bxbm=").append(repairTypes).append("&fgs=").append(arr[0]); | |
| 12902 | - | |
| 12903 | - int count = repairReportRepository.repairReportBySch(id, isActive ? 1 : 0); | |
| 12904 | - if (count > 0) return res; | |
| 12905 | - RepairReport lrr = dayOfSchedule.getLastestRepairReport(incode); | |
| 12906 | - // 非主动上报并且无上报记录或上次已上报 则不用上报 | |
| 12907 | - if (!isActive && (lrr == null || lrr.getReportState() != 0)) { | |
| 12908 | - reportState = 0; | |
| 12909 | - } else { | |
| 12910 | - res = request(url.toString()); | |
| 12911 | - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1; | |
| 12912 | - } | |
| 12913 | - // 持久化此次上报记录 | |
| 12914 | - RepairReport rr = new RepairReport(); | |
| 12915 | - rr.setLineId(sch.getXlBm()); | |
| 12916 | - rr.setLineName(sch.getXlName()); | |
| 12917 | - rr.setReportUser(reportUser); | |
| 12918 | - rr.setReportName(reportName); | |
| 12919 | - rr.setSchId(id); | |
| 12920 | - rr.setIncode(incode); | |
| 12921 | - rr.setDepartureTime(sch.getFcsj()); | |
| 12922 | - rr.setRepairType(repairTypes); | |
| 12923 | - rr.setReportType(reportTypes); | |
| 12924 | - rr.setReportDate(new Date()); | |
| 12925 | - rr.setReportState(reportState); | |
| 12926 | - rr.setReportMode(isActive ? 1 : 0); | |
| 12927 | - rr = repairReportRepository.save(rr); | |
| 12928 | - dayOfSchedule.setLastestRepairReport(rr); | |
| 12929 | - // 如果上报失败,放到重传队列 | |
| 12930 | - if (rr.getReportState() == -1) queue.add(rr); | |
| 12931 | - | |
| 12932 | - return res; | |
| 12933 | - } | |
| 12934 | - | |
| 12935 | - private void repairReport(RepairReport rr) { | |
| 12936 | - int reportState = -1; | |
| 12937 | - // 分公司保存格式 分公司编码_公司编码 | |
| 12938 | - String val = BasicData.nbbm2FgsCompanyCodeMap.get(rr.getIncode()); | |
| 12939 | - String[] arr = val.split("_"); | |
| 12940 | - StringBuilder url = new StringBuilder(ConfigUtil.get("http.report.url." + arr[1])); | |
| 12941 | - url.append("?nbbm=").append(rr.getIncode()).append("&bxy=").append(rr.getReportUser()).append("&bxbm=").append(rr.getRepairType()).append("&fgs=").append(arr[0]); | |
| 12942 | - | |
| 12943 | - Map<String, Object> res = request(url.toString()); | |
| 12944 | - if (ResponseCode.SUCCESS.equals(res.get("status"))) reportState = 1; | |
| 12945 | - if (reportState == 1) { | |
| 12946 | - rr.setReportState(1); | |
| 12947 | - repairReportRepository.save(rr); | |
| 12948 | - } | |
| 12949 | - } | |
| 12950 | - | |
| 12951 | - /** | |
| 12952 | - ** 业务类型转报修类型 | |
| 12953 | - */ | |
| 12954 | - private String reportType2RepairType(String reportType) { | |
| 12955 | - String[] reportTypes = reportType.split(";"); | |
| 12956 | - List<String> repairTypes = new ArrayList<>(); | |
| 12957 | - for (String rt : reportTypes) { | |
| 12958 | - repairTypes.add(report2repair.get(rt)); | |
| 12959 | - } | |
| 12960 | - | |
| 12961 | - return StringUtils.join(repairTypes, ";"); | |
| 12962 | - } | |
| 12963 | - | |
| 12964 | - @Override | |
| 12965 | - public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) { | |
| 12966 | - List<RepairReport> result = new ArrayList<RepairReport>(); | |
| 12967 | - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 12968 | - | |
| 12969 | - Date start = null, end = null; | |
| 12970 | - if (date.length() > 0) { | |
| 12971 | - try { | |
| 12972 | - start = sdf.parse(date + " 00:00:00"); | |
| 12973 | - end = sdf.parse(date + " 23:59:59"); | |
| 12974 | - } catch (ParseException e) { | |
| 12975 | - // TODO Auto-generated catch block | |
| 12976 | - e.printStackTrace(); | |
| 12977 | - } | |
| 12978 | - | |
| 12979 | - } | |
| 12980 | - | |
| 12981 | - result = repairReportRepository.repairReportList(lineId, start, end, incode); | |
| 12982 | - Map<String, Object> dMap=new HashMap<>(); | |
| 12983 | - dMap.put("dGroup_eq", "repairtype"); | |
| 12984 | - Map<String, String> code2name = new HashMap<String, String>(); | |
| 12985 | - for (Dictionary dic : dictionaryService.list(dMap)) { | |
| 12986 | - code2name.put(dic.getdCode(), dic.getdName()); | |
| 12987 | - } | |
| 12988 | - for (RepairReport rr : result) { | |
| 12989 | - String reportType = rr.getReportType(); | |
| 12990 | - String[] types = reportType.split(";"); | |
| 12991 | - StringBuilder sb = new StringBuilder(); | |
| 12992 | - | |
| 12993 | - for (String t : types) { | |
| 12994 | - sb.append(code2name.get(t)).append(";"); | |
| 12995 | - } | |
| 12996 | - | |
| 12997 | - rr.setRepairType(sb.toString()); | |
| 12998 | - rr.setReportDateStr(sdf.format(rr.getReportDate())); | |
| 12999 | - switch (rr.getReportState()) { | |
| 13000 | - case 0: | |
| 13001 | - rr.setReportStateStr("不报"); | |
| 13002 | - break; | |
| 13003 | - case 1: | |
| 13004 | - rr.setReportStateStr("上报成功"); | |
| 13005 | - break; | |
| 13006 | - case -1: | |
| 13007 | - rr.setReportStateStr("上报失败"); | |
| 13008 | - break; | |
| 13009 | - default: | |
| 13010 | - break; | |
| 13011 | - } | |
| 13012 | - } | |
| 13013 | - | |
| 13014 | - if ("export".equals(type)) { | |
| 13015 | - String lineName = BasicData.lineCode2NameMap.get(lineId); | |
| 13016 | - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 13017 | - sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 13018 | - List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 13019 | - Map<String, Object> m = new HashMap<String, Object>(); | |
| 13020 | - ReportUtils ee = new ReportUtils(); | |
| 13021 | - List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | |
| 13022 | - for (int i = 0; i < result.size(); i++) { | |
| 13023 | - Map<String, Object> map = new HashMap<String, Object>(); | |
| 13024 | - RepairReport rr = result.get(i); | |
| 13025 | - map.put("row", i + 1); | |
| 13026 | - map.put("lineId", rr.getLineName()); | |
| 13027 | - map.put("incode", rr.getIncode()); | |
| 13028 | - map.put("departureTime", rr.getDepartureTime()); | |
| 13029 | - map.put("reportUser", rr.getReportUser()); | |
| 13030 | - map.put("reportDateStr", rr.getReportDate()); | |
| 13031 | - map.put("repairType", rr.getRepairType()); | |
| 13032 | - map.put("reportStateStr", rr.getReportStateStr()); | |
| 13033 | - newList.add(map); | |
| 13034 | - } | |
| 13035 | - try { | |
| 13036 | - listI.add(newList.iterator()); | |
| 13037 | - String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | |
| 13038 | - ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls", | |
| 13039 | - path + "export/" + sdfSimple.format(sdfMonth.parse(date)) | |
| 13040 | - + "-" + lineName + "-维修上报记录.xls"); | |
| 13041 | - } catch (Exception e) { | |
| 13042 | - // TODO: handle exception | |
| 13043 | - e.printStackTrace(); | |
| 13044 | - } | |
| 13045 | - } | |
| 13046 | - | |
| 13047 | - return result; | |
| 13048 | - } | |
| 13049 | - | |
| 13050 | - @Override | |
| 13051 | - public Map<String, String> getLevelsByLines(List<String> lines) { | |
| 13052 | - Map<String, String> result = new HashMap<String, String>(), currSchDate = dayOfSchedule.getCurrSchDate(); | |
| 13053 | - for (String line : lines) { | |
| 13054 | - String level = BasicData.lineDate2Level.get(line + "_" + currSchDate.get(line)); | |
| 13055 | - result.put(line, level == null ? "" : level); | |
| 13056 | - } | |
| 13057 | - | |
| 13058 | - return result; | |
| 13059 | - } | |
| 13060 | - | |
| 13061 | - | |
| 13062 | - @Override | |
| 13063 | - public void destroy() throws Exception { | |
| 13064 | - // TODO Auto-generated method stub | |
| 13065 | - exec.shutdown(); | |
| 13066 | - } | |
| 13067 | - | |
| 13068 | - | |
| 13069 | - @Override | |
| 13070 | - public void afterPropertiesSet() throws Exception { | |
| 13071 | - // TODO Auto-generated method stub | |
| 13072 | - // 维修上报重发调度 | |
| 13073 | - exec.scheduleAtFixedRate(new Runnable() { | |
| 13074 | - | |
| 13075 | - @Override | |
| 13076 | - public void run() { | |
| 13077 | - // TODO Auto-generated method stub | |
| 13078 | - try { | |
| 13079 | - Iterator<RepairReport> it = queue.iterator(); | |
| 13080 | - while (it.hasNext()) { | |
| 13081 | - RepairReport rr = it.next(); | |
| 13082 | - repairReport(rr); | |
| 13083 | - if (rr.getReportState() == 1 || System.currentTimeMillis() - rr.getReportDate().getTime() > 86400000) queue.remove(rr); | |
| 13084 | - } | |
| 13085 | - } catch (Exception e) { | |
| 13086 | - logger.error("维修上报重发错误", e); | |
| 13087 | - } | |
| 13088 | - } | |
| 13089 | - }, 30, 30, TimeUnit.MINUTES); | |
| 13090 | - | |
| 13091 | - //// --- | |
| 13092 | - exec.scheduleWithFixedDelay(new Runnable() { | |
| 13093 | - @Override | |
| 13094 | - public void run() { | |
| 13095 | - Map<String, Object> res = new HashMap<>(); | |
| 13096 | - InputStream in = null; | |
| 13097 | - String url ="http://211.95.61.66:9008/modules/tSafedrivingCs/DSMBHforCLBH"; | |
| 13098 | - | |
| 13099 | - try { | |
| 13100 | - HttpURLConnection con = (HttpURLConnection)new URL(url.toString()).openConnection(); | |
| 13101 | - con.setDoInput(true); | |
| 13102 | - con.setRequestMethod("POST"); | |
| 13103 | - con.setConnectTimeout(5000); | |
| 13104 | - con.setReadTimeout(5000); | |
| 13105 | - con.setRequestProperty("keep-alive", "true"); | |
| 13106 | - con.setRequestProperty("accept", "*/*"); | |
| 13107 | - con.setRequestProperty("content-type", "application/x-www-form-urlencoded"); | |
| 13108 | - con.connect(); | |
| 13109 | - | |
| 13110 | - if (con.getResponseCode() == 200) { | |
| 13111 | - in = con.getInputStream(); | |
| 13112 | - ByteArrayOutputStream bout = new ByteArrayOutputStream(); | |
| 13113 | - IOUtils.copy(in, bout); | |
| 13114 | - DIRMAP = new ObjectMapper().readValue(bout.toByteArray(), Map.class); | |
| 13115 | - } | |
| 13116 | - } catch (MalformedURLException e) { | |
| 13117 | - // TODO Auto-generated catch block | |
| 13118 | - e.printStackTrace(); | |
| 13119 | - } catch (IOException e) { | |
| 13120 | - // TODO Auto-generated catch block | |
| 13121 | - e.printStackTrace(); | |
| 13122 | - } | |
| 13123 | - | |
| 13124 | - } | |
| 13125 | - }, 0, 60 * 60 * 24, TimeUnit.MINUTES); | |
| 13126 | - } | |
| 13127 | -} | |
| 13128 | - | |
| 13129 | -class AccountMap implements Comparator<Map<String, Object>> { | |
| 13130 | - @Override | |
| 13131 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 13132 | - // TODO Auto-generated method stub | |
| 13133 | - return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString()); | |
| 13134 | - } | |
| 13135 | -} | |
| 13136 | - | |
| 13137 | -class AccountMap2 implements Comparator<Map<String, Object>> { | |
| 13138 | - @Override | |
| 13139 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 13140 | - // TODO Auto-generated method stub | |
| 13141 | - return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString()); | |
| 13142 | - } | |
| 13143 | -} | |
| 13144 | - | |
| 13145 | -class AccountXlbm implements Comparator<Map<String, Object>> { | |
| 13146 | - @Override | |
| 13147 | - public int compare(Map<String, Object> o1, Map<String, Object> o2) { | |
| 13148 | - // TODO Auto-generated method stub | |
| 13149 | -// PinyinHelper.convertToPinyinString(ppy.getName(), | |
| 13150 | -// "" , PinyinFormat.WITHOUT_TONE) | |
| 13151 | - return o1.get("xlNamePy").toString().compareTo( | |
| 13152 | - o2.get("xlNamePy").toString()); | |
| 13153 | - } | |
| 13154 | -} | |
| 13155 | - | |
| 13156 | -class compareLpFcsjType implements Comparator<ScheduleRealInfo> { | |
| 13157 | - @Override | |
| 13158 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 13159 | - // TODO Auto-generated method stub | |
| 13160 | - return (o1.getLpName()+o1.getFcsjT() + o1.getRemark()).compareTo(o2.getLpName()+o2.getFcsjT() + o2.getRemark()); | |
| 13161 | - } | |
| 13162 | - | |
| 13163 | -} | |
| 13164 | - | |
| 13165 | -class compareDirLpFcsjType implements Comparator<ScheduleRealInfo> { | |
| 13166 | - @Override | |
| 13167 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 13168 | - // TODO Auto-generated method stub | |
| 13169 | - return (o1.getXlDir()+o1.getFcsjT() + o1.getRemark()+o1.getLpName()).compareTo(o2.getXlDir()+o2.getFcsjT() + o2.getRemark()+o2.getLpName()); | |
| 13170 | - } | |
| 13171 | - | |
| 13172 | -} | |
| 13173 | -class compareFcsjType implements Comparator<ScheduleRealInfo> { | |
| 13174 | - @Override | |
| 13175 | - public int compare(ScheduleRealInfo o1, ScheduleRealInfo o2) { | |
| 13176 | - // TODO Auto-generated method stub | |
| 13177 | - return (o1.getFcsjT() + o1.getRemark()).compareTo(o2.getFcsjT() + o2.getRemark()); | |
| 13178 | - } | |
| 13179 | - | |
| 13180 | -} | |
| 13181 | ->>>>>>> 2021.05.11 历史版本 选择版本 查看历史版本修改当前版本和待更新版本 | ... | ... |