Commit c6c0822ad09cdcaba9f4bc57fd635e7c17158bf3

Authored by 廖磊
1 parent b19309b3

驾驶员请求台账sql修改

src/main/java/com/bsth/repository/LineRepository.java
@@ -39,6 +39,6 @@ public interface LineRepository extends BaseRepository<Line, Integer> { @@ -39,6 +39,6 @@ public interface LineRepository extends BaseRepository<Line, Integer> {
39 39
40 public Line findByLineCode(String string); 40 public Line findByLineCode(String string);
41 41
42 - @Query(value = " SELECT l FROM Line l where l.company like ?1 and l.brancheCompany like ?2 and l.lineCode like ?3") 42 + @Query(value = " SELECT l FROM Line l where l.company like %?1% and l.brancheCompany like %?2% and l.lineCode like ?3")
43 public List<Line> findLineBygsBm(String gsBm, String fgsBm, String line); 43 public List<Line> findLineBygsBm(String gsBm, String fgsBm, String line);
44 } 44 }
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
@@ -81,7 +81,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -81,7 +81,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
81 @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") 81 @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0")
82 int findLjbc(String jName,String clZbh,String lpName); 82 int findLjbc(String jName,String clZbh,String lpName);
83 83
84 - @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T'),c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code like %?3%",nativeQuery=true) 84 + @Query(value="SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,device_id FROM bsth_v_report_80 WHERE FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = ?2 AND line_id = ?1 and device_id like %?3%",nativeQuery=true)
85 List<Object[]> account(String line,String date,String code); 85 List<Object[]> account(String line,String date,String code);
86 86
87 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') " 87 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') "
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -1687,45 +1687,66 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1687,45 +1687,66 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1687 public List<Map<String, Object>> accountPx(String line, String date, 1687 public List<Map<String, Object>> accountPx(String line, String date,
1688 String code, String xlName, String px) { 1688 String code, String xlName, String px) {
1689 // List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px); 1689 // List<Object[]> lsitObj = scheduleRealInfoRepository.accountPx(line, date, code,px);
  1690 + if(!code.trim().equals("")){
  1691 + code=BasicData.deviceId2NbbmMap.inverse().get(code);
  1692 + }
  1693 + String fgs="";
  1694 + List<Line> lineList= lineRepository.findLineBygsBm("", "", line);
  1695 + if(lineList.size()>0){
  1696 + Line l=lineList.get(0);
  1697 + fgs=BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany()+"_"+l.getCompany());
  1698 + }
1690 List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); 1699 List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
1691 - String sql= "SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T') as date,"  
1692 - + "c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c "  
1693 - + "ON c.equipment_code = r.device_id where "  
1694 - + "FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = '"+date +"'"  
1695 - + "and r.line_id = "+line+" and c.inside_code like '%"+code+"%'"  
1696 - + " order by c.inside_code "+px; 1700 + String sql= "SELECT request_code,FROM_UNIXTIME(TIMESTAMP / 1000,'%Y-%m-%d %T') as TIMESTAMP ,"
  1701 + + " device_id FROM bsth_v_report_80 WHERE "
  1702 + + " FROM_UNIXTIME( TIMESTAMP / 1000,'%Y-%m-%d') = '"+date+"' AND"
  1703 + + " line_id = '"+line+"' and device_id like '%"+code+"%'";
1697 Map<String, Object> map; 1704 Map<String, Object> map;
1698 List<Object[]> lsitObj = jdbcTemplate.query(sql, 1705 List<Object[]> lsitObj = jdbcTemplate.query(sql,
1699 new RowMapper<Object[]>() { 1706 new RowMapper<Object[]>() {
1700 @Override 1707 @Override
1701 public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException { 1708 public Object[] mapRow(ResultSet rs, int rowNum) throws SQLException {
1702 - Object[] t = new Object[4];  
1703 - t[0]=rs.getString("company");  
1704 - t[1]=rs.getString("request_code");  
1705 - t[2]=rs.getString("date");  
1706 - t[3]=rs.getString("inside_code"); 1709 + Object[] t = new Object[3];
  1710 + t[0]=rs.getString("request_code");
  1711 + t[1]=rs.getString("TIMESTAMP");
  1712 + t[2]=rs.getString("device_id");
1707 return t; 1713 return t;
1708 } 1714 }
1709 }); 1715 });
1710 int i = 1; 1716 int i = 1;
1711 for (Object[] obj : lsitObj) { 1717 for (Object[] obj : lsitObj) {
1712 if (obj != null) { 1718 if (obj != null) {
1713 - map = new HashMap<String, Object>();  
1714 - map.put("num", i++);  
1715 - map.put("xlName", xlName);  
1716 - map.put("clZbh", obj[3]);  
1717 - map.put("company", obj[0]);  
1718 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1] + "")).toUpperCase());  
1719 - map.put("requestTime", obj[2]);  
1720 - listMap.add(map); 1719 + map = new HashMap<String, Object>();
  1720 + map.put("num", i++);
  1721 + map.put("xlName", xlName);
  1722 + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));
  1723 + map.put("company",fgs);
  1724 + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());
  1725 + map.put("requestTime", obj[1]);
  1726 + listMap.add(map);
1721 } 1727 }
1722 } 1728 }
1723 - 1729 + if(listMap.size()>1){
  1730 + if(px.equals("asc")){
  1731 + Collections.sort(listMap,new AccountMap());
  1732 + }else{
  1733 + Collections.sort(listMap,new AccountMap2());
  1734 + }
  1735 + }
1724 return listMap; 1736 return listMap;
1725 } 1737 }
1726 @Override 1738 @Override
1727 public List<Map<String, Object>> account(String line, String date, 1739 public List<Map<String, Object>> account(String line, String date,
1728 String code, String xlName, String type) { 1740 String code, String xlName, String type) {
  1741 + if(!code.trim().equals("")){
  1742 + code=BasicData.deviceId2NbbmMap.inverse().get(code);
  1743 + }
  1744 + String fgs="";
  1745 + List<Line> lineList= lineRepository.findLineBygsBm("", "", line);
  1746 + if(lineList.size()>0){
  1747 + Line l=lineList.get(0);
  1748 + fgs=BasicData.businessFgsCodeNameMap.get(l.getBrancheCompany()+"_"+l.getCompany());
  1749 + }
1729 List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code); 1750 List<Object[]> lsitObj = scheduleRealInfoRepository.account(line, date, code);
1730 List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>(); 1751 List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
1731 Map<String, Object> map; 1752 Map<String, Object> map;
@@ -1735,10 +1756,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1735,10 +1756,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1735 map = new HashMap<String, Object>(); 1756 map = new HashMap<String, Object>();
1736 map.put("num", i++); 1757 map.put("num", i++);
1737 map.put("xlName", xlName); 1758 map.put("xlName", xlName);
1738 - map.put("clZbh", obj[3]);  
1739 - map.put("company", obj[0]);  
1740 - map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[1] + "")).toUpperCase());  
1741 - map.put("requestTime", obj[2]); 1759 + map.put("clZbh", BasicData.deviceId2NbbmMap.get(obj[2]));
  1760 + map.put("company",fgs);
  1761 + map.put("requestType", "0x" + Integer.toHexString(Integer.parseInt(obj[0] + "")).toUpperCase());
  1762 + map.put("requestTime", obj[1]);
1742 listMap.add(map); 1763 listMap.add(map);
1743 } 1764 }
1744 } 1765 }
@@ -4199,4 +4220,20 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4199,4 +4220,20 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4199 } 4220 }
4200 return rs; 4221 return rs;
4201 } 4222 }
4202 -}  
4203 \ No newline at end of file 4223 \ No newline at end of file
  4224 +}
  4225 +
  4226 +class AccountMap implements Comparator<Map<String, Object>>{
  4227 + @Override
  4228 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  4229 + // TODO Auto-generated method stub
  4230 + return o1.get("clZbh").toString().compareTo(o2.get("clZbh").toString());
  4231 + }
  4232 +}
  4233 +
  4234 +class AccountMap2 implements Comparator<Map<String, Object>>{
  4235 + @Override
  4236 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  4237 + // TODO Auto-generated method stub
  4238 + return o2.get("clZbh").toString().compareTo(o1.get("clZbh").toString());
  4239 + }
  4240 +}