作者 shenhailong

。。。。

... ... @@ -197,9 +197,16 @@ public class SDCARGONAMEController {
public ResponseModel delete(String ids) {
ResponseModel model = new ResponseModel();
try {
sdbigtypeService.bigTypeDelete(ids);
model.setStatus(200);
model.setMsg(HttpJsonMsg.SUCCESS);
if (sdbigtypeService.bigTypeDelete(ids) == 0){
model.setStatus(200);
model.setMsg(HttpJsonMsg.SUCCESS);
}else {
model.setStatus(201);
model.setMsg("请先删除该类下包含的二级类");
}
} catch (Exception e) {
e.printStackTrace();
model.setStatus(500);
... ... @@ -224,15 +231,11 @@ public class SDCARGONAMEController {
pageForm.setSearchParams(searchParams);
// pageForm.parseData(sdtwotypeService.getPage(pageForm));
List<SDTWOTYPEEntity> sdtwotypeEntities = sdtwotypeService.twoFindAll();
// pageForm.parseData();
DataGrid<SDTWOTYPEEntity> hzshipperinformationEntityDataGrid = pageForm.getData();
List<SdTwoTypeVo> rows = new ArrayList<>();
// if (CollectionUtils.isNotEmpty(hzshipperinformationEntityDataGrid.getRows())){
for (SDTWOTYPEEntity sd: sdtwotypeEntities){
SdTwoTypeVo sdTwoTypeVo = new SdTwoTypeVo();
... ... @@ -250,7 +253,6 @@ public class SDCARGONAMEController {
DataGrid<SdTwoTypeVo> vos = new DataGrid<>();
vos.setRows(rows);
// vos.setTotal(hzshipperinformationEntityDataGrid.getTotal());
return vos;
}
... ...
... ... @@ -44,4 +44,7 @@ public interface SDTWOTYPERepository extends PagingAndSortingRepository<SDTWOTYP
@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)
List<SDTWOTYPEEntity> twoFindAll();
@Query(value = "select count(*) from SD_TWO_TYPE where BIG_TYPE_ID=?1", nativeQuery = true)
int counttwotype(Long id);
}
... ...
... ... @@ -5,6 +5,7 @@ import com.agent.entity.agent.ManifestEntity;
import com.agent.entity.agent.SecurityDeclarationEntity;
import com.agent.entity.system.SDBIGTYPEEntity;
import com.agent.repository.system.SDBIGTYPERepository;
import com.agent.repository.system.SDTWOTYPERepository;
import com.agent.service.BasicService;
import com.google.common.base.Splitter;
import com.plugin.easyui.EasyPage;
... ... @@ -27,6 +28,9 @@ public class SDBIGTYPEService extends BasicService<SDBIGTYPEEntity> {
@Autowired
SDBIGTYPERepository sdbigtypeRepository;
@Autowired
SDTWOTYPERepository sdtwotypeRepository;
/**
* 分页查询
*
... ... @@ -58,14 +62,26 @@ public class SDBIGTYPEService extends BasicService<SDBIGTYPEEntity> {
}
@Transactional
public void bigTypeDelete(String ids) {
public int bigTypeDelete(String ids) {
try {
List<String> list = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(ids);
int i = 0;
// 查询 是否还有二级类 存在不可以删除
for (String id : list) {
sdbigtypeRepository.bigTypeDelete(Long.valueOf(id));
i+= sdtwotypeRepository.counttwotype(Long.valueOf(id));
}
if (i == 0){
for (String id : list) {
sdbigtypeRepository.bigTypeDelete(Long.valueOf(id));
}
}else {
return 1;
}
return 0;
}catch (Exception e){
e.printStackTrace();
return 1;
}
}
... ...
... ... @@ -201,7 +201,7 @@
window.location.href="<%=basePath %>type/list";
})
}else{
layer.open({content:"<spring:message code="opt.delfailed" />!"});
layer.open({content:"请先删除该类下所有二级类名称!"});
}
},"json");
... ...
<%--
Created by IntelliJ IDEA.
User: shenhailong
Date: 2019/11/5
Time: 14:44
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
</body>
</html>
... ...