Ver Fonte

大屏生产计划

zhanghe há 5 meses atrás
pai
commit
2e048b83ef

+ 10 - 1
src/main/java/com/jeesite/modules/mes/dao/MesProductRecordDao.java

@@ -38,4 +38,13 @@ public interface MesProductRecordDao extends CrudDao<MesProductRecord> {
             @Param("dayEnd") Date dayEnd,
             @Param("filterLineSn") boolean filterLineSn);
 
-}
+    /**
+     * 当前小时按产线、工位前缀统计工艺号 100000 且结果不为 UDF 的数量
+     */
+    Long countHourCapacityByLineAndOprnoPrefix(
+            @Param("lineSn") String lineSn,
+            @Param("oprnoPrefix") String oprnoPrefix,
+            @Param("startTime") Date startTime,
+            @Param("endTime") Date endTime);
+
+}

+ 24 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -1294,6 +1294,30 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 		return ret;
 	}
 
+	public Map<String, Integer> getCurrentHourCapacityStats(String lineSn, List<String> oprnos) {
+		Map<String, Integer> ret = MapUtils.newHashMap();
+		if (StringUtils.isBlank(lineSn) || oprnos == null || oprnos.isEmpty()) {
+			return ret;
+		}
+		Calendar calendar = Calendar.getInstance();
+		calendar.set(Calendar.MINUTE, 0);
+		calendar.set(Calendar.SECOND, 0);
+		calendar.set(Calendar.MILLISECOND, 0);
+		Date startTime = calendar.getTime();
+		calendar.add(Calendar.HOUR_OF_DAY, 1);
+		Date endTime = calendar.getTime();
+		for (String oprno : oprnos) {
+			if (StringUtils.isBlank(oprno)) {
+				continue;
+			}
+			String formatOprno = CommonUitl.formatOprno(oprno.trim());
+			Long count = mesProductRecordDao.countHourCapacityByLineAndOprnoPrefix(
+					lineSn.trim(), formatOprno, startTime, endTime);
+			ret.put(formatOprno, count == null ? 0 : count.intValue());
+		}
+		return ret;
+	}
+
 	private void fillHourlyCounts(List<Map<String, Object>> rows, int[] bucket) {
 		if (rows == null) {
 			return;

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

@@ -371,6 +371,36 @@ public class MesProductRecordController extends BaseController {
 		return page;
 	}
 
+	@RequestMapping(value = "hourlyCapacityData")
+	@ResponseBody
+	public CommonResp<Map<String, Integer>> hourlyCapacityData(HttpServletRequest request) {
+		CommonResp<Map<String, Integer>> resp = new CommonResp<>();
+		String lineSn = StringUtils.trimToEmpty(request.getParameter("lineSn"));
+		String oprnos = StringUtils.trimToEmpty(request.getParameter("oprnos"));
+		if (StringUtils.isBlank(lineSn) || StringUtils.isBlank(oprnos)) {
+			resp.setResult("false");
+			resp.setMessage("lineSn、oprnos 不能为空");
+			return resp;
+		}
+		try {
+			List<String> oprnoList = new ArrayList<>();
+			String[] arr = oprnos.split(",");
+			for (String item : arr) {
+				String oprno = StringUtils.trimToEmpty(item);
+				if (StringUtils.isNotBlank(oprno)) {
+					oprnoList.add(oprno);
+				}
+			}
+			resp.setData(mesProductRecordService.getCurrentHourCapacityStats(lineSn, oprnoList));
+			resp.setResult("true");
+		} catch (Exception e) {
+			logger.error(e.getMessage(), e);
+			resp.setResult("false");
+			resp.setMessage("查询失败:" + e.getMessage());
+		}
+		return resp;
+	}
+
 	/**
 	 * 查看编辑表单
 	 */

+ 12 - 1
src/main/resources/mappings/modules/mes/MesProductRecordDao.xml

@@ -64,4 +64,15 @@
         GROUP BY HOUR(a.update_date)
         ORDER BY HOUR(a.update_date)
     </select>
-</mapper>
+
+    <select id="countHourCapacityByLineAndOprnoPrefix" resultType="java.lang.Long">
+        SELECT COUNT(1)
+        FROM mes_product_record a
+        WHERE a.update_date <![CDATA[ >= ]]> #{startTime}
+          AND a.update_date <![CDATA[ < ]]> #{endTime}
+          AND a.line_sn = #{lineSn}
+          AND a.craft = '100000'
+          AND UPPER(TRIM(IFNULL(a.content, ''))) != 'UDF'
+          AND a.oprno LIKE CONCAT(#{oprnoPrefix}, '%')
+    </select>
+</mapper>

+ 37 - 0
src/main/resources/views/modules/mes/mesScreen4.html

@@ -909,11 +909,48 @@
 				if (out.length > 0) {
 					mockData.opTable = out;
 					renderTable();
+					updateHourlyCapacityByApi();
 				}
 			}
 		});
 	}
 
