Parcourir la source

Merge branch 'master' of http://git.iamberry.com/hexiugang/iamberry-common-parent

wangxiaoming il y a 7 ans
Parent
commit
fccf5af7e7

+ 9 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/pts/PtsMachine.java

@@ -22,6 +22,7 @@ public class PtsMachine implements Serializable{
     private Integer machineProcessState;//生成流程状态
     private String machineSoftwareVersion;//软件版本
     private String machineHardwareVersion;//硬件版本
+    private String machineNfcId;//nfcId(卡片ID)
     private Date machineCreateTime;//创建时间
     private Date machineUpdateTime;//修改时间
 
@@ -152,4 +153,12 @@ public class PtsMachine implements Serializable{
     public void setMachineProduceType(Integer machineProduceType) {
         this.machineProduceType = machineProduceType;
     }
+
+    public String getMachineNfcId() {
+        return machineNfcId;
+    }
+
+    public void setMachineNfcId(String machineNfcId) {
+        this.machineNfcId = machineNfcId;
+    }
 }

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

@@ -41,4 +41,10 @@ public interface MachineService {
 
     //根据机器id获取产品类型
     Integer getProduceType(Integer machineId);
+
+    //查询是否存在相同的机器信息
+    Integer getMachineIsHave(PtsMachine ptsMachine);
+
+    //批量修改打印状态
+    Integer batchUpdateMachineIsPring(String[] machineBarcodes);
 }

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

@@ -76,4 +76,14 @@ public class MachineServiceImpl implements MachineService {
         return machineMapper.getProduceType(machineId);
     }
 
+    @Override
+    public Integer getMachineIsHave(PtsMachine ptsMachine) {
+        return machineMapper.getMachineIsHave(ptsMachine);
+    }
+
+    @Override
+    public Integer batchUpdateMachineIsPring(String[] machineBarcodes) {
+        return machineMapper.batchUpdateMachineIsPring(machineBarcodes);
+    }
+
 }

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

@@ -37,4 +37,9 @@ public interface MachineMapper {
 
    //根据机器id获取产品类型
    Integer getProduceType(Integer machineId);
+
+   //查询是否存在相同的机器信息
+   Integer getMachineIsHave(PtsMachine ptsMachine);
+   //批量修改打印状态
+   Integer batchUpdateMachineIsPring(String[] machineBarcodes);
 }

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

@@ -5,11 +5,11 @@
         INSERT INTO tb_rst_pts_machine
         (machine_qrcode,machine_barcode,machine_sales_state,
         machine_status,machine_produced_time,machine_is_print,
-        machine_compound_img,machine_process_state,machine_create_time,machine_produce_type)
+        machine_compound_img,machine_process_state,machine_create_time,machine_produce_type,machine_nfcId)
         VALUES
         (#{machineQrcode},#{machineBarcode},2,#{machineStatus},
         #{machineProducedTime},#{machineIsPrint},#{machineCompoundImg},#{machineProcessState},
-        #{machineCreateTime},#{machineProduceType})
+        #{machineCreateTime},#{machineProduceType},#{machineNfcId})
     </insert>
 
     <update id="updateMachine" parameterType="PtsMachine" >
@@ -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 -->
@@ -165,4 +168,24 @@
         where pm.machine_id = #{machineId} limit 1
 
     </select>
+    
+    <select id="getMachineIsHave" parameterType="PtsMachine" resultType="Integer">
+        SELECT
+            COUNT(*)
+        FROM
+            tb_rst_pts_machine pm
+        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);
+    }
 }

