作者 王勇

提交git做备份,为稍后修改做铺垫

@@ -43,6 +43,12 @@ public class YardController { @@ -43,6 +43,12 @@ public class YardController {
43 return yardService.selectListByPage(yard, pageNum, pageSize); 43 return yardService.selectListByPage(yard, pageNum, pageSize);
44 } 44 }
45 45
  46 + @GetMapping("/list")
  47 + public ResultJson selectList()
  48 + {
  49 + return yardService.selectList();
  50 + }
  51 +
46 /** 52 /**
47 * 删除 53 * 删除
48 * 条件:id 54 * 条件:id
1 package com.sunyo.wlpt.station.manage.mapper; 1 package com.sunyo.wlpt.station.manage.mapper;
2 2
3 import com.sunyo.wlpt.station.manage.domain.Yard; 3 import com.sunyo.wlpt.station.manage.domain.Yard;
  4 +import com.sunyo.wlpt.station.manage.response.ResultJson;
4 import org.apache.ibatis.annotations.Mapper; 5 import org.apache.ibatis.annotations.Mapper;
  6 +import org.apache.ibatis.annotations.Param;
5 7
6 import java.util.List; 8 import java.util.List;
7 9
@@ -68,4 +70,19 @@ public interface YardMapper { @@ -68,4 +70,19 @@ public interface YardMapper {
68 * @return 70 * @return
69 */ 71 */
70 List<Yard> selectListByPage(Yard yard); 72 List<Yard> selectListByPage(Yard yard);
  73 +
  74 + /**
  75 + * 查询全部场站列表
  76 + *
  77 + * @return
  78 + */
  79 + List<Yard> selectList();
  80 +
  81 + /**
  82 + * 根据场站名称查询场站信息
  83 + *
  84 + * @param name 场站名称
  85 + * @return
  86 + */
  87 + Yard selectByYardName(@Param("name") String name);
71 } 88 }
@@ -68,4 +68,11 @@ public interface YardService { @@ -68,4 +68,11 @@ public interface YardService {
68 * @return 68 * @return
69 */ 69 */
70 ResultJson selectListByPage(Yard yard, Integer pageNum, Integer pageSize); 70 ResultJson selectListByPage(Yard yard, Integer pageNum, Integer pageSize);
  71 +
  72 + /**
  73 + * 查询全部场站
  74 + *
  75 + * @return
  76 + */
  77 + ResultJson selectList();
71 } 78 }
@@ -3,6 +3,7 @@ package com.sunyo.wlpt.station.manage.service.impl; @@ -3,6 +3,7 @@ package com.sunyo.wlpt.station.manage.service.impl;
3 import com.github.pagehelper.PageHelper; 3 import com.github.pagehelper.PageHelper;
4 import com.github.pagehelper.PageInfo; 4 import com.github.pagehelper.PageInfo;
5 import com.sunyo.wlpt.station.manage.domain.Yard; 5 import com.sunyo.wlpt.station.manage.domain.Yard;
  6 +import com.sunyo.wlpt.station.manage.mapper.YardMapper;
