|
@@ -4,22 +4,28 @@ import com.iamberry.rst.core.order.Order;
|
|
|
import com.iamberry.rst.core.order.RentType;
|
|
|
import com.iamberry.rst.core.page.PageRequest;
|
|
|
import com.iamberry.rst.core.page.PagedResult;
|
|
|
+import com.iamberry.rst.core.pts.ProduceProcess;
|
|
|
import com.iamberry.rst.core.pts.PtsMachine;
|
|
|
import com.iamberry.rst.core.pts.PtsMachineLogs;
|
|
|
+import com.iamberry.rst.core.pts.PtsMachineStatistics;
|
|
|
import com.iamberry.rst.faces.pts.*;
|
|
|
+import com.iamberry.wechat.tools.ResponseJson;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
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.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.text.NumberFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by LJK on 2017/8/29.
|
|
@@ -30,6 +36,9 @@ public class AdminMachineController {
|
|
|
|
|
|
@Autowired
|
|
|
private MachineService machineService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProduceService produceService;
|
|
|
/**
|
|
|
* 查询机器列表
|
|
|
* @author LJK
|
|
@@ -188,4 +197,122 @@ public class AdminMachineController {
|
|
|
String[] a = s.split(",");
|
|
|
return machineService.batchUpdateMachineIsPring(a);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询机器打印列表
|
|
|
+ * @author LJK
|
|
|
+ * @date 2017年8月31日16:08:15
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequiresPermissions("machine:abnormality:statistics")
|
|
|
+ @RequestMapping("/_produced_abnormality_statistics")
|
|
|
+ public ModelAndView producedAbnormalityStatistics(HttpServletRequest request,PtsMachine ptsMachine){
|
|
|
+ ModelAndView mv = new ModelAndView("pts/machine/producedAbnormalityStatistics");
|
|
|
+ String machineType = request.getParameter("machineType");//1.净水机 2.冲奶机
|
|
|
+ if(machineType == null || machineType.equals("")){
|
|
|
+ machineType = "1";
|
|
|
+ }
|
|
|
+ mv.addObject("machineType",machineType);
|
|
|
+ PtsMachineStatistics ptsMachineStatistics = new PtsMachineStatistics();
|
|
|
+ Calendar date = Calendar.getInstance();
|
|
|
+ String year = String.valueOf(date.get(Calendar.YEAR));//年
|
|
|
+ ptsMachineStatistics.setYear(year);
|
|
|
+ ptsMachineStatistics.setMachineType(Integer.valueOf(machineType));
|
|
|
+ //查询1-12月每月生产机器数
|
|
|
+ List<PtsMachineStatistics> ptsMachineStatisticsList = machineService.monthStatistics(ptsMachineStatistics);
|
|
|
+ if(ptsMachineStatisticsList.size() > 0){
|
|
|
+ StringBuffer yearBf = new StringBuffer();
|
|
|
+ for(int i=0;i< ptsMachineStatisticsList.size();i++){
|
|
|
+ yearBf.append(ptsMachineStatisticsList.get(i).getNum().toString()+",");
|
|
|
+ }
|
|
|
+ String yearString = yearBf.toString();
|
|
|
+ mv.addObject("years", "["+yearString.substring(0,yearString.length()-1)+"]");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询最近七天生产机器
|
|
|
+ List<PtsMachineStatistics> dayList = machineService.dayStatistics(ptsMachineStatistics);
|
|
|
+ if(dayList.size() > 0){
|
|
|
+ StringBuffer dayBf = new StringBuffer();
|
|
|
+ StringBuffer dateBf = new StringBuffer();
|
|
|
+ for(int i=0;i< dayList.size();i++){
|
|
|
+ dayBf.append(dayList.get(i).getNum().toString()+",");
|
|
|
+ dateBf.append(dayList.get(i).getDate()+",");
|
|
|
+ }
|
|
|
+ String dayString = dayBf.toString();
|
|
|
+ String monthDayString = dateBf.toString();
|
|
|
+ mv.addObject("days", "["+dayString.substring(0,dayString.length()-1)+"]");
|
|
|
+ mv.addObject("monthDay", "["+monthDayString.substring(0,monthDayString.length()-1)+"]");
|
|
|
+ }
|
|
|
+
|
|
|
+ /*机器总数及流程异常数*/
|
|
|
+ PtsMachineStatistics numbers = machineService.flowAbnormality(ptsMachineStatistics);
|
|
|
+ /*机器总数*/
|
|
|
+ mv.addObject("machineNum", numbers.getMachineCount());
|
|
|
+ /*机器异常总数*/
|
|
|
+ mv.addObject("machineAbnormality", numbers.getMachineAbnormality());
|
|
|
+ /*流程异常百分比*/
|
|
|
+ double percentage = (double)numbers.getMachineAbnormality() / (double)numbers.getMachineCount()*100;
|
|
|
+ NumberFormat nf=new DecimalFormat( "0.0 ");
|
|
|
+ percentage = Double.parseDouble(nf.format(percentage));
|
|
|
+ mv.addObject("abnormalityPercentage", percentage);
|
|
|
+ /*正常百分比*/
|
|
|
+ double normalPercentage = Double.parseDouble(nf.format(100.0 - percentage));
|
|
|
+ mv.addObject("normalPercentage",normalPercentage);
|
|
|
+ /*根据机器类型查询机器所有工序*/
|
|
|
+ ProduceProcess produceProcess = new ProduceProcess();
|
|
|
+ produceProcess.setProduceId(machineType.equals("1")? 1:2);
|
|
|
+ List<ProduceProcess> processList = produceService.listProduceProcess(produceProcess);
|
|
|
+ mv.addObject("processList",processList);
|
|
|
+ //查询第一条的工序值 默认选择第一条工序
|
|
|
+ List<PtsMachineStatistics> nodeCountList = machineService.nodeNormalByPrduceId(processList.get(0).getProcessId());
|
|
|
+ if(nodeCountList.size() > 0){
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ StringBuffer nodeBf = new StringBuffer();
|
|
|
+ StringBuffer desBf = new StringBuffer();
|
|
|
+ for(int i=0;i< nodeCountList.size();i++){
|
|
|
+ nodeBf.append(nodeCountList.get(i).getNum().toString()+",");
|
|
|
+ desBf.append("\""+nodeCountList.get(i).getNodeDes()+"\"" + ",");
|
|
|
+
|
|
|
+ }
|
|
|
+ String nodeString = nodeBf.toString();
|
|
|
+ String desString = desBf.toString();
|
|
|
+ mv.addObject("nodeString", "["+nodeString.substring(0,nodeString.length()-1)+"]");
|
|
|
+ mv.addObject("desString", "["+desString.substring(0,desString.length()-1)+"]");
|
|
|
+ }
|
|
|
+
|
|
|
+ return mv;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据工序id统计选项数量
|
|
|
+ * @author LJK
|
|
|
+ * @date 2017年8月31日16:08:15
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequiresPermissions("machine:abnormality:statistics")
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping("/_node_normal")
|
|
|
+ public ModelMap nodeNormal(HttpServletRequest request){
|
|
|
+ String processId = request.getParameter("processId");//工序id
|
|
|
+ ModelMap mm = new ModelMap();
|
|
|
+ if(processId == null || processId.equals("")){
|
|
|
+ mm.put("returnCode",500);
|
|
|
+ return mm;
|
|
|
+ }
|
|
|
+ List<PtsMachineStatistics> nodeCountList = machineService.nodeNormalByPrduceId(Integer.valueOf(processId));
|
|
|
+ if(nodeCountList.size() > 0){
|
|
|
+ StringBuffer nodeBf = new StringBuffer();
|
|
|
+ StringBuffer desBf = new StringBuffer();
|
|
|
+ for(int i=0;i< nodeCountList.size();i++){
|
|
|
+ nodeBf.append(nodeCountList.get(i).getNum().toString()+",");
|
|
|
+ desBf.append("\""+nodeCountList.get(i).getNodeDes()+"\"" + ",");
|
|
|
+ }
|
|
|
+ String nodeString = nodeBf.toString();
|
|
|
+ String desString = desBf.toString();
|
|
|
+ mm.put("returnCode",200);
|
|
|
+ mm.put("nodeString","["+nodeString.substring(0,nodeString.length()-1)+"]");
|
|
|
+ mm.put("desString","["+desString.substring(0,desString.length()-1)+"]");
|
|
|
+ }
|
|
|
+ return mm;
|
|
|
+ }
|
|
|
}
|