+ 26 - 4
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;
@@ -56,6 +57,23 @@ public class MachineController {
         JSONObject query = JSONObject.fromObject(nodeList);
         Integer employeeId = query.getInt("employeeId");//员工id
         String produceNo = query.getString("produceId");//产品编号
+        String nfcId = query.getString("nfcId");//NFCID(卡片id)
+        JSONArray nodes = query.getJSONArray("nodes");//选项集合(包含一个或多个工序选项,详情见示例)
+
+        //根据卡片id与生产时间判断数据库是否存在相同的数据
+        JSONObject machineJsonObject = nodes.getJSONObject(0);
+        String ProcessTime = machineJsonObject.getString("logsProcessTime"); //工序执行时间 (时间戳)
+        Date ProcessDate = timeConversions(ProcessTime);
+        PtsMachine machine = new PtsMachine();
+        machine.setMachineNfcId(nfcId);
+        machine.setMachineCreateTime(ProcessDate);
+        Integer ishave = machineService.getMachineIsHave(machine);
+        if(ishave > 0){
+            rj.setResultCode(500);
+            rj.setResultMsg("500");
+            rj.setResultMsg("此卡片内容已生成二维码");
+            return rj;
+        }
         Produce produce = produceService.getProduce(produceNo);//根据产品编号获取产品信息
         //生成条形码,二维码
         String berQrcode = generationBarCode();
@@ -72,10 +90,11 @@ public class MachineController {
             ptsMachine.setMachineProcessState(1);//生成流程状态1.正常2.异常
             ptsMachine.setMachineCreateTime(new Date());//创建时间
             ptsMachine.setMachineProduceType(produce.getProduceType());//产品类型
+            ptsMachine.setMachineNfcId(nfcId);
             machineService.addMachine(ptsMachine);
         }
         boolean isAbnormality = true;//状态是否异常
-        JSONArray nodes = query.getJSONArray("nodes");//选项集合(包含一个或多个工序选项,详情见示例)
+
         PtsMachineLogs ptsMachineLogs = new PtsMachineLogs();
         for(int i = 0;i< nodes.size();i++){
             JSONObject jsonObject = nodes.getJSONObject(i);
@@ -214,7 +233,7 @@ public class MachineController {
     }
 
 
-    private String productModel = "1x";//产品型号
+    private String productModel = "1X";//产品型号
     private String productFeatures = "A";//产品特性
     private String softwareVersion = "30";//软件版本
     //生成条形码
@@ -246,9 +265,12 @@ public class MachineController {
                 num = String.valueOf(number);
                 break;
         }
-
+        String months = String.valueOf(month);
+        if(month < 10){
+            months = "0"+months;
+        }
         //拼接
-        String barcode = productModel+productFeatures+softwareVersion+String.valueOf(year).substring(2,4)+month+num;
+        String barcode = productModel+productFeatures+softwareVersion+String.valueOf(year).substring(2,4)+months+num;
         return barcode;
     }
 }

+ 116 - 75
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>
@@ -70,11 +70,15 @@
         <script type="text/javascript" src="${path}/common/static/h-ui.admin/js/H-ui.js"></script>
 
 		<script type="text/javascript">
-            $("#all").click(function(){
-                $("input[name='checkbox']").attr("checked","true");
-            })
-
+            $("#all").on('click',function(){
+                console.log($(this).prop('checked'));
+                if($(this).prop('checked')){
+                    $("input[name='checkbox']").prop("checked","true");
+                }else{
+                    $("input[name='checkbox']").removeAttr("checked");
+                }
 
+            });
                 if(${machineIsPrint} == 1){
                     $("#notPrint").attr("class", "current");
                     $("#machineIsPrint").val(1);
@@ -105,43 +109,71 @@
 
                 }
             function  printList() {
+
+
+
                 var machineBarcode = null;
                 var machineQrcode = null;
-                var machineProduceType = 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);
                         machineQrcode = $(this).val().substring(13,($(this).val().length)-1);
                         machineProduceType = $(this).val().substring(($(this).val().length)-1,$(this).val().length);
