Explorar o código

底护板录入

wangxichen hai 1 semana
pai
achega
0090bd91f2

+ 14 - 0
src/main/java/com/jeesite/modules/mes/dao/MesProductDhbKcDao.java

@@ -0,0 +1,14 @@
+package com.jeesite.modules.mes.dao;
+
+import com.jeesite.common.dao.CrudDao;
+import com.jeesite.common.mybatis.annotation.MyBatisDao;
+import com.jeesite.modules.mes.entity.MesProductDhbKc;
+
+/**
+ * 底护板入库 DAO
+ */
+@MyBatisDao
+public interface MesProductDhbKcDao extends CrudDao<MesProductDhbKc> {
+
+    MesProductDhbKc findInfo(MesProductDhbKc mesProductDhbKc);
+}

+ 106 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductDhbKc.java

@@ -0,0 +1,106 @@
+package com.jeesite.modules.mes.entity;
+
+import javax.validation.constraints.Size;
+
+import com.jeesite.common.entity.DataEntity;
+import com.jeesite.common.mybatis.annotation.Column;
+import com.jeesite.common.mybatis.annotation.Table;
+import com.jeesite.common.mybatis.mapper.query.QueryType;
+
+import java.util.Date;
+
+/**
+ * 底护板入库表 Entity
+ * 工序:520-OP285 / 610-OP290(清洗后入库)
+ */
+@Table(name = "mes_product_dhb_kc", alias = "a", label = "底护板入库",
+        columns = {
+                @Column(name = "id", attrName = "id", label = "id", isPK = true),
+                @Column(name = "batch_sn", attrName = "batchSn", label = "底护板码", queryType = QueryType.LIKE),
+                @Column(name = "state", attrName = "state", label = "状态"),
+                @Column(name = "bind_sn", attrName = "bindSn", label = "绑定工件码", queryType = QueryType.LIKE),
+                @Column(name = "oprno", attrName = "oprno", label = "入库工位"),
+                @Column(name = "line_sn", attrName = "lineSn", label = "产线"),
+                @Column(name = "remark", attrName = "remark"),
+                @Column(name = "status", attrName = "status"),
+                @Column(name = "create_by", attrName = "createBy", isUpdate = false),
+                @Column(name = "create_date", attrName = "createDate", isUpdate = false, isUpdateForce = true),
+                @Column(name = "update_by", attrName = "updateBy"),
+                @Column(name = "update_date", attrName = "updateDate", isUpdateForce = true),
+        }, orderBy = "a.id DESC"
+)
+public class MesProductDhbKc extends DataEntity<MesProductDhbKc> {
+
+    private static final long serialVersionUID = 1L;
+
+    private String batchSn;   // 底护板码
+    private String state;     // 0 未绑工件 1 已绑工件
+    private String bindSn;    // 绑定的工件码
+    private String oprno;     // 入库工位(OP285/OP290)
+    private String lineSn;    // 产线
+
+    public MesProductDhbKc() {
+        this(null);
+    }
+
+    public MesProductDhbKc(String id) {
+        super(id);
+    }
+
+    @Size(min = 0, max = 100, message = "底护板码长度不能超过 100 个字符")
+    public String getBatchSn() {
+        return batchSn;
+    }
+
+    public void setBatchSn(String batchSn) {
+        this.batchSn = batchSn;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getBindSn() {
+        return bindSn;
+    }
+
+    public void setBindSn(String bindSn) {
+        this.bindSn = bindSn;
+    }
+
+    public String getOprno() {
+        return oprno;
+    }
+
+    public void setOprno(String oprno) {
+        this.oprno = oprno;
+    }
+
+    public String getLineSn() {
+        return lineSn;
+    }
+
+    public void setLineSn(String lineSn) {
+        this.lineSn = lineSn;
+    }
+
+    public Date getCreateDate_gte() {
+        return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
+    }
+
+    public void setCreateDate_gte(Date createDate) {
+        sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
+    }
+
+    public Date getCreateDate_lte() {
+        return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
+    }
+
+    public void setCreateDate_lte(Date createDate) {
+        sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
+    }
+}

+ 48 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductDhbKcService.java

@@ -0,0 +1,48 @@
+package com.jeesite.modules.mes.service;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.service.CrudService;
+import com.jeesite.modules.mes.dao.MesProductDhbKcDao;
+import com.jeesite.modules.mes.entity.MesProductDhbKc;
+
+/**
+ * 底护板入库 Service
+ */
+@Service
+public class MesProductDhbKcService extends CrudService<MesProductDhbKcDao, MesProductDhbKc> {
+
+    @Autowired
+    private MesProductDhbKcDao mesProductDhbKcDao;
+
+    public MesProductDhbKc findInfo(MesProductDhbKc mesProductDhbKc) {
+        return mesProductDhbKcDao.findInfo(mesProductDhbKc);
+    }
+
+    @Override
+    public Page<MesProductDhbKc> findPage(MesProductDhbKc mesProductDhbKc) {
+        return super.findPage(mesProductDhbKc);
+    }
+
+    @Override
+    public List<MesProductDhbKc> findList(MesProductDhbKc mesProductDhbKc) {
+        return super.findList(mesProductDhbKc);
+    }
+
+    @Override
+    @Transactional
+    public void save(MesProductDhbKc mesProductDhbKc) {
+        super.save(mesProductDhbKc);
+    }
+
+    @Override
+    @Transactional
+    public void delete(MesProductDhbKc mesProductDhbKc) {
+        super.delete(mesProductDhbKc);
+    }
+}

+ 145 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductDhbKcController.java

@@ -0,0 +1,145 @@
+package com.jeesite.modules.mes.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.jeesite.common.config.Global;
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.lang.ObjectUtils;
+import com.jeesite.common.lang.StringUtils;
+import com.jeesite.common.web.BaseController;
+import com.jeesite.modules.mes.entity.MesProductDhbKc;
+import com.jeesite.modules.mes.resp.CommonResp;
+import com.jeesite.modules.mes.service.MesProductDhbKcService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * 底护板入库 Controller(清洗工位)
+ * 520: OP285 / 610: OP290
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/mes/mesProductDhbKc")
+public class MesProductDhbKcController extends BaseController {
+
+    @Autowired
+    private MesProductDhbKcService mesProductDhbKcService;
+
+    /**
+     * 后台列表页
+     */
+    @RequestMapping(value = {"list", ""})
+    public String list(MesProductDhbKc mesProductDhbKc, Model model) {
+        model.addAttribute("mesProductDhbKc", mesProductDhbKc);
+        return "modules/mes/mesProductDhbKcList";
+    }
+
+    /**
+     * 后台列表数据
+     */
+    @RequestMapping(value = "listData")
+    @ResponseBody
+    public Page<MesProductDhbKc> listData(MesProductDhbKc mesProductDhbKc, HttpServletRequest request, HttpServletResponse response) {
+        mesProductDhbKc.setPage(new Page<>(request, response));
+        return mesProductDhbKcService.findPage(mesProductDhbKc);
+    }
+
+    /**
+     * 入库(客户端 op290-dh 调用)
+     * params: batchSn 底护板码 / oprno 工位号 / lineSn 产线 / userCode 操作员
+     */
+    @RequestMapping(value = "in")
+    @ResponseBody
+    public CommonResp<MesProductDhbKc> in(HttpServletRequest request) {
+        CommonResp<MesProductDhbKc> resp = new CommonResp<>();
+        String batchSn = StringUtils.trim(request.getParameter("batchSn"));
+        String oprno = StringUtils.trim(request.getParameter("oprno"));
+        String lineSn = StringUtils.trim(request.getParameter("lineSn"));
+        String userCode = StringUtils.trim(request.getParameter("userCode"));
+
+        if (StringUtils.isEmpty(batchSn)) {
+            resp.setResult(Global.FALSE);
+            resp.setMessage("底护板码不能为空");
+            return resp;
+        }
+
+        // 已存在 → 直接返回(保证幂等:重复扫不报错)
+        MesProductDhbKc q = new MesProductDhbKc();
+        q.setBatchSn(batchSn);
+        MesProductDhbKc exist = mesProductDhbKcService.findInfo(q);
+        if (!ObjectUtils.isEmpty(exist)) {
+            resp.setResult(Global.TRUE);
+            if ("1".equals(exist.getState())) {
+                resp.setMessage("该底护板已绑定工件: " + exist.getBindSn());
+            } else {
+                resp.setMessage("该底护板已入库");
+            }
+            resp.setData(exist);
+            return resp;
+        }
+
+        // 新增
+        MesProductDhbKc kc = new MesProductDhbKc();
+        kc.setBatchSn(batchSn);
+        kc.setState("0");
+        kc.setOprno(oprno);
+        kc.setLineSn(lineSn);
+        if (StringUtils.isNotEmpty(userCode)) {
+            kc.setCreateBy(userCode);
+            kc.setUpdateBy(userCode);
+        }
+        mesProductDhbKcService.save(kc);
+
+        resp.setResult(Global.TRUE);
+        resp.setMessage("入库成功");
+        resp.setData(kc);
+        return resp;
+    }
+
+    /**
+     * 校验是否已入库(压合工位绑定时调用)
+     */
+    @RequestMapping(value = "check")
+    @ResponseBody
+    public CommonResp<MesProductDhbKc> check(HttpServletRequest request) {
+        CommonResp<MesProductDhbKc> resp = new CommonResp<>();
+        String batchSn = StringUtils.trim(request.getParameter("batchSn"));
+        if (StringUtils.isEmpty(batchSn)) {
+            resp.setResult(Global.FALSE);
+            resp.setMessage("底护板码不能为空");
+            return resp;
+        }
+        MesProductDhbKc q = new MesProductDhbKc();
+        q.setBatchSn(batchSn);
+        MesProductDhbKc exist = mesProductDhbKcService.findInfo(q);
+        if (ObjectUtils.isEmpty(exist)) {
+            resp.setResult(Global.FALSE);
+            resp.setMessage("该底护板未入库");
+            return resp;
+        }
+        resp.setResult(Global.TRUE);
+        resp.setData(exist);
+        if ("1".equals(exist.getState())) {
+            resp.setMessage("已绑定工件: " + exist.getBindSn());
+        } else {
+            resp.setMessage("已入库, 未绑工件");
+        }
+        return resp;
+    }
+
+    /**
+     * 服务器健康检查(客户端启动时探测)
+     */
+    @RequestMapping(value = "ping")
+    @ResponseBody
+    public CommonResp<String> ping() {
+        CommonResp<String> resp = new CommonResp<>();
+        resp.setResult(Global.TRUE);
+        resp.setMessage("ok");
+        resp.setData("ok");
+        return resp;
+    }
+}

+ 4 - 0
src/main/resources/config/application.yml

@@ -671,6 +671,10 @@ shiro:
     ${adminPath}/mes/mesProductRecord/updateOprno = anon
     ${adminPath}/mes/mesProduct/alarmData = anon
     ${adminPath}/mes/mesProcessAlarm/add = anon
+    ${adminPath}/mes/mesProductDhbKc/in = anon
+    ${adminPath}/mes/mesProductDhbKc/check = anon
+    ${adminPath}/mes/mesProductDhbKc/ping = anon
+    ${adminPath}/mes/mesProductDhbKc/listData = anon
 
     ${adminPath}/** = user
 

+ 14 - 0
src/main/resources/mappings/modules/mes/MesProductDhbKcDao.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jeesite.modules.mes.dao.MesProductDhbKcDao">
+
+    <select id="findInfo" resultType="com.jeesite.modules.mes.entity.MesProductDhbKc">
+        SELECT ${sqlMap.column.toSql()}
+        FROM ${sqlMap.table.toSql()}
+        <where>
+            ${sqlMap.where.toSql()}
+        </where>
+        ORDER BY ${sqlMap.order.toSql()}
+        LIMIT 1
+    </select>
+</mapper>