+	function updateHourlyCapacityByApi() {
+		var list = mockData.opTable || [];
+		if (!list.length) {
+			return;
+		}
+		var oprnos = [];
+		for (var i = 0; i < list.length; i++) {
+			if (list[i] && list[i].code) {
+				oprnos.push(list[i].code);
+			}
+		}
+		if (!oprnos.length) {
+			return;
+		}
+		$.ajax({
+			url: '${ctx}/mes/mesProductRecord/hourlyCapacityData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				lineSn: 'MP',
+				oprnos: oprnos.join(',')
+			},
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) {
+					return;
+				}
+				var hourMap = resp.data || {};
+				for (var i = 0; i < list.length; i++) {
+					var code = list[i].code || '';
+					list[i].hour = Number(hourMap[code]) || 0;
+				}
+				renderTable();
+			}
+		});
+	}
+
 	function updateLatestPlanProductionByApi() {
 		$.ajax({
 			url: '${ctx}/mes/mesPlan/latestPlanNums',

+ 37 - 0
src/main/resources/views/modules/mes/mesScreen5.html

@@ -997,11 +997,48 @@
 					opTablePageIndex = 0;
 					renderTable();
 					startOpTablePageRotate();
+					updateHourlyCapacityByApi();
 				}
 			}
 		});
 	}
 
+	function updateHourlyCapacityByApi() {
+		var list = mockData.opTable || [];
+		if (!list.length) {
+			return;
+		}
+		var oprnos = [];
+		for (var i = 0; i < list.length; i++) {
+			if (list[i] && list[i].code) {
+				oprnos.push(list[i].code);
+			}
+		}
+		if (!oprnos.length) {
+			return;
+		}
+		$.ajax({
+			url: '${ctx}/mes/mesProductRecord/hourlyCapacityData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				lineSn: 'XT',
+				oprnos: oprnos.join(',')
+			},
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) {
+					return;
+				}
+				var hourMap = resp.data || {};
+				for (var i = 0; i < list.length; i++) {
+					var code = list[i].code || '';
+					list[i].hour = Number(hourMap[code]) || 0;
+				}
+				renderTable();
+			}
+		});
+	}
+
 	function updateLatestPlanProductionByApi() {
 		$.ajax({
 			url: '${ctx}/mes/mesPlan/latestPlanNums',

+ 37 - 0
src/main/resources/views/modules/mes/mesScreen6.html

@@ -997,11 +997,48 @@
 					opTablePageIndex = 0;
 					renderTable();
 					startOpTablePageRotate();
+					updateHourlyCapacityByApi();
 				}
 			}
 		});
 	}
 
+	function updateHourlyCapacityByApi() {
+		var list = mockData.opTable || [];
+		if (!list.length) {
+			return;
+		}
+		var oprnos = [];
+		for (var i = 0; i < list.length; i++) {
+			if (list[i] && list[i].code) {
+				oprnos.push(list[i].code);
+			}
+		}
+		if (!oprnos.length) {
+			return;
+		}
+		$.ajax({
+			url: '${ctx}/mes/mesProductRecord/hourlyCapacityData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				lineSn: 'ZP',
+				oprnos: oprnos.join(',')
+			},
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) {
+					return;
+				}
+				var hourMap = resp.data || {};
+				for (var i = 0; i < list.length; i++) {
+					var code = list[i].code || '';
+					list[i].hour = Number(hourMap[code]) || 0;
+				}
+				renderTable();
+			}
+		});
+	}
+
 	function updateLatestPlanProductionByApi() {
 		$.ajax({
 			url: '${ctx}/mes/mesPlan/latestPlanNums',