Bladeren bron

PDA报工

hfy 3 maanden geleden
bovenliggende
commit
38fc8396a1

+ 2 - 0
src/main/java/com/jeesite/modules/mes/dao/MesLineProcessDao.java

@@ -29,6 +29,8 @@ public interface MesLineProcessDao extends CrudDao<MesLineProcess> {
 
     List<MesLineProcess> getAllSonOpron();
 
+    List<MesLineProcess> findOprnoListByLineSn(@Param("lineSn") String lineSn);
+
 
     /**
      * 根据ID修改jar路径

+ 9 - 0
src/main/java/com/jeesite/modules/mes/dao/MesPdaScanRecordDao.java

@@ -5,6 +5,9 @@ import com.jeesite.common.mybatis.annotation.MyBatisDao;
 import com.jeesite.modules.mes.entity.MesPdaScanRecord;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
+import java.util.List;
+
 /**
  * PDA scan record DAO.
  * @author mes
@@ -20,4 +23,10 @@ public interface MesPdaScanRecordDao extends CrudDao<MesPdaScanRecord> {
 			@Param("oprno") String oprno);
 
 	int updateRecordStatus(@Param("id") String id, @Param("status") String status);
+
+	int countNormalByQuery(@Param("lineSn") String lineSn, @Param("oprno") String oprno,
+			@Param("ucode") String ucode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+	List<MesPdaScanRecord> findNormalListByQuery(@Param("lineSn") String lineSn, @Param("oprno") String oprno,
+			@Param("ucode") String ucode, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
 }

+ 7 - 0
src/main/java/com/jeesite/modules/mes/service/MesLineProcessService.java

@@ -210,6 +210,13 @@ public class MesLineProcessService extends CrudService<MesLineProcessDao, MesLin
 	}
 
 	// 获取固化工位
+	public List<MesLineProcess> findOprnoListByLineSn(String lineSn) {
+		if (StringUtils.isBlank(lineSn)) {
+			return ListUtils.newArrayList();
+		}
+		return mesLineProcessDao.findOprnoListByLineSn(lineSn.trim());
+	}
+
 	public List<String> getGhOpronStr(String lineSn) {
 		List<MesLineProcess> mesLineProcesses = this.getGhOprons(lineSn);
 

+ 19 - 0
src/main/java/com/jeesite/modules/mes/service/MesPdaScanRecordService.java

@@ -1,6 +1,7 @@
 package com.jeesite.modules.mes.service;
 
 import com.jeesite.common.entity.Page;
+import com.jeesite.common.collect.ListUtils;
 import com.jeesite.common.lang.StringUtils;
 import com.jeesite.common.service.CrudService;
 import com.jeesite.modules.mes.dao.MesPdaScanRecordDao;
@@ -8,6 +9,7 @@ import com.jeesite.modules.mes.entity.MesPdaScanRecord;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -47,6 +49,23 @@ public class MesPdaScanRecordService extends CrudService<MesPdaScanRecordDao, Me
 		return dao.findLatestNormalBySnLineOprno(sn.trim(), lineSn.trim(), oprno.trim());
 	}
 
+	public int countNormalByQuery(String lineSn, String oprno, String ucode, Date startTime, Date endTime) {
+		if (StringUtils.isBlank(lineSn) || StringUtils.isBlank(oprno) || StringUtils.isBlank(ucode)
+				|| startTime == null || endTime == null) {
+			return 0;
+		}
+		return dao.countNormalByQuery(lineSn.trim(), oprno.trim(), ucode.trim(), startTime, endTime);
+	}
+
+	public List<MesPdaScanRecord> findNormalListByQuery(String lineSn, String oprno, String ucode,
+			Date startTime, Date endTime) {
+		if (StringUtils.isBlank(lineSn) || StringUtils.isBlank(oprno) || StringUtils.isBlank(ucode)
+				|| startTime == null || endTime == null) {
+			return ListUtils.newArrayList();
+		}
+		return dao.findNormalListByQuery(lineSn.trim(), oprno.trim(), ucode.trim(), startTime, endTime);
+	}
+
 	@Transactional
 	public void finishPreviousScanRecord(String sn, String lineSn, String oprno) {
 		MesPdaScanRecord record = findLatestBySnLineOprno(sn, lineSn, oprno);

+ 135 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -4667,6 +4667,141 @@ public class MesProductRecordController extends BaseController {
 	}
 
 
+	// PDA查询所有lineSn
+	@PostMapping(value = "pdaQueryLineSn")
+	@ResponseBody
+	public CommonResp pdaQueryLineSn(HttpServletRequest request) {
+		CommonResp resp = new CommonResp<>();
+		try {
+			MesLine mesLine = new MesLine();
+			mesLine.setStatus("0");
+			List<MesLine> lineList = mesLineService.findList(mesLine);
+			List<Map<String, Object>> dataList = ListUtils.newArrayList();
+			Set<String> lineSnSet = new LinkedHashSet<>();
+			for (MesLine line : lineList) {
+				if (line != null && StringUtils.isNotBlank(line.getSn())) {
+					lineSnSet.add(line.getSn());
+				}
+			}
+			for (String lineSn : lineSnSet) {
+				Map<String, Object> map = MapUtils.newHashMap();
+				map.put("lineSn", lineSn);
+				dataList.add(map);
+			}
+			resp.setResult(Global.TRUE);
+			resp.setMessage("成功");
+			resp.setData(dataList);
+			return resp;
+		} catch (Exception e) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage(e.getMessage());
+			return resp;
+		}
+	}
+
+	// PDA通过lineSn查询所有oprno
+	@PostMapping(value = "pdaQueryOprno")
+	@ResponseBody
+	public CommonResp pdaQueryOprno(HttpServletRequest request) {
+		CommonResp resp = new CommonResp<>();
+		String lineSn = request.getParameter("lineSn");
+		if (StringUtils.isEmpty(lineSn)) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage("参数错误");
+			return resp;
+		}
+		try {
+			List<MesLineProcess> processList = mesLineProcessService.findOprnoListByLineSn(lineSn);
+			List<Map<String, Object>> dataList = ListUtils.newArrayList();
+			for (MesLineProcess process : processList) {
+				if (process.getOprno().length()!=5||("OP050".equals(process.getOprno())&&"HEVXT".equals(lineSn))){
+					continue;
+				}
+				Map<String, Object> map = MapUtils.newHashMap();
+				map.put("lineSn", lineSn);
+				map.put("title", process.getTitle());
+				map.put("oprno", process.getOprno());
+				dataList.add(map);
+			}
+			resp.setResult(Global.TRUE);
+			resp.setMessage("成功");
+			resp.setData(dataList);
+			return resp;
+		} catch (Exception e) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage(e.getMessage());
+			return resp;
+		}
+	}
+
+	// PDA查询所有扫码记录
+	@PostMapping(value = "pdaQueryScanRecord")
+	@ResponseBody
+	public CommonResp pdaQueryScanRecord(HttpServletRequest request) {
+		CommonResp resp = new CommonResp<>();
+		String lineSn = request.getParameter("lineSn");
+		String oprno = request.getParameter("oprno");
+		String ucode = request.getParameter("ucode");
+		String startTimeStr = request.getParameter("startTime");
+		String endTimeStr = request.getParameter("endTime");
+		if (StringUtils.isEmpty(lineSn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(ucode)
+				|| StringUtils.isEmpty(startTimeStr) || StringUtils.isEmpty(endTimeStr)) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage("参数错误");
+			return resp;
+		}
+		try {
+			Date startTime = parsePdaScanTime(startTimeStr);
+			Date endTime = parsePdaScanTime(endTimeStr);
+			if (startTime == null || endTime == null) {
+				resp.setResult(Global.FALSE);
+				resp.setMessage("时间格式错误,应为 yyyy-MM-dd HH:mm:ss");
+				return resp;
+			}
+			if (endTime.before(startTime)) {
+				resp.setResult(Global.FALSE);
+				resp.setMessage("结束时间不能小于开始时间");
+				return resp;
+			}
+
+			int total = mesPdaScanRecordService.countNormalByQuery(lineSn, oprno, ucode, startTime, endTime);
+			List<MesPdaScanRecord> recordList = mesPdaScanRecordService.findNormalListByQuery(lineSn, oprno, ucode,
+					startTime, endTime);
+			List<Map<String, Object>> dataList = ListUtils.newArrayList();
+			for (MesPdaScanRecord record : recordList) {
+				Map<String, Object> map = MapUtils.newHashMap();
+				map.put("sn", record.getSn());
+				map.put("createDate", DateUtils.formatDate(record.getCreateDate(), "yyyy-MM-dd HH:mm:ss"));
+				dataList.add(map);
+			}
+
+			Map<String, Object> data = MapUtils.newHashMap();
+			data.put("total", total);
+			data.put("lineSn", lineSn);
+			data.put("oprno", oprno);
+			data.put("ucode", ucode);
+			data.put("list", dataList);
+			resp.setResult(Global.TRUE);
+			resp.setMessage("成功");
+			resp.setData(data);
+			return resp;
+		} catch (Exception e) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage(e.getMessage());
+			return resp;
+		}
+	}
+
+	private Date parsePdaScanTime(String time) {
+		try {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+			sdf.setLenient(false);
+			return sdf.parse(time);
+		} catch (ParseException e) {
+			return null;
+		}
+	}
+
 	//pda查询工位是否有工件
 	@PostMapping(value = "pdaQueryIsSn")
 	@ResponseBody

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

@@ -842,6 +842,9 @@ shiro:
     ${adminPath}/mes/mesProductRecord/pcunbind = anon
     ${adminPath}/mes/mesProductRecord/pdaQueryIsSn = anon
     ${adminPath}/mes/mesProductRecord/pdaQueryQuality = anon
+    ${adminPath}/mes/mesProductRecord/pdaQueryLineSn = anon
+    ${adminPath}/mes/mesProductRecord/pdaQueryOprno = anon
+    ${adminPath}/mes/mesProductRecord/pdaQueryScanRecord = anon
     ${adminPath}/mes/mesProductRecord/getCurSn= anon
     ${adminPath}/mes/mesProductRecord/cancelCurSn= anon
     ${adminPath}/mes/mesProductRecord/ocr= anon

+ 15 - 0
src/main/resources/mappings/modules/mes/MesLineProcessDao.xml

@@ -72,6 +72,21 @@
 		SELECT * FROM `mes_line_process` where pid IS NOT NULL
 	</select>
 
+	<select id="findOprnoListByLineSn" resultType="com.jeesite.modules.mes.entity.MesLineProcess">
+		SELECT a.oprno,
+		       a.title,
+			b.sn AS lineSn,
+			MIN(a.sorts) AS sorts
+		FROM mes_line_process a
+		INNER JOIN mes_line b ON b.id = a.line_id AND b.status = '0'
+		WHERE a.status = '0'
+		  AND b.sn = #{lineSn}
+		  AND a.oprno IS NOT NULL
+		  AND a.oprno != ''
+		GROUP BY a.oprno, b.sn
+		ORDER BY MIN(a.sorts) ASC, a.oprno ASC
+	</select>
+
     <update id="updateStopByOprno">
 		update   mes_line_process set stop=#{stop}  where oprno=#{oprno}
 	</update>

+ 33 - 0
src/main/resources/mappings/modules/mes/MesPdaScanRecordDao.xml

@@ -57,4 +57,37 @@
 		WHERE id = #{id}
 	</update>
 
+	<select id="countNormalByQuery" resultType="int">
+		SELECT COUNT(1)
+		FROM mes_pda_scan_record
+		WHERE status = '0'
+		  AND line_sn = #{lineSn}
+		  AND oprno LIKE CONCAT('%', #{oprno}, '%')
+		  AND ucode = #{ucode}
+		  AND create_date &gt;= #{startTime}
+		  AND create_date &lt;= #{endTime}
+	</select>
+
+	<select id="findNormalListByQuery" resultType="com.jeesite.modules.mes.entity.MesPdaScanRecord">
+		SELECT id,
+			sn,
+			oprno,
+			line_sn AS lineSn,
+			ucode,
+			remarks,
+			status,
+			create_by AS createBy,
+			create_date AS createDate,
+			update_by AS updateBy,
+			update_date AS updateDate
+		FROM mes_pda_scan_record
+		WHERE status = '0'
+		  AND line_sn = #{lineSn}
+		  AND oprno LIKE CONCAT('%', #{oprno}, '%')
+		  AND ucode = #{ucode}
+		  AND create_date &gt;= #{startTime}
+		  AND create_date &lt;= #{endTime}
+		ORDER BY create_date DESC, id DESC
+	</select>
+
 </mapper>