浏览代码

后台机器类 机器列表

liujiankang 7 年之前
父节点
当前提交
0167e7e2cd

+ 6 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/pts/MachineService.java

@@ -20,4 +20,10 @@ public interface MachineService {
 
     //查询机器列表
     PagedResult<PtsMachine> listMachine(int pageNO, int pageSize, PtsMachine ptsMachine, boolean isTotalNum);
+
+    //查询最新机器
+    List<PtsMachine> listLatestMachine(Integer machineId);
+
+    //查询数据库最大的机器id
+    Integer maxMachineId();
 }

+ 11 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/pts/MachineServiceImpl.java

@@ -39,4 +39,15 @@ public class MachineServiceImpl implements MachineService {
         List<PtsMachine> list = machineMapper.listMachine(ptsMachine);
         return PageUtil.getPage(list);
     }
+
+    @Override
+    public List<PtsMachine> listLatestMachine(Integer machineId) {
+        return machineMapper.listLatestMachine(machineId);
+    }
+
+    @Override
+    public Integer maxMachineId() {
+        return machineMapper.maxMachineId();
+    }
+
 }

+ 6 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/pts/mapper/MachineMapper.java

@@ -18,4 +18,10 @@ public interface MachineMapper {
 
     //查询机器列表
     List<PtsMachine> listMachine(PtsMachine ptsMachine);
+
+    //查询最新机器
+    List<PtsMachine> listLatestMachine(Integer machineId);
+
+    //查询数据库最大的机器id
+    Integer maxMachineId();
 }

+ 27 - 3
watero-rst-service/src/main/java/com/iamberry/rst/service/pts/mapper/machineMapper.xml

@@ -68,15 +68,39 @@
          machine_update_time machineUpdateTime
          FROM  tb_rst_pts_machine
         <where>
-            <if test="machineBarcode != null">
+            <if test="machineBarcode != null and machineBarcode != ''">
                 machine_barcode = #{machineBarcode}
             </if>
-            <if test="machineIsPrint != null">
+            <if test="machineIsPrint != null and machineIsPrint != ''">
                AND machine_is_print = #{machineIsPrint}
             </if>
-            <if test="machineProcessState != null">
+            <if test="machineProcessState != null and machineProcessState != ''">
                 AND machine_process_state = #{machineProcessState}
             </if>
         </where>
     </select>
+    
+    <select id="listLatestMachine" parameterType="Integer" resultType="PtsMachine">
+        select
+         machine_id machineId,
+         machine_qrcode machineQrcode,
+         machine_barcode machineBarcode,
+         machine_sales_date machineSalesDate,
+         machine_sales_state machineSalesState,
+         machine_status machineStatus,
+         machine_produced_time machineProducedTime,
+         machine_sub_time machineSubTime,
+         machine_is_print machineIsPrint,
+         machine_compound_img machineCompoundImg,
+         machine_process_state machineProcessState,
+         machine_software_version machineSoftwareVersion,
+         machine_hardware_version machineHardwareVersion,
+         machine_create_time machineCreateTime,
+         machine_update_time machineUpdateTime
+         from tb_rst_pts_machine where machine_id > #{machineId}
+    </select>
+
+    <select id="maxMachineId" resultType="Integer">
+        select * from tb_rst_pts_machine ORDER BY machine_id DESC  limit 1
+    </select>
 </mapper>

+ 25 - 4
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/AdminMachineController.java

@@ -11,14 +11,17 @@ 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.util.List;
 
 /**
  * Created by LJK on 2017/8/29.
  */
 @Controller
-@RequestMapping("/admin/mcahine")
+@RequestMapping("/admin/machine")
 public class AdminMachineController {
 
     @Autowired
@@ -38,14 +41,14 @@ public class AdminMachineController {
             @RequestParam(value = "pageNO", defaultValue = "1",required=false) Integer pageNO,
             @RequestParam(value = "totalNum", defaultValue = "0",required=false) Integer totalNum,
             PtsMachine ptsMachine){
-        ModelAndView mv = new ModelAndView("machine/machine_list");
+        ModelAndView mv = new ModelAndView("pts/machine/machine_list");
         PagedResult<PtsMachine> pagedResult = machineService.listMachine(pageNO, pageSize, ptsMachine, totalNum == 0);
 
         if(totalNum != 0) {
             pagedResult.setTotal(totalNum);
             pagedResult.setPages((int) Math.ceil((double)totalNum/pageSize));
         }
-        StringBuilder sb = new StringBuilder("/admin/mcahine/_machine_list?pageSize=" + pageSize);
+        StringBuilder sb = new StringBuilder("/admin/machine/_machine_list?pageSize=" + pageSize);
 
         if (StringUtils.isNotEmpty(ptsMachine.getMachineBarcode())) {
             sb.append("&machineBarcode=");
@@ -65,9 +68,27 @@ public class AdminMachineController {
         sb.append("&totalNum=");
         sb.append(totalNum == 0 ? pagedResult.getTotal() : totalNum);
         sb.append("&pageNO=");
-
+        //查询最新一条机器id
+        Integer machineId = machineService.maxMachineId();
+        mv.addObject("machineId",machineId);
         mv.addObject("page", pagedResult);
         mv.addObject("url", sb.toString());
         return mv;
     }
+
+    /**
+     * 查询最新机器信息
+     * @param request
+     * @return
+     */
+    @RequiresPermissions("machine:latest_all:machine")
+    @ResponseBody
+    @RequestMapping("/_LatestMachine_list")
+    public List<PtsMachine> listLatestMachine(HttpServletRequest request){
+        String machineId = request.getParameter("machineId");
+        if(machineId == null){
+            return null;
+        }
+        return  machineService.listLatestMachine(Integer.valueOf(machineId));
+    }
 }

+ 136 - 15
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/machine_List.ftl

@@ -13,17 +13,54 @@
 		<#include "/base/list_base.ftl">
 	</head>
 	<body>
-		<div>
-		<input class="my-input" type="text" placeholder="请输入机器编号"/>
-		<select class="my-select">
-			<option value ="未打印">未打印</option>
-		</select>
-		<select class="my-select">
-			<option value ="正常">正常</option>
-		</select>
-		<button type="submit" class="my-btn-search">搜索</button>
+		<div class="text-c" style="margin-top: 20px;">
+			<form action="${path}/admin/machine/_machine_list" method="post">
+
+					<input class="my-input" type="text" name="printNumber" value="${printNumber!''}" placeholder="每个机器打印数量"/>
+					<button type="button" class="my-btn-search" style="margin-right: 50px;">打印</button>
+
+					<input class="my-input" type="text" name="machineBarcode" value="${machineBarcode!''}" placeholder="请输入机器编号"/>
+					<select class="my-select" name="machineIsPrint">
+						<option value ="">是否打印过</option>
+					<#if machineIsPrint??>
+						<#if machineIsPrint == 1>
+						<option value ="1" selected>未打印</option>
+						<#else >
+							<option value ="1">未打印</option>
+						</#if>
+						<#if machineIsPrint == 2>
+							<option value ="2" selected>已打印</option>
+						<#else >
+							<option value ="2">已打印</option>
+						</#if>
+					<#else >
+						<option value ="1">未打印</option>
+						<option value ="2">已打印</option>
+					</#if>
+					</select>
+					<select class="my-select" name="machineProcessState">
+						<option value ="">流程是否正常</option>
+
+						<#if machineProcessState??>
+							<#if machineProcessState == 1>
+								<option value ="1" selected>正常</option>
+							<#else >
+								<option value ="1">正常</option>
+							</#if>
+							<#if machineProcessState == 2>
+								<option value ="2" selected>异常</option>
+							<#else >
+								<option value ="2">异常</option>
+							</#if>
+						<#else >
+							<option value ="1">正常</option>
+							<option value ="2">异常</option>
+						</#if>
+					</select>
+					<button type="submit" class="my-btn-search">搜索</button>
+			</form>
 		</div>
-		<div class="mt-20">
+		<div class="mt-20" style="margin: 20px;">
 			<table class="table table-border table-bordered table-bg table-hover table-sort">
 				<thead>
 				<tr class="text-c">
@@ -38,10 +75,10 @@
 				</tr>
 				</thead>
 				<tbody id="listid">
-					<#list page.dataList as order>
+					<#list page.dataList as list>
 						<tr>
-							<td class="text-c" width="10">${list.machineBarcode }</td>
-							<td class="text-c" width="100"><div id="${100000 + st.index}"><img style="width: 50px;height: 50px;" src="${list.machineQrcode }"></td>
+							<td class="text-c" width="100">${list.machineBarcode }</td>
+							<td class="text-c" width="100"><div id="${100000 + list_index}"><img style="width: 50px;height: 50px;" src="${list.machineQrcode }"></td>
                             <td class="text-c" width="100">
 							<#if list.machineIsPrint == 1>
                                     未打印
@@ -58,7 +95,7 @@
                                     未售出
 							</#if>
                             </td>
-							<td class="text-c" width="100"><fmt:formatDate value="${list.machineSalesDate }" pattern="yyyy-MM-dd HH:mm" /></td>
+							<td class="text-c" width="100">${(list.machineSalesDate?string("yyyy-MM-dd"))!''}</td>
                             <td class="text-c" width="100">
 							<#if list.machineProcessState == 1>
                                     正常
@@ -67,7 +104,7 @@
                                     异常
 							</#if>
                             </td>
-                            <td class="text-c" width="100"><fmt:formatDate value="${list.machineProducedTime }" pattern="yyyy-MM-dd HH:mm" /></td>
+                            <td class="text-c" width="100">${(list.machineProducedTime?string("yyyy-MM-dd"))!''}</td>
 							<!-- 遍历操作 -->
 							<td class="td-manage text-c">
 								<#--<a onclick="print(${100000 + st.index},${list.numberId},${list.numberIsPrint})" title="打印" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe652;</i></a>
@@ -77,7 +114,91 @@
 					</#list>
 				</tbody>
 			</table>
+			<input type="hidden" value="${machineId!''}" name="machineId" id="machineId">
 		</div>
 		<#include "/base/page_util.ftl">
+        <script type="text/javascript">
+            ref = setInterval(function(){
+                latestMachine();
+            },2000);
+            function  latestMachine() {
+                $.ajax({
+                    cache: true,
+                    type: "POST",
+                    url: "${path}/admin/machine/_LatestMachine_list",
+                    data:{machineId : $("#machineId").val()},// 你的formid
+                    success: function(data){
+                        if(data != null){
+                            $.each(data,function(i,value) {
+                                if(i+1 == data.length){
+                                    $("#machineId").val(value.machineId);
+								}
+								var machineIsPrint = null;
+                                var machineSalesState = null;
+                                var machineProcessState = null;
+
+								if(value.machineIsPrint == 1){
+                                    machineIsPrint = "未打印";
+								}else{
+                                    machineIsPrint = "已打印";
+								}
+                                if(value.machineSalesState == 1){
+                                    machineSalesState = "已售出";
+                                }else{
+                                    machineSalesState = "未售出";
+                                }
+                                if(value.machineProcessState == 1){
+                                    machineProcessState = "正常";
+                                }else{
+                                    machineProcessState = "异常";
+                                }
+                                var machineSalesDate = null;
+								if(value.machineSalesDate != null && value.machineSalesDate != undefined){
+                                    machineSalesDate =  formatDate(value.machineSalesDate);
+								}
+                                var machineProducedTime = null;
+                                if(value.machineProducedTime != null && value.machineProducedTime != undefined){
+                                    machineProducedTime =  formatDate(value.machineProducedTime);
+                                }
+
+								$("#listid").prepend('<tr>'
+                                        +'<td class="text-c" width="100">'+value.machineBarcode+'</td>'
+                                        +'<td class="text-c" width="100"><div id=""><img style="width: 50px;height: 50px;" src="'+value.machineQrcode+'"></td>'
+                                        +'<td class="text-c" width="100">'+machineIsPrint+'</td>'
+                                        +'<td class="text-c" width="100">'+machineSalesState+'</td>'
+										+'<td class="text-c" width="100">'+machineSalesDate+'</td>'
+                            			+'<td class="text-c" width="100">'+machineProcessState+'</td>'
+                                        +'<td class="text-c" width="100">'+machineProducedTime+'</td>'
+                            			+'<td class="td-manage text-c"></td></tr>');
+							});
+						}
+
+                    },
+                    error: function(){
+                        console.log("查询最新机器失败!");
+                    }
+                });
+            }
+
+            function   formatDate(now)   {
+                var time = new Date(now);
+                var   year=time.getFullYear();
+                var   month=time.getMonth()+1;
+                var   date=time.getDate();
+                var   hour=time.getHours();
+                var   minute=time.getMinutes();
+                var   second=time.getSeconds();
+                if(month < 10){
+                    month = "0"+month;
+                }
+                if(date < 10){
+                    date = "0"+date;
+                }
+                if(minute < 10){
+                    minute = "0"+minute;
+                }
+                return   year+"-"+month+"-"+date;
+            }
+        </script>
 	</body>
 </html>