作者 shenhailong

。。。。

@@ -197,9 +197,16 @@ public class SDCARGONAMEController { @@ -197,9 +197,16 @@ public class SDCARGONAMEController {
197 public ResponseModel delete(String ids) { 197 public ResponseModel delete(String ids) {
198 ResponseModel model = new ResponseModel(); 198 ResponseModel model = new ResponseModel();
199 try { 199 try {
200 - sdbigtypeService.bigTypeDelete(ids);  
201 - model.setStatus(200);  
202 - model.setMsg(HttpJsonMsg.SUCCESS); 200 +
  201 + if (sdbigtypeService.bigTypeDelete(ids) == 0){
  202 + model.setStatus(200);
  203 + model.setMsg(HttpJsonMsg.SUCCESS);
  204 + }else {
  205 + model.setStatus(201);
  206 + model.setMsg("请先删除该类下包含的二级类");
  207 + }
  208 +
  209 +
203 } catch (Exception e) { 210 } catch (Exception e) {
204 e.printStackTrace(); 211 e.printStackTrace();
205 model.setStatus(500); 212 model.setStatus(500);
@@ -224,15 +231,11 @@ public class SDCARGONAMEController { @@ -224,15 +231,11 @@ public class SDCARGONAMEController {
224 231
225 pageForm.setSearchParams(searchParams); 232 pageForm.setSearchParams(searchParams);
226 233
227 -// pageForm.parseData(sdtwotypeService.getPage(pageForm));  
228 List<SDTWOTYPEEntity> sdtwotypeEntities = sdtwotypeService.twoFindAll(); 234 List<SDTWOTYPEEntity> sdtwotypeEntities = sdtwotypeService.twoFindAll();
229 -// pageForm.parseData();  
230 -  
231 DataGrid<SDTWOTYPEEntity> hzshipperinformationEntityDataGrid = pageForm.getData(); 235 DataGrid<SDTWOTYPEEntity> hzshipperinformationEntityDataGrid = pageForm.getData();
232 236
233 List<SdTwoTypeVo> rows = new ArrayList<>(); 237 List<SdTwoTypeVo> rows = new ArrayList<>();
234 238
235 -// if (CollectionUtils.isNotEmpty(hzshipperinformationEntityDataGrid.getRows())){  
236 for (SDTWOTYPEEntity sd: sdtwotypeEntities){ 239 for (SDTWOTYPEEntity sd: sdtwotypeEntities){
237 SdTwoTypeVo sdTwoTypeVo = new SdTwoTypeVo(); 240 SdTwoTypeVo sdTwoTypeVo = new SdTwoTypeVo();
238 241
@@ -250,7 +253,6 @@ public class SDCARGONAMEController { @@ -250,7 +253,6 @@ public class SDCARGONAMEController {
250 253
251 DataGrid<SdTwoTypeVo> vos = new DataGrid<>(); 254 DataGrid<SdTwoTypeVo> vos = new DataGrid<>();
252 vos.setRows(rows); 255 vos.setRows(rows);
253 -// vos.setTotal(hzshipperinformationEntityDataGrid.getTotal());  
254 return vos; 256 return vos;
255 } 257 }
256 258
@@ -44,4 +44,7 @@ public interface SDTWOTYPERepository extends PagingAndSortingRepository<SDTWOTYP @@ -44,4 +44,7 @@ public interface SDTWOTYPERepository extends PagingAndSortingRepository<SDTWOTYP
44 44
45 @Query(value = "select * from (select stt.*, row_number() over(partition by stt.TWO_TYPE_NAME order by 1) rn from SD_TWO_TYPE stt) stt where stt.rn = 1 ORDER BY stt.BIG_TYPE_ID", nativeQuery = true) 45 @Query(value = "select * from (select stt.*, row_number() over(partition by stt.TWO_TYPE_NAME order by 1) rn from SD_TWO_TYPE stt) stt where stt.rn = 1 ORDER BY stt.BIG_TYPE_ID", nativeQuery = true)
46 List<SDTWOTYPEEntity> twoFindAll(); 46 List<SDTWOTYPEEntity> twoFindAll();
  47 +
  48 + @Query(value = "select count(*) from SD_TWO_TYPE where BIG_TYPE_ID=?1", nativeQuery = true)
  49 + int counttwotype(Long id);
47 } 50 }
@@ -5,6 +5,7 @@ import com.agent.entity.agent.ManifestEntity; @@ -5,6 +5,7 @@ import com.agent.entity.agent.ManifestEntity;
5 import com.agent.entity.agent.SecurityDeclarationEntity; 5 import com.agent.entity.agent.SecurityDeclarationEntity;
6 import com.agent.entity.system.SDBIGTYPEEntity; 6 import com.agent.entity.system.SDBIGTYPEEntity;
7 import com.agent.repository.system.SDBIGTYPERepository; 7 import com.agent.repository.system.SDBIGTYPERepository;
  8 +import com.agent.repository.system.SDTWOTYPERepository;
8 import com.agent.service.BasicService; 9 import com.agent.service.BasicService;
9 import com.google.common.base.Splitter; 10 import com.google.common.base.Splitter;
10 import com.plugin.easyui.EasyPage; 11 import com.plugin.easyui.EasyPage;
@@ -27,6 +28,9 @@ public class SDBIGTYPEService extends BasicService<SDBIGTYPEEntity> { @@ -27,6 +28,9 @@ public class SDBIGTYPEService extends BasicService<SDBIGTYPEEntity> {
27 @Autowired 28 @Autowired
28 SDBIGTYPERepository sdbigtypeRepository; 29 SDBIGTYPERepository sdbigtypeRepository;
29 30
  31 + @Autowired
  32 + SDTWOTYPERepository sdtwotypeRepository;
  33 +
30 /** 34 /**
31 * 分页查询 35 * 分页查询
32 * 36 *
@@ -58,14 +62,26 @@ public class SDBIGTYPEService extends BasicService<SDBIGTYPEEntity> { @@ -58,14 +62,26 @@ public class SDBIGTYPEService extends BasicService<SDBIGTYPEEntity> {
58 } 62 }
59 63
60 @Transactional 64 @Transactional
61 - public void bigTypeDelete(String ids) { 65 + public int bigTypeDelete(String ids) {
62 try { 66 try {
63 List<String> list = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(ids); 67 List<String> list = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(ids);
  68 + int i = 0;
  69 + // 查询 是否还有二级类 存在不可以删除
64 for (String id : list) { 70 for (String id : list) {
65 - sdbigtypeRepository.bigTypeDelete(Long.valueOf(id)); 71 + i+= sdtwotypeRepository.counttwotype(Long.valueOf(id));
  72 +
  73 + }
  74 + if (i == 0){
  75 + for (String id : list) {
  76 + sdbigtypeRepository.bigTypeDelete(Long.valueOf(id));
  77 + }
  78 + }else {
  79 + return 1;
66 } 80 }
  81 + return 0;
67 }catch (Exception e){ 82 }catch (Exception e){
68 e.printStackTrace(); 83 e.printStackTrace();
  84 + return 1;
69 } 85 }
70 86
71 } 87 }
@@ -201,7 +201,7 @@ @@ -201,7 +201,7 @@
201 window.location.href="<%=basePath %>type/list"; 201 window.location.href="<%=basePath %>type/list";
202 }) 202 })
203 }else{ 203 }else{
204 - layer.open({content:"<spring:message code="opt.delfailed" />!"}); 204 + layer.open({content:"请先删除该类下所有二级类名称!"});
205 } 205 }
206 },"json"); 206 },"json");
207 207
  1 +<%--
  2 + Created by IntelliJ IDEA.
  3 + User: shenhailong
  4 + Date: 2019/11/5
  5 + Time: 14:44
  6 + To change this template use File | Settings | File Templates.
  7 +--%>
  8 +<%@ page contentType="text/html;charset=UTF-8" language="java" %>
  9 +<html>
  10 +<head>
  11 + <title>Title</title>
  12 +</head>
  13 +<body>
  14 +
  15 +</body>
  16 +</html>