瀏覽代碼

添加翻新机

liujiankang 7 年之前
父節點
當前提交
ca912a67e6

+ 2 - 1
watero-rst-interface/src/main/java/com/iamberry/rst/faces/pts/PtsBatchService.java

@@ -23,5 +23,6 @@ public interface PtsBatchService {
     //修改批次
     Integer updatePtsBatch(PtsBatch ptsBatch);
 
-
+    //查询所有状态为可用的批次
+    List<PtsBatch> listPtsBatchByStatus();
 }

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

@@ -54,4 +54,9 @@ public class PtsBatchServiceImpl implements PtsBatchService {
         return ptsBatchMapper.updatePtsBatch(ptsBatch);
     }
 
+    @Override
+    public List<PtsBatch> listPtsBatchByStatus() {
+        return ptsBatchMapper.listPtsBatchByStatus();
+    }
+
 }

+ 3 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/pts/mapper/PtsBatchMapper.java

@@ -20,4 +20,7 @@ public interface PtsBatchMapper {
 
     //停用其他相同产品的批次
     Integer batchStatusDisabled(PtsBatch ptsBatch);
+
+    //查询所有状态为可用的批次
+    List<PtsBatch> listPtsBatchByStatus();
 }

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

@@ -5,11 +5,12 @@
         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_nfcId,machine_produce_id)
+        machine_compound_img,machine_process_state,machine_create_time,
+        machine_produce_type,machine_nfcId,machine_produce_id,machine_batch_id,machine_bom_id,machine_is_retreading)
         VALUES
         (#{machineQrcode},#{machineBarcode},2,#{machineStatus},
         #{machineProducedTime},#{machineIsPrint},#{machineCompoundImg},#{machineProcessState},
-        #{machineCreateTime},#{machineProduceType},#{machineNfcId},#{machineProduceId})
+        #{machineCreateTime},#{machineProduceType},#{machineNfcId},#{machineProduceId},#{item.machineProduceId},#{item.machineBatchId},#{machineIsRetreading})
     </insert>
 
     <update id="updateMachine" parameterType="PtsMachine" >
@@ -323,12 +324,12 @@
     <insert id="addMahineBatch" useGeneratedKeys="true" parameterType="java.util.List">
         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_nfcId,machine_produce_id)
