diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetLaborController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetLaborController.java
index 1e16f750..bc5636c2 100644
--- a/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetLaborController.java
+++ b/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetLaborController.java
@@ -1,8 +1,11 @@
package com.xm.core.ctrl;
import com.mdp.core.entity.Tips;
+import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils;
+import com.mdp.safe.client.entity.User;
+import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmBudgetLabor;
import com.xm.core.service.XmBudgetLaborService;
@@ -10,17 +13,16 @@ import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
+import static com.mdp.core.utils.BaseUtils.fromMap;
import static com.mdp.core.utils.BaseUtils.toMap;
+import static com.mdp.core.utils.ResponseHelper.failed;
/**
* url编制采用rest风格,如对xm_budget_labor 项目人力成本预算的操作有增删改查,对应的url分别为:
@@ -82,8 +84,7 @@ public class XmBudgetLaborController {
m.put("tips", tips);
return m;
}
-
- /**
+
@ApiOperation( value = "新增一条项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmBudgetLabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@@ -105,7 +106,7 @@ public class XmBudgetLaborController {
}
xmBudgetLaborService.insert(xmBudgetLabor);
m.put("data",xmBudgetLabor);
- }catch (BizException e) {
+ }catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
@@ -115,9 +116,7 @@ public class XmBudgetLaborController {
m.put("tips", tips);
return m;
}
- */
-
- /**
+
@ApiOperation( value = "删除一条项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@@ -145,9 +144,7 @@ public class XmBudgetLaborController {
m.put("tips", tips);
return m;
}
- */
-
- /**
+
@ApiOperation( value = "根据主键修改一条项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmBudgetLabor.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@@ -176,9 +173,7 @@ public class XmBudgetLaborController {
m.put("tips", tips);
return m;
}
- */
- /**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmBudgetLabor.class, props={ }, remark = "项目人力成本预算", paramType = "body" )
@ApiResponses({
@@ -250,9 +245,56 @@ public class XmBudgetLaborController {
m.put("tips", tips);
return m;
}
- */
- /**
+
+ @ApiOperation( value = "批量新增人力预算",notes=" ")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
+ })
+ @RequestMapping(value="/batchAdd",method=RequestMethod.POST)
+ public Map batchAddXmBudgetLabor(@RequestBody List xmBudgetLabors) {
+ Map m = new HashMap<>();
+ Tips tips=new Tips("成功删除");
+ try{
+ if(xmBudgetLabors.size()<=0){
+ return failed("data-0","请上送待新增数据列表");
+ }
+ List datasDb=xmBudgetLabors;
+ List can=new ArrayList<>();
+ List no=new ArrayList<>();
+ for (XmBudgetLabor data : datasDb) {
+ if(true){
+ data.setId(this.xmBudgetLaborService.createKey("id"));
+ can.add(data);
+ }else{
+ no.add(data);
+ }
+ }
+ List msgs=new ArrayList<>();
+ if(can.size()>0){
+ xmBudgetLaborService.batchInsert(can);
+ msgs.add(String.format("成功新增%s条数据.",can.size()));
+ }
+
+ if(no.size()>0){
+ msgs.add(String.format("以下%s条数据不能新增.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(","))));
+ }
+ if(can.size()>0){
+ tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
+ }else {
+ tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
+ }
+ }catch (BizException e) {
+ tips=e.getTips();
+ logger.error("",e);
+ }catch (Exception e) {
+ tips.setFailureMsg(e.getMessage());
+ logger.error("",e);
+ }
+ m.put("tips", tips);
+ return m;
+ }
+
@ApiOperation( value = "根据主键列表批量删除项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@@ -278,7 +320,7 @@ public class XmBudgetLaborController {
}
List msgs=new ArrayList<>();
if(can.size()>0){
- xmBudgetLaborService.batchDelete(xmBudgetLabors);
+ xmBudgetLaborService.batchDelete(can);
msgs.add(String.format("成功删除%s条数据.",can.size()));
}
@@ -300,5 +342,5 @@ public class XmBudgetLaborController {
m.put("tips", tips);
return m;
}
- */
+
}
diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetNlaborController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetNlaborController.java
index 448d8076..8fbde200 100644
--- a/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetNlaborController.java
+++ b/xm-core/src/main/java/com/xm/core/ctrl/XmBudgetNlaborController.java
@@ -1,8 +1,12 @@
package com.xm.core.ctrl;
import com.mdp.core.entity.Tips;
+import com.mdp.core.err.BizException;
+import com.mdp.core.utils.BaseUtils;
import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils;
+import com.mdp.safe.client.entity.User;
+import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmBudgetNlabor;
import com.xm.core.service.XmBudgetNlaborService;
@@ -10,17 +14,15 @@ import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
import static com.mdp.core.utils.BaseUtils.toMap;
+import static com.mdp.core.utils.ResponseHelper.failed;
/**
* url编制采用rest风格,如对xm_budget_nlabor 项目人力成本预算的操作有增删改查,对应的url分别为:
@@ -83,7 +85,7 @@ public class XmBudgetNlaborController {
return m;
}
- /**
+
@ApiOperation( value = "新增一条项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmBudgetNlabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@@ -105,7 +107,7 @@ public class XmBudgetNlaborController {
}
xmBudgetNlaborService.insert(xmBudgetNlabor);
m.put("data",xmBudgetNlabor);
- }catch (BizException e) {
+ }catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
@@ -115,9 +117,7 @@ public class XmBudgetNlaborController {
m.put("tips", tips);
return m;
}
- */
-
- /**
+
@ApiOperation( value = "删除一条项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@@ -145,9 +145,7 @@ public class XmBudgetNlaborController {
m.put("tips", tips);
return m;
}
- */
-
- /**
+
@ApiOperation( value = "根据主键修改一条项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmBudgetNlabor.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@@ -176,9 +174,7 @@ public class XmBudgetNlaborController {
m.put("tips", tips);
return m;
}
- */
- /**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmBudgetNlabor.class, props={ }, remark = "项目人力成本预算", paramType = "body" )
@ApiResponses({
@@ -207,7 +203,7 @@ public class XmBudgetNlaborController {
if(fieldKey.size()<=0) {
return failed("fieldKey-0","没有需要更新的字段");
}
- XmBudgetNlabor xmBudgetNlabor = fromMap(xmBudgetNlaborMap,XmBudgetNlabor.class);
+ XmBudgetNlabor xmBudgetNlabor = BaseUtils.fromMap(xmBudgetNlaborMap,XmBudgetNlabor.class);
List xmBudgetNlaborsDb=xmBudgetNlaborService.selectListByIds(ids);
if(xmBudgetNlaborsDb==null ||xmBudgetNlaborsDb.size()==0){
return failed("data-0","记录已不存在");
@@ -250,9 +246,55 @@ public class XmBudgetNlaborController {
m.put("tips", tips);
return m;
}
- */
- /**
+ @ApiOperation( value = "批量新增非人力预算",notes=" ")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
+ })
+ @RequestMapping(value="/batchAdd",method=RequestMethod.POST)
+ public Map batchAddXmBudgetNlabor(@RequestBody List xmBudgetNlabors) {
+ Map m = new HashMap<>();
+ Tips tips=new Tips("成功删除");
+ try{
+ if(xmBudgetNlabors.size()<=0){
+ return failed("data-0","请上送待新增数据列表");
+ }
+ List datasDb=xmBudgetNlabors;
+ List can=new ArrayList<>();
+ List no=new ArrayList<>();
+ for (XmBudgetNlabor data : datasDb) {
+ if(true){
+ data.setId(this.xmBudgetNlaborService.createKey("id"));
+ can.add(data);
+ }else{
+ no.add(data);
+ }
+ }
+ List msgs=new ArrayList<>();
+ if(can.size()>0){
+ xmBudgetNlaborService.batchInsert(can);
+ msgs.add(String.format("成功新增%s条数据.",can.size()));
+ }
+
+ if(no.size()>0){
+ msgs.add(String.format("以下%s条数据不能新增.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(","))));
+ }
+ if(can.size()>0){
+ tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
+ }else {
+ tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
+ }
+ }catch (BizException e) {
+ tips=e.getTips();
+ logger.error("",e);
+ }catch (Exception e) {
+ tips.setFailureMsg(e.getMessage());
+ logger.error("",e);
+ }
+ m.put("tips", tips);
+ return m;
+ }
+
@ApiOperation( value = "根据主键列表批量删除项目人力成本预算信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@@ -300,5 +342,5 @@ public class XmBudgetNlaborController {
m.put("tips", tips);
return m;
}
- */
+
}
diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmCostNlaborController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmCostNlaborController.java
index 1ab7324f..5f946e1d 100644
--- a/xm-core/src/main/java/com/xm/core/ctrl/XmCostNlaborController.java
+++ b/xm-core/src/main/java/com/xm/core/ctrl/XmCostNlaborController.java
@@ -1,8 +1,11 @@
package com.xm.core.ctrl;
import com.mdp.core.entity.Tips;
+import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils;
+import com.mdp.safe.client.entity.User;
+import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmCostNlabor;
import com.xm.core.service.XmCostNlaborService;
@@ -10,17 +13,16 @@ import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
+import static com.mdp.core.utils.BaseUtils.fromMap;
import static com.mdp.core.utils.BaseUtils.toMap;
+import static com.mdp.core.utils.ResponseHelper.failed;
/**
* url编制采用rest风格,如对xm_cost_nlabor 项目实际人工成本费用的操作有增删改查,对应的url分别为:
@@ -84,7 +86,7 @@ public class XmCostNlaborController {
return m;
}
- /**
+
@ApiOperation( value = "新增一条项目实际人工成本费用信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmCostNlabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@@ -106,7 +108,7 @@ public class XmCostNlaborController {
}
xmCostNlaborService.insert(xmCostNlabor);
m.put("data",xmCostNlabor);
- }catch (BizException e) {
+ }catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
@@ -116,9 +118,7 @@ public class XmCostNlaborController {
m.put("tips", tips);
return m;
}
- */
-
- /**
+
@ApiOperation( value = "删除一条项目实际人工成本费用信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@@ -146,9 +146,7 @@ public class XmCostNlaborController {
m.put("tips", tips);
return m;
}
- */
-
- /**
+
@ApiOperation( value = "根据主键修改一条项目实际人工成本费用信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmCostNlabor.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@@ -177,9 +175,7 @@ public class XmCostNlaborController {
m.put("tips", tips);
return m;
}
- */
- /**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmCostNlabor.class, props={ }, remark = "项目实际人工成本费用", paramType = "body" )
@ApiResponses({
@@ -251,9 +247,7 @@ public class XmCostNlaborController {
m.put("tips", tips);
return m;
}
- */
- /**
@ApiOperation( value = "根据主键列表批量删除项目实际人工成本费用信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@@ -301,5 +295,5 @@ public class XmCostNlaborController {
m.put("tips", tips);
return m;
}
- */
+
}