|
@@ -0,0 +1,317 @@
|
|
|
+package com.iamberry.rst.controllers.pts;
|
|
|
+
|
|
|
+import com.iamberry.rst.core.fm.InventoryInfo;
|
|
|
+import com.iamberry.rst.core.fm.InventoryLog;
|
|
|
+import com.iamberry.rst.core.order.OrderWarehouse;
|
|
|
+import com.iamberry.rst.core.order.Product;
|
|
|
+import com.iamberry.rst.core.order.ProductColor;
|
|
|
+import com.iamberry.rst.core.order.ProductType;
|
|
|
+import com.iamberry.rst.core.page.PageRequest;
|
|
|
+import com.iamberry.rst.core.page.PagedResult;
|
|
|
+import com.iamberry.rst.core.pts.ProductionEmployees;
|
|
|
+import com.iamberry.rst.core.pts.ProductionPlan;
|
|
|
+import com.iamberry.rst.core.pts.ProductionProcess;
|
|
|
+import com.iamberry.rst.core.pts.PtsEmployee;
|
|
|
+import com.iamberry.rst.core.sys.Admin;
|
|
|
+import com.iamberry.rst.faces.cm.InventoryLogService;
|
|
|
+import com.iamberry.rst.faces.cm.InventoryService;
|
|
|
+import com.iamberry.rst.faces.cm.SalesOrderService;
|
|
|
+import com.iamberry.rst.faces.order.OrderWarehouseService;
|
|
|
+import com.iamberry.rst.faces.product.ProductColorService;
|
|
|
+import com.iamberry.rst.faces.product.ProductService;
|
|
|
+import com.iamberry.rst.faces.pts.ProductionPlanService;
|
|
|
+import com.iamberry.rst.faces.pts.PtsEmployeeService;
|
|
|
+import com.iamberry.rst.utils.AdminUtils;
|
|
|
+import com.iamberry.rst.utils.StitchAttrUtil;
|
|
|
+import com.iamberry.wechat.tools.ResponseJson;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+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.servlet.ModelAndView;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by LJK on 2019年12月12日
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping("/admin/productionPlan")
|
|
|
+public class ProductionPlanController {
|
|
|
+ @Autowired
|
|
|
+ private ProductionPlanService productionPlanService;
|
|
|
+ @Autowired
|
|
|
+ private PtsEmployeeService ptsEmployeeService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询生产计划列表信息
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param pageNO
|
|
|
+ * @param pageTotal
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequiresPermissions("productionPlan:select:productionPlan")
|
|
|
+ @RequestMapping("/select_productionPlan_list")
|
|
|
+ public ModelAndView selectProductionPlanList(HttpServletRequest request,
|
|
|
+ @RequestParam(value = "pageNO", defaultValue = "1", required = false) int pageNO,
|
|
|
+ @RequestParam(value = "pageTotal", required = false) Integer pageTotal,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize,
|
|
|
+ ProductionPlan productionPlan
|
|
|
+ ) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("pts/productionPlan/productionPlan_list");
|
|
|
+ StringBuilder url = new StringBuilder("/admin/productionPlan/select_productionPlan_list?pageSize=" + pageSize);
|
|
|
+ String planDate = request.getParameter("plan_Date");
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if(planDate != null && !planDate.equals("")){
|
|
|
+ productionPlan.setPlanDate(format.parse(planDate));
|
|
|
+ }
|
|
|
+ // 封装请求数据
|
|
|
+ PageRequest<ProductionPlan> pageRequest = new PageRequest<>(productionPlan, pageNO, pageSize, pageTotal == null);
|
|
|
+ // 查询生产计划列表
|
|
|
+ PagedResult<ProductionPlan> result = productionPlanService.listProductionPlan(pageRequest);
|
|
|
+ ProductionProcess productionProcess = new ProductionProcess();
|
|
|
+ productionProcess.setProcessStatus(1);
|
|
|
+ List<ProductionProcess> listProductionProcess = productionPlanService.listProductionProcess(productionProcess);
|
|
|
+ mv.addObject("listProductionProcess", listProductionProcess);
|
|
|
+ long total = 0;
|
|
|
+ if (pageTotal == null) {
|
|
|
+ total = result.getPages();
|
|
|
+ } else {
|
|
|
+ total = pageTotal;
|
|
|
+ result.setPages(total);
|
|
|
+ }
|
|
|
+ StitchAttrUtil.getSa().setModelAndView(productionPlan, mv, "/admin/productionPlan/select_productionPlan_list", result);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查询生产计划统计列表信息
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param pageNO
|
|
|
+ * @param pageTotal
|
|
|
+ * @param pageSize
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequiresPermissions("productionPlan:statistical:productionPlan")
|
|
|
+ @RequestMapping("/select_productionPlan_statistical")
|
|
|
+ public ModelAndView select_productionPlan_statistical(HttpServletRequest request,
|
|
|
+ @RequestParam(value = "pageNO", defaultValue = "1", required = false) int pageNO,
|
|
|
+ @RequestParam(value = "pageTotal", required = false) Integer pageTotal,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10", required = false) int pageSize,
|
|
|
+ ProductionPlan productionPlan
|
|
|
+ ) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("pts/productionPlan/productionPlan_statistical");
|
|
|
+ StringBuilder url = new StringBuilder("/admin/productionPlan/select_productionPlan_statistical?pageSize=" + pageSize);
|
|
|
+ String planDate = request.getParameter("plan_Date");
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if(planDate != null && !planDate.equals("")){
|
|
|
+ productionPlan.setPlanDate(format.parse(planDate));
|
|
|
+ }
|
|
|
+ // 封装请求数据
|
|
|
+ PageRequest<ProductionPlan> pageRequest = new PageRequest<>(productionPlan, pageNO, pageSize, pageTotal == null);
|
|
|
+ // 查询生产计划列表
|
|
|
+ PagedResult<ProductionPlan> result = productionPlanService.listProductionPlan(pageRequest);
|
|
|
+ ProductionProcess productionProcess = new ProductionProcess();
|
|
|
+ productionProcess.setProcessStatus(1);
|
|
|
+ List<ProductionProcess> listProductionProcess = productionPlanService.listProductionProcess(productionProcess);
|
|
|
+ mv.addObject("listProductionProcess", listProductionProcess);
|
|
|
+ long total = 0;
|
|
|
+ if (pageTotal == null) {
|
|
|
+ total = result.getPages();
|
|
|
+ } else {
|
|
|
+ total = pageTotal;
|
|
|
+ result.setPages(total);
|
|
|
+ }
|
|
|
+ StitchAttrUtil.getSa().setModelAndView(productionPlan, mv, "/admin/productionPlan/select_productionPlan_statistical", result);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 进入添加生产计划
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping("/to_addProductionPlan")
|
|
|
+ public ModelAndView to_addProductionPlan(ProductionPlan productionPlan) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("pts/productionPlan/add_productionPlan");
|
|
|
+ ProductionProcess productionProcess = new ProductionProcess();
|
|
|
+ productionProcess.setProcessStatus(1);
|
|
|
+ List<ProductionProcess> listProductionProcess = productionPlanService.listProductionProcess(productionProcess);
|
|
|
+ mv.addObject("listProductionProcess", listProductionProcess);
|
|
|
+ Integer planCount = productionPlanService.getPlanCount();
|
|
|
+ mv.addObject("planCount", planCount);
|
|
|
+ mv.addObject("plan_date", new Date());
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加生产计划
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "/addProductionPlan")
|
|
|
+ public ResponseJson addProductionPlan(HttpServletRequest request,ProductionPlan productionPlan) throws Exception {
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
+ if(productionPlan == null ){
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(500);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ String planDate = request.getParameter("plan_date");
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if(planDate != null && !planDate.equals("")){
|
|
|
+ productionPlan.setPlanDate(format.parse(planDate));
|
|
|
+ }else {
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if(productionPlan.getEmployeeString() == null && !productionPlan.getEmployeeString().equals("")){
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ //判断是否有员工重复工序
|
|
|
+ if(productionPlan.getEmployeeString() != null && !productionPlan.getEmployeeString().equals("")){
|
|
|
+ List<PtsEmployee> employeeList = new ArrayList<>();
|
|
|
+ boolean is = false;
|
|
|
+ ProductionPlan plan = new ProductionPlan();
|
|
|
+ plan.setPlanDate(productionPlan.getPlanDate());
|
|
|
+ String[] employees = productionPlan.getEmployeeString().split("_");
|
|
|
+ for(String employee : employees){
|
|
|
+ if(!employee.equals("")){
|
|
|
+ plan.setEmployeeId(Integer.valueOf(employee));
|
|
|
+ Integer s = productionPlanService.getPlanRepeat(plan);
|
|
|
+ if(s > 0){
|
|
|
+ is = true;
|
|
|
+ //查询重复员工姓名
|
|
|
+ employeeList.add(ptsEmployeeService.getPtsEmployeeById(Integer.valueOf(employee)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(is){
|
|
|
+ msg.addResponseKeyValue("employeeList",employeeList);
|
|
|
+ msg.setResultCode(501);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(productionPlanService.addProductionPlan(productionPlan) > 0){
|
|
|
+ msg.setResultCode(200);
|
|
|
+ msg.setReturnCode(200);
|
|
|
+ }else{
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *删除生产计划
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "/delProductionPlan")
|
|
|
+ public ResponseJson delProductionPlan(HttpServletRequest request,Integer planId) throws Exception {
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
+ if(planId == null ){
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(500);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if(productionPlanService.delProductionPlan(planId) > 0){
|
|
|
+ msg.setResultCode(200);
|
|
|
+ msg.setReturnCode(200);
|
|
|
+ }else{
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *进入完善工作计划页面
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping("/to_perfect_productionPlan")
|
|
|
+ public ModelAndView toPerfectProductionPlan(Integer planId) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("pts/productionPlan/perfect_productionPlan");
|
|
|
+ ProductionPlan productionPlan = productionPlanService.getProductionPlan(planId);
|
|
|
+ List<ProductionEmployees> listProductionEmployees = productionPlanService.listProductionEmployees(planId);
|
|
|
+ mv.addObject("productionPlan", productionPlan);
|
|
|
+ mv.addObject("listProductionEmployees", listProductionEmployees);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *进入修改工作计划页面
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping("/to_update_productionPlan")
|
|
|
+ public ModelAndView to_update_productionPlan(Integer planId) throws Exception {
|
|
|
+ ModelAndView mv = new ModelAndView("pts/productionPlan/update_productionPlan");
|
|
|
+ ProductionPlan productionPlan = productionPlanService.getProductionPlan(planId);
|
|
|
+ ProductionProcess productionProcess = new ProductionProcess();
|
|
|
+ productionProcess.setProcessStatus(1);
|
|
|
+ List<ProductionProcess> listProductionProcess = productionPlanService.listProductionProcess(productionProcess);
|
|
|
+ mv.addObject("listProductionProcess", listProductionProcess);
|
|
|
+ List<ProductionEmployees> listProductionEmployees = productionPlanService.listProductionEmployees(planId);
|
|
|
+ mv.addObject("productionPlan", productionPlan);
|
|
|
+ mv.addObject("listProductionEmployees", listProductionEmployees);
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 完善生产计划
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "/perfect_productionPlan")
|
|
|
+ public ResponseJson perfectProductionPlan(HttpServletRequest request,ProductionPlan productionPlan) throws Exception {
|
|
|
+ ResponseJson msg = new ResponseJson();
|
|
|
+ if(productionPlan == null ){
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(500);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ String planDate = request.getParameter("plan_date");
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if(planDate != null && !planDate.equals("")){
|
|
|
+ productionPlan.setPlanDate(format.parse(planDate));
|
|
|
+ }else {
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if(productionPlan.getEmployeeString() == null && !productionPlan.getEmployeeString().equals("")){
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ if(productionPlanService.updateProductionPlan(productionPlan) > 0){
|
|
|
+ msg.setResultCode(200);
|
|
|
+ msg.setReturnCode(200);
|
|
|
+ }else{
|
|
|
+ msg.setResultCode(500);
|
|
|
+ msg.setReturnCode(501);
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+}
|