+        machine_compound_img,machine_process_state,machine_create_time,machine_produce_type,machine_nfcId,machine_produce_id,machine_batch_id,machine_bom_id,machine_is_retreading)
         values
         <foreach collection="list" item="item" index="index" separator="," >
             (#{item.machineQrcode},#{item.machineBarcode},2,#{item.machineStatus},
             #{item.machineProducedTime},#{item.machineIsPrint},#{item.machineCompoundImg},#{item.machineProcessState},
-            #{item.machineCreateTime},#{item.machineProduceType},#{item.machineNfcId},#{item.machineProduceId})
+            #{item.machineCreateTime},#{item.machineProduceType},#{item.machineNfcId},#{item.machineProduceId},#{item.machineBatchId},#{item.machineBomId},#{item.machineIsRetreading})
         </foreach>
     </insert>
 </mapper>

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

@@ -112,4 +112,23 @@
         WHERE
             batch_id = #{batchId}
     </update>
+
+    <select id="listPtsBatchByStatus" resultType="PtsBatch">
+        SELECT
+        t.batch_id AS batchId,
+        t.batch_no AS batchNo,
+        t.batch_quantity AS batchQuantity,
+        t.batch_color_quantity AS batchColorQuantity,
+        t.bom_id AS bomId,
+        t.produce_id AS produceId,
+        t.batch_software_version_id AS batchSoftwareVersionId,
+        t.batch_status AS  batchStatus,
+        t.batch_desc AS batchDesc,
+        t.batch_create_time AS batchCreateTime,
+        t.batch_update_time AS batchUpdateTime
+        FROM
+        tb_rst_pts_batch t
+        WHERE
+        batch_status = 1
+    </select>
 </mapper>

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

@@ -46,6 +46,14 @@ public class AdminMachineController {
     @Autowired
     private ProduceService produceService;
 
+    @Autowired
+    private PtsBatchService ptsBatchService;
+
+    @Autowired
+    private MachineVersionService machineVersionService;
+
+    @Autowired
+    private PtsBomService ptsBomService;
     /**
      * 查询机器列表
      *
@@ -462,6 +470,7 @@ public class AdminMachineController {
             ptsMachine.setMachineHardwareVersion(machineSoftwareVersion);
             ptsMachine.setMachineSoftwareVersion(machineSoftwareVersion);
             ptsMachine.setMachineProduceId(Integer.valueOf(produceId));
+            ptsMachine.setMachineIsRetreading(2);
             ptsList.add(ptsMachine);
         }
         Integer msg = machineService.addMahineBatch(ptsList);
@@ -493,5 +502,138 @@ public class AdminMachineController {
         String barcode = productModel+productFeatures+softwareVersion+String.valueOf(year).substring(2,4)+months;
         return barcode;
     }
+
+    /**
+     * 进入添加翻新机界面
+     * **/
+    @RequiresPermissions("machine:add:batch")
+    @RequestMapping("/_to_add_renovation")
+    public ModelAndView toAddRenovationMachine(){
+        ModelAndView mv = new ModelAndView("pts/machine/addRenovationMachine");
+        //查询所有状态为可用的批次
+        List<PtsBatch>  listptsBatch = ptsBatchService.listPtsBatchByStatus();
+        mv.addObject("listptsBatch",listptsBatch);
+        //查询所有软件版本
+        PtsMachineVersion ptsMachineVersion = new PtsMachineVersion();
+        ptsMachineVersion.setMachineVersionType(2);
+        List<PtsMachineVersion> ListVersion = machineVersionService.listMachineVersion(ptsMachineVersion);
+        mv.addObject("listVersion",ListVersion);
+        //根据第一个批次查询所有bom
+        if(listptsBatch.size() > 0){
+            PtsBom ptsBom = new PtsBom();
+            ptsBom.setBomId(listptsBatch.get(0).getBomId());
+            List<PtsBom> listBom = ptsBomService.listBom(ptsBom);
+            mv.addObject("listBom",listBom);
+        }
+        return mv;
+    }
+
+    /**
+     * 根据产品id获取所有bom
+     * **/
+    @ResponseBody
+    @RequiresPermissions("machine:add:batch")
+    @RequestMapping("/select_bom")
+    public ResponseJson selectBatchByProduceId(HttpServletRequest request,Integer batchId){
+        ResponseJson rj = new ResponseJson();
+        if (batchId == null || batchId.equals("")) {
+            rj.setReturnCode(500);
+            return rj;
+        }
+        PtsBatch ptsBatch = new PtsBatch();
+        ptsBatch.setBatchId(batchId);
+        ptsBatch = ptsBatchService.getPtsBatch(ptsBatch);
+
+        PtsBom ptsBom = new PtsBom();
+        ptsBom.setBomId(ptsBatch.getBomId());
+        List<PtsBom> listBom = ptsBomService.listBom(ptsBom);
+        rj.addResponseKeyValue("listBom",listBom);
+        rj.setReturnCode(200);
+        return rj;
+    }
+
+    /**
+     * 添加翻新机
+     * **/
+    @ResponseBody
+    @RequiresPermissions("machine:add:batch")
+    @RequestMapping("/add_renovationMachine")
+    public ResponseJson addRenovationMachine(HttpServletRequest request,Integer batchId,Integer versionId,Integer bomId,Integer number){
+        ResponseJson rj = new ResponseJson();
+        if (batchId == null || versionId == null || bomId == null) {
+            rj.setReturnCode(500);
+            return rj;
+        }
+        PtsBatch ptsBatch = new PtsBatch();
+        ptsBatch.setBatchId(batchId);
+        ptsBatch = ptsBatchService.getPtsBatch(ptsBatch);
+        Produce produce = new Produce();
+        produce.setProduceId(ptsBatch.getProduceId());
+        produce = produceService.getProduce(produce);
+
+        PtsBom ptsBom = new PtsBom();
+        ptsBom.setBomId(bomId);
+        ptsBom = ptsBomService.getPtsBom(ptsBom);
+        if(number == null || number < 1){
+            number = ptsBatch.getBatchQuantity();
+        }
+        ArrayList<PtsMachine> ptsList = new ArrayList<PtsMachine>();
+        //生成条形码前缀
+        String berQrcode = generationBarCode(produce);
+        //获取当前月机器总数
+        java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM");
+        java.util.Date currTime = new java.util.Date();
+        String curTime = formatter.format(currTime);
+        Integer machineNumber = machineService.selectMonthCount(curTime);
+        String num = null;
+        for (int i = 0; i < number; i++) {
+            machineNumber = machineNumber + i;
+            switch(String.valueOf(machineNumber+1).length()){
+                case 0:
+                    num = "0001";
+                    break;
+                case 1:
+                    num = "000"+String.valueOf(machineNumber);
+                    break;
+                case 2:
+                    num = "00"+String.valueOf(machineNumber);
+                    break;
+                case 3:
+                    num = "0"+String.valueOf(machineNumber);
+                    break;
+                case 4:
+                    num = String.valueOf(machineNumber);
+                    break;
+            }
+            String json = String.format(NameUtils.QR_LIMIT_STR_SCENE, ResultInfo.barCodePrefix + berQrcode);
+            QRCJson qrc = WeixinUtil.createQrcode(json);
+            PtsMachine ptsMachine = new PtsMachine();
+            ptsMachine.setMachineQrcode(qrc.getUrl());//二维码
+            ptsMachine.setMachineBarcode(berQrcode+num);//条形码
+            ptsMachine.setMachineStatus(1);//机器状态
+            ptsMachine.setMachineProducedTime(new Date());//生产时间
+            ptsMachine.setMachineIsPrint(1);//是否打印1:未打印2:已打印
+            ptsMachine.setMachineCompoundImg("合成的图片url");
+            ptsMachine.setMachineProcessState(1);//生成流程状态1.正常2.异常
+            ptsMachine.setMachineCreateTime(new Date());//创建时间
+            ptsMachine.setMachineProduceType(produce.getProduceType());//产品类型
+            ptsMachine.setMachineNfcId(productNfcId);
+            ptsMachine.setMachineHardwareVersion(ptsBom.getBomVersion());
+            ptsMachine.setMachineSoftwareVersion(ptsBatch.getSoftwareVersionNo());
+            ptsMachine.setMachineProduceId(produce.getProduceId());
+            ptsMachine.setMachineIsRetreading(1);
+            ptsMachine.setMachineBatchId(batchId);
+            ptsMachine.setMachineBomId(bomId);
+            ptsList.add(ptsMachine);
+        }
+        Integer msg = machineService.addMahineBatch(ptsList);
+        if (msg > 0) {
+            rj.setReturnCode(200);
+        } else {
+            rj.setReturnCode(500);
+        }
+        return rj;
+    }
+
 }
 

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

@@ -93,7 +93,10 @@ public class MachineController {
             ptsMachine.setMachineNfcId(nfcId);
             ptsMachine.setMachineHardwareVersion("30");
             ptsMachine.setMachineSoftwareVersion("30");
-            ptsMachine.setMachineProduceId(1);
+            ptsMachine.setMachineProduceId(produce.getProduceId());
+            ptsMachine.setMachineBomId(0);//默认为0
+            ptsMachine.setMachineBatchId(0);//默认为0
+            ptsMachine.setMachineIsRetreading(2);
             machineService.addMachine(ptsMachine);
         }
         boolean isAbnormality = true;//状态是否异常

+ 161 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/pts/machine/addRenovationMachine.ftl

@@ -0,0 +1,161 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="renderer" content="webkit|ie-comp|ie-stand">
+<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+<meta http-equiv="Cache-Control" content="no-siteapp" />
+<title>添加翻新机</title>
+    <style>
+        .my-title{font-weight: 500;padding-left: 15px;position: relative;}
+        .my-title:after{content: '';position: absolute;left: 0;top:12%;width: 3px;height: 80%;background: #32a3d8;}
+        .my-input{padding: 8px 10px;width: 80%;border:1px solid rgba(0,0,0,.1);}
+        .my-input-date{padding: 8px 10px;border:1px solid rgba(0,0,0,.1);width: 80%;background: url(http://s.iamberry.com/images/rili-1.png) 98.5% center no-repeat; background-size:auto 50%;}
+        .input-box{margin: 18px 0;}
+        .input-dic{float: left;margin:5px 10px 0 0;font-size: 12px;}
+        .add-list{list-style-type: none;padding: 10px;background-color: #f5f5f5;width: 60%;float: left;margin: 0;}
+        .add-list>li{margin: 10px 0;}
+        .my-textarea{padding: 5px 10px;width: 80%;border:1px solid rgba(0,0,0,.1);}
+        .my-btn-reset{padding: 10px 20px;width: 150px; background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
+        .my-btn-submit{padding: 10px 20px;width: 150px; background-color: #32a3d8;color: #fff;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
+        .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;width: 60%; height: 34px; -webkit-appearance:none;appearance:none;background: url(http://s.iamberry.com/images/select-1.png) right center no-repeat #fff;background-size:auto 100%;}
+        input[type=radio]{-webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
+        input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(/rst/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
+    	.spanhidth{width: 48px;}
+	</style>
+<#include "/base/add_base.ftl">
+</head>
+<body>
+<div class="pd-20">
+	<form   class="form form-horizontal" id="form-admin-add">
+            <div class="input-box">
+                <span class="input-dic spanhidth">请选择批次</span>
+				<select class="my-select" name="batchId" id="batchId">
+						<#if (listptsBatch ?size > 0)>
+							<#list listptsBatch as list>
+                                <option value ="${list.batchId}">${list.batchNo}</option>
+							</#list>
+						<#else >
+                            <option value ="">暂无批次,请先添加批次</option>
+						</#if>
+				</select>
+            </div>
+        <div class="input-box">
+            <span class="input-dic spanhidth">软件版本</span>
+            <select class="my-select" name="versionId">
+            <#if (listVersion ?size > 0)>
+                <#list listVersion as list>
+                    <option value ="${list.machineVersionId}">${list.machineVersionName}</option>
+                </#list>
+            <#else >
+                <option value ="">暂无软件版本,请先添加软件版本</option>
+            </#if>
+            </select>
+        </div>
+        <div class="input-box">
+            <span class="input-dic spanhidth">Bom</span>
+            <select class="my-select" name="bomId" id="bomId">
+            <#if (listBom ?size > 0)>
+                <#list listBom as list>
+                    <option value ="${list.bomId}">${list.bomName}</option>
+                </#list>
+            <#else >
+                <option value ="">暂无Bom,请先添加Bom单</option>
+            </#if>
+            </select>
+        </div>
+
+
+        <div class="input-box"><span class="input-dic spanhidth">数量</span><input class="my-input" type="text"  name="number" id="number" placeholder="每次最少生成一个机器"/> </div>
+		<div class="row cl">
+			<div class="col-9 col-offset-3">
+				<input id="sumbit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" onclick="admin_add()">
+			</div>
+		</div>
+	</form>
+</div>
+<#--<script type="text/javascript" src="${path}/common/admin/js/tips.js"></script>-->
+<script type="text/javascript">
+
+    /*监听批次修改Bom  bom单*/
+    $("#batchId").change(function(){
+        var batchId = $(this).val();
+        getBom(batchId);
+    });
+
+
+    /*获取bom信息,赋值在页面上*/
+    function getBom(batchId){
+        var bom = new Object();
+        $.ajax({
+            type: "POST",
+            data: {
+                batchId : batchId
+            },
+            url: "${path}/admin/machine/select_bom",
+            async: false,
+            success: function(data){
+                if (data.returnCode == 200) {
+                    bom = data.returnMsg.listBom;
+                }
+            },
+            error: function(XmlHttpRequest, textStatus, errorThrown){
+            }
+        });
+
+        if(bom != null){
+            $("#bomId").empty();
+            $.each(bom,function(n,value) {
+                var appoption = "<option value='"+value.bomId+"'>"+value.bomName+"</option>";
+                $("#bomId").append(appoption);
+            });
+
+        }
+    }
+
+ function dataCharm() {
+         var number = $("#number").val();
+         if(number == null){
+             layer.msg("数量不能为空",{icon: 5,time:3000});
+             return false;
+         }
+         if(1 > number.length > 5){
+             layer.msg("数量长度为2-10位",{icon: 5,time:3000});
+             return false;
+         }
+         return true;
+ }
+
+/*机器-添加*/
+function admin_add(){
+   		  var msg = dataCharm();
+   		  if(msg){
+              $.ajax({
+                  url: '${path}/admin/machine/add_renovationMachine',
+                  type: "POST",
+                  dataType: "json",
+                  data: $("#form-admin-add").serialize(),
+                  beforeSubmit: function (data) {
+                      $("#submit").attr("disabled","disabled");
+                  },
+                  success:  function(data){
+                      if(data.returnCode){
+                          layer.msg("添加成功",{icon: 1,time:3000});
+                              window.parent.location.reload();
+                              var index = parent.layer.getFrameIndex(window.name);
+                              parent.layer.close(index);
+
+                      }else{
+                          layer.msg("添加失败",{icon: 5,time:3000});
+                      }
+                  },
+                  error:function(data){
+                      layer.msg("添加失败",{icon: 5,time:3000});
+                  }
+              });
+		  }
+}
+</script>
+</body>
+</html>

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

@@ -28,6 +28,9 @@
                 	<input class="my-input" type="hidden" id="settingNumber" name="settingNumber" value="1"/>
 					<#--<button type="button" class="my-btn-search" onclick="setting();" style="cursor:pointer; margin-right: 50px;">设置</button>-->
                      <button type="button" class="my-btn-search" onclick="batch_add_machine('批量添加机器','${path}/admin/machine/_to_add_batch','','550');" style="cursor:pointer; margin-right: 50px;">添加机器</button>
+                     &nbsp; &nbsp;
+                     <button type="button" class="my-btn-search" onclick="add_renovationmachine('批量添加机器','${path}/admin/machine/_to_add_renovation','','550');" style="cursor:pointer; margin-right: 50px;">添加翻新机</button>
+
 					<input class="my-input" type="text" name="machineBarcode" value="${machineBarcode!''}" placeholder="请输入机器编号"/>
 					<select class="my-select" name="machineIsPrint">
 						<option value ="">是否打印过</option>
@@ -327,6 +330,10 @@
             function batch_add_machine(title,url,w,h){
                 layer_show(title,url,w,h);
             }
+            /*批量添加机器*/
+            function add_renovationmachine(title,url,w,h){
+                layer_show(title,url,w,h);
+            }
 
             /*获取产品信息*/
             function getProduce(machineId){