|
@@ -1,7 +1,10 @@
|
|
|
package com.iamberry.rst.controllers.pts;
|
|
|
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
-import com.iamberry.rst.core.pts.*;
|
|
|
+import com.iamberry.rst.core.pts.Produce;
|
|
|
+import com.iamberry.rst.core.pts.PtsBom;
|
|
|
+import com.iamberry.rst.core.pts.PtsBomComponents;
|
|
|
+import com.iamberry.rst.core.pts.PtsComponents;
|
|
|
import com.iamberry.rst.faces.pts.MachinePartsService;
|
|
|
import com.iamberry.rst.faces.pts.ProduceService;
|
|
|
import com.iamberry.rst.faces.pts.PtsBomService;
|
|
@@ -11,7 +14,6 @@ import net.sf.json.JSONArray;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -19,7 +21,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -47,19 +48,19 @@ public class AdminPtsBomController {
|
|
|
*/
|
|
|
@RequiresPermissions("bom:select:list")
|
|
|
@RequestMapping("/_bom_list")
|
|
|
- public ModelAndView getPtsBom(HttpServletRequest request,PtsBom ptsBom,
|
|
|
+ public ModelAndView getPtsBom(HttpServletRequest request, PtsBom ptsBom,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
|
|
|
@RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
|
|
|
@RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
|
|
|
ModelAndView mv = new ModelAndView("pts/bom/bom_list");
|
|
|
PagedResult<PtsBom> pagedResult = ptsBomService.listPtsBom(pageNO, pageSize, ptsBom, totalNum == 0);
|
|
|
- if (totalNum != 0){
|
|
|
+ if (totalNum != 0) {
|
|
|
pagedResult.setTotal(totalNum);
|
|
|
}
|
|
|
|
|
|
//获取产品集合,用于页面选择产品
|
|
|
List<Produce> list = produceService.getProduceList();
|
|
|
- mv.addObject("produceList",list);
|
|
|
+ mv.addObject("produceList", list);
|
|
|
|
|
|
StitchAttrUtil.setModelAndView(ptsBom, mv, "/admin/bom/_bom_list", pagedResult);
|
|
|
return mv;
|
|
@@ -71,14 +72,14 @@ public class AdminPtsBomController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequiresPermissions("bom:add:bom")
|
|
|
- @RequestMapping(value="/to_add_bom")
|
|
|
- public ModelAndView toAddBom(String BomId, HttpServletRequest request) {
|
|
|
+ @RequestMapping(value = "/to_add_bom")
|
|
|
+ public ModelAndView toAddBom(HttpServletRequest request) {
|
|
|
ModelAndView mv = new ModelAndView("pts/bom/add_bom");
|
|
|
|
|
|
//获取产品集合,用于页面选择产品
|
|
|
List<Produce> produceList = produceService.getProduceList();
|
|
|
|
|
|
- mv.addObject("produceList",produceList);
|
|
|
+ mv.addObject("produceList", produceList);
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
@@ -89,29 +90,29 @@ public class AdminPtsBomController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequiresPermissions("bom:add:bom")
|
|
|
- @RequestMapping(value="/save_bom")
|
|
|
+ @RequestMapping(value = "/save_bom")
|
|
|
public ResponseJson saveBom(PtsBom ptsBom, String bomComponentJson, HttpServletRequest request) {
|
|
|
|
|
|
- if(!this.isValiData(ptsBom) || bomComponentJson == null){
|
|
|
+ if (!this.isValiData(ptsBom) || bomComponentJson == null) {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.fromObject(bomComponentJson);
|
|
|
- List<PtsBomComponents> ptsBomComponentsList = (List) JSONArray.toCollection(jsonArray,PtsBomComponents.class);
|
|
|
+ List<PtsBomComponents> ptsBomComponentsList = (List) JSONArray.toCollection(jsonArray, PtsBomComponents.class);
|
|
|
ptsBom.setPtsBomComponentsList(ptsBomComponentsList);
|
|
|
|
|
|
Integer flag = ptsBomService.savePtsBom(ptsBom);
|
|
|
|
|
|
- if (flag < 1 ){
|
|
|
+ if (flag < 1) {
|
|
|
return new ResponseJson(500, "添加失败", 500);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ResponseJson(200, "添加成功", 200);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public boolean isValiData(PtsBom ptsBom){
|
|
|
+ public boolean isValiData(PtsBom ptsBom) {
|
|
|
boolean flag = true;
|
|
|
- if(ptsBom.getBomName() != null && "".equals(ptsBom.getBomName())){
|
|
|
+ if (ptsBom.getBomName() != null && "".equals(ptsBom.getBomName())) {
|
|
|
|
|
|
}
|
|
|
|
|
@@ -124,12 +125,12 @@ public class AdminPtsBomController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequiresPermissions(value={"bom:add:bom","bom:update:bom"},logical= Logical.OR)
|
|
|
- @RequestMapping(value="/get_listBom")
|
|
|
+ @RequiresPermissions(value = {"bom:add:bom", "bom:update:bom"}, logical = Logical.OR)
|
|
|
+ @RequestMapping(value = "/get_listBom")
|
|
|
public ResponseJson listBomByProduceId(HttpServletRequest request) {
|
|
|
|
|
|
String produceId = request.getParameter("produceId");
|
|
|
- if (produceId == null || "".equals(produceId)){
|
|
|
+ if (produceId == null || "".equals(produceId)) {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
|
|
@@ -137,11 +138,11 @@ public class AdminPtsBomController {
|
|
|
ptsBom.setProduceId(Integer.valueOf(produceId));
|
|
|
List<PtsBom> ptsBomsList = ptsBomService.listBom(ptsBom);
|
|
|
|
|
|
- if (ptsBomsList != null ){
|
|
|
+ if (ptsBomsList != null) {
|
|
|
ResponseJson rj = new ResponseJson(200, "SUCCESS", 200);
|
|
|
- rj.addResponseKeyValue("ptsBomsList",ptsBomsList);
|
|
|
+ rj.addResponseKeyValue("ptsBomsList", ptsBomsList);
|
|
|
return rj;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
}
|
|
@@ -152,12 +153,12 @@ public class AdminPtsBomController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequiresPermissions(value={"bom:add:bom","bom:update:bom"},logical= Logical.OR)
|
|
|
- @RequestMapping(value="/get_bom")
|
|
|
+ @RequiresPermissions(value = {"bom:add:bom", "bom:update:bom"}, logical = Logical.OR)
|
|
|
+ @RequestMapping(value = "/get_bom")
|
|
|
public ResponseJson getBom(HttpServletRequest request) {
|
|
|
|
|
|
String bomId = request.getParameter("bomId");
|
|
|
- if (bomId == null || "".equals(bomId)){
|
|
|
+ if (bomId == null || "".equals(bomId)) {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
|
|
@@ -165,11 +166,11 @@ public class AdminPtsBomController {
|
|
|
ptsBom.setBomId(Integer.valueOf(bomId));
|
|
|
ptsBom = ptsBomService.getPtsBom(ptsBom);
|
|
|
|
|
|
- if (ptsBom != null ){
|
|
|
+ if (ptsBom != null) {
|
|
|
ResponseJson rj = new ResponseJson(200, "SUCCESS", 200);
|
|
|
- rj.addResponseKeyValue("ptsBom",ptsBom);
|
|
|
+ rj.addResponseKeyValue("ptsBom", ptsBom);
|
|
|
return rj;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
}
|
|
@@ -180,12 +181,12 @@ public class AdminPtsBomController {
|
|
|
* @return
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
- @RequiresPermissions(value={"bom:add:bom","bom:update:bom"},logical= Logical.OR)
|
|
|
- @RequestMapping(value="/get_listComponents")
|
|
|
+ @RequiresPermissions(value = {"bom:add:bom", "bom:update:bom"}, logical = Logical.OR)
|
|
|
+ @RequestMapping(value = "/get_listComponents")
|
|
|
public ResponseJson listComponents(HttpServletRequest request) {
|
|
|
|
|
|
String produceId = request.getParameter("produceId");
|
|
|
- if (produceId == null || "".equals(produceId)){
|
|
|
+ if (produceId == null || "".equals(produceId)) {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
PtsComponents ptsComponents = new PtsComponents();
|
|
@@ -194,11 +195,11 @@ public class AdminPtsBomController {
|
|
|
//查询所有零件
|
|
|
List<PtsComponents> ptsComponentsList = machinePartsService.listPtsComponents(ptsComponents);
|
|
|
|
|
|
- if (ptsComponentsList != null ){
|
|
|
+ if (ptsComponentsList != null) {
|
|
|
ResponseJson rj = new ResponseJson(200, "SUCCESS", 200);
|
|
|
- rj.addResponseKeyValue("ptsComponentsList",ptsComponentsList);
|
|
|
+ rj.addResponseKeyValue("ptsComponentsList", ptsComponentsList);
|
|
|
return rj;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ResponseJson(500, "ERROR", 500);
|
|
|
}
|
|
|
}
|
|
@@ -210,10 +211,10 @@ public class AdminPtsBomController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequiresPermissions("bom:update:bom")
|
|
|
- @RequestMapping(value="/to_update_bom")
|
|
|
+ @RequestMapping(value = "/to_update_bom")
|
|
|
public ModelAndView toUpdateBom(String bomId, HttpServletRequest request) {
|
|
|
ModelAndView mv = new ModelAndView("pts/bom/update_bom");
|
|
|
- if (bomId == null || "".equals(bomId)){
|
|
|
+ if (bomId == null || "".equals(bomId)) {
|
|
|
return mv;
|
|
|
}
|
|
|
//获取产品集合,用于页面选择产品
|
|
@@ -230,9 +231,9 @@ public class AdminPtsBomController {
|
|
|
ptsComponents.setComponentsStatus(1);
|
|
|
List<PtsComponents> ptsComponentsList = machinePartsService.listPtsComponents(ptsComponents);
|
|
|
|
|
|
- mv.addObject("produceList",produceList);
|
|
|
- mv.addObject("ptsBom",ptsBom);
|
|
|
- mv.addObject("ptsComponentsList",ptsComponentsList);
|
|
|
+ mv.addObject("produceList", produceList);
|
|
|
+ mv.addObject("ptsBom", ptsBom);
|
|
|
+ mv.addObject("ptsComponentsList", ptsComponentsList);
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
@@ -243,21 +244,53 @@ public class AdminPtsBomController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequiresPermissions("bom:add:bom")
|
|
|
- @RequestMapping(value="/update_bom")
|
|
|
+ @RequestMapping(value = "/update_bom")
|
|
|
public ResponseJson updateBom(PtsBom ptsBom, String bomComponentJson, HttpServletRequest request) {
|
|
|
|
|
|
JSONArray jsonArray = JSONArray.fromObject(bomComponentJson);
|
|
|
- List<PtsBomComponents> ptsBomComponentsList = (List) JSONArray.toCollection(jsonArray,PtsBomComponents.class);
|
|
|
+ List<PtsBomComponents> ptsBomComponentsList = (List) JSONArray.toCollection(jsonArray, PtsBomComponents.class);
|
|
|
ptsBom.setPtsBomComponentsList(ptsBomComponentsList);
|
|
|
|
|
|
ptsBom.setProduceId(null);
|
|
|
|
|
|
Integer flag = ptsBomService.updatePtsBom(ptsBom);
|
|
|
|
|
|
- if (flag < 1 ){
|
|
|
+ if (flag < 1) {
|
|
|
return new ResponseJson(500, "修改失败", 500);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new ResponseJson(200, "修改成功", 200);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取bom单详情
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresPermissions("bom:select:details")
|
|
|
+ @RequestMapping(value = "/to_details_bom")
|
|
|
+ public ModelAndView toBomDetails(String bomId, HttpServletRequest request) {
|
|
|
+ ModelAndView mv = new ModelAndView("pts/bom/bom_details");
|
|
|
+ if (bomId == null || "".equals(bomId)) {
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询bom信息
|
|
|
+ PtsBom ptsBom = new PtsBom();
|
|
|
+ ptsBom.setBomId(Integer.valueOf(bomId));
|
|
|
+ ptsBom = ptsBomService.getPtsBom(ptsBom);
|
|
|
+
|
|
|
+ //所有零件
|
|
|
+ PtsComponents ptsComponents = new PtsComponents();
|
|
|
+ ptsComponents.setProduceId(ptsBom.getProduceId());
|
|
|
+ ptsComponents.setComponentsStatus(1);
|
|
|
+ List<PtsComponents> ptsComponentsList = machinePartsService.listPtsComponents(ptsComponents);
|
|
|
+
|
|
|
+ mv.addObject("ptsBom", ptsBom);
|
|
|
+ mv.addObject("ptsComponentsList", ptsComponentsList);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|