Commit 4eebb4733c59f094a8e0bab88f7c47ca136e7c1d

Authored by YRF
1 parent 37f94c0d

Signed-off-by: YRF <YRF@DESKTOP-UNV37O6>

src/main/java/com/bsth/controller/LineController.java
... ... @@ -90,7 +90,7 @@ public class LineController extends BaseController&lt;Line, Integer&gt; {
90 90 map.put("status", ResponseCode.ERROR);
91 91 return map;
92 92 }
93   - return service.save(l);
  93 + return service.update(l);
94 94 }
95 95  
96 96 @RequestMapping(value ="/findById" , method = RequestMethod.GET)
... ...
src/main/java/com/bsth/repository/LineRepository.java
1 1 package com.bsth.repository;
2 2  
  3 +import java.util.Date;
3 4 import java.util.List;
  5 +import java.util.Map;
4 6  
  7 +import org.springframework.data.jpa.repository.Modifying;
5 8 import org.springframework.data.jpa.repository.Query;
6 9 import org.springframework.stereotype.Repository;
  10 +import org.springframework.transaction.annotation.Transactional;
7 11  
8 12 import com.bsth.entity.Line;
9 13  
... ... @@ -24,8 +28,7 @@ import com.bsth.entity.Line;
24 28 */
25 29 @Repository
26 30 public interface LineRepository extends BaseRepository<Line, Integer> {
27   -
28   -
  31 +
29 32 /**
30 33 * 获取线路编码
31 34 *
... ... @@ -33,15 +36,31 @@ public interface LineRepository extends BaseRepository&lt;Line, Integer&gt; {
33 36 */
34 37 @Query(value = " SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_line) k ", nativeQuery = true)
35 38 public long selectMaxIdToLineCode();
36   -
  39 +
37 40 @Query(value = " SELECT l FROM Line l where l.name like ?1")
38 41 List<Line> findLine(String line);
39   -
  42 +
40 43 public Line findByLineCode(String string);
41   -
  44 +
42 45 @Query(value = " SELECT l FROM Line l where l.company like %?1% and l.brancheCompany like %?2% and l.lineCode like ?3")
43 46 public List<Line> findLineBygsBm(String gsBm, String fgsBm, String line);
44 47  
45 48 @Query("SELECT L FROM Line L where L.destroy=0")
46 49 List<Line> findAllService();
  50 +
  51 +
  52 + @Modifying
  53 + @Query(value = "UPDATE Line l set l.name=?1 , l.company=?2, l.brancheCompany=?3, "
  54 + + "l.level=?4, l.nature=?5, l.startStationName=?6, l.endStationName=?7, l.startStationFirstTime=?8, "
  55 + + "l.startStationEndTime=?9, l.endStationFirstTime=?10, l.endStationEndTime=?11, l.linePlayType=?12, "
  56 + + "l.openDate=?13, l.es=?14, l.shortName=?15, l.shanghaiLinecode=?16, l.eqLinecode=?17, l.startPhone=?18, "
  57 + + "l.endPhone=?19, l.carSumNumber=?20, l.hvacCarNumber=?21, l.ordCarNumber=?22, l.history=?23, "
  58 + + "l.descriptions=?24, l.destroy=?25, l.supperLine=?26, l.spacGrade=?27, l.warrantCar=?28 where "
  59 + + "l.lineCode=?29 ")
  60 + public int update(String name, String company, String brancheCompany, String level, String nature,
  61 + String startStationName, String endStationName, String startStationFirstTime, String startStationEndTime,
  62 + String endStationFirstTime, String endStationEndTime, Integer linePlayType, Date openDate, String es,
  63 + String shortName, String shanghaiLinecode, String eqLinecode, String startPhone, String endPhone,
  64 + Integer carSumNumber, Integer hvacCarNumber, Integer ordCarNumber, String history, String descriptions,
  65 + Integer destroy, Integer supperLine, Integer spacGrade, Integer warrantCar, String lineCode);
47 66 }
... ...
src/main/java/com/bsth/service/LineService.java
... ... @@ -36,4 +36,6 @@ public interface LineService extends BaseService&lt;Line, Integer&gt; {
36 36 Line findById(Integer id);
37 37  
38 38 String lineCodeVerification(String lineCode);
  39 +
  40 + Map<String, Object> update(Line l);
39 41 }
... ...
src/main/java/com/bsth/service/impl/LineServiceImpl.java
... ... @@ -5,7 +5,9 @@ import java.util.Map;
5 5  
6 6 import org.springframework.beans.factory.annotation.Autowired;
7 7 import org.springframework.stereotype.Service;
  8 +import org.springframework.transaction.annotation.Transactional;