6 import com.sunyo.wlpt.station.manage.response.ResultJson; 7 import com.sunyo.wlpt.station.manage.response.ResultJson;
7 import com.sunyo.wlpt.station.manage.utils.IdUtils; 8 import com.sunyo.wlpt.station.manage.utils.IdUtils;
8 import org.springframework.stereotype.Service; 9 import org.springframework.stereotype.Service;
@@ -25,6 +26,8 @@ public class BayonetServiceImpl implements BayonetService { @@ -25,6 +26,8 @@ public class BayonetServiceImpl implements BayonetService {
25 26
26 @Resource 27 @Resource
27 private BayonetMapper bayonetMapper; 28 private BayonetMapper bayonetMapper;
  29 + @Resource
  30 + private YardMapper yardMapper;
28 31
29 /** 32 /**
30 * 删除卡口信息 33 * 删除卡口信息
@@ -55,6 +58,8 @@ public class BayonetServiceImpl implements BayonetService { @@ -55,6 +58,8 @@ public class BayonetServiceImpl implements BayonetService {
55 @Override 58 @Override
56 public ResultJson insertSelective(Bayonet bayonet) 59 public ResultJson insertSelective(Bayonet bayonet)
57 { 60 {
  61 + Yard yard = yardMapper.selectByYardName(bayonet.getStationName());
  62 + bayonet.setYardId(yard.getId());
58 bayonet.setId(IdUtils.generateId()); 63 bayonet.setId(IdUtils.generateId());
59 return bayonetMapper.insertSelective(bayonet) > 0 64 return bayonetMapper.insertSelective(bayonet) > 0
60 ? ResultJson.success("200", "新增卡口信息,成功") 65 ? ResultJson.success("200", "新增卡口信息,成功")
@@ -76,6 +81,8 @@ public class BayonetServiceImpl implements BayonetService { @@ -76,6 +81,8 @@ public class BayonetServiceImpl implements BayonetService {
76 @Override 81 @Override
77 public ResultJson updateByPrimaryKeySelective(Bayonet bayonet) 82 public ResultJson updateByPrimaryKeySelective(Bayonet bayonet)
78 { 83 {
  84 + Yard yard = yardMapper.selectByYardName(bayonet.getStationName());
  85 + bayonet.setYardId(yard.getId());
79 return bayonetMapper.updateByPrimaryKeySelective(bayonet) > 0 86 return bayonetMapper.updateByPrimaryKeySelective(bayonet) > 0
80 ? ResultJson.success("200", "编辑卡口信息,成功") 87 ? ResultJson.success("200", "编辑卡口信息,成功")
81 : ResultJson.error("500", "编辑卡口信息,失败"); 88 : ResultJson.error("500", "编辑卡口信息,失败");
@@ -100,6 +107,11 @@ public class BayonetServiceImpl implements BayonetService { @@ -100,6 +107,11 @@ public class BayonetServiceImpl implements BayonetService {
100 { 107 {
101 PageHelper.startPage(pageNum, pageSize); 108 PageHelper.startPage(pageNum, pageSize);
102 List<Bayonet> bayonetList = bayonetMapper.selectListByPage(bayonet); 109 List<Bayonet> bayonetList = bayonetMapper.selectListByPage(bayonet);
  110 +
  111 + bayonetList.stream().parallel().forEach(item -> {
  112 + item.setStationName(yardMapper.selectByPrimaryKey(item.getYardId()).getName());
  113 + });
  114 +
103 PageInfo<Bayonet> pageInfo = new PageInfo<>(bayonetList); 115 PageInfo<Bayonet> pageInfo = new PageInfo<>(bayonetList);
104 return pageInfo.getTotal() >= 0 116 return pageInfo.getTotal() >= 0
105 ? ResultJson.success("200", "查询卡口信息列表,成功!", pageInfo) 117 ? ResultJson.success("200", "查询卡口信息列表,成功!", pageInfo)
@@ -98,4 +98,13 @@ public class YardServiceImpl implements YardService { @@ -98,4 +98,13 @@ public class YardServiceImpl implements YardService {
98 ? ResultJson.success("200", "查询场站信息列表,成功!", pageInfo) 98 ? ResultJson.success("200", "查询场站信息列表,成功!", pageInfo)
99 : ResultJson.error("500", "查询场站信息列表,失败!"); 99 : ResultJson.error("500", "查询场站信息列表,失败!");
100 } 100 }
  101 +
  102 + @Override
  103 + public ResultJson selectList()
  104 + {
  105 + List<Yard> yards = yardMapper.selectList();
  106 + return yards.size()>=0
  107 + ? ResultJson.success("200", "查询场站信息列表,成功!", yards)
  108 + : ResultJson.error("500", "查询场站信息列表,失败!");
  109 + }
101 } 110 }
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 <if test="stationName != null and stationName != ''"> 65 <if test="stationName != null and stationName != ''">
66 and y.name = #{stationName,jdbcType=VARCHAR} 66 and y.name = #{stationName,jdbcType=VARCHAR}
67 </if> 67 </if>
68 - and b.yard_id = y.stationId 68 + and b.yard_id = y.id
69 </where> 69 </where>
70 </select> 70 </select>
71 71
@@ -30,6 +30,18 @@ @@ -30,6 +30,18 @@
30 where id = #{id,jdbcType=VARCHAR} 30 where id = #{id,jdbcType=VARCHAR}
31 </select> 31 </select>
32 32
  33 +<select id="selectByYardName" parameterType="java.lang.String" resultMap="BaseResultMap">
  34 + select
  35 + <include refid="Base_Column_List"/>
  36 + from yard
  37 + where name = #{name,jdbcType=VARCHAR}
  38 +</select>
  39 +
  40 +<select id="selectList" parameterType="com.sunyo.wlpt.station.manage.domain.Yard" resultMap="BaseResultMap">
  41 + select
  42 + <include refid="Base_Column_List"/>
  43 + from yard
  44 +</select>
33 <select id="selectListByPage" parameterType="com.sunyo.wlpt.station.manage.domain.Yard" resultMap="BaseResultMap"> 45 <select id="selectListByPage" parameterType="com.sunyo.wlpt.station.manage.domain.Yard" resultMap="BaseResultMap">
34 select 46 select
35 <include refid="Base_Column_List"/> 47 <include refid="Base_Column_List"/>