Browse Source

预算及成本重构

master
陈裕财 4 years ago
parent
commit
ba6de8f607
  1. 86
      xm-core/src/main/java/com/xm/core/ctrl/XmBudgetLaborController.java
  2. 84
      xm-core/src/main/java/com/xm/core/ctrl/XmBudgetNlaborController.java
  3. 34
      xm-core/src/main/java/com/xm/core/ctrl/XmCostNlaborController.java

86
xm-core/src/main/java/com/xm/core/ctrl/XmBudgetLaborController.java

@ -1,8 +1,11 @@
package com.xm.core.ctrl; package com.xm.core.ctrl;
import com.mdp.core.entity.Tips; import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils; import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils; 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.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmBudgetLabor; import com.xm.core.entity.XmBudgetLabor;
import com.xm.core.service.XmBudgetLaborService; import com.xm.core.service.XmBudgetLaborService;
@ -10,17 +13,16 @@ import io.swagger.annotations.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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 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.BaseUtils.toMap;
import static com.mdp.core.utils.ResponseHelper.failed;
/** /**
* url编制采用rest风格,如对xm_budget_labor 项目人力成本预算的操作有增删改查,对应的url分别为:<br> * url编制采用rest风格,如对xm_budget_labor 项目人力成本预算的操作有增删改查,对应的url分别为:<br>
@ -82,8 +84,7 @@ public class XmBudgetLaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
/**
@ApiOperation( value = "新增一条项目人力成本预算信息",notes=" ") @ApiOperation( value = "新增一条项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmBudgetLabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @ApiResponse(code = 200,response=XmBudgetLabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@ -105,7 +106,7 @@ public class XmBudgetLaborController {
} }
xmBudgetLaborService.insert(xmBudgetLabor); xmBudgetLaborService.insert(xmBudgetLabor);
m.put("data",xmBudgetLabor); m.put("data",xmBudgetLabor);
}catch (BizException e) {
}catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
logger.error("",e); logger.error("",e);
}catch (Exception e) { }catch (Exception e) {
@ -115,9 +116,7 @@ public class XmBudgetLaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "删除一条项目人力成本预算信息",notes=" ") @ApiOperation( value = "删除一条项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@ -145,9 +144,7 @@ public class XmBudgetLaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "根据主键修改一条项目人力成本预算信息",notes=" ") @ApiOperation( value = "根据主键修改一条项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmBudgetLabor.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @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); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="") @ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmBudgetLabor.class, props={ }, remark = "项目人力成本预算", paramType = "body" ) @ApiEntityParams( value = XmBudgetLabor.class, props={ }, remark = "项目人力成本预算", paramType = "body" )
@ApiResponses({ @ApiResponses({
@ -250,9 +245,56 @@ public class XmBudgetLaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "批量新增人力预算",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchAdd",method=RequestMethod.POST)
public Map<String,Object> batchAddXmBudgetLabor(@RequestBody List<XmBudgetLabor> xmBudgetLabors) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除");
try{
if(xmBudgetLabors.size()<=0){
return failed("data-0","请上送待新增数据列表");
}
List<XmBudgetLabor> datasDb=xmBudgetLabors;
List<XmBudgetLabor> can=new ArrayList<>();
List<XmBudgetLabor> no=new ArrayList<>();
for (XmBudgetLabor data : datasDb) {
if(true){
data.setId(this.xmBudgetLaborService.createKey("id"));
can.add(data);
}else{
no.add(data);
}
}
List<String> 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=" ") @ApiOperation( value = "根据主键列表批量删除项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@ -278,7 +320,7 @@ public class XmBudgetLaborController {
} }
List<String> msgs=new ArrayList<>(); List<String> msgs=new ArrayList<>();
if(can.size()>0){ if(can.size()>0){
xmBudgetLaborService.batchDelete(xmBudgetLabors);
xmBudgetLaborService.batchDelete(can);
msgs.add(String.format("成功删除%s条数据.",can.size())); msgs.add(String.format("成功删除%s条数据.",can.size()));
} }
@ -300,5 +342,5 @@ public class XmBudgetLaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
} }

84
xm-core/src/main/java/com/xm/core/ctrl/XmBudgetNlaborController.java

@ -1,8 +1,12 @@
package com.xm.core.ctrl; package com.xm.core.ctrl;
import com.mdp.core.entity.Tips; 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.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils; 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.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmBudgetNlabor; import com.xm.core.entity.XmBudgetNlabor;
import com.xm.core.service.XmBudgetNlaborService; import com.xm.core.service.XmBudgetNlaborService;
@ -10,17 +14,15 @@ import io.swagger.annotations.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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 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.BaseUtils.toMap;
import static com.mdp.core.utils.ResponseHelper.failed;
/** /**
* url编制采用rest风格,如对xm_budget_nlabor 项目人力成本预算的操作有增删改查,对应的url分别为:<br> * url编制采用rest风格,如对xm_budget_nlabor 项目人力成本预算的操作有增删改查,对应的url分别为:<br>
@ -83,7 +85,7 @@ public class XmBudgetNlaborController {
return m; return m;
} }
/**
@ApiOperation( value = "新增一条项目人力成本预算信息",notes=" ") @ApiOperation( value = "新增一条项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmBudgetNlabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @ApiResponse(code = 200,response=XmBudgetNlabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@ -105,7 +107,7 @@ public class XmBudgetNlaborController {
} }
xmBudgetNlaborService.insert(xmBudgetNlabor); xmBudgetNlaborService.insert(xmBudgetNlabor);
m.put("data",xmBudgetNlabor); m.put("data",xmBudgetNlabor);
}catch (BizException e) {
}catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
logger.error("",e); logger.error("",e);
}catch (Exception e) { }catch (Exception e) {
@ -115,9 +117,7 @@ public class XmBudgetNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "删除一条项目人力成本预算信息",notes=" ") @ApiOperation( value = "删除一条项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@ -145,9 +145,7 @@ public class XmBudgetNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "根据主键修改一条项目人力成本预算信息",notes=" ") @ApiOperation( value = "根据主键修改一条项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmBudgetNlabor.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @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); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="") @ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmBudgetNlabor.class, props={ }, remark = "项目人力成本预算", paramType = "body" ) @ApiEntityParams( value = XmBudgetNlabor.class, props={ }, remark = "项目人力成本预算", paramType = "body" )
@ApiResponses({ @ApiResponses({
@ -207,7 +203,7 @@ public class XmBudgetNlaborController {
if(fieldKey.size()<=0) { if(fieldKey.size()<=0) {
return failed("fieldKey-0","没有需要更新的字段"); return failed("fieldKey-0","没有需要更新的字段");
} }
XmBudgetNlabor xmBudgetNlabor = fromMap(xmBudgetNlaborMap,XmBudgetNlabor.class);
XmBudgetNlabor xmBudgetNlabor = BaseUtils.fromMap(xmBudgetNlaborMap,XmBudgetNlabor.class);
List<XmBudgetNlabor> xmBudgetNlaborsDb=xmBudgetNlaborService.selectListByIds(ids); List<XmBudgetNlabor> xmBudgetNlaborsDb=xmBudgetNlaborService.selectListByIds(ids);
if(xmBudgetNlaborsDb==null ||xmBudgetNlaborsDb.size()==0){ if(xmBudgetNlaborsDb==null ||xmBudgetNlaborsDb.size()==0){
return failed("data-0","记录已不存在"); return failed("data-0","记录已不存在");
@ -250,9 +246,55 @@ public class XmBudgetNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "批量新增非人力预算",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchAdd",method=RequestMethod.POST)
public Map<String,Object> batchAddXmBudgetNlabor(@RequestBody List<XmBudgetNlabor> xmBudgetNlabors) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除");
try{
if(xmBudgetNlabors.size()<=0){
return failed("data-0","请上送待新增数据列表");
}
List<XmBudgetNlabor> datasDb=xmBudgetNlabors;
List<XmBudgetNlabor> can=new ArrayList<>();
List<XmBudgetNlabor> no=new ArrayList<>();
for (XmBudgetNlabor data : datasDb) {
if(true){
data.setId(this.xmBudgetNlaborService.createKey("id"));
can.add(data);
}else{
no.add(data);
}
}
List<String> 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=" ") @ApiOperation( value = "根据主键列表批量删除项目人力成本预算信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@ -300,5 +342,5 @@ public class XmBudgetNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
} }

34
xm-core/src/main/java/com/xm/core/ctrl/XmCostNlaborController.java

@ -1,8 +1,11 @@
package com.xm.core.ctrl; package com.xm.core.ctrl;
import com.mdp.core.entity.Tips; import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils; import com.mdp.core.utils.RequestUtils;
import com.mdp.mybatis.PageUtils; 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.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmCostNlabor; import com.xm.core.entity.XmCostNlabor;
import com.xm.core.service.XmCostNlaborService; import com.xm.core.service.XmCostNlaborService;
@ -10,17 +13,16 @@ import io.swagger.annotations.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; 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 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.BaseUtils.toMap;
import static com.mdp.core.utils.ResponseHelper.failed;
/** /**
* url编制采用rest风格,如对xm_cost_nlabor 项目实际人工成本费用的操作有增删改查,对应的url分别为:<br> * url编制采用rest风格,如对xm_cost_nlabor 项目实际人工成本费用的操作有增删改查,对应的url分别为:<br>
@ -84,7 +86,7 @@ public class XmCostNlaborController {
return m; return m;
} }
/**
@ApiOperation( value = "新增一条项目实际人工成本费用信息",notes=" ") @ApiOperation( value = "新增一条项目实际人工成本费用信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmCostNlabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @ApiResponse(code = 200,response=XmCostNlabor.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@ -106,7 +108,7 @@ public class XmCostNlaborController {
} }
xmCostNlaborService.insert(xmCostNlabor); xmCostNlaborService.insert(xmCostNlabor);
m.put("data",xmCostNlabor); m.put("data",xmCostNlabor);
}catch (BizException e) {
}catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
logger.error("",e); logger.error("",e);
}catch (Exception e) { }catch (Exception e) {
@ -116,9 +118,7 @@ public class XmCostNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "删除一条项目实际人工成本费用信息",notes=" ") @ApiOperation( value = "删除一条项目实际人工成本费用信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@ -146,9 +146,7 @@ public class XmCostNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "根据主键修改一条项目实际人工成本费用信息",notes=" ") @ApiOperation( value = "根据主键修改一条项目实际人工成本费用信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmCostNlabor.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @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); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="") @ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmCostNlabor.class, props={ }, remark = "项目实际人工成本费用", paramType = "body" ) @ApiEntityParams( value = XmCostNlabor.class, props={ }, remark = "项目实际人工成本费用", paramType = "body" )
@ApiResponses({ @ApiResponses({
@ -251,9 +247,7 @@ public class XmCostNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "根据主键列表批量删除项目实际人工成本费用信息",notes=" ") @ApiOperation( value = "根据主键列表批量删除项目实际人工成本费用信息",notes=" ")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@ -301,5 +295,5 @@ public class XmCostNlaborController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
} }
Loading…
Cancel
Save