8 9  
  10 +import com.bsth.common.ResponseCode;
9 11 import com.bsth.entity.Line;
10 12 import com.bsth.repository.LineRepository;
11 13 import com.bsth.service.LineService;
... ... @@ -27,11 +29,11 @@ import com.bsth.service.LineService;
27 29 */
28 30  
29 31 @Service
30   -public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements LineService{
31   -
  32 +public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements LineService {
  33 +
32 34 @Autowired
33 35 private LineRepository repository;
34   -
  36 +
35 37 /**
36 38 * 获取线路编码
37 39 *
... ... @@ -41,7 +43,7 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L
41 43 // TODO Auto-generated method stub
42 44 return repository.selectMaxIdToLineCode();
43 45 }
44   -
  46 +
45 47 @Override
46 48 public Line findByLineCode(String lineCode) {
47 49 return repository.findByLineCode(lineCode);
... ... @@ -57,10 +59,31 @@ public class LineServiceImpl extends BaseServiceImpl&lt;Line, Integer&gt; implements L
57 59 public String lineCodeVerification(String lineCode) {
58 60 String state = "true";
59 61 Line line = repository.findByLineCode(lineCode);
60   - if(line != null){
  62 + if (line != null) {
61 63 state = "false";
62 64 }
63 65 return state;
64 66 }
  67 +
  68 + @Transactional
  69 + @Override
  70 + public Map<String, Object> update(Line l) {
  71 + Map<String, Object> map = new HashMap<>();
  72 +
  73 + int status = repository.update(l.getName(), l.getCompany(), l.getBrancheCompany(), l.getLevel(), l.getNature(),
  74 + l.getStartStationName(), l.getEndStationName(), l.getStartStationFirstTime(),
  75 + l.getStartStationEndTime(), l.getEndStationFirstTime(), l.getEndStationEndTime(), l.getLinePlayType(),
  76 + l.getOpenDate(), l.getEs(), l.getShortName(), l.getShanghaiLinecode(), l.getEqLinecode(),
  77 + l.getStartPhone(), l.getEndPhone(), l.getCarSumNumber(), l.getHvacCarNumber(), l.getOrdCarNumber(),
  78 + l.getHistory(), l.getDescriptions(), l.getDestroy(), l.getSupperLine(), l.getSpacGrade(),
  79 + l.getWarrantCar(), l.getLineCode());
  80 + if (status==1) {
  81 + map.put("status", ResponseCode.SUCCESS);
  82 + } else {
  83 + map.put("status", ResponseCode.ERROR);
  84 + }
  85 +
  86 + return map;
  87 + }
65 88  
66 89 }
... ...
src/main/resources/static/pages/base/line/js/line-edit-form.js
... ... @@ -9,7 +9,8 @@
9 9  
10 10  
11 11 !function(){
12   -
  12 + // 关闭左侧栏
  13 + if (!$('body').hasClass('page-sidebar-closed')) {$('.menu-toggler.sidebar-toggler').click();}
13 14 /** 开辟日期 日期控件 <format:日期控件时间格式;locale:语言> */
14 15 $('#openDateInput').datetimepicker({format : 'YYYY-MM-DD', locale: 'zh-cn'});
15 16 /** 起始站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */
... ...