Commit 4eebb4733c59f094a8e0bab88f7c47ca136e7c1d
1 parent
37f94c0d
Signed-off-by: YRF <YRF@DESKTOP-UNV37O6>
Showing
5 changed files
with
57 additions
and
12 deletions
src/main/java/com/bsth/controller/LineController.java
| @@ -90,7 +90,7 @@ public class LineController extends BaseController<Line, Integer> { | @@ -90,7 +90,7 @@ public class LineController extends BaseController<Line, Integer> { | ||
| 90 | map.put("status", ResponseCode.ERROR); | 90 | map.put("status", ResponseCode.ERROR); |
| 91 | return map; | 91 | return map; |
| 92 | } | 92 | } |
| 93 | - return service.save(l); | 93 | + return service.update(l); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | @RequestMapping(value ="/findById" , method = RequestMethod.GET) | 96 | @RequestMapping(value ="/findById" , method = RequestMethod.GET) |
src/main/java/com/bsth/repository/LineRepository.java
| 1 | package com.bsth.repository; | 1 | package com.bsth.repository; |
| 2 | 2 | ||
| 3 | +import java.util.Date; | ||
| 3 | import java.util.List; | 4 | import java.util.List; |
| 5 | +import java.util.Map; | ||
| 4 | 6 | ||
| 7 | +import org.springframework.data.jpa.repository.Modifying; | ||
| 5 | import org.springframework.data.jpa.repository.Query; | 8 | import org.springframework.data.jpa.repository.Query; |
| 6 | import org.springframework.stereotype.Repository; | 9 | import org.springframework.stereotype.Repository; |
| 10 | +import org.springframework.transaction.annotation.Transactional; | ||
| 7 | 11 | ||
| 8 | import com.bsth.entity.Line; | 12 | import com.bsth.entity.Line; |
| 9 | 13 | ||
| @@ -24,8 +28,7 @@ import com.bsth.entity.Line; | @@ -24,8 +28,7 @@ import com.bsth.entity.Line; | ||
| 24 | */ | 28 | */ |
| 25 | @Repository | 29 | @Repository |
| 26 | public interface LineRepository extends BaseRepository<Line, Integer> { | 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<Line, Integer> { | @@ -33,15 +36,31 @@ public interface LineRepository extends BaseRepository<Line, Integer> { | ||
| 33 | */ | 36 | */ |
| 34 | @Query(value = " SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_line) k ", nativeQuery = true) | 37 | @Query(value = " SELECT IFNULL(num,0) as maxId from (SELECT MAX(id) as num FROM bsth_c_line) k ", nativeQuery = true) |
| 35 | public long selectMaxIdToLineCode(); | 38 | public long selectMaxIdToLineCode(); |
| 36 | - | 39 | + |
| 37 | @Query(value = " SELECT l FROM Line l where l.name like ?1") | 40 | @Query(value = " SELECT l FROM Line l where l.name like ?1") |
| 38 | List<Line> findLine(String line); | 41 | List<Line> findLine(String line); |
| 39 | - | 42 | + |
| 40 | public Line findByLineCode(String string); | 43 | public Line findByLineCode(String string); |
| 41 | - | 44 | + |
| 42 | @Query(value = " SELECT l FROM Line l where l.company like %?1% and l.brancheCompany like %?2% and l.lineCode like ?3") | 45 | @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); | 46 | public List<Line> findLineBygsBm(String gsBm, String fgsBm, String line); |
| 44 | 47 | ||
| 45 | @Query("SELECT L FROM Line L where L.destroy=0") | 48 | @Query("SELECT L FROM Line L where L.destroy=0") |
| 46 | List<Line> findAllService(); | 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<Line, Integer> { | @@ -36,4 +36,6 @@ public interface LineService extends BaseService<Line, Integer> { | ||
| 36 | Line findById(Integer id); | 36 | Line findById(Integer id); |
| 37 | 37 | ||
| 38 | String lineCodeVerification(String lineCode); | 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,7 +5,9 @@ import java.util.Map; | ||
| 5 | 5 | ||
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | import org.springframework.stereotype.Service; | 7 | import org.springframework.stereotype.Service; |
| 8 | +import org.springframework.transaction.annotation.Transactional; | ||
| 8 | 9 | ||
| 10 | +import com.bsth.common.ResponseCode; | ||
| 9 | import com.bsth.entity.Line; | 11 | import com.bsth.entity.Line; |
| 10 | import com.bsth.repository.LineRepository; | 12 | import com.bsth.repository.LineRepository; |
| 11 | import com.bsth.service.LineService; | 13 | import com.bsth.service.LineService; |
| @@ -27,11 +29,11 @@ import com.bsth.service.LineService; | @@ -27,11 +29,11 @@ import com.bsth.service.LineService; | ||
| 27 | */ | 29 | */ |
| 28 | 30 | ||
| 29 | @Service | 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 | @Autowired | 34 | @Autowired |
| 33 | private LineRepository repository; | 35 | private LineRepository repository; |
| 34 | - | 36 | + |
| 35 | /** | 37 | /** |
| 36 | * 获取线路编码 | 38 | * 获取线路编码 |
| 37 | * | 39 | * |
| @@ -41,7 +43,7 @@ public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements L | @@ -41,7 +43,7 @@ public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements L | ||
| 41 | // TODO Auto-generated method stub | 43 | // TODO Auto-generated method stub |
| 42 | return repository.selectMaxIdToLineCode(); | 44 | return repository.selectMaxIdToLineCode(); |
| 43 | } | 45 | } |
| 44 | - | 46 | + |
| 45 | @Override | 47 | @Override |
| 46 | public Line findByLineCode(String lineCode) { | 48 | public Line findByLineCode(String lineCode) { |
| 47 | return repository.findByLineCode(lineCode); | 49 | return repository.findByLineCode(lineCode); |
| @@ -57,10 +59,31 @@ public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements L | @@ -57,10 +59,31 @@ public class LineServiceImpl extends BaseServiceImpl<Line, Integer> implements L | ||
| 57 | public String lineCodeVerification(String lineCode) { | 59 | public String lineCodeVerification(String lineCode) { |
| 58 | String state = "true"; | 60 | String state = "true"; |
| 59 | Line line = repository.findByLineCode(lineCode); | 61 | Line line = repository.findByLineCode(lineCode); |
| 60 | - if(line != null){ | 62 | + if (line != null) { |
| 61 | state = "false"; | 63 | state = "false"; |
| 62 | } | 64 | } |
| 63 | return state; | 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,7 +9,8 @@ | ||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | !function(){ | 11 | !function(){ |
| 12 | - | 12 | + // 关闭左侧栏 |
| 13 | + if (!$('body').hasClass('page-sidebar-closed')) {$('.menu-toggler.sidebar-toggler').click();} | ||
| 13 | /** 开辟日期 日期控件 <format:日期控件时间格式;locale:语言> */ | 14 | /** 开辟日期 日期控件 <format:日期控件时间格式;locale:语言> */ |
| 14 | $('#openDateInput').datetimepicker({format : 'YYYY-MM-DD', locale: 'zh-cn'}); | 15 | $('#openDateInput').datetimepicker({format : 'YYYY-MM-DD', locale: 'zh-cn'}); |
| 15 | /** 起始站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | 16 | /** 起始站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */ |