فهرست منبع

机器生产统计页面修改

liujiankang 7 سال پیش
والد
کامیت
41e6db4ed3

+ 37 - 24
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/AdminMachineController.java

@@ -249,7 +249,7 @@ public class AdminMachineController {
     }
 
     /**
-     * 查询机器打印列表
+     * 查询机器生产&异常统计
      *
      * @return
      * @author LJK
@@ -259,16 +259,21 @@ public class AdminMachineController {
     @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";
+        String produceId = request.getParameter("produceId");//1.产品id
+        if (produceId == null || produceId.equals("")) {
+            produceId = "1";//默认为第一个产品
         }
-        mv.addObject("machineType", machineType);
+        mv.addObject("produceId", produceId);
+        //根据产品id查询产品类型
+        Produce produce = new Produce();
+        produce.setProduceId(Integer.valueOf(produceId));
+        produce = produceService.getProduce(produce);
+
         PtsMachineStatistics ptsMachineStatistics = new PtsMachineStatistics();
         Calendar date = Calendar.getInstance();
         String year = String.valueOf(date.get(Calendar.YEAR));//年
         ptsMachineStatistics.setYear(year);
-        ptsMachineStatistics.setMachineType(Integer.valueOf(machineType));
+        ptsMachineStatistics.setMachineType(produce.getProduceType());
         //查询1-12月每月生产机器数
         List<PtsMachineStatistics> ptsMachineStatisticsList = machineService.monthStatistics(ptsMachineStatistics);
         if (ptsMachineStatisticsList.size() > 0) {
@@ -299,10 +304,14 @@ public class AdminMachineController {
         PtsMachineStatistics numbers = machineService.flowAbnormality(ptsMachineStatistics);
         /*机器总数*/
         mv.addObject("machineNum", numbers.getMachineCount());
-        /*机器异常总数*/
-        mv.addObject("machineAbnormality", numbers.getMachineAbnormality());
+        double percentage = 0.0;
         /*流程异常百分比*/
-        double percentage = (numbers.getMachineAbnormality() == null ? 0.0 : (double) numbers.getMachineAbnormality()) / (numbers.getMachineCount() == null ? 0.0 : (double) numbers.getMachineCount()) * 100;
+        if(numbers.getMachineAbnormality() == null){
+            /*机器异常总数*/
+            mv.addObject("machineAbnormality", 0);
+        }else{
+            percentage = (double) numbers.getMachineAbnormality() / (double) numbers.getMachineCount() * 100;
+        }
         NumberFormat nf = new DecimalFormat("0.0 ");
         percentage = Double.parseDouble(nf.format(percentage));
         mv.addObject("abnormalityPercentage", percentage);
@@ -311,26 +320,30 @@ public class AdminMachineController {
         mv.addObject("normalPercentage", normalPercentage);
         /*根据机器类型查询机器所有工序*/
         ProduceProcess produceProcess = new ProduceProcess();
-        produceProcess.setProduceId(machineType.equals("1") ? 1 : 2);
+        produceProcess.setProduceId(produce.getProduceType());
         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() + "\"" + ",");
-
+        if(processList.size() > 0){
+            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) + "]");
             }
-            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) + "]");
         }
-
+        //查询所有产品
+        List<Produce> list = produceService.getProduceList();
+        mv.addObject("produceList", list);
         return mv;
     }
 

+ 13 - 6
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/producedAbnormalityStatistics.ftl

@@ -20,9 +20,15 @@
 <body>
 <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 统计管理 <span class="c-gray en">&gt;</span> 生产统计 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px;background-color: #32a3d8;border: 1px solid #32a3d8;" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
 <div class="pd-20">
-	<div style="width: 250px;margin-bottom: 20px;">
+	<div style="width: 780px;margin-bottom: 20px;">
 	<nav class="my-nav" id="tab-nav-menu">
-		<a <#if machineType == '1'>class="active" </#if> onclick="machineTypeNormal(1);">净水机</a><a <#if machineType == '2'>class="active" </#if> onclick="machineTypeNormal(2);">冲奶机</a>
+		<#--<a <#if machineType == '1'>class="active" </#if> onclick="machineTypeNormal(1);">净水机</a><a <#if machineType == '2'>class="active" </#if> onclick="machineTypeNormal(2);">冲奶机</a>-->
+
+    <#if (produceList ?size > 0)>
+        <#list produceList as list>
+            <a style="width: 100px;" <#if produceId == (""+list.produceId)>class="active"</#if>  onclick="machineTypeNormal(${list.produceId});">${list.produceName}</a>
+        </#list>
+    </#if>
 	</nav>
 	</div>
 	<div>
@@ -42,7 +48,7 @@
             </#list>
 		</nav>
 		</div>
-	<div id="container3" style="width:500px;height:400px;display: inline-block;"></div>
+    <div id="container3"  style="width:500px;height:400px;display: inline-block;"></div>
 	</div>	
 		<div class="charts-box" style="height: 478px;">
 	<div id="container2" style="width:500px;height:478px;display: inline-block;"></div>
@@ -201,6 +207,7 @@ $(function () {
             ]
         }]
     });
+<#if desString?? >
   var chart3 =new Highcharts.Chart('container3', {
 
         chart: {
@@ -245,7 +252,7 @@ $(function () {
 
         }]
     });
-    
+</#if>
     
 //按钮切换    
 $(document).on('click', '#tab-nav-menu>a', function() {
@@ -320,8 +327,8 @@ $(document).on('click', '#tab-nav-map>a', function() {
 
 });
 
-function machineTypeNormal(machineType) {
-    window.location.href=root_path + '/admin/machine/_produced_abnormality_statistics?machineType='+machineType;
+function machineTypeNormal(produceId) {
+    window.location.href=root_path + '/admin/machine/_produced_abnormality_statistics?produceId='+produceId;
 }
 </script>
 </body>