正在显示
1 个修改的文件
包含
33 行增加
和
6 行删除
@@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; | @@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; | ||
4 | import com.github.pagehelper.PageInfo; | 4 | import com.github.pagehelper.PageInfo; |
5 | import com.sunyo.wlpt.vehicle.manage.common.Common; | 5 | import com.sunyo.wlpt.vehicle.manage.common.Common; |
6 | import com.sunyo.wlpt.vehicle.manage.domain.LandRoadVeRecord; | 6 | import com.sunyo.wlpt.vehicle.manage.domain.LandRoadVeRecord; |
7 | +import com.sunyo.wlpt.vehicle.manage.mapper.LandRoadVeRecordMapper; | ||
7 | import com.sunyo.wlpt.vehicle.manage.response.ResultJson; | 8 | import com.sunyo.wlpt.vehicle.manage.response.ResultJson; |
8 | import com.sunyo.wlpt.vehicle.manage.utils.IdUtils; | 9 | import com.sunyo.wlpt.vehicle.manage.utils.IdUtils; |
9 | import io.netty.util.internal.StringUtil; | 10 | import io.netty.util.internal.StringUtil; |
@@ -15,8 +16,7 @@ import com.sunyo.wlpt.vehicle.manage.domain.LandRoadTrailerRecord; | @@ -15,8 +16,7 @@ import com.sunyo.wlpt.vehicle.manage.domain.LandRoadTrailerRecord; | ||
15 | import com.sunyo.wlpt.vehicle.manage.mapper.LandRoadTrailerRecordMapper; | 16 | import com.sunyo.wlpt.vehicle.manage.mapper.LandRoadTrailerRecordMapper; |
16 | import com.sunyo.wlpt.vehicle.manage.service.LandRoadTrailerRecordService; | 17 | import com.sunyo.wlpt.vehicle.manage.service.LandRoadTrailerRecordService; |
17 | 18 | ||
18 | -import java.util.Date; | ||
19 | -import java.util.List; | 19 | +import java.util.*; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author 子诚 | 22 | * @author 子诚 |
@@ -29,8 +29,13 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | @@ -29,8 +29,13 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | ||
29 | @Resource | 29 | @Resource |
30 | private LandRoadTrailerRecordMapper landRoadTrailerRecordMapper; | 30 | private LandRoadTrailerRecordMapper landRoadTrailerRecordMapper; |
31 | 31 | ||
32 | + @Resource | ||
33 | + private LandRoadVeRecordMapper landRoadVeRecordMapper; | ||
34 | + | ||
32 | /** | 35 | /** |
33 | * 删除 | 36 | * 删除 |
37 | + * <p> | ||
38 | + * 删除挂车时,要确定该挂车是否被车辆是挂载?没有被挂载,可以被删除 | ||
34 | * | 39 | * |
35 | * @param id primaryKey | 40 | * @param id primaryKey |
36 | * @return | 41 | * @return |
@@ -38,6 +43,12 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | @@ -38,6 +43,12 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | ||
38 | @Override | 43 | @Override |
39 | public ResultJson deleteByPrimaryKey(String id) | 44 | public ResultJson deleteByPrimaryKey(String id) |
40 | { | 45 | { |
46 | + String trailerLicenseNo = landRoadTrailerRecordMapper.selectByPrimaryKey(id).getTrailerLicenseNo(); | ||
47 | + List<LandRoadVeRecord> landRoadVeRecordList = landRoadVeRecordMapper.selectByTrailerLicenseNo(trailerLicenseNo); | ||
48 | + if (landRoadVeRecordList.size() > 0) { | ||
49 | + return ResultJson.error("500", "该挂车已经被车牌号为:" + landRoadVeRecordList.get(0).getDomesticLisenceNo() | ||
50 | + + "的车辆所挂载,无法删除;"); | ||
51 | + } | ||
41 | return landRoadTrailerRecordMapper.deleteByPrimaryKey(id) > 0 | 52 | return landRoadTrailerRecordMapper.deleteByPrimaryKey(id) > 0 |
42 | ? ResultJson.success("200", "删除挂车信息,成功") | 53 | ? ResultJson.success("200", "删除挂车信息,成功") |
43 | : ResultJson.error("500", "删除挂车信息失败"); | 54 | : ResultJson.error("500", "删除挂车信息失败"); |
@@ -45,6 +56,7 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | @@ -45,6 +56,7 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | ||
45 | 56 | ||
46 | /** | 57 | /** |
47 | * 批量删除 | 58 | * 批量删除 |
59 | + * 判断每一个id对应的挂车是否被使用 | ||
48 | * | 60 | * |
49 | * @param ids 被删除的id,多个以,相隔的字符串 | 61 | * @param ids 被删除的id,多个以,相隔的字符串 |
50 | * @return | 62 | * @return |
@@ -52,10 +64,25 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | @@ -52,10 +64,25 @@ public class LandRoadTrailerRecordServiceImpl implements LandRoadTrailerRecordSe | ||
52 | @Override | 64 | @Override |
53 | public ResultJson batchRemoveByIds(String ids) | 65 | public ResultJson batchRemoveByIds(String ids) |
54 | { | 66 | { |
55 | - String[] idList = ids.split(","); | ||
56 | - return landRoadTrailerRecordMapper.batchRemoveByIds(idList) > 0 | ||
57 | - ? ResultJson.success("200", "批量删除挂车信息,成功") | ||
58 | - : ResultJson.error("500", "批量删除挂车信息,失败"); | 67 | + String resultMsg = ""; |
68 | + int index = 0; | ||
69 | + | ||
70 | + String[] IdList = ids.split(","); | ||
71 | + for (int i = 0; i < IdList.length; i++) { | ||
72 | + String id = IdList[i]; | ||
73 | + String trailerLicenseNo = landRoadTrailerRecordMapper.selectByPrimaryKey(id).getTrailerLicenseNo(); | ||
74 | + List<LandRoadVeRecord> landRoadVeRecordList = landRoadVeRecordMapper.selectByTrailerLicenseNo(trailerLicenseNo); | ||
75 | + if (landRoadVeRecordList.size() > 0) { | ||
76 | + String errorMsg = "挂车(" + trailerLicenseNo + ")已经被车牌号为:" + landRoadVeRecordList.get(0).getDomesticLisenceNo() | ||
77 | + + "的车辆所挂载,无法删除;"; | ||
78 | + resultMsg += errorMsg; | ||
79 | + continue; | ||
80 | + } | ||
81 | + index += landRoadTrailerRecordMapper.deleteByPrimaryKey(id); | ||
82 | + } | ||
83 | + return index > 0 | ||
84 | + ? ResultJson.success("200", "批量删除挂车信息,成功!" + resultMsg) | ||
85 | + : ResultJson.error("500", "批量删除挂车信息,失败" + resultMsg); | ||
59 | } | 86 | } |
60 | 87 | ||
61 | @Override | 88 | @Override |
-
请 注册 或 登录 后发表评论