|
@@ -1,17 +1,28 @@
|
|
package com.iamberry.rst.controllers.pts;
|
|
package com.iamberry.rst.controllers.pts;
|
|
|
|
|
|
|
|
+import com.iamberry.rst.core.page.PageRequest;
|
|
|
|
+import com.iamberry.rst.core.page.PagedResult;
|
|
import com.iamberry.rst.core.pts.Produce;
|
|
import com.iamberry.rst.core.pts.Produce;
|
|
|
|
+import com.iamberry.rst.core.pts.ProduceProcess;
|
|
|
|
+import com.iamberry.rst.core.pts.PtsDevice;
|
|
|
|
+import com.iamberry.rst.core.pts.PtsEmployee;
|
|
|
|
+import com.iamberry.rst.faces.pts.EquipmentService;
|
|
import com.iamberry.rst.faces.pts.ProduceService;
|
|
import com.iamberry.rst.faces.pts.ProduceService;
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
|
|
+import com.iamberry.wechat.tools.payUtil.StringUtil;
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by Administrator on 2017/8/29.
|
|
* Created by Administrator on 2017/8/29.
|
|
@@ -22,13 +33,29 @@ public class EquipmentController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ProduceService produceService;
|
|
private ProduceService produceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private EquipmentService equipmentService;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 进入添加设备页面
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("equipment:add:device")
|
|
@RequestMapping("/_add_equpment")
|
|
@RequestMapping("/_add_equpment")
|
|
public ModelAndView addEqupmentUI(HttpServletRequest request) throws Exception {
|
|
public ModelAndView addEqupmentUI(HttpServletRequest request) throws Exception {
|
|
- ModelAndView mv = new ModelAndView("produce/addEqupment");
|
|
|
|
|
|
+ ModelAndView mv = new ModelAndView("pts/device/add_device");
|
|
return mv;
|
|
return mv;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询所有可用产品工序信息
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("equipment:select:produce")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@RequestMapping("/select_produce_list")
|
|
@RequestMapping("/select_produce_list")
|
|
public ResponseJson selectProduceList(HttpServletRequest request) throws Exception {
|
|
public ResponseJson selectProduceList(HttpServletRequest request) throws Exception {
|
|
@@ -42,9 +69,231 @@ public class EquipmentController {
|
|
iter.remove();
|
|
iter.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ msg.setReturnCode(200);
|
|
|
|
+ msg.setResultCode(200);
|
|
|
|
+ msg.addResponseKeyValue("produceList",produceList);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 添加设备信息
|
|
|
|
+ * @param request
|
|
|
|
+ * @param device
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("equipment:add:device")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/add_equpment")
|
|
|
|
+ public ResponseJson addEqupment(HttpServletRequest request,PtsDevice device) throws Exception {
|
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
|
+ String processId = request.getParameter("selProcess");
|
|
|
|
+ String[] processIds = null;
|
|
|
|
+ /*if (processId != null && !"".equals(processId) && processId.indexOf(",") > 0) {
|
|
|
|
+ processId = processId.substring(0,processId.lastIndexOf(","));
|
|
|
|
+ processIds = processId.split(",");
|
|
|
|
+ }*/
|
|
|
|
+ //添加设备信息和修改工序信息
|
|
|
|
+ boolean flag = equipmentService.addDevice(device, processIds);
|
|
|
|
+ if (flag) {
|
|
|
|
+ msg.setResultCode(200);
|
|
|
|
+ msg.setReturnCode(200);
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(500);
|
|
|
|
+ msg.setReturnCode(500);
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询设备列表信息
|
|
|
|
+ * @param request
|
|
|
|
+ * @param pageNO
|
|
|
|
+ * @param pageTotal
|
|
|
|
+ * @param pageSize
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("equipment:select:device")
|
|
|
|
+ @RequestMapping("/select_device_list")
|
|
|
|
+ public ModelAndView selectDeviceList(HttpServletRequest request,
|
|
|
|
+ @RequestParam(value = "pageNO", defaultValue = "1", required = false) int pageNO,
|
|
|
|
+ @RequestParam(value = "pageTotal", required = false) Integer pageTotal,
|
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "5", required = false) int pageSize
|
|
|
|
+ ) throws Exception {
|
|
|
|
+ ModelAndView mv = new ModelAndView("pts/device/device_list");
|
|
|
|
+ StringBuilder url = new StringBuilder("/admin/equipment/select_device_list?pageSize=" + pageSize);
|
|
|
|
+ String deviceNumber = request.getParameter("deviceNumber");
|
|
|
|
+ String deviceStatus = request.getParameter("deviceStatus");
|
|
|
|
+ String deviceName = request.getParameter("deviceName");
|
|
|
|
+ String deviceRemake = request.getParameter("deviceRemake");
|
|
|
|
+ PtsDevice device = new PtsDevice();
|
|
|
|
+ if (StringUtil.isNotEmpty(deviceNumber)) {
|
|
|
|
+ device.setDeviceNumber(deviceNumber);
|
|
|
|
+ mv.addObject("deviceNumber", deviceNumber);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(deviceName)) {
|
|
|
|
+ device.setDeviceName(deviceName);
|
|
|
|
+ mv.addObject("deviceName", deviceName);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(deviceStatus)) {
|
|
|
|
+ device.setDeviceStatus(Integer.parseInt(deviceStatus));
|
|
|
|
+ mv.addObject("deviceStatus", device.getDeviceStatus());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotEmpty(deviceRemake)) {
|
|
|
|
+ device.setDeviceRemake(deviceRemake);
|
|
|
|
+ mv.addObject("deviceRemake", deviceRemake);
|
|
|
|
+ }
|
|
|
|
+ // 封装请求数据
|
|
|
|
+ PageRequest<PtsDevice> pageRequest = new PageRequest<PtsDevice>(device, pageNO, pageSize, pageTotal == null);
|
|
|
|
+ PagedResult<PtsDevice> result = equipmentService.listDevice(pageRequest);
|
|
|
|
+ long total = 0;
|
|
|
|
+ if (pageTotal == null) {
|
|
|
|
+ total = result.getPages();
|
|
|
|
+ } else {
|
|
|
|
+ total = pageTotal;
|
|
|
|
+ result.setPages(total);
|
|
|
|
+ }
|
|
|
|
+ url.append("&pageTotal=").append(total).append("&pageNO=");
|
|
|
|
+ mv.addObject("page", result);
|
|
|
|
+ mv.addObject("url", url.toString());
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 进入修改设备页面
|
|
|
|
+ * @param request
|
|
|
|
+ * @param deviceId
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("equipment:update:device")
|
|
|
|
+ @RequestMapping("/_update_device")
|
|
|
|
+ public ModelAndView editDevice(HttpServletRequest request,
|
|
|
|
+ @RequestParam(value = "deviceId", defaultValue = "", required = false) Integer deviceId
|
|
|
|
+ ) throws Exception {
|
|
|
|
+ ModelAndView mv = new ModelAndView("pts/device/update_device");
|
|
|
|
+ if (deviceId == null) {
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+ PtsDevice device = new PtsDevice();
|
|
|
|
+ device.setDeviceId(deviceId);
|
|
|
|
+ //获取机器列表
|
|
|
|
+ List<PtsDevice> deviceList = equipmentService.listPtsDevice(device);
|
|
|
|
+ if (deviceList == null || deviceList.size() <= 0) {
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+ device = deviceList.get(0);//通过id获取只可能有一条数据
|
|
|
|
+ mv.addObject("device",device);
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 修改设备信息
|
|
|
|
+ * @param request
|
|
|
|
+ * @param device
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("equipment:update:device")
|
|
|
|
+ @RequestMapping("/update_device")
|
|
|
|
+ public ResponseJson updateDevice(HttpServletRequest request,PtsDevice device) throws Exception {
|
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
|
+ //修改设备信息
|
|
|
|
+ int num = equipmentService.updateDevice(device);
|
|
|
|
+ if (num > 0) {
|
|
|
|
+ msg.setResultCode(200);
|
|
|
|
+ msg.setReturnCode(200);
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(500);
|
|
|
|
+ msg.setReturnCode(500);
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 进入修改生产流程页面
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("equipment:update:process")
|
|
|
|
+ @RequestMapping("/_update_process")
|
|
|
|
+ public ModelAndView editProcess(HttpServletRequest request) throws Exception {
|
|
|
|
+ ModelAndView mv = new ModelAndView("pts/device/update_process");
|
|
|
|
+ String deviceId = request.getParameter("deviceId");
|
|
|
|
+ mv.addObject("deviceId",deviceId);
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询产品及工序信息
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("equipment:select:process")
|
|
|
|
+ @RequestMapping("/select_produce_process")
|
|
|
|
+ public ResponseJson selectproduceProcess(HttpServletRequest request) throws Exception {
|
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
|
+ Map<String, Object> objMap = new HashMap<String, Object>();
|
|
|
|
+ Produce produce = new Produce();
|
|
|
|
+ //查询产品及工序信息
|
|
|
|
+ List<Produce> produceList = equipmentService.listProduct(produce);
|
|
|
|
+
|
|
|
|
+ PtsEmployee employee = new PtsEmployee();
|
|
|
|
+ employee.setEmployeeState(1);
|
|
|
|
+ //查询员工集合
|
|
|
|
+ List<PtsEmployee> employeeList = equipmentService.listEmployee(employee);
|
|
|
|
+
|
|
|
|
+ PtsDevice device = new PtsDevice();
|
|
|
|
+ device.setDeviceStatus(1);
|
|
|
|
+ //获取机器列表
|
|
|
|
+ List<PtsDevice> deviceList = equipmentService.listPtsDevice(device);
|
|
|
|
+
|
|
|
|
+ if (produceList != null && produceList.size() > 0) {
|
|
|
|
+ objMap.put("employeeList",employeeList);
|
|
|
|
+ objMap.put("produceList",produceList);
|
|
|
|
+ objMap.put("deviceList",deviceList);
|
|
|
|
+ msg.setResultCode(200);
|
|
|
|
+ msg.setReturnCode(200);
|
|
|
|
+ msg.addResponseKeyValue("objMap",objMap);
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(500);
|
|
|
|
+ msg.setReturnCode(500);
|
|
|
|
+ }
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改产品工序方法
|
|
|
|
+ * @param request
|
|
|
|
+ * @param process
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("equipment:update:process")
|
|
|
|
+ @RequestMapping("/update_process_info")
|
|
|
|
+ public ResponseJson updateProcessInfo(HttpServletRequest request,ProduceProcess process) throws Exception {
|
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
|
+ if (process == null || process.getProcessId() == null || "".equals(process.getProcessId())) {
|
|
|
|
+ msg.setResultCode(500);
|
|
|
|
+ msg.setReturnCode(500);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ //修改产品工序
|
|
|
|
+ boolean flag = equipmentService.updateProcessInfo(process);
|
|
|
|
+ if (flag) {
|
|
|
|
+ msg.setResultCode(200);
|
|
|
|
+ msg.setReturnCode(200);
|
|
|
|
+ return msg;
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(500);
|
|
|
|
+ msg.setReturnCode(500);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|