-                        code128(machineBarcode);
-                        var barcodes = $("#bcTarget").html();
-                        /*$("#barcodeId").html(machineBarcode);
-                        $("#qrcodeImg").attr('src',machineQrcode);*/
-                        if(machineProduceType == 1){//净水机模板
-                            $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                    '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">WaterO可移动智能净水机</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                    '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                    '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                    '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                    '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no.:4295</span> ' +
-                                    '</div>');
+                        for (var i=0;i<settingNumber;i++){
+                            code128(machineBarcode);
+                            var barcodes = $("#bcTarget").html();
+                            /*$("#barcodeId").html(machineBarcode);
+                            $("#qrcodeImg").attr('src',machineQrcode);*/
+                            if(machineProduceType == 1){//净水机模板
+                                $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                        '<span style="position: absolute;top:0px;font-size: 14px;">WaterO可移动智能净水机</span>' +
+                                        '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                        '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                        '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                        '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                        '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                        '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
+                                        '</div>');
+                            }
+                            if(machineProduceType == 2){//冲奶机模板
+                                $("#printlist").append('<div style="width: 268px;height: 152px;position: relative;">' +
+                                        '<span style="position: absolute;top:0px;font-size: 14px;">爱贝源冲奶机</span>' +
+                                        '<span style="position: absolute;top: 24px;font-size: 12px;">型号:WA-1X</span>' +
+                                        '<span style="position: absolute;top: 40px;font-size: 12px;">S/N</span>' +
+                                        '<div style="position: absolute;left: -10px;top: 75px;height: 30px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
+                                        '<span style="position: absolute;top: 102px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
+                                        '<img style="position: absolute;right: 2px;top:18px;width: 86px;height: 86px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
+                                        '<span style="position: absolute;right: 26px;top: 102px;font-size: 12px;">NO.4295</span> ' +
+                                        '</div>');
+                            }
+                            /*updatePrint(machineBarcode);*/
                         }
-                        if(machineProduceType == 2){//冲奶机模板
-                            $("#printlist").append('<div style="width: 227px;height: 142px;position: relative;margin-left: 20px;">' +
-                                    '<span style="position: absolute;left: 10px;top:20px;font-size: 14px;">爱贝源冲奶机</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 44px;font-size: 12px;">型号:WA-1X</span>' +
-                                    '<span style="position: absolute;left: 10px;top: 60px;font-size: 12px;">S/N</span>' +
-                                    '<div style="position: absolute;top: 80px;height: 23px;" id="bcTarget2" class="barcodeImg">'+barcodes+'</div>' +
-                                    '<span style="position: absolute;left: 10px;top: 108px;font-size: 12px;width: 116px;text-align: center;" id="barcodeId">'+machineBarcode+'</span>' +
-                                    '<img style="position: absolute;right: 10px;top:24px;width: 78px;height: 78px;" id="qrcodeImg" src="'+machineQrcode+'" /> ' +
-                                    '<span style="position: absolute;right: 26px;top: 108px;font-size: 12px;">no:4295</span> ' +
-                                    '</div>');
-                        }
-                        updatePrint(machineBarcode);
                     })
-                $("#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{
+                    return;
+                }*/
+
+                prints = "";
             /*$.ajax({
                     cache: true,
                     type: "POST",
@@ -207,50 +239,38 @@
                 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);
-                                }
-                                $("#listid").prepend('<td class="text-c" width="10">'+value.machineBarcode+'</td>' +
-                                        '<td class="td-manage text-c"> <a onclick="machineLogs('+value.machineId+');" title="生产流程" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe667;</i></a> </td>');
-                            });
-                        }
+                var machineIsPrint = $("#machineIsPrint").val();
+                if(machineIsPrint == 2){
+                    $.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);
+                                    }
+                                    $("#listid").prepend('<tr><td width="2"> ' +
+                                            '<input name="checkbox" type="checkbox" value="'+value.machineBarcode+value.machineQrcode+value.machineProduceType+'" > </td>' +
+                                            '<td class="text-c" width="10">'+value.machineBarcode+'</td>' +
+                                            '<td class="td-manage text-c"> <a onclick="machineLogs('+value.machineId+');" title="生产流程" href="javascript:;"  class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe667;</i></a> </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;
+                        },
+                        error: function(){
+                            console.log("查询最新机器失败!");
+                        }
+                    });
                 }
-                return   year+"-"+month+"-"+date;
+
             }
 
+
                 function updatePrint(machineBarcode){
                     $.ajax({
                         "type" : "post",
@@ -269,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>