Commit 96ea8d3834ad35872c51014238f2402dd01c3a1f
Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
Showing
7 changed files
with
300 additions
and
211 deletions
src/main/java/com/bsth/controller/report/ReportController.java
| @@ -46,11 +46,18 @@ public class ReportController { | @@ -46,11 +46,18 @@ public class ReportController { | ||
| 46 | for (ArrivalInfo a:list ) { | 46 | for (ArrivalInfo a:list ) { |
| 47 | Map<String, Object> m = new HashMap<String, Object>(); | 47 | Map<String, Object> m = new HashMap<String, Object>(); |
| 48 | m.put("i", i); | 48 | m.put("i", i); |
| 49 | - m.put("mbbm", a.getNbbm()); | 49 | + m.put("nbbm", a.getNbbm()); |
| 50 | m.put("stopName", a.getStopName()); | 50 | m.put("stopName", a.getStopName()); |
| 51 | m.put("jzsj", a.getJzsj()); | 51 | m.put("jzsj", a.getJzsj()); |
| 52 | m.put("czsj", a.getCzsj()); | 52 | m.put("czsj", a.getCzsj()); |
| 53 | + m.put("kgm", ""); | ||
| 53 | m.put("upDown", a.getUpDown()==0?"上行":"下行"); | 54 | m.put("upDown", a.getUpDown()==0?"上行":"下行"); |
| 55 | + m.put("kmsd", ""); | ||
| 56 | + m.put("bufa", ""); | ||
| 57 | + m.put("skcs", ""); | ||
| 58 | + m.put("skje", ""); | ||
| 59 | + m.put("mfskcs", ""); | ||
| 60 | + m.put("mfskje", ""); | ||
| 54 | resList.add(m); | 61 | resList.add(m); |
| 55 | i++; | 62 | i++; |
| 56 | } | 63 | } |
| @@ -77,6 +84,46 @@ public class ReportController { | @@ -77,6 +84,46 @@ public class ReportController { | ||
| 77 | 84 | ||
| 78 | 85 | ||
| 79 | 86 | ||
| 87 | + @RequestMapping(value="/exportQueryListClzd" ,method = RequestMethod.GET) | ||
| 88 | + public List<Map<String, Object>> exportQueryListClzd(@RequestParam String zd,@RequestParam String line, | ||
| 89 | + @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){ | ||
| 90 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 91 | + ReportUtils ee = new ReportUtils(); | ||
| 92 | + List<ArrivalInfo> list=service.queryListClzd(line,zd,zdlx,fcsj,ddsj); | ||
| 93 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 94 | + int i=1; | ||
| 95 | + for (ArrivalInfo a:list ) { | ||
| 96 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 97 | + m.put("i", i); | ||
| 98 | + m.put("nbbm", a.getNbbm()); | ||
| 99 | + m.put("stopName", a.getStopName()); | ||
| 100 | + m.put("jzsj", a.getJzsj()); | ||
| 101 | + m.put("czsj", a.getCzsj()); | ||
| 102 | + m.put("kgm", ""); | ||
| 103 | + m.put("upDown", a.getUpDown()==0?"上行":"下行"); | ||
| 104 | + m.put("kmsd", ""); | ||
| 105 | + m.put("bufa", ""); | ||
| 106 | + m.put("skcs", ""); | ||
| 107 | + m.put("skje", ""); | ||
| 108 | + m.put("mfskcs", ""); | ||
| 109 | + m.put("mfskje", ""); | ||
| 110 | + resList.add(m); | ||
| 111 | + i++; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + try { | ||
| 115 | + Map<String, Object> map=new HashMap<String, Object>(); | ||
| 116 | + listI.add(resList.iterator()); | ||
| 117 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 118 | + ee.excelReplace(listI, new Object[] { map }, path + "mould/inoutstation.xls", | ||
| 119 | + path + "export/班次到离站.xls"); | ||
| 120 | + } catch (Exception e) { | ||
| 121 | + e.printStackTrace(); | ||
| 122 | + } | ||
| 123 | + return resList; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + | ||
| 80 | @RequestMapping(value="/jobSummaryExport" ,method = RequestMethod.GET) | 127 | @RequestMapping(value="/jobSummaryExport" ,method = RequestMethod.GET) |
| 81 | public List<Map<String, Object>> jobSummaryExport(@RequestParam Map<String, Object> map){ | 128 | public List<Map<String, Object>> jobSummaryExport(@RequestParam Map<String, Object> map){ |
| 82 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | 129 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); |
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
| @@ -141,8 +141,15 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -141,8 +141,15 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 141 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | 141 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 142 | List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); | 142 | List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); |
| 143 | 143 | ||
| 144 | - String company = map.get("company").toString(); | ||
| 145 | - String subCompany = map.get("subCompany").toString(); | 144 | + /*String company = ""; |
| 145 | + String subCompany =""; | ||
| 146 | + if(map.get("company")!=null){ | ||
| 147 | + company = map.get("company").toString(); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + if(map.get("subCompany")!=null){ | ||
| 151 | + subCompany=map.get("subCompany").toString(); | ||
| 152 | + }*/ | ||
| 146 | String line = map.get("line").toString(); | 153 | String line = map.get("line").toString(); |
| 147 | String date = map.get("date").toString(); | 154 | String date = map.get("date").toString(); |
| 148 | String type = map.get("type").toString(); | 155 | String type = map.get("type").toString(); |
| @@ -157,9 +164,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -157,9 +164,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 157 | if(line.length() != 0){ | 164 | if(line.length() != 0){ |
| 158 | sql += " and xl_bm = '"+line+"'"; | 165 | sql += " and xl_bm = '"+line+"'"; |
| 159 | } | 166 | } |
| 160 | - if(company.length() != 0){ | 167 | + /*if(company.length() != 0){ |
| 161 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; | 168 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; |
| 162 | - } | 169 | + }*/ |
| 163 | 170 | ||
| 164 | list = jdbcTemplate.query(sql, | 171 | list = jdbcTemplate.query(sql, |
| 165 | new RowMapper<SchedulePlanInfo>(){ | 172 | new RowMapper<SchedulePlanInfo>(){ |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleService.java
| 1 | -package com.bsth.service.schedule.rules; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.schedule.SchedulePlan; | ||
| 4 | -import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 5 | -import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; | ||
| 6 | - | ||
| 7 | -import java.util.Date; | ||
| 8 | -import java.util.List; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * 排班计划使用的service。 | ||
| 12 | - */ | ||
| 13 | -public interface ScheduleRuleService { | ||
| 14 | - | ||
| 15 | - // TODO:之后所有排班使用的方法汇总到这里 | ||
| 16 | - | ||
| 17 | - /** | ||
| 18 | - * 查找最近的历史排班记录 | ||
| 19 | - * @param xlid 线路id | ||
| 20 | - * @param from 开始时间 | ||
| 21 | - * @return | ||
| 22 | - */ | ||
| 23 | - List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from); | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * 生成排班计划。 | ||
| 27 | - * @param schedulePlan 计划主表 | ||
| 28 | - * @param schedulePlanInfos 计划明细表 | ||
| 29 | - */ | ||
| 30 | - void generateSchedulePlan(SchedulePlan schedulePlan, List<SchedulePlanInfo> schedulePlanInfos); | ||
| 31 | - | ||
| 32 | - /** | ||
| 33 | - * 删除排班计划。 | ||
| 34 | - * @param id 排班计划id | ||
| 35 | - */ | ||
| 36 | - void deleteSchedulePlanAll(Long id); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * 删除指定时间范围的排班明细。 | ||
| 40 | - * @param xlid 线路id | ||
| 41 | - * @param datefrom 开始日期 | ||
| 42 | - * @param dateto 结束日期 | ||
| 43 | - */ | ||
| 44 | - void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto); | ||
| 45 | -} | ||
| 46 | - | 1 | +package com.bsth.service.schedule.rules; |
| 2 | + | ||
| 3 | +import com.bsth.entity.schedule.SchedulePlan; | ||
| 4 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 5 | +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; | ||
| 6 | + | ||
| 7 | +import java.util.Date; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 排班计划使用的service。 | ||
| 12 | + */ | ||
| 13 | +public interface ScheduleRuleService { | ||
| 14 | + | ||
| 15 | + // TODO:之后所有排班使用的方法汇总到这里 | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 查找最近的历史排班记录 | ||
| 19 | + * @param xlid 线路id | ||
| 20 | + * @param from 开始时间 | ||
| 21 | + * @return | ||
| 22 | + */ | ||
| 23 | + List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 生成排班计划。 | ||
| 27 | + * @param schedulePlan 计划主表 | ||
| 28 | + * @param schedulePlanInfos 计划明细表 | ||
| 29 | + */ | ||
| 30 | + void generateSchedulePlan(SchedulePlan schedulePlan, List<SchedulePlanInfo> schedulePlanInfos); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除排班计划。 | ||
| 34 | + * @param id 排班计划id | ||
| 35 | + */ | ||
| 36 | + void deleteSchedulePlanAll(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 删除指定时间范围的排班明细。 | ||
| 40 | + * @param xlid 线路id | ||
| 41 | + * @param datefrom 开始日期 | ||
| 42 | + * @param dateto 结束日期 | ||
| 43 | + */ | ||
| 44 | + void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto); | ||
| 45 | +} | ||
| 46 | + |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java
| 1 | -package com.bsth.service.schedule.rules; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.schedule.SchedulePlan; | ||
| 4 | -import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 5 | -import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; | ||
| 6 | -import org.slf4j.Logger; | ||
| 7 | -import org.slf4j.LoggerFactory; | ||
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 10 | -import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | -import org.springframework.jdbc.core.PreparedStatementCreator; | ||
| 12 | -import org.springframework.jdbc.core.RowMapper; | ||
| 13 | -import org.springframework.jdbc.support.GeneratedKeyHolder; | ||
| 14 | -import org.springframework.jdbc.support.KeyHolder; | ||
| 15 | -import org.springframework.stereotype.Service; | ||
| 16 | -import org.springframework.transaction.annotation.Isolation; | ||
| 17 | -import org.springframework.transaction.annotation.Propagation; | ||
| 18 | -import org.springframework.transaction.annotation.Transactional; | ||
| 19 | - | ||
| 20 | -import java.sql.Connection; | ||
| 21 | -import java.sql.PreparedStatement; | ||
| 22 | -import java.sql.ResultSet; | ||
| 23 | -import java.sql.SQLException; | ||
| 24 | -import java.util.ArrayList; | ||
| 25 | -import java.util.Date; | ||
| 26 | -import java.util.List; | ||
| 27 | - | ||
| 28 | -/** | ||
| 29 | - * Created by xu on 17/4/19. | ||
| 30 | - */ | ||
| 31 | -@Service | ||
| 32 | -public class ScheduleRuleServiceImpl implements ScheduleRuleService { | ||
| 33 | - /** 日志记录器 */ | ||
| 34 | - private static final Logger logger = LoggerFactory.getLogger(ScheduleRuleServiceImpl.class); | ||
| 35 | - | ||
| 36 | - @Autowired | ||
| 37 | - private JdbcTemplate jdbcTemplate; | ||
| 38 | - | ||
| 39 | - @Override | ||
| 40 | - public List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from) { | ||
| 41 | - String sql = "select * from bsth_c_s_sp_rule_rst a " + | ||
| 42 | - "where exists (select 1 from " + | ||
| 43 | - "(select t.rule_id as rid, max(t.schedule_date) as sd from bsth_c_s_sp_rule_rst t " + | ||
| 44 | - "where t.xl_id = ? and t.schedule_date < ? " + | ||
| 45 | - "group by t.rule_id) a2 " + | ||
| 46 | - "where a.rule_id = rid and a.schedule_date = sd) "; | ||
| 47 | - | ||
| 48 | - return jdbcTemplate.query(sql, new Object[]{xlid, from}, new RowMapper<SchedulePlanRuleResult>() { | ||
| 49 | - @Override | ||
| 50 | - public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException { | ||
| 51 | - SchedulePlanRuleResult obj = new SchedulePlanRuleResult(); | ||
| 52 | - obj.setRuleId(rs.getString("rule_id")); | ||
| 53 | - obj.setScheduleDate(rs.getDate("schedule_date")); | ||
| 54 | - obj.setGidindex(rs.getString("gidindex")); | ||
| 55 | - obj.setEcindex(rs.getString("ecindex")); | ||
| 56 | - | ||
| 57 | - // 其他字段没用 | ||
| 58 | - return obj; | ||
| 59 | - } | ||
| 60 | - }); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 64 | - public void deleteSchedulePlanAll(Long id) { | ||
| 65 | - String sql1 = "delete from bsth_c_s_sp where id = ?"; | ||
| 66 | - String sql2 = "delete from bsth_c_s_sp_info where schedule_plan = ?"; | ||
| 67 | - | ||
| 68 | - jdbcTemplate.update(sql2, id); | ||
| 69 | - jdbcTemplate.update(sql1, id); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 73 | - public void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto) { | ||
| 74 | - String sql = "delete from bsth_c_s_sp_info where xl = ? and schedule_date >= ? and schedule_date <= ?"; | ||
| 75 | - jdbcTemplate.update(sql, xlid, datefrom, dateto); | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 79 | - @Override | ||
| 80 | - public void generateSchedulePlan(final SchedulePlan schedulePlan, final List<SchedulePlanInfo> schedulePlanInfos) { | ||
| 81 | - // 1、插入排班计划主表,并获取主键id | ||
| 82 | - KeyHolder keyHolder = new GeneratedKeyHolder(); | ||
| 83 | - jdbcTemplate.update(new PreparedStatementCreator() { | ||
| 84 | - @Override | ||
| 85 | - public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { | ||
| 86 | - PreparedStatement ps = connection.prepareStatement( | ||
| 87 | - SchedulePlan.generateInsertSql(), new String[] {"id"}); | ||
| 88 | - schedulePlan.preparedStatementSet(ps); | ||
| 89 | - | ||
| 90 | - return ps; | ||
| 91 | - } | ||
| 92 | - }, keyHolder); | ||
| 93 | - | ||
| 94 | - SchedulePlan master = new SchedulePlan(); | ||
| 95 | - master.setId(keyHolder.getKey().longValue()); | ||
| 96 | - for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | ||
| 97 | - schedulePlanInfo.setSchedulePlan(master); | ||
| 98 | - } | ||
| 99 | - | ||
| 100 | - // 2、批量插入排班计划从表 | ||
| 101 | - List<List<SchedulePlanInfo>> lists = new ArrayList<>(); | ||
| 102 | - int batchSize = 2000; | ||
| 103 | - int loopCount = schedulePlanInfos.size() / batchSize; | ||
| 104 | - int otherCount = schedulePlanInfos.size() % batchSize; | ||
| 105 | - for (int i = 0; i < loopCount; i++) { | ||
| 106 | - lists.add(schedulePlanInfos.subList(i * batchSize, i * batchSize + batchSize)); | ||
| 107 | - } | ||
| 108 | - if (otherCount > 0) { | ||
| 109 | - lists.add(schedulePlanInfos.subList(loopCount * batchSize, loopCount * batchSize + otherCount)); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - for (final List<SchedulePlanInfo> list : lists) { | ||
| 113 | - jdbcTemplate.batchUpdate(SchedulePlanInfo.generateInsertSql(), new BatchPreparedStatementSetter() { | ||
| 114 | - @Override | ||
| 115 | - public void setValues(PreparedStatement preparedStatement, int i) throws SQLException { | ||
| 116 | - SchedulePlanInfo schedulePlanInfo = list.get(i); | ||
| 117 | - schedulePlanInfo.preparedStatementSet(preparedStatement); | ||
| 118 | - } | ||
| 119 | - @Override | ||
| 120 | - public int getBatchSize() { | ||
| 121 | - return list.size(); | ||
| 122 | - } | ||
| 123 | - }); | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - } | ||
| 127 | -} | ||
| 128 | - | 1 | +package com.bsth.service.schedule.rules; |
| 2 | + | ||
| 3 | +import com.bsth.entity.schedule.SchedulePlan; | ||
| 4 | +import com.bsth.entity.schedule.SchedulePlanInfo; | ||
| 5 | +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; | ||
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 10 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | +import org.springframework.jdbc.core.PreparedStatementCreator; | ||
| 12 | +import org.springframework.jdbc.core.RowMapper; | ||
| 13 | +import org.springframework.jdbc.support.GeneratedKeyHolder; | ||
| 14 | +import org.springframework.jdbc.support.KeyHolder; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | +import org.springframework.transaction.annotation.Isolation; | ||
| 17 | +import org.springframework.transaction.annotation.Propagation; | ||
| 18 | +import org.springframework.transaction.annotation.Transactional; | ||
| 19 | + | ||
| 20 | +import java.sql.Connection; | ||
| 21 | +import java.sql.PreparedStatement; | ||
| 22 | +import java.sql.ResultSet; | ||
| 23 | +import java.sql.SQLException; | ||
| 24 | +import java.util.ArrayList; | ||
| 25 | +import java.util.Date; | ||
| 26 | +import java.util.List; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | + * Created by xu on 17/4/19. | ||
| 30 | + */ | ||
| 31 | +@Service | ||
| 32 | +public class ScheduleRuleServiceImpl implements ScheduleRuleService { | ||
| 33 | + /** 日志记录器 */ | ||
| 34 | + private static final Logger logger = LoggerFactory.getLogger(ScheduleRuleServiceImpl.class); | ||
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + private JdbcTemplate jdbcTemplate; | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from) { | ||
| 41 | + String sql = "select * from bsth_c_s_sp_rule_rst a " + | ||
| 42 | + "where exists (select 1 from " + | ||
| 43 | + "(select t.rule_id as rid, max(t.schedule_date) as sd from bsth_c_s_sp_rule_rst t " + | ||
| 44 | + "where t.xl_id = ? and t.schedule_date < ? " + | ||
| 45 | + "group by t.rule_id) a2 " + | ||
| 46 | + "where a.rule_id = rid and a.schedule_date = sd) "; | ||
| 47 | + | ||
| 48 | + return jdbcTemplate.query(sql, new Object[]{xlid, from}, new RowMapper<SchedulePlanRuleResult>() { | ||
| 49 | + @Override | ||
| 50 | + public SchedulePlanRuleResult mapRow(ResultSet rs, int i) throws SQLException { | ||
| 51 | + SchedulePlanRuleResult obj = new SchedulePlanRuleResult(); | ||
| 52 | + obj.setRuleId(rs.getString("rule_id")); | ||
| 53 | + obj.setScheduleDate(rs.getDate("schedule_date")); | ||
| 54 | + obj.setGidindex(rs.getString("gidindex")); | ||
| 55 | + obj.setEcindex(rs.getString("ecindex")); | ||
| 56 | + | ||
| 57 | + // 其他字段没用 | ||
| 58 | + return obj; | ||
| 59 | + } | ||
| 60 | + }); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 64 | + public void deleteSchedulePlanAll(Long id) { | ||
| 65 | + String sql1 = "delete from bsth_c_s_sp where id = ?"; | ||
| 66 | + String sql2 = "delete from bsth_c_s_sp_info where schedule_plan = ?"; | ||
| 67 | + | ||
| 68 | + jdbcTemplate.update(sql2, id); | ||
| 69 | + jdbcTemplate.update(sql1, id); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 73 | + public void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto) { | ||
| 74 | + String sql = "delete from bsth_c_s_sp_info where xl = ? and schedule_date >= ? and schedule_date <= ?"; | ||
| 75 | + jdbcTemplate.update(sql, xlid, datefrom, dateto); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 79 | + @Override | ||
| 80 | + public void generateSchedulePlan(final SchedulePlan schedulePlan, final List<SchedulePlanInfo> schedulePlanInfos) { | ||
| 81 | + // 1、插入排班计划主表,并获取主键id | ||
| 82 | + KeyHolder keyHolder = new GeneratedKeyHolder(); | ||
| 83 | + jdbcTemplate.update(new PreparedStatementCreator() { | ||
| 84 | + @Override | ||
| 85 | + public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { | ||
| 86 | + PreparedStatement ps = connection.prepareStatement( | ||
| 87 | + SchedulePlan.generateInsertSql(), new String[] {"id"}); | ||
| 88 | + schedulePlan.preparedStatementSet(ps); | ||
| 89 | + | ||
| 90 | + return ps; | ||
| 91 | + } | ||
| 92 | + }, keyHolder); | ||
| 93 | + | ||
| 94 | + SchedulePlan master = new SchedulePlan(); | ||
| 95 | + master.setId(keyHolder.getKey().longValue()); | ||
| 96 | + for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | ||
| 97 | + schedulePlanInfo.setSchedulePlan(master); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + // 2、批量插入排班计划从表 | ||
| 101 | + List<List<SchedulePlanInfo>> lists = new ArrayList<>(); | ||
| 102 | + int batchSize = 2000; | ||
| 103 | + int loopCount = schedulePlanInfos.size() / batchSize; | ||
| 104 | + int otherCount = schedulePlanInfos.size() % batchSize; | ||
| 105 | + for (int i = 0; i < loopCount; i++) { | ||
| 106 | + lists.add(schedulePlanInfos.subList(i * batchSize, i * batchSize + batchSize)); | ||
| 107 | + } | ||
| 108 | + if (otherCount > 0) { | ||
| 109 | + lists.add(schedulePlanInfos.subList(loopCount * batchSize, loopCount * batchSize + otherCount)); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + for (final List<SchedulePlanInfo> list : lists) { | ||
| 113 | + jdbcTemplate.batchUpdate(SchedulePlanInfo.generateInsertSql(), new BatchPreparedStatementSetter() { | ||
| 114 | + @Override | ||
| 115 | + public void setValues(PreparedStatement preparedStatement, int i) throws SQLException { | ||
| 116 | + SchedulePlanInfo schedulePlanInfo = list.get(i); | ||
| 117 | + schedulePlanInfo.preparedStatementSet(preparedStatement); | ||
| 118 | + } | ||
| 119 | + @Override | ||
| 120 | + public int getBatchSize() { | ||
| 121 | + return list.size(); | ||
| 122 | + } | ||
| 123 | + }); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + } | ||
| 127 | +} | ||
| 128 | + |
src/main/resources/static/pages/forms/mould/inoutstation.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/peopleCarPlan.html
| @@ -101,32 +101,31 @@ | @@ -101,32 +101,31 @@ | ||
| 101 | day = "0" + day; | 101 | day = "0" + day; |
| 102 | $("#date").val(year + "-" + month + "-" + day); | 102 | $("#date").val(year + "-" + month + "-" + day); |
| 103 | 103 | ||
| 104 | - $.get('/basic/lineCode2Name',function(result){ | ||
| 105 | - var data=[]; | ||
| 106 | - | ||
| 107 | - data.push({id: " ", text: "全部线路"}); | ||
| 108 | - for(var code in result){ | ||
| 109 | - data.push({id: code, text: result[code]}); | ||
| 110 | - } | ||
| 111 | - console.log(data); | ||
| 112 | - initPinYinSelect2('#line',data,''); | ||
| 113 | - }); | ||
| 114 | - | 104 | + var fage=false; |
| 105 | + var xlList; | ||
| 115 | var obj = []; | 106 | var obj = []; |
| 116 | - $.get('/user/companyData', function(result){ | ||
| 117 | - obj = result; | ||
| 118 | - var options = ''; | ||
| 119 | - for(var i = 0; i < obj.length; i++){ | ||
| 120 | - options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; | ||
| 121 | - } | ||
| 122 | - if(obj.length == 1){ | ||
| 123 | - $('#company1').hide(); | ||
| 124 | - if(obj[0].children.length == 1) | ||
| 125 | - $('#subCompany1').hide(); | ||
| 126 | - } | ||
| 127 | - $('#company').html(options); | ||
| 128 | - updateCompany(); | ||
| 129 | - }); | 107 | + |
| 108 | + | ||
| 109 | + $.get('/report/lineList',function(result){ | ||
| 110 | + xlList=result; | ||
| 111 | + $.get('/user/companyData', function(result){ | ||
| 112 | + obj = result; | ||
| 113 | + var options = ''; | ||
| 114 | + for(var i = 0; i < obj.length; i++){ | ||
| 115 | + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + if(obj.length ==0){ | ||
| 119 | + $("#company1").css('display','none'); | ||
| 120 | + }else if(obj.length ==1){ | ||
| 121 | + $("#company1").css('display','none'); | ||
| 122 | + if(obj[0].children.length == 1 || obj[0].children.length ==0) | ||
| 123 | + $('#subCompany1').css('display','none'); | ||
| 124 | + } | ||
| 125 | + $('#company').html(options); | ||
| 126 | + updateCompany(); | ||
| 127 | + }); | ||
| 128 | + }) | ||
| 130 | $("#company").on("change",updateCompany); | 129 | $("#company").on("change",updateCompany); |
| 131 | function updateCompany(){ | 130 | function updateCompany(){ |
| 132 | var company = $('#company').val(); | 131 | var company = $('#company').val(); |
| @@ -140,6 +139,42 @@ | @@ -140,6 +139,42 @@ | ||
| 140 | } | 139 | } |
| 141 | } | 140 | } |
| 142 | $('#subCompany').html(options); | 141 | $('#subCompany').html(options); |
| 142 | + initXl(); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + /* $.get('/basic/lineCode2Name',function(result){ | ||
| 146 | + var data=[]; | ||
| 147 | + | ||
| 148 | + for(var code in result){ | ||
| 149 | + data.push({id: code, text: result[code]}); | ||
| 150 | + } | ||
| 151 | + initPinYinSelect2('#line',data,''); | ||
| 152 | + | ||
| 153 | + }) */ | ||
| 154 | + | ||
| 155 | + $("#subCompany").on("change",initXl); | ||
| 156 | + function initXl(){ | ||
| 157 | + var data=[]; | ||
| 158 | + if(fage){ | ||
| 159 | + $("#line").select2("destroy").html(''); | ||
| 160 | + } | ||
| 161 | + var fgs=$('#subCompany').val(); | ||
| 162 | + var gs=$('#company').val(); | ||
| 163 | + for(var i=0;i<xlList.length;i++){ | ||
| 164 | + if(gs!=""){ | ||
| 165 | + if(fgs!=""){ | ||
| 166 | + if(xlList[i]["fgsbm"]==fgs && xlList[i]["gsbm"]==gs){ | ||
| 167 | + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]}); | ||
| 168 | + } | ||
| 169 | + }else{ | ||
| 170 | + if(xlList[i]["gsbm"]==gs){ | ||
| 171 | + data.push({id: xlList[i]["xlbm"], text: xlList[i]["xlname"]}); | ||
| 172 | + } | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + initPinYinSelect2('#line',data,''); | ||
| 177 | + fage=true; | ||
| 143 | } | 178 | } |
| 144 | 179 | ||
| 145 | 180 |
src/test/resources/testdata/test5.txt
| 1 | -update bsth_c_s_sp_info a | ||
| 2 | -set a.schedule_plan = ( | ||
| 3 | -select sp_id from bsth_c_s_sp_r_info b where a.id = b.sp_info_id | ||
| 4 | -) | ||
| 5 | -where a.schedule_plan is null | ||
| 6 | - | ||
| 7 | -select count(*) from bsth_c_s_sp_info | 1 | +update bsth_c_s_sp_info a |
| 2 | +set a.schedule_plan = ( | ||
| 3 | +select sp_id from bsth_c_s_sp_r_info b where a.id = b.sp_info_id | ||
| 4 | +) | ||
| 5 | +where a.schedule_plan is null | ||
| 6 | + | ||
| 7 | +select count(*) from bsth_c_s_sp_info | ||
| 8 | where schedule_plan is null | 8 | where schedule_plan is null |
| 9 | \ No newline at end of file | 9 | \ No newline at end of file |