Browse Source

机器打印列表功能

liujiankang 7 years ago
parent
commit
d8c6abf44b

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

@@ -44,4 +44,7 @@ public interface MachineService {
 
     //查询是否存在相同的机器信息
     Integer getMachineIsHave(PtsMachine ptsMachine);
+
+    //批量修改打印状态
+    Integer batchUpdateMachineIsPring(String[] machineBarcodes);
 }

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

@@ -81,4 +81,9 @@ public class MachineServiceImpl implements MachineService {
         return machineMapper.getMachineIsHave(ptsMachine);
     }
 
+    @Override
+    public Integer batchUpdateMachineIsPring(String[] machineBarcodes) {
+        return machineMapper.batchUpdateMachineIsPring(machineBarcodes);
+    }
+
 }

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

@@ -40,4 +40,6 @@ public interface MachineMapper {
 
    //查询是否存在相同的机器信息
    Integer getMachineIsHave(PtsMachine ptsMachine);
+   //批量修改打印状态
+   Integer batchUpdateMachineIsPring(String[] machineBarcodes);
 }

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

@@ -83,6 +83,7 @@
                 AND machine_process_state = #{machineProcessState}
             </if>
         </where>
+        order by machine_create_time desc
     </select>
     
     <select id="listLatestMachine" parameterType="Integer" resultType="PtsMachine">
@@ -104,6 +105,7 @@
          machine_update_time machineUpdateTime,
          machine_produce_type machineProduceType
          from tb_rst_pts_machine where machine_id > #{machineId}
+         order by machine_create_time desc
     </select>
 
     <select id="maxMachineId" resultType="Integer">
@@ -148,6 +150,7 @@
          machine_update_time machineUpdateTime,
          machine_produce_type machineProduceType
         from tb_rst_pts_machine WHERE  machine_id = #{machineId}
+        order by machine_create_time desc
     </select>
 
     <!-- 查询每月机器台数 ,参数格式:2017-09 -->
@@ -174,4 +177,15 @@
         LEFT JOIN tb_rst_pts_machine_logs ml ON pm.machine_id = ml.machine_id
         where pm.machine_nfcId = #{machineNfcId} and ml.logs_process_time = #{machineCreateTime}
     </select>
+    
+    <update id="batchUpdateMachineIsPring" parameterType="java.util.List">
+        UPDATE tb_rst_pts_machine
+        SET machine_is_print = '2'
+        WHERE
+        machine_barcode  IN (
+        <foreach collection="array" item="item" separator=",">
+            #{item}
+        </foreach>)
+    </update>
+
 </mapper>

+ 21 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/AdminMachineController.java

@@ -6,6 +6,7 @@ import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.core.pts.PtsMachine;
 import com.iamberry.rst.core.pts.PtsMachineLogs;
 import com.iamberry.rst.faces.pts.*;
+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;
@@ -16,6 +17,7 @@ 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;
 
 /**
@@ -163,4 +165,23 @@ public class AdminMachineController {
         mv.addObject("ptsMachine", ptsMachine);
         return mv;
     }
+
+    /**
+     * 批量修改机器打印状态为已打印
+     * @param request
+     * @return
+     */
+    @RequiresPermissions("machine:update_print:machine")
+    @ResponseBody
+    @RequestMapping("/_batchUpdate_print")
+    public Integer batchUpdateMachineIsPring(HttpServletRequest request){
+        /*String[] listId = request.getParameterValues("machineBarcodes");*/
+        String listId = request.getParameter("machineBarcodes");
+        if(listId == null){
+            return 0;
+        }
+        String s = new String(listId);
+        String[] a = s.split(",");
+        return machineService.batchUpdateMachineIsPring(a);
+    }
 }

+ 4 - 2
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/MachineController.java

@@ -49,6 +49,7 @@ public class MachineController {
         ResponseJson rj = new ResponseJson();
         String nodeList = request.getParameter("nodeList"); //获取员工id
         if(nodeList == null || nodeList.equals("")){
+            rj.setResultCode(500);
             rj.setResultMsg("200");
             rj.setResultMsg("ERROR");
             return rj;
@@ -68,8 +69,9 @@ public class MachineController {
         machine.setMachineCreateTime(ProcessDate);
         Integer ishave = machineService.getMachineIsHave(machine);
         if(ishave > 0){
+            rj.setResultCode(500);
             rj.setResultMsg("500");
-            rj.setResultMsg("ERROR");
+            rj.setResultMsg("此卡片内容已生成二维码");
             return rj;
         }
         Produce produce = produceService.getProduce(produceNo);//根据产品编号获取产品信息
@@ -231,7 +233,7 @@ public class MachineController {
     }
 
 
-    private String productModel = "1x";//产品型号
+    private String productModel = "1X";//产品型号
     private String productFeatures = "A";//产品特性
     private String softwareVersion = "30";//软件版本
     //生成条形码

+ 49 - 10
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/machine_print_List.ftl

@@ -30,21 +30,21 @@
                 <input class="my-input" type="hidden" id="machineIsPrint" name="machineIsPrint"/>
                 <input class="my-input" type="text" id="settingNumber" name="printNumber" value="3" placeholder="打印数量" style="margin-top: 10px;"/>
                 <button type="button" class="my-btn-search" onclick="printList();" style="margin-right: 50px;margin-top: 10px;">打印</button>
-
+                    <button type="button" class="my-btn-search" onclick="batchUpdatePring();" style="margin-right: 50px;margin-top: 10px;">修改为已打印</button>
 			</form>
 		</div>
 		<div class="mt-2" style="margin: 20px;">
-			<table class="table table-border table-bordered table-bg table-hover table-sort">
+			<table class="table table-border table-bordered table-bg table-hover table-sort" style=" width: 50%;margin: 0 auto;">
 				<thead>
 				<tr class="text-c">
                     <th width="1"><input name='checkbox' type='checkbox' value='' id="all" >全选</th>
-					<th width="10">机器条码(点击打印)</th>
+					<th width="10">产品条码</th>
 					<th width="20">操作</th>
 				</tr>
 				</thead>
 				<tbody id="listid">
 					<#list machineList as list>
-						<tr >
+						<tr class="text-c">
                             <td width="2">
                                 <input name='checkbox' type='checkbox' value='${list.machineBarcode }${list.machineQrcode }${list.machineProduceType }' >
                             </td>
@@ -109,11 +109,18 @@
 
                 }
             function  printList() {
+
+
+
                 var machineBarcode = null;
                 var machineQrcode = null;
                 var machineProduceType = null;
                 var prints = "";
                 var settingNumber = $("#settingNumber").val();
+                var msg = "每个条形码打印数量为"+settingNumber+"条!";
+                layer.confirm(msg, {
+                    btn: ['确认','取消'] //按钮
+                }, function(){
                     $("input[name='checkbox']:checkbox:checked").each(function(){
                         prints += $(this).val();
                         machineBarcode = $(this).val().substring(0,13);
@@ -146,15 +153,26 @@
                                         '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
                                         '</div>');
                             }
-                            updatePrint(machineBarcode);
+                            /*updatePrint(machineBarcode);*/
                         }
                     })
-                if(prints != ""){
-                    $("#printlist").printArea();
-                    $("#printlist").html("");
+                    if(prints != ""){
+                        $("#printlist").printArea();
+                        $("#printlist").html("");
+                        layer.closeAll();
+                    }else{
+                        layer.msg('未选中需要打印的条形码', {icon: 2,time:2000});
+                    }
+                }, function(){
+                    return;
+                });
+
+                /*if (confirm(msg)==true){
+
                 }else{
-                    alert("未选中需要打印的条形码");
-                }
+                    return;
+                }*/
+
                 prints = "";
             /*$.ajax({
                     cache: true,
@@ -271,6 +289,27 @@
                 function machineLogs(machineId) {
                     window.location.href=root_path + '/admin/machine/_machine_logs_list?machineId='+machineId;
                 }
+
+            function batchUpdatePring(){
+                var a = new Array();
+                $("input[name='checkbox']:checkbox:checked").each(function(i) {
+                    a[i] = $(this).val().substring(0, 13);
+                })
+                $.ajax({
+                    "type" : "post",
+                    "url" : "${path}/admin/machine/_batchUpdate_print",
+                    "dataType" : "json",
+                    "data" :{machineBarcodes : ""+a},
+                    /*"data" :{machineBarcodes : JSON.stringify(a)},*/
+                    "success" : function(data) {
+                        layer.msg('修改成功!', {icon: 1,time:2000});
+                    },
+                    "error":function(data){
+                        /*alert("操作失败,请联系管理员!");*/
+                        layer.msg('操作失败!', {icon: 2,time:2000});
+                    }
+                });
+            }
         </script>
 	</body>
 </html>