From 8d87e04c9e5fb2fd54b25b045af6c60bf5641027 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 29 十一月 2024 14:54:26 +0800
Subject: [PATCH] 导出升级结果为excel文件的一个bug
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java | 84 ++++++++++++++++++++++--------------------
1 files changed, 44 insertions(+), 40 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
index d89f165..053f427 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
@@ -67,12 +67,13 @@
@SsoAop()
public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){
try {
- QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
- if(res.itemTotal != null && res.itemTotal > 0) {
- return BaseResponseUtils.buildSuccess(res);
- }else {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage());
- }
+ //QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
+ //if(res.itemTotal != null && res.itemTotal > 0) {
+ // return BaseResponseUtils.buildSuccess(res);
+ //}else {
+ // return BaseResponseUtils.buildSuccess(ProjectResultCode.NO_DIVIDES.getMessage());
+ //}
+ return BaseResponseUtils.buildSuccess(divideSv.getDivides(vo));
} catch (Exception e) {
log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e);
return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -101,7 +102,7 @@
if(res != null) {
return BaseResponseUtils.buildSuccess(res);
}else {
- return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_DIVIDES.getMessage());
}
} catch (Exception e) {
log.error("鏌ヨ鍐滄埛寮傚父", e);
@@ -129,32 +130,33 @@
@SsoAop()
public BaseResponse<Boolean> add(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
// 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛�
Long villageId = po.getVillageId();
- /**
- * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
- */
- Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
- if(map_districts.size() <= 0) {
- return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎");
- }
-
PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po);
- Long countryId = Long.parseLong(map_districts.get("countryId").toString());
- Long townId = Long.parseLong(map_districts.get("townId").toString());
- prDivide.setCountyid(countryId);
- prDivide.setTownid(townId);
+ if (villageId!=null){
+ /**
+ * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
+ */
+ Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
+ if(map_districts.size() <= 0) {
+ return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎");
+ }
+ Long countryId = Long.parseLong(map_districts.get("countryId").toString());
+ Long townId = Long.parseLong(map_districts.get("townId").toString());
+ prDivide.setCountyid(countryId);
+ prDivide.setTownid(townId);
+ }
Date operateTime = new Date();
prDivide.setOperatedt(operateTime);
prDivide.setDeleted((byte)0);
Integer rec = Optional.ofNullable(divideSv.addDivide(prDivide)).orElse(0);
if(rec == 0) {
- return BaseResponseUtils.buildFail(ProjectResultCode.DIVIDE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DIVIDE_FAIL.getMessage());
}
return BaseResponseUtils.buildSuccess(true) ;
}
@@ -185,7 +187,7 @@
try {
Integer res = Optional.ofNullable(divideSv.deleteDivideById(id)).orElse(0);
if(res == 0)
- return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
+ return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
return BaseResponseUtils.buildSuccess(true);
} catch (Exception e) {
@@ -212,34 +214,36 @@
@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
@Transactional(rollbackFor = Exception.class)
@SsoAop()
- public BaseResponse<Boolean> update(@RequestBody @Valid PrDivide po, BindingResult bindingResult){
+ public BaseResponse<Boolean> update(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){
if(bindingResult != null && bindingResult.hasErrors()){
- return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
}
// 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛�
- Long villageId = po.getVillageid();
+ Long villageId = po.getVillageId();
- /**
- * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
- */
- Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
- if(map_districts.size() <= 0) {
- return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎");
+ PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po);
+
+ if (villageId!=null){
+ /**
+ * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭�
+ */
+ Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap());
+ if(map_districts.size() <= 0) {
+ return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎");
+ }
+ Long countryId = Long.parseLong(map_districts.get("countryId").toString());
+ Long townId = Long.parseLong(map_districts.get("townId").toString());
+ prDivide.setCountyid(countryId);
+ prDivide.setTownid(townId);
}
- Long countryId = Long.parseLong(map_districts.get("countryId").toString());
- Long townId = Long.parseLong(map_districts.get("townId").toString());
-
- po.setCountyid(countryId);
- po.setTownid(townId);
-
Date operateTime = new Date();
- po.setOperatedt(operateTime);
+ prDivide.setOperatedt(operateTime);
- Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(po)).orElse(0);
+ Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(prDivide)).orElse(0);
if(rec == 0) {
- return BaseResponseUtils.buildFail("鍒嗘按鎴夸慨鏀瑰け璐�");
+ return BaseResponseUtils.buildErrorMsg("鍒嗘按鎴夸慨鏀瑰け璐�");
}
return BaseResponseUtils.buildSuccess(true) ;
}
--
Gitblit v1.8.0