Просмотр исходного кода

大屏修改和OP090,OP080工序变更

sunxianglong 3 недель назад
Родитель
Сommit
addc78c944

+ 13 - 0
db/mes_product_screen_plan_hist.sql

@@ -0,0 +1,13 @@
+-- 大屏工位计划历史(按业务日归档白/夜班计划)
+CREATE TABLE IF NOT EXISTS `mes_product_screen_plan_hist` (
+  `id` varchar(64) NOT NULL COMMENT '编号',
+  `screen_type` varchar(32) DEFAULT NULL COMMENT '大屏类型 MP/JJ/ZP',
+  `biz_date` varchar(10) DEFAULT NULL COMMENT '业务日 yyyy-MM-dd',
+  `op_plan` varchar(2000) DEFAULT NULL COMMENT '工位白夜班计划JSON',
+  `create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
+  `create_date` datetime DEFAULT NULL COMMENT '创建时间',
+  `update_by` varchar(64) DEFAULT NULL COMMENT '更新者',
+  `update_date` datetime DEFAULT NULL COMMENT '更新时间',
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `uk_screen_biz` (`screen_type`,`biz_date`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='大屏工位计划历史';

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

@@ -48,6 +48,15 @@ public interface MesProductRecordDao extends CrudDao<MesProductRecord> {
             @Param("endTime") Date endTime);
 
     /**
+     * 当前小时按产线、精确工位号统计工艺号 100000 且结果不为 UDF 的数量
+     */
+    Long countHourCapacityByLineAndOprnoExact(
+            @Param("lineSn") String lineSn,
+            @Param("oprno") String oprno,
+            @Param("startTime") Date startTime,
+            @Param("endTime") Date endTime);
+
+    /**
      * 统计指定产线、工位前缀、时间段内 content=OK 的条数
      */
     Long countOkByLineAndOprnoPrefix(

+ 10 - 0
src/main/java/com/jeesite/modules/mes/dao/MesProductScreenPlanHistDao.java

@@ -0,0 +1,10 @@
+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.MesProductScreenPlanHist;
+
+@MyBatisDao
+public interface MesProductScreenPlanHistDao extends CrudDao<MesProductScreenPlanHist> {
+
+}

+ 67 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductScreenPlanHist.java

@@ -0,0 +1,67 @@
+package com.jeesite.modules.mes.entity;
+
+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 javax.validation.constraints.Size;
+
+/**
+ * 大屏工位计划历史(按业务日归档)
+ * 对应表 mes_product_screen_plan_hist
+ */
+@Table(name="mes_product_screen_plan_hist", alias="a", label="大屏工位计划历史", columns={
+		@Column(name="id", attrName="id", label="id", isPK=true),
+		@Column(name="screen_type", attrName="screenType", label="大屏类型", comment="MP铸造 JJ机加 ZP装配", queryType=QueryType.EQ),
+		@Column(name="biz_date", attrName="bizDate", label="业务日", comment="yyyy-MM-dd", queryType=QueryType.EQ),
+		@Column(name="op_plan", attrName="opPlan", label="工位白夜班计划", isQuery=false),
+		@Column(name="create_by", attrName="createBy", label="创建人", isUpdate=false, isQuery=false),
+		@Column(name="create_date", attrName="createDate", label="创建日期", isUpdate=false, isQuery=false, isUpdateForce=true),
+		@Column(name="update_by", attrName="updateBy", label="update_by", isQuery=false),
+		@Column(name="update_date", attrName="updateDate", label="更新日期", isQuery=false, isUpdateForce=true),
+	}, orderBy="a.biz_date DESC"
+)
+public class MesProductScreenPlanHist extends DataEntity<MesProductScreenPlanHist> {
+
+	private static final long serialVersionUID = 1L;
+
+	private String screenType;
+	private String bizDate;
+	private String opPlan;
+
+	public MesProductScreenPlanHist() {
+		this(null);
+	}
+
+	public MesProductScreenPlanHist(String id) {
+		super(id);
+	}
+
+	@Size(min=0, max=32, message="大屏类型长度不能超过 32 个字符")
+	public String getScreenType() {
+		return screenType;
+	}
+
+	public void setScreenType(String screenType) {
+		this.screenType = screenType;
+	}
+
+	@Size(min=0, max=10, message="业务日长度不能超过 10 个字符")
+	public String getBizDate() {
+		return bizDate;
+	}
+
+	public void setBizDate(String bizDate) {
+		this.bizDate = bizDate;
+	}
+
+	@Size(min=0, max=2000, message="工位白夜班计划长度不能超过 2000 个字符")
+	public String getOpPlan() {
+		return opPlan;
+	}
+
+	public void setOpPlan(String opPlan) {
+		this.opPlan = opPlan;
+	}
+}

+ 40 - 5
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -1420,8 +1420,18 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 	 * @return [start, end],解析失败返回 null
 	 */
 	public Date[] getBusinessDayFixedTwoShiftRange(String shiftType) {
+		return getBusinessDayFixedTwoShiftRange(shiftType, 0);
+	}
+
+	/**
+	 * 固定两班时间窗;dayOffset 相对当前业务日偏移(如 -1 为上一业务日)
+	 */
+	public Date[] getBusinessDayFixedTwoShiftRange(String shiftType, int dayOffset) {
 		boolean night = "night".equalsIgnoreCase(StringUtils.trimToEmpty(shiftType));
 		Calendar startCal = resolveBusinessDayCalendar();
+		if (dayOffset != 0) {
+			startCal.add(Calendar.DAY_OF_MONTH, dayOffset);
+		}
 		Calendar endCal = (Calendar) startCal.clone();
 		if (night) {
 			startCal.set(Calendar.HOUR_OF_DAY, 20);
@@ -1516,11 +1526,28 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 	 * day = 业务日 08:00–20:00;night = 业务日 20:00–次日 08:00
 	 */
 	public Map<String, Integer> getCalendarDayShiftCapacityStats(String lineSn, List<String> oprnos, String shiftType) {
+		return getCalendarDayShiftCapacityStats(lineSn, oprnos, shiftType, 0);
+	}
+
+	/**
+	 * 业务日固定两班产能;dayOffset 相对当前业务日偏移(如 -1 为上一业务日)
+	 */
+	public Map<String, Integer> getCalendarDayShiftCapacityStats(String lineSn, List<String> oprnos,
+			String shiftType, int dayOffset) {
+		return getCalendarDayShiftCapacityStats(lineSn, oprnos, shiftType, dayOffset, false);
+	}
+
+	/**
+	 * 业务日固定两班产能。
+	 * exact=true 时按完整工位号精确匹配(如 OP110A),不做 formatOprno 前缀归并。
+	 */
+	public Map<String, Integer> getCalendarDayShiftCapacityStats(String lineSn, List<String> oprnos,
+			String shiftType, int dayOffset, boolean exact) {
 		Map<String, Integer> ret = MapUtils.newHashMap();
 		if (StringUtils.isBlank(lineSn) || oprnos == null || oprnos.isEmpty()) {
 			return ret;
 		}
-		Date[] range = getBusinessDayFixedTwoShiftRange(shiftType);
+		Date[] range = getBusinessDayFixedTwoShiftRange(shiftType, dayOffset);
 		if (range == null || range.length < 2 || range[0] == null || range[1] == null) {
 			return ret;
 		}
@@ -1530,10 +1557,18 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 			if (StringUtils.isBlank(oprno)) {
 				continue;
 			}
-			String formatOprno = CommonUitl.formatOprno(oprno.trim());
-			Long c = mesProductRecordDao.countHourCapacityByLineAndOprnoPrefix(
-					lineSn.trim(), formatOprno, startTime, endTime);
-			ret.put(formatOprno, c == null ? 0 : c.intValue());
+			String key = oprno.trim();
+			Long c;
+			if (exact) {
+				c = mesProductRecordDao.countHourCapacityByLineAndOprnoExact(
+						lineSn.trim(), key, startTime, endTime);
+				ret.put(key.toUpperCase(), c == null ? 0 : c.intValue());
+			} else {
+				String formatOprno = CommonUitl.formatOprno(key);
+				c = mesProductRecordDao.countHourCapacityByLineAndOprnoPrefix(
+						lineSn.trim(), formatOprno, startTime, endTime);
+				ret.put(formatOprno, c == null ? 0 : c.intValue());
+			}
 		}
 		return ret;
 	}

+ 90 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductScreenPlanHistService.java

@@ -0,0 +1,90 @@
+package com.jeesite.modules.mes.service;
+
+import com.jeesite.common.lang.ObjectUtils;
+import com.jeesite.common.lang.StringUtils;
+import com.jeesite.common.service.CrudService;
+import com.jeesite.modules.mes.dao.MesProductScreenPlanHistDao;
+import com.jeesite.modules.mes.entity.MesProductScreenPlanHist;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * 大屏工位计划历史 Service
+ */
+@Service
+public class MesProductScreenPlanHistService extends CrudService<MesProductScreenPlanHistDao, MesProductScreenPlanHist> {
+
+	public MesProductScreenPlanHist findByScreenTypeAndBizDate(String screenType, String bizDate) {
+		String type = MesProductScreenService.normalizeScreenType(screenType);
+		if (StringUtils.isBlank(type) || StringUtils.isBlank(bizDate)) {
+			return null;
+		}
+		MesProductScreenPlanHist q = new MesProductScreenPlanHist();
+		q.setScreenType(type);
+		q.setBizDate(bizDate.trim());
+		List<MesProductScreenPlanHist> list = findList(q);
+		if (ObjectUtils.isEmpty(list)) {
+			return null;
+		}
+		return list.get(0);
+	}
+
+	/**
+	 * 取指定大屏类型、业务日不晚于 maxBizDate 的最近一条历史(biz_date DESC)。
+	 * maxBizDate 为空时取该类型全局最近一条。
+	 */
+	public MesProductScreenPlanHist findLatestByScreenType(String screenType, String maxBizDate) {
+		String type = MesProductScreenService.normalizeScreenType(screenType);
+		if (StringUtils.isBlank(type)) {
+			return null;
+		}
+		MesProductScreenPlanHist q = new MesProductScreenPlanHist();
+		q.setScreenType(type);
+		List<MesProductScreenPlanHist> list = findList(q);
+		if (ObjectUtils.isEmpty(list)) {
+			return null;
+		}
+		String max = StringUtils.trimToEmpty(maxBizDate);
+		MesProductScreenPlanHist best = null;
+		for (MesProductScreenPlanHist item : list) {
+			if (item == null || StringUtils.isBlank(item.getBizDate())) {
+				continue;
+			}
+			String biz = item.getBizDate().trim();
+			if (StringUtils.isNotBlank(max) && biz.compareTo(max) > 0) {
+				continue;
+			}
+			if (best == null || biz.compareTo(best.getBizDate().trim()) > 0) {
+				best = item;
+			}
+		}
+		return best;
+	}
+
+	/**
+	 * 按 (screenType, bizDate) upsert;insertOnly=true 时已存在则不覆盖。
+	 */
+	@Transactional
+	public void upsert(String screenType, String bizDate, String opPlan, boolean insertOnly) {
+		String type = MesProductScreenService.normalizeScreenType(screenType);
+		if (StringUtils.isBlank(type) || StringUtils.isBlank(bizDate) || StringUtils.isBlank(opPlan)) {
+			return;
+		}
+		MesProductScreenPlanHist exist = findByScreenTypeAndBizDate(type, bizDate);
+		if (exist != null) {
+			if (insertOnly) {
+				return;
+			}
+			exist.setOpPlan(opPlan);
+			super.save(exist);
+			return;
+		}
+		MesProductScreenPlanHist hist = new MesProductScreenPlanHist();
+		hist.setScreenType(type);
+		hist.setBizDate(bizDate.trim());
+		hist.setOpPlan(opPlan);
+		super.save(hist);
+	}
+}

+ 72 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductScreenService.java

@@ -8,9 +8,13 @@ import com.jeesite.common.lang.StringUtils;
 import com.jeesite.common.service.CrudService;
 import com.jeesite.modules.mes.dao.MesProductScreenDao;
 import com.jeesite.modules.mes.entity.MesProductScreen;
+import com.jeesite.modules.mes.entity.MesProductScreenPlanHist;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -23,6 +27,11 @@ import java.util.Map;
 @Service
 public class MesProductScreenService extends CrudService<MesProductScreenDao, MesProductScreen> {
 
+	@Autowired
+	private MesProductScreenPlanHistService mesProductScreenPlanHistService;
+	@Autowired
+	private MesProductRecordService mesProductRecordService;
+
 	@Override
 	public MesProductScreen get(MesProductScreen mesProductScreen) {
 		return super.get(mesProductScreen);
@@ -43,10 +52,73 @@ public class MesProductScreenService extends CrudService<MesProductScreenDao, Me
 	public void save(MesProductScreen mesProductScreen) {
 		if (mesProductScreen != null) {
 			mesProductScreen.setScreenType(normalizeScreenType(mesProductScreen.getScreenType()));
+			archiveOpPlanOnSave(mesProductScreen);
 		}
 		super.save(mesProductScreen);
 	}
 
+	/**
+	 * 保存前归档:上一业务日无历史则写入旧计划;当天快照始终更新为新计划。
+	 */
+	private void archiveOpPlanOnSave(MesProductScreen mesProductScreen) {
+		String screenType = normalizeScreenType(mesProductScreen.getScreenType());
+		String newOpPlan = mesProductScreen.getOpPlan();
+		if (StringUtils.isBlank(screenType)) {
+			return;
+		}
+		String bizToday = formatBizDate(mesProductRecordService.resolveBusinessDayCalendar());
+		String bizPrev = formatBizDate(addDays(mesProductRecordService.resolveBusinessDayCalendar(), -1));
+		MesProductScreen old = null;
+		if (!mesProductScreen.getIsNewRecord() && StringUtils.isNotBlank(mesProductScreen.getId())) {
+			old = get(mesProductScreen.getId());
+		}
+		if (old == null) {
+			old = getLatestByScreenType(screenType);
+		}
+		if (old != null && StringUtils.isNotBlank(old.getOpPlan())) {
+			mesProductScreenPlanHistService.upsert(screenType, bizPrev, old.getOpPlan(), true);
+		}
+		if (StringUtils.isNotBlank(newOpPlan)) {
+			mesProductScreenPlanHistService.upsert(screenType, bizToday, newOpPlan, false);
+		}
+	}
+
+	/**
+	 * 上一业务日工位白/夜班计划。
+	 * 优先取上一业务日历史;没有则取不晚于上一业务日的最近一条历史;
+	 * 仍没有则取该类型任意最近历史;再没有则回退当前大屏配置。
+	 */
+	public Map<String, Map<String, Integer>> getPrevDayOpPlanShiftMaps(String screenType) {
+		String type = normalizeScreenType(screenType);
+		String bizPrev = formatBizDate(addDays(mesProductRecordService.resolveBusinessDayCalendar(), -1));
+		MesProductScreenPlanHist hist = mesProductScreenPlanHistService.findByScreenTypeAndBizDate(type, bizPrev);
+		if (hist == null) {
+			hist = mesProductScreenPlanHistService.findLatestByScreenType(type, bizPrev);
+		}
+		if (hist == null) {
+			hist = mesProductScreenPlanHistService.findLatestByScreenType(type, null);
+		}
+		if (hist != null && StringUtils.isNotBlank(hist.getOpPlan())) {
+			return parseOpPlanShiftMaps(hist.getOpPlan());
+		}
+		MesProductScreen latest = getLatestByScreenType(type);
+		return parseOpPlanShiftMaps(latest == null ? null : latest.getOpPlan());
+	}
+
+	public String getPrevBizDate() {
+		return formatBizDate(addDays(mesProductRecordService.resolveBusinessDayCalendar(), -1));
+	}
+
+	private static Calendar addDays(Calendar cal, int days) {
+		Calendar c = (Calendar) cal.clone();
+		c.add(Calendar.DAY_OF_MONTH, days);
+		return c;
+	}
+
+	private static String formatBizDate(Calendar cal) {
+		return new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
+	}
+
 	@Override
 	@Transactional
 	public void delete(MesProductScreen mesProductScreen) {

+ 12 - 1
src/main/java/com/jeesite/modules/mes/web/MesFlawRecordController.java

@@ -99,13 +99,24 @@ public class MesFlawRecordController extends BaseController {
 	public CommonResp<Integer> calendarShiftDistinctCount(HttpServletRequest request) {
 		CommonResp<Integer> resp = new CommonResp<>();
 		String shiftType = StringUtils.trimToEmpty(request.getParameter("shiftType"));
+		String dayOffsetStr = StringUtils.trimToEmpty(request.getParameter("dayOffset"));
 		if (!"day".equalsIgnoreCase(shiftType) && !"night".equalsIgnoreCase(shiftType)) {
 			resp.setResult("false");
 			resp.setMessage("shiftType 只能为 day 或 night");
 			return resp;
 		}
+		int dayOffset = 0;
+		if (StringUtils.isNotBlank(dayOffsetStr)) {
+			try {
+				dayOffset = Integer.parseInt(dayOffsetStr);
+			} catch (Exception e) {
+				resp.setResult("false");
+				resp.setMessage("dayOffset 必须为整数");
+				return resp;
+			}
+		}
 		try {
-			Date[] range = mesProductRecordService.getBusinessDayFixedTwoShiftRange(shiftType);
+			Date[] range = mesProductRecordService.getBusinessDayFixedTwoShiftRange(shiftType, dayOffset);
 			if (range == null || range.length < 2 || range[0] == null || range[1] == null) {
 				resp.setData(0);
 				resp.setResult("false");

+ 28 - 13
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -466,6 +466,8 @@ public class MesProductRecordController extends BaseController {
 	 * 业务日白班/夜班产量(与大屏表头日期一致,取当前班次开始日):
 	 * shiftType=day  -> 业务日 08:00–20:00
 	 * shiftType=night -> 业务日 20:00–次日 08:00
+	 * 可选 dayOffset:相对当前业务日偏移,如 -1 为上一业务日
+	 * 可选 exact=true:按完整工位号精确匹配(如 OP110A),不做父工位前缀归并
 	 */
 	@RequestMapping(value = "calendarShiftCapacityData")
 	@ResponseBody
@@ -474,6 +476,8 @@ public class MesProductRecordController extends BaseController {
 		String lineSn = StringUtils.trimToEmpty(request.getParameter("lineSn"));
 		String oprnos = StringUtils.trimToEmpty(request.getParameter("oprnos"));
 		String shiftType = StringUtils.trimToEmpty(request.getParameter("shiftType"));
+		String dayOffsetStr = StringUtils.trimToEmpty(request.getParameter("dayOffset"));
+		String exactStr = StringUtils.trimToEmpty(request.getParameter("exact"));
 		if (StringUtils.isBlank(lineSn) || StringUtils.isBlank(oprnos)) {
 			resp.setResult("false");
 			resp.setMessage("lineSn、oprnos 不能为空");
@@ -484,6 +488,17 @@ public class MesProductRecordController extends BaseController {
 			resp.setMessage("shiftType 只能为 day 或 night");
 			return resp;
 		}
+		int dayOffset = 0;
+		if (StringUtils.isNotBlank(dayOffsetStr)) {
+			try {
+				dayOffset = Integer.parseInt(dayOffsetStr);
+			} catch (Exception e) {
+				resp.setResult("false");
+				resp.setMessage("dayOffset 必须为整数");
+				return resp;
+			}
+		}
+		boolean exact = "true".equalsIgnoreCase(exactStr) || "1".equals(exactStr);
 		try {
 			List<String> oprnoList = new ArrayList<>();
 			String[] arr = oprnos.split(",");
@@ -493,7 +508,8 @@ public class MesProductRecordController extends BaseController {
 					oprnoList.add(oprno);
 				}
 			}
-			resp.setData(mesProductRecordService.getCalendarDayShiftCapacityStats(lineSn, oprnoList, shiftType));
+			resp.setData(mesProductRecordService.getCalendarDayShiftCapacityStats(
+					lineSn, oprnoList, shiftType, dayOffset, exact));
 			resp.setResult("true");
 		} catch (Exception e) {
 			logger.error(e.getMessage(), e);
@@ -3006,10 +3022,6 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 
 		String craft = "100000";
 		String remark = request.getParameter("remark");
-		String oldOprno = oprno;
-		if(oldOprno.length()==5){
-			oldOprno += "A";
-		}
 		String mesProductRecord_image = request.getParameter("mesProductRecord_image");
 //		if(com.alibaba.druid.util.StringUtils.isEmpty(mesProductRecord_image)){
 //			return renderResult(Global.FALSE, text("图片不能为空!"));
@@ -3021,6 +3033,9 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 			return renderResult(Global.FALSE, text("结果错误!"));
 		}
 
+		// 提交工位结果统一使用 W 子工位,例如 OP110 / OP110A -> OP110W
+		oprno = CommonUitl.formatOprno(oprno) + "W";
+
 		User user = UserUtils.getUser();
 		String userCode = user.getUserCode();
 
@@ -3033,22 +3048,22 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 		}
 
 		try{
-			// OP110提交OK时,同步将OP110~OP160工位结果都提交为OK
+			// OP110提交OK时,同步将OP110~OP160工位结果都提交为OK(均为 W 子工位)
 			if("OP110".equals(CommonUitl.formatOprno(oprno)) && "OK".equals(result)){
-				String[] relatedOprnos = new String[]{"OP110", "OP120", "OP130", "OP140", "OP150", "OP160"};
+				String[] relatedOprnos = new String[]{"OP110W", "OP120W", "OP130W", "OP140W", "OP150W", "OP160W"};
 				for(String relatedOprno : relatedOprnos){
-					MesLineProcess mlp = "OP110".equals(relatedOprno)
+					MesLineProcess mlp = "OP110W".equals(relatedOprno)
 							? mesLineProcess1
 							: mesLineProcessService.findInfoByOprnoLineSn(relatedOprno, lineSn);
 					if(ObjectUtils.isEmpty(mlp)){
 						return renderResult(Global.FALSE, text(relatedOprno + "子工位未配置!"));
 					}
 					// OP120-OP160提交前检查模板,缺失则补建
-					if(!"OP110".equals(relatedOprno)){
+					if(!"OP110W".equals(relatedOprno)){
 						checkTempalte(sn, relatedOprno, lineSn);
 					}
 					String res = updateQualityCommon(mlp, relatedOprno, lineSn, sn, craft, "OK", userCode, params,
-							"OP110".equals(relatedOprno) ? remark : null);
+							"OP110W".equals(relatedOprno) ? remark : null);
 					String checkret = res.substring(2,4);
 					if(!checkret.equals("OK")){
 						String lx = res.substring(0,2)+" ";
@@ -3089,9 +3104,9 @@ public String check(@RequestBody MesElectricTorque mesElectricTorque,HttpServlet
 			oldOprno += "A";
 		}
 		String mesProductRecord_image = request.getParameter("mesProductRecord_image");
-		if(StringUtils.isEmpty(mesProductRecord_image)){
-			return renderResult(Global.FALSE, text("图片不能为空!"));
-		}
+//		if(StringUtils.isEmpty(mesProductRecord_image)){
+//			return renderResult(Global.FALSE, text("图片不能为空!"));
+//		}
 		if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(result) || StringUtils.isEmpty(lineSn)){
 			return renderResult(Global.FALSE, text("参数错误!"));
 		}

+ 33 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductScreenController.java

@@ -194,6 +194,39 @@ public class MesProductScreenController extends BaseController {
 		return resp;
 	}
 
+	/**
+	 * 上一业务日工位白/夜班计划(来自保存配置时自动归档的历史表)
+	 */
+	@RequestMapping(value = "prevDayOpPlans")
+	@ResponseBody
+	public CommonResp<Map<String, Object>> prevDayOpPlans(HttpServletRequest request) {
+		CommonResp<Map<String, Object>> resp = new CommonResp<>();
+		String screenType = StringUtils.trimToEmpty(request.getParameter("screenType"));
+		Map<String, Object> data = new HashMap<>();
+		String bizDate = mesProductScreenService.getPrevBizDate();
+		data.put("bizDate", bizDate);
+		data.put("bizDateMd", toMd(bizDate));
+		Map<String, Map<String, Integer>> shiftPlans = mesProductScreenService.getPrevDayOpPlanShiftMaps(screenType);
+		data.put("opPlansDay", shiftPlans.get("day"));
+		data.put("opPlansNight", shiftPlans.get("night"));
+		resp.setData(data);
+		resp.setResult(Global.TRUE);
+		return resp;
+	}
+
+	private static String toMd(String yyyyMmDd) {
+		if (StringUtils.isBlank(yyyyMmDd) || yyyyMmDd.length() < 10) {
+			return "";
+		}
+		try {
+			int m = Integer.parseInt(yyyyMmDd.substring(5, 7));
+			int d = Integer.parseInt(yyyyMmDd.substring(8, 10));
+			return m + "." + d;
+		} catch (Exception e) {
+			return "";
+		}
+	}
+
 	/** 大屏:待处理设备报警列表(替代 mesDeviceAlarm/listData)
 	 * 解析 deviceSn(如 RL_OP030_01)中间工位号写入 oprno,便于按工序归类展示 */
 	@RequestMapping(value = "alertList")

+ 11 - 0
src/main/resources/mappings/modules/mes/MesProductRecordDao.xml

@@ -76,6 +76,17 @@
           AND a.oprno LIKE CONCAT(#{oprnoPrefix}, '%')
     </select>
 
+    <select id="countHourCapacityByLineAndOprnoExact" 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 UPPER(TRIM(IFNULL(a.oprno, ''))) = UPPER(TRIM(#{oprno}))
+    </select>
+
     <select id="countOkByLineAndOprnoPrefix" resultType="java.lang.Long">
         SELECT COUNT(1)
         FROM mes_product_record a

+ 8 - 1
src/main/resources/views/modules/mes/mesProductScreenForm.html

@@ -102,7 +102,14 @@
 <% } %>
 <script>
 var OPS_MP = ['OP060','OP070','OP080','OP090','OP100'];
-var OPS_JJ = ['OP110','OP120','OP130','OP140','OP150','OP160'];
+/** 机加:OP110-OP160(第1/2页)+ OP170-OP210(第3页) */
+var OPS_JJ = (function(){
+	var arr = [];
+	for (var n = 110; n <= 210; n += 10) {
+		arr.push('OP' + n);
+	}
+	return arr;
+})();
 var OPS_ZP = (function(){
 	var arr = [];
 	for (var n = 170; n <= 400; n += 10) {

+ 89 - 15
src/main/resources/views/modules/mes/mesScreen4.html

@@ -327,12 +327,14 @@
 			<table class="op-table">
 				<thead>
 				<tr>
-					<th style="width:160px">工位</th>
-					<th style="width:300px">工位名称</th>
-					<th id="thDayPlan">白班计划</th>
-					<th id="thDayOutput">白班产量</th>
-					<th id="thNightPlan">夜班计划</th>
-					<th id="thNightOutput">夜班产量</th>
+					<th style="width:100px">工位</th>
+					<th style="width:150px">工位名称</th>
+					<th id="thPrevDayPlan" style="width:100px">日计划</th>
+					<th id="thPrevDayOutput" style="width:100px">日产出</th>
+					<th id="thDayPlan" style="width:100px">白班计划</th>
+					<th id="thDayOutput" style="width:100px">白班产量</th>
+					<th id="thNightPlan" style="width:100px">夜班计划</th>
+					<th id="thNightOutput" style="width:100px">夜班产量</th>
 				</tr>
 				</thead>
 				<tbody id="opTableBody"></tbody>
@@ -416,6 +418,7 @@
 
 	/** 表头业务日期按当前班次开始日(如 11.3);跨自然日不切,换班才切到 11.4 */
 	var headerShiftDateMd = '';
+	var headerPrevDayMd = '';
 	var headerShiftStartMs = 0;
 	var headerShiftEndMs = 0;
 	var headerShiftLoading = false;
@@ -466,16 +469,30 @@
 		});
 	}
 
+	function prevMdFromHeader() {
+		if (headerShiftStartMs > 0) {
+			return formatMd(new Date(headerShiftStartMs - 24 * 60 * 60 * 1000));
+		}
+		var d = new Date();
+		d.setDate(d.getDate() - 1);
+		return formatMd(d);
+	}
+
 	function updateCapacityHeaders() {
 		var now = Date.now();
 		if (!headerShiftDateMd || !(now >= headerShiftStartMs && now < headerShiftEndMs)) {
 			refreshHeaderShiftDate(false);
 		}
 		var today = headerShiftDateMd || formatMd(new Date());
+		var prev = headerPrevDayMd || prevMdFromHeader();
+		var prevPlanEl = document.getElementById('thPrevDayPlan');
+		var prevOutEl = document.getElementById('thPrevDayOutput');
 		var dayPlanEl = document.getElementById('thDayPlan');
 		var dayOutEl = document.getElementById('thDayOutput');
 		var nightPlanEl = document.getElementById('thNightPlan');
 		var nightOutEl = document.getElementById('thNightOutput');
+		if (prevPlanEl) prevPlanEl.textContent = prev + '日计划';
+		if (prevOutEl) prevOutEl.textContent = prev + '日产出';
 		if (dayPlanEl) dayPlanEl.textContent = today + '白班计划';
 		if (dayOutEl) dayOutEl.textContent = today + '白班产量';
 		if (nightPlanEl) nightPlanEl.textContent = today + '夜班计划';
@@ -1020,6 +1037,8 @@
 			html += '<tr>';
 			html += '<td class="op-col">' + r.code + '</td>';
 			html += '<td class="op-name">' + r.name + '</td>';
+			html += '<td class="op-val">' + (r.prevDayPlan || 0) + '</td>';
+			html += '<td class="op-val">' + (r.prevDayOutput || 0) + '</td>';
 			html += '<td class="op-val">' + (r.dayPlan || 0) + '</td>';
 			html += '<td class="op-val">' + (r.dayOutput || 0) + '</td>';
 			html += '<td class="op-val">' + (r.nightPlan || 0) + '</td>';
@@ -1057,10 +1076,43 @@
 		for (var i = 0; i < list.length; i++) {
 			list[i].dayPlan = lookupOpPlan(list[i].code, mockData.opPlansDay);
 			list[i].nightPlan = lookupOpPlan(list[i].code, mockData.opPlansNight);
+			var prevDay = lookupOpPlan(list[i].code, mockData.prevOpPlansDay);
+			var prevNight = lookupOpPlan(list[i].code, mockData.prevOpPlansNight);
+			list[i].prevDayPlan = prevDay + prevNight;
 		}
 		renderTable();
 	}
 
+	function applyPrevDayPlansToTable() {
+		var list = mockData.opTable || [];
+		for (var i = 0; i < list.length; i++) {
+			var prevDay = lookupOpPlan(list[i].code, mockData.prevOpPlansDay);
+			var prevNight = lookupOpPlan(list[i].code, mockData.prevOpPlansNight);
+			list[i].prevDayPlan = prevDay + prevNight;
+		}
+		renderTable();
+	}
+
+	function updatePrevDayOpPlansByApi() {
+		$.ajax({
+			url: '${ctx}/mes/mesProductScreen/prevDayOpPlans',
+			type: 'POST',
+			dataType: 'json',
+			data: { screenType: SCREEN_TYPE },
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) return;
+				var d = resp.data;
+				mockData.prevOpPlansDay = d.opPlansDay || {};
+				mockData.prevOpPlansNight = d.opPlansNight || {};
+				if (d.bizDateMd) {
+					headerPrevDayMd = d.bizDateMd;
+					updateCapacityHeaders();
+				}
+				applyPrevDayPlansToTable();
+			}
+		});
+	}
+
 	function applyLatestPlanNumsToTable(planNums) {}
 	function calcRatePercent(actual, plan) {
 		actual = Number(actual) || 0;
@@ -1074,6 +1126,7 @@
 	function ensureOp070Row(list) {
 		var out = [];
 		var has070 = false;
+		var prevDay070 = lookupOpPlan('OP070', mockData.prevOpPlansDay) + lookupOpPlan('OP070', mockData.prevOpPlansNight);
 		for (var i = 0; i < list.length; i++) {
 			var row = list[i];
 			if (parseOprnoNum(row.code) === 70) {
@@ -1084,6 +1137,8 @@
 				row._flaw = true;
 				row.dayPlan = lookupOpPlan('OP070', mockData.opPlansDay);
 				row.nightPlan = lookupOpPlan('OP070', mockData.opPlansNight);
+				row.prevDayPlan = prevDay070;
+				row.prevDayOutput = row.prevDayOutput || 0;
 				has070 = true;
 			}
 			out.push(row);
@@ -1092,6 +1147,8 @@
 			out.push({
 				code: 'OP070',
 				name: '探伤处理',
+				prevDayPlan: prevDay070,
+				prevDayOutput: 0,
 				dayPlan: lookupOpPlan('OP070', mockData.opPlansDay),
 				nightPlan: lookupOpPlan('OP070', mockData.opPlansNight),
 				dayOutput: 0,
@@ -1127,6 +1184,8 @@
 					out.push({
 						code: code,
 						name: p.title || '',
+						prevDayPlan: lookupOpPlan(code, mockData.prevOpPlansDay) + lookupOpPlan(code, mockData.prevOpPlansNight),
+						prevDayOutput: 0,
 						dayPlan: lookupOpPlan(code, mockData.opPlansDay),
 						nightPlan: lookupOpPlan(code, mockData.opPlansNight),
 						dayOutput: 0,
@@ -1155,14 +1214,18 @@
 			if (list[i] && list[i].code && !list[i]._flaw) oprnos.push(list[i].code);
 		}
 		if (oprnos.length) {
-			fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'dayOutput');
-			fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'nightOutput');
-		}
-		fetchFlawShiftCapacity('day', 'dayOutput');
-		fetchFlawShiftCapacity('night', 'nightOutput');
+			fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'dayOutput', 0);
+			fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'nightOutput', 0);
+			fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'prevDayDay', -1);
+			fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'prevDayNight', -1);
+		}
+		fetchFlawShiftCapacity('day', 'dayOutput', 0);
+		fetchFlawShiftCapacity('night', 'nightOutput', 0);
+		fetchFlawShiftCapacity('day', 'prevDayDay', -1);
+		fetchFlawShiftCapacity('night', 'prevDayNight', -1);
 	}
 
-	function fetchCalendarShiftCapacity(lineSn, oprnos, shiftType, field) {
+	function fetchCalendarShiftCapacity(lineSn, oprnos, shiftType, field, dayOffset) {
 		$.ajax({
 			url: '${ctx}/mes/mesProductRecord/calendarShiftCapacityData',
 			type: 'POST',
@@ -1170,7 +1233,8 @@
 			data: {
 				lineSn: lineSn,
 				oprnos: oprnos.join(','),
-				shiftType: shiftType
+				shiftType: shiftType,
+				dayOffset: dayOffset || 0
 			},
 			success: function(resp) {
 				if (!resp || resp.result !== 'true' || !resp.data) return;
@@ -1181,6 +1245,9 @@
 					var code = list[i].code || '';
 					var formatted = code.length === 6 ? code.substring(0, 5) : code;
 					list[i][field] = Number(map[code] != null ? map[code] : map[formatted]) || 0;
+					if (field === 'prevDayDay' || field === 'prevDayNight') {
+						list[i].prevDayOutput = (Number(list[i].prevDayDay) || 0) + (Number(list[i].prevDayNight) || 0);
+					}
 				}
 				renderTable();
 			}
@@ -1188,12 +1255,15 @@
 	}
 
 	/** OP070 探伤产量:探伤记录管理口径,时间段内有图片的记录按工件码去重 */
-	function fetchFlawShiftCapacity(shiftType, field) {
+	function fetchFlawShiftCapacity(shiftType, field, dayOffset) {
 		$.ajax({
 			url: '${ctx}/mes/mesFlawRecord/calendarShiftDistinctCount',
 			type: 'POST',
 			dataType: 'json',
-			data: { shiftType: shiftType },
+			data: {
+				shiftType: shiftType,
+				dayOffset: dayOffset || 0
+			},
 			success: function(resp) {
 				if (!resp || resp.result !== 'true') return;
 				var count = Number(resp.data) || 0;
@@ -1201,6 +1271,9 @@
 				for (var i = 0; i < list.length; i++) {
 					if (list[i]._flaw || parseOprnoNum(list[i].code) === 70) {
 						list[i][field] = count;
+						if (field === 'prevDayDay' || field === 'prevDayNight') {
+							list[i].prevDayOutput = (Number(list[i].prevDayDay) || 0) + (Number(list[i].prevDayNight) || 0);
+						}
 					}
 				}
 				renderTable();
@@ -1392,6 +1465,7 @@
 		renderTable();
 		refreshHeaderShiftDate(true);
 		updateScreenConfigByApi();
+		updatePrevDayOpPlansByApi();
 		updateActualProductionByApi();
 		updateLineProcessTableByApi();
 		updateDeviceAlarmAlertsByApi();

+ 275 - 79
src/main/resources/views/modules/mes/mesScreen5.html

@@ -226,6 +226,7 @@
 		}
 		.op-table td.op-col  { color: #00C8FF; font-weight: bold; font-size: 26px; }
 		.op-table td.op-name { color: #ffffff; text-align: center; font-size: 22px; }
+		.op-table td.op-line { color: #FFDD00; text-align: center; font-size: 20px; font-weight: bold; }
 		.op-table td.op-val  { color: #00F7FF; font-weight: bold; font-size: 28px; }
 
 		/* ===== 产线阶段数据总览 (按模板排布) ===== */
@@ -345,12 +346,15 @@
 			<table class="op-table">
 				<thead>
 				<tr>
-					<th style="width:160px">工位</th>
-					<th style="width:300px">工位名称</th>
-					<th id="thDayPlan">白班计划</th>
-					<th id="thDayOutput">白班产量</th>
-					<th id="thNightPlan">夜班计划</th>
-					<th id="thNightOutput">夜班产量</th>
+					<th style="width:100px">产线</th>
+					<th style="width:90px">工位</th>
+					<th style="width:120px">工位名称</th>
+					<th id="thPrevDayPlan" style="width:90px">日计划</th>
+					<th id="thPrevDayOutput" style="width:90px">日产出</th>
+					<th id="thDayPlan" style="width:90px">白班计划</th>
+					<th id="thDayOutput" style="width:90px">白班产量</th>
+					<th id="thNightPlan" style="width:90px">夜班计划</th>
+					<th id="thNightOutput" style="width:90px">夜班产量</th>
 				</tr>
 				</thead>
 				<tbody id="opTableBody"></tbody>
@@ -434,6 +438,7 @@
 
 	/** 表头业务日期按当前班次开始日(如 11.3);跨自然日不切,换班才切到 11.4 */
 	var headerShiftDateMd = '';
+	var headerPrevDayMd = '';
 	var headerShiftStartMs = 0;
 	var headerShiftEndMs = 0;
 	var headerShiftLoading = false;
@@ -484,16 +489,30 @@
 		});
 	}
 
+	function prevMdFromHeader() {
+		if (headerShiftStartMs > 0) {
+			return formatMd(new Date(headerShiftStartMs - 24 * 60 * 60 * 1000));
+		}
+		var d = new Date();
+		d.setDate(d.getDate() - 1);
+		return formatMd(d);
+	}
+
 	function updateCapacityHeaders() {
 		var now = Date.now();
 		if (!headerShiftDateMd || !(now >= headerShiftStartMs && now < headerShiftEndMs)) {
 			refreshHeaderShiftDate(false);
 		}
 		var today = headerShiftDateMd || formatMd(new Date());
+		var prev = headerPrevDayMd || prevMdFromHeader();
+		var prevPlanEl = document.getElementById('thPrevDayPlan');
+		var prevOutEl = document.getElementById('thPrevDayOutput');
 		var dayPlanEl = document.getElementById('thDayPlan');
 		var dayOutEl = document.getElementById('thDayOutput');
 		var nightPlanEl = document.getElementById('thNightPlan');
 		var nightOutEl = document.getElementById('thNightOutput');
+		if (prevPlanEl) prevPlanEl.textContent = prev + '日计划';
+		if (prevOutEl) prevOutEl.textContent = prev + '日产出';
 		if (dayPlanEl) dayPlanEl.textContent = today + '白班计划';
 		if (dayOutEl) dayOutEl.textContent = today + '白班产量';
 		if (nightPlanEl) nightPlanEl.textContent = today + '夜班计划';
@@ -504,28 +523,26 @@
 		if (actualLabel) actualLabel.textContent = today + '实际产量';
 	}
 
-	/** 工位表:每页条数与自动翻页间隔(毫秒) */
+	/** 工位表:固定三页轮播(毫秒) */
 	var OP_TABLE_PAGE_SIZE = 6;
+	var OP_TABLE_SCREEN_COUNT = 3;
 	var OP_TABLE_PAGE_ROTATE_MS = 8000;
 	var opTablePageIndex = 0;
 	var opTableRotateTimer = null;
+	/** 第1/2页工位(数据相同,产线标签不同);第3页工位 */
+	var PAGE_MAIN_OPS = ['OP110', 'OP120', 'OP130', 'OP140', 'OP150', 'OP160'];
+	var PAGE_EXT_OPS = ['OP170', 'OP180', 'OP190', 'OP200', 'OP210'];
+	var PAGE1_LINE_LABELS = ['A/B', 'A/B/C/D', 'A/B', 'A/B', 'A/B/Z', 'A/B'];
+	var PAGE2_LINE_LABELS = ['C/D', 'A/B/C/D', 'C/D', 'C/D', 'C/D/Y', 'C/D'];
 
 	function padOpTableRowsToPageSize(html, rowCount) {
 		for (var j = rowCount; j < OP_TABLE_PAGE_SIZE; j++) {
 			var alt = (j % 2 === 1) ? ' op-row-alt' : '';
-			html += '<tr class="op-row-empty' + alt + '"><td colspan="6">&nbsp;</td></tr>';
+			html += '<tr class="op-row-empty' + alt + '"><td colspan="9">&nbsp;</td></tr>';
 		}
 		return html;
 	}
 
-	function getOpTablePageCount(list) {
-		list = list || [];
-		if (list.length === 0) {
-			return 1;
-		}
-		return Math.ceil(list.length / OP_TABLE_PAGE_SIZE);
-	}
-
 	function stopOpTablePageRotate() {
 		if (opTableRotateTimer) {
 			clearInterval(opTableRotateTimer);
@@ -535,21 +552,74 @@
 
 	function startOpTablePageRotate() {
 		stopOpTablePageRotate();
-		var listNow = mockData.opTable || [];
-		if (getOpTablePageCount(listNow) <= 1) {
-			return;
-		}
 		opTableRotateTimer = setInterval(function() {
-			var list = mockData.opTable || [];
-			var pageCount = getOpTablePageCount(list);
-			if (pageCount <= 1) {
-				return;
-			}
-			opTablePageIndex = (opTablePageIndex + 1) % pageCount;
+			opTablePageIndex = (opTablePageIndex + 1) % OP_TABLE_SCREEN_COUNT;
 			renderTable();
 		}, OP_TABLE_PAGE_ROTATE_MS);
 	}
 
+	function forEachOpTableRow(fn) {
+		var pages = mockData.opTablePages || [];
+		for (var pi = 0; pi < pages.length; pi++) {
+			var list = pages[pi] || [];
+			for (var i = 0; i < list.length; i++) {
+				fn(list[i], pi);
+			}
+		}
+	}
+
+	function parseLineSuffixes(line) {
+		var s = String(line || '').trim();
+		if (!s) return [];
+		return s.split('/').map(function(p) { return String(p || '').trim().toUpperCase(); }).filter(Boolean);
+	}
+
+	/** 产线 A/B + 工位 OP110 -> [OP110A, OP110B];产线为空返回空数组(走父工位前缀) */
+	function childOprnosByLine(baseCode, line) {
+		var base = String(baseCode || '').toUpperCase();
+		var suffixes = parseLineSuffixes(line);
+		if (!base || !suffixes.length) return [];
+		var out = [];
+		for (var i = 0; i < suffixes.length; i++) {
+			out.push(base + suffixes[i]);
+		}
+		return out;
+	}
+
+	function rebuildOpTablePages() {
+		function withLines(src, labels) {
+			var out = [];
+			for (var i = 0; i < (src || []).length; i++) {
+				var r = src[i] || {};
+				out.push({
+					code: r.code,
+					name: r.name,
+					line: labels[i] != null ? labels[i] : '',
+					prevDayPlan: r.prevDayPlan || 0,
+					prevDayOutput: r.prevDayOutput || 0,
+					dayPlan: r.dayPlan || 0,
+					dayOutput: 0,
+					nightPlan: r.nightPlan || 0,
+					nightOutput: 0,
+					_opNum: r._opNum
+				});
+			}
+			return out;
+		}
+		mockData.opTablePages = [
+			withLines(mockData.opTableMain, PAGE1_LINE_LABELS),
+			withLines(mockData.opTableMain, PAGE2_LINE_LABELS),
+			withLines(mockData.opTableExt, [])
+		];
+		mockData.opTable = (mockData.opTableMain || []).concat(mockData.opTableExt || []);
+	}
+
+	function getOpTablePageRows() {
+		var pages = mockData.opTablePages || [];
+		var page = opTablePageIndex % OP_TABLE_SCREEN_COUNT;
+		return pages[page] || [];
+	}
+
 	function updateClock() {
 		var now = new Date();
 		var y = now.getFullYear();
@@ -564,10 +634,8 @@
 
 	// ====== 页面数据 ======
 	var mockData = {};
-	/** 本屏产线:XT(工位 OP110-OP160) */
+	/** 本屏产线:XT(第1/2页 OP110-OP160;第3页 OP170-OP210) */
 	var LINE_SN = 'XT';
-	var OP_FROM = 110;
-	var OP_TO = 160;
 	/** 大屏配置类型:机加 */
 	var SCREEN_TYPE = 'JJ';
 	/** 每小时上下线:上线 OP110 / 下线 OP160 */
@@ -637,7 +705,10 @@
 		// 报警信息由 updateDeviceAlarmAlertsByApi 拉取
 		mockData.alerts = [];
 
-		// 工位表由 mesLineProcess(XT,OP110-OP160)拉取
+		// 工位表由 mesLineProcess 拉取:第1/2页 OP110-OP160,第3页 OP170-OP210
+		mockData.opTableMain = [];
+		mockData.opTableExt = [];
+		mockData.opTablePages = [[], [], []];
 		mockData.opTable = [];
 
 		// 数据卡(总览固定展示)
@@ -1079,19 +1150,19 @@
 		if (el) el.innerHTML = html;
 	}
 	function renderTable() {
-		var list = mockData.opTable || [];
-		var pageCount = getOpTablePageCount(list);
-		if (opTablePageIndex >= pageCount) {
+		if (opTablePageIndex >= OP_TABLE_SCREEN_COUNT) {
 			opTablePageIndex = 0;
 		}
-		var start = opTablePageIndex * OP_TABLE_PAGE_SIZE;
-		var slice = list.slice(start, start + OP_TABLE_PAGE_SIZE);
+		var slice = getOpTablePageRows();
 		var html = '';
 		for (var i = 0; i < slice.length; i++) {
 			var r = slice[i];
 			html += '<tr' + ((i % 2 === 1) ? ' class="op-row-alt"' : '') + '>';
-			html += '<td class="op-col">' + r.code + '</td>';
-			html += '<td class="op-name">' + r.name + '</td>';
+			html += '<td class="op-line">' + (r.line || '') + '</td>';
+			html += '<td class="op-col">' + (r.code || '') + '</td>';
+			html += '<td class="op-name">' + (r.name || '') + '</td>';
+			html += '<td class="op-val">' + (r.prevDayPlan || 0) + '</td>';
+			html += '<td class="op-val">' + (r.prevDayOutput || 0) + '</td>';
 			html += '<td class="op-val">' + (r.dayPlan || 0) + '</td>';
 			html += '<td class="op-val">' + (r.dayOutput || 0) + '</td>';
 			html += '<td class="op-val">' + (r.nightPlan || 0) + '</td>';
@@ -1103,13 +1174,7 @@
 		if (el) el.innerHTML = html;
 		var hint = document.getElementById('opTablePageHint');
 		if (hint) {
-			if (list.length === 0) {
-				hint.textContent = '';
-			} else if (pageCount > 1) {
-				hint.textContent = '第 ' + (opTablePageIndex + 1) + ' / ' + pageCount + ' 页 / 每页 ' + OP_TABLE_PAGE_SIZE + ' 条 / 共 ' + list.length + ' 条';
-			} else {
-				hint.textContent = '共 ' + list.length + ' 条';
-			}
+			hint.textContent = '第 ' + (opTablePageIndex + 1) + ' / ' + OP_TABLE_SCREEN_COUNT + ' 页';
 		}
 	}
 
@@ -1125,15 +1190,55 @@
 		if (plans[k2] != null && plans[k2] !== '') return Number(plans[k2]) || 0;
 		return 0;
 	}
-	function applyOpPlansToTable() {
-		var list = mockData.opTable || [];
-		for (var i = 0; i < list.length; i++) {
+	function applyPlansToBaseRows(list) {
+		for (var i = 0; i < (list || []).length; i++) {
 			list[i].dayPlan = lookupOpPlan(list[i].code, mockData.opPlansDay);
 			list[i].nightPlan = lookupOpPlan(list[i].code, mockData.opPlansNight);
+			var prevDay = lookupOpPlan(list[i].code, mockData.prevOpPlansDay);
+			var prevNight = lookupOpPlan(list[i].code, mockData.prevOpPlansNight);
+			list[i].prevDayPlan = prevDay + prevNight;
 		}
+	}
+
+	function applyOpPlansToTable() {
+		applyPlansToBaseRows(mockData.opTableMain);
+		applyPlansToBaseRows(mockData.opTableExt);
+		rebuildOpTablePages();
+		updateHourlyCapacityByApi();
 		renderTable();
 	}
 
+	function applyPrevDayPlansToTable() {
+		applyPlansToBaseRows(mockData.opTableMain);
+		applyPlansToBaseRows(mockData.opTableExt);
+		forEachOpTableRow(function(row) {
+			var prevDay = lookupOpPlan(row.code, mockData.prevOpPlansDay);
+			var prevNight = lookupOpPlan(row.code, mockData.prevOpPlansNight);
+			row.prevDayPlan = prevDay + prevNight;
+		});
+		renderTable();
+	}
+
+	function updatePrevDayOpPlansByApi() {
+		$.ajax({
+			url: '${ctx}/mes/mesProductScreen/prevDayOpPlans',
+			type: 'POST',
+			dataType: 'json',
+			data: { screenType: SCREEN_TYPE },
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) return;
+				var d = resp.data;
+				mockData.prevOpPlansDay = d.opPlansDay || {};
+				mockData.prevOpPlansNight = d.opPlansNight || {};
+				if (d.bizDateMd) {
+					headerPrevDayMd = d.bizDateMd;
+					updateCapacityHeaders();
+				}
+				applyPrevDayPlansToTable();
+			}
+		});
+	}
+
 	function applyLatestPlanNumsToTable(planNums) {}
 	function syncAchieveRateWithPlan() {}
 
@@ -1147,6 +1252,30 @@
 		return n >= fromNum && n <= toNum;
 	}
 
+	function makeOpRow(code, name) {
+		return {
+			code: code,
+			name: name || '',
+			prevDayPlan: lookupOpPlan(code, mockData.prevOpPlansDay) + lookupOpPlan(code, mockData.prevOpPlansNight),
+			prevDayOutput: 0,
+			dayPlan: lookupOpPlan(code, mockData.opPlansDay),
+			nightPlan: lookupOpPlan(code, mockData.opPlansNight),
+			dayOutput: 0,
+			nightOutput: 0,
+			_opNum: parseOprnoNum(code)
+		};
+	}
+
+	function buildOrderedOpRows(ops, byCode) {
+		var out = [];
+		for (var i = 0; i < ops.length; i++) {
+			var code = ops[i];
+			var hit = byCode[code];
+			out.push(hit || makeOpRow(code, ''));
+		}
+		return out;
+	}
+
 	function updateLineProcessTableByApi() {
 		$.ajax({
 			url: '${ctx}/mes/mesProductScreen/lineProcessList',
@@ -1159,49 +1288,106 @@
 			},
 			success: function(resp) {
 				var rows = extractUserList(resp);
-				var out = [];
+				var byCode = {};
 				for (var i = 0; i < rows.length; i++) {
 					var p = rows[i] || {};
 					var ls = String(p.lineSn || p.line_sn || '').toUpperCase();
 					if (ls !== LINE_SN) continue;
-					var code = p.oprno || '';
-					if (!isOprnoInRange(code, OP_FROM, OP_TO)) continue;
-					out.push({
-						code: code,
-						name: p.title || '',
-						dayPlan: lookupOpPlan(code, mockData.opPlansDay),
-						nightPlan: lookupOpPlan(code, mockData.opPlansNight),
-						dayOutput: 0,
-						nightOutput: 0,
-						_opNum: parseOprnoNum(code)
-					});
+					var code = String(p.oprno || '').toUpperCase();
+					var num = parseOprnoNum(code);
+					if (num < 110 || num > 210) continue;
+					var key = 'OP' + ('000' + num).slice(-3);
+					byCode[key] = makeOpRow(key, p.title || '');
 				}
-				out.sort(function(a, b) { return a._opNum - b._opNum; });
-				mockData.opTable = out;
+				mockData.opTableMain = buildOrderedOpRows(PAGE_MAIN_OPS, byCode);
+				mockData.opTableExt = buildOrderedOpRows(PAGE_EXT_OPS, byCode);
+				rebuildOpTablePages();
 				opTablePageIndex = 0;
 				renderTable();
 				startOpTablePageRotate();
-				if (out.length > 0) {
-					updateHourlyCapacityByApi();
-				}
+				updateHourlyCapacityByApi();
 				updateDeviceAlarmAlertsByApi();
 			}
 		});
 	}
 
+	function collectExactChildOprnos() {
+		var set = {};
+		var pages = mockData.opTablePages || [];
+		for (var pi = 0; pi < pages.length; pi++) {
+			var list = pages[pi] || [];
+			for (var i = 0; i < list.length; i++) {
+				var children = childOprnosByLine(list[i].code, list[i].line);
+				for (var j = 0; j < children.length; j++) {
+					set[children[j]] = true;
+				}
+			}
+		}
+		return Object.keys(set);
+	}
+
+	function sumExactCapacity(map, children) {
+		var total = 0;
+		for (var i = 0; i < children.length; i++) {
+			var key = children[i];
+			total += Number(map[key] != null ? map[key] : map[String(key).toUpperCase()]) || 0;
+		}
+		return total;
+	}
+
 	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);
+		var pages = mockData.opTablePages || [];
+		if (!pages.length) return;
+		// 当日白/夜班产量:有产线时按子工位精确合计(如 A/B -> OP110A+OP110B)
+		var exactOprnos = collectExactChildOprnos();
+		if (exactOprnos.length) {
+			fetchExactShiftCapacity(LINE_SN, exactOprnos, 'day', 'dayOutput');
+			fetchExactShiftCapacity(LINE_SN, exactOprnos, 'night', 'nightOutput');
+		}
+		// 第3页无产线:仍按父工位前缀统计当日产量
+		var prefixOprnos = [];
+		var page3 = pages[2] || [];
+		for (var i = 0; i < page3.length; i++) {
+			if (page3[i] && page3[i].code && !String(page3[i].line || '').trim()) {
+				prefixOprnos.push(page3[i].code);
+			}
+		}
+		if (prefixOprnos.length) {
+			fetchPrefixShiftCapacity(LINE_SN, prefixOprnos, 'day', 'dayOutput');
+			fetchPrefixShiftCapacity(LINE_SN, prefixOprnos, 'night', 'nightOutput');
 		}
-		if (!oprnos.length) return;
-		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'dayOutput');
-		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'nightOutput');
+		// 上一日产出仍按父工位前缀(所有页)
+		var allPrefix = PAGE_MAIN_OPS.concat(PAGE_EXT_OPS);
+		fetchPrefixShiftCapacity(LINE_SN, allPrefix, 'day', 'prevDayDay', -1);
+		fetchPrefixShiftCapacity(LINE_SN, allPrefix, 'night', 'prevDayNight', -1);
+	}
+
+	function fetchExactShiftCapacity(lineSn, oprnos, shiftType, field) {
+		$.ajax({
+			url: '${ctx}/mes/mesProductRecord/calendarShiftCapacityData',
+			type: 'POST',
+			dataType: 'json',
+			data: {
+				lineSn: lineSn,
+				oprnos: oprnos.join(','),
+				shiftType: shiftType,
+				dayOffset: 0,
+				exact: true
+			},
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) return;
+				var map = resp.data || {};
+				forEachOpTableRow(function(row) {
+					var children = childOprnosByLine(row.code, row.line);
+					if (!children.length) return;
+					row[field] = sumExactCapacity(map, children);
+				});
+				renderTable();
+			}
+		});
 	}
 
-	function fetchCalendarShiftCapacity(lineSn, oprnos, shiftType, field) {
+	function fetchPrefixShiftCapacity(lineSn, oprnos, shiftType, field, dayOffset) {
 		$.ajax({
 			url: '${ctx}/mes/mesProductRecord/calendarShiftCapacityData',
 			type: 'POST',
@@ -1209,17 +1395,26 @@
 			data: {
 				lineSn: lineSn,
 				oprnos: oprnos.join(','),
-				shiftType: shiftType
+				shiftType: shiftType,
+				dayOffset: dayOffset || 0
 			},
 			success: function(resp) {
 				if (!resp || resp.result !== 'true' || !resp.data) return;
 				var map = resp.data || {};
-				var list = mockData.opTable || [];
-				for (var i = 0; i < list.length; i++) {
-					var code = list[i].code || '';
+				forEachOpTableRow(function(row, pageIndex) {
+					var code = row.code || '';
 					var formatted = code.length === 6 ? code.substring(0, 5) : code;
-					list[i][field] = Number(map[code] != null ? map[code] : map[formatted]) || 0;
-				}
+					var val = Number(map[code] != null ? map[code] : map[formatted]) || 0;
+					if (field === 'prevDayDay' || field === 'prevDayNight') {
+						row[field] = val;
+						row.prevDayOutput = (Number(row.prevDayDay) || 0) + (Number(row.prevDayNight) || 0);
+						return;
+					}
+					// 当日产量:仅回填无产线的行(第3页),避免覆盖按产线精确统计的结果
+					if (!String(row.line || '').trim()) {
+						row[field] = val;
+					}
+				});
 				renderTable();
 			}
 		});
@@ -1413,6 +1608,7 @@
 		startOpTablePageRotate();
 		refreshHeaderShiftDate(true);
 		updateScreenConfigByApi();
+		updatePrevDayOpPlansByApi();
 		updateActualProductionByApi();
 		updateLineProcessTableByApi();
 		updateDeviceAlarmAlertsByApi();

+ 76 - 14
src/main/resources/views/modules/mes/mesScreen7.html

@@ -345,12 +345,14 @@
 			<table class="op-table">
 				<thead>
 				<tr>
-					<th style="width:160px">工位</th>
-					<th style="width:300px">工位名称</th>
-					<th id="thDayPlan">白班计划</th>
-					<th id="thDayOutput">白班产量</th>
-					<th id="thNightPlan">夜班计划</th>
-					<th id="thNightOutput">夜班产量</th>
+					<th style="width:100px">工位</th>
+					<th style="width:150px">工位名称</th>
+					<th id="thPrevDayPlan" style="width:100px">日计划</th>
+					<th id="thPrevDayOutput" style="width:100px">日产出</th>
+					<th id="thDayPlan" style="width:100px">白班计划</th>
+					<th id="thDayOutput" style="width:100px">白班产量</th>
+					<th id="thNightPlan" style="width:100px">夜班计划</th>
+					<th id="thNightOutput" style="width:100px">夜班产量</th>
 				</tr>
 				</thead>
 				<tbody id="opTableBody"></tbody>
@@ -434,6 +436,7 @@
 
 	/** 表头业务日期按当前班次开始日(如 11.3);跨自然日不切,换班才切到 11.4 */
 	var headerShiftDateMd = '';
+	var headerPrevDayMd = '';
 	var headerShiftStartMs = 0;
 	var headerShiftEndMs = 0;
 	var headerShiftLoading = false;
@@ -484,16 +487,30 @@
 		});
 	}
 
+	function prevMdFromHeader() {
+		if (headerShiftStartMs > 0) {
+			return formatMd(new Date(headerShiftStartMs - 24 * 60 * 60 * 1000));
+		}
+		var d = new Date();
+		d.setDate(d.getDate() - 1);
+		return formatMd(d);
+	}
+
 	function updateCapacityHeaders() {
 		var now = Date.now();
 		if (!headerShiftDateMd || !(now >= headerShiftStartMs && now < headerShiftEndMs)) {
 			refreshHeaderShiftDate(false);
 		}
 		var today = headerShiftDateMd || formatMd(new Date());
+		var prev = headerPrevDayMd || prevMdFromHeader();
+		var prevPlanEl = document.getElementById('thPrevDayPlan');
+		var prevOutEl = document.getElementById('thPrevDayOutput');
 		var dayPlanEl = document.getElementById('thDayPlan');
 		var dayOutEl = document.getElementById('thDayOutput');
 		var nightPlanEl = document.getElementById('thNightPlan');
 		var nightOutEl = document.getElementById('thNightOutput');
+		if (prevPlanEl) prevPlanEl.textContent = prev + '日计划';
+		if (prevOutEl) prevOutEl.textContent = prev + '日产出';
 		if (dayPlanEl) dayPlanEl.textContent = today + '白班计划';
 		if (dayOutEl) dayOutEl.textContent = today + '白班产量';
 		if (nightPlanEl) nightPlanEl.textContent = today + '夜班计划';
@@ -513,7 +530,7 @@
 	function padOpTableRowsToPageSize(html, rowCount) {
 		for (var j = rowCount; j < OP_TABLE_PAGE_SIZE; j++) {
 			var alt = (j % 2 === 1) ? ' op-row-alt' : '';
-			html += '<tr class="op-row-empty' + alt + '"><td colspan="6">&nbsp;</td></tr>';
+			html += '<tr class="op-row-empty' + alt + '"><td colspan="8">&nbsp;</td></tr>';
 		}
 		return html;
 	}
@@ -564,9 +581,9 @@
 
 	// ====== 页面数据 ======
 	var mockData = {};
-	/** 本屏产线:XT(工位 OP170-OP400) */
+	/** 本屏产线:XT(工位 OP220-OP400;隐藏 OP170-OP210) */
 	var LINE_SN = 'XT';
-	var OP_FROM = 170;
+	var OP_FROM = 220;
 	var OP_TO = 400;
 	/** 大屏配置类型:装配 */
 	var SCREEN_TYPE = 'ZP';
@@ -637,7 +654,7 @@
 		// 报警信息由 updateDeviceAlarmAlertsByApi 拉取
 		mockData.alerts = [];
 
-		// 工位表由 mesLineProcess(XT,OP170-OP400)拉取
+		// 工位表由 mesLineProcess(XT,OP220-OP400;隐藏 OP170-OP210)拉取
 		mockData.opTable = [];
 
 		// 数据卡(总览固定展示)
@@ -1092,6 +1109,8 @@
 			html += '<tr' + ((i % 2 === 1) ? ' class="op-row-alt"' : '') + '>';
 			html += '<td class="op-col">' + r.code + '</td>';
 			html += '<td class="op-name">' + r.name + '</td>';
+			html += '<td class="op-val">' + (r.prevDayPlan || 0) + '</td>';
+			html += '<td class="op-val">' + (r.prevDayOutput || 0) + '</td>';
 			html += '<td class="op-val">' + (r.dayPlan || 0) + '</td>';
 			html += '<td class="op-val">' + (r.dayOutput || 0) + '</td>';
 			html += '<td class="op-val">' + (r.nightPlan || 0) + '</td>';
@@ -1130,10 +1149,43 @@
 		for (var i = 0; i < list.length; i++) {
 			list[i].dayPlan = lookupOpPlan(list[i].code, mockData.opPlansDay);
 			list[i].nightPlan = lookupOpPlan(list[i].code, mockData.opPlansNight);
+			var prevDay = lookupOpPlan(list[i].code, mockData.prevOpPlansDay);
+			var prevNight = lookupOpPlan(list[i].code, mockData.prevOpPlansNight);
+			list[i].prevDayPlan = prevDay + prevNight;
+		}
+		renderTable();
+	}
+
+	function applyPrevDayPlansToTable() {
+		var list = mockData.opTable || [];
+		for (var i = 0; i < list.length; i++) {
+			var prevDay = lookupOpPlan(list[i].code, mockData.prevOpPlansDay);
+			var prevNight = lookupOpPlan(list[i].code, mockData.prevOpPlansNight);
+			list[i].prevDayPlan = prevDay + prevNight;
 		}
 		renderTable();
 	}
 
+	function updatePrevDayOpPlansByApi() {
+		$.ajax({
+			url: '${ctx}/mes/mesProductScreen/prevDayOpPlans',
+			type: 'POST',
+			dataType: 'json',
+			data: { screenType: SCREEN_TYPE },
+			success: function(resp) {
+				if (!resp || resp.result !== 'true' || !resp.data) return;
+				var d = resp.data;
+				mockData.prevOpPlansDay = d.opPlansDay || {};
+				mockData.prevOpPlansNight = d.opPlansNight || {};
+				if (d.bizDateMd) {
+					headerPrevDayMd = d.bizDateMd;
+					updateCapacityHeaders();
+				}
+				applyPrevDayPlansToTable();
+			}
+		});
+	}
+
 	function applyLatestPlanNumsToTable(planNums) {}
 	function syncAchieveRateWithPlan() {}
 
@@ -1169,6 +1221,8 @@
 					out.push({
 						code: code,
 						name: p.title || '',
+						prevDayPlan: lookupOpPlan(code, mockData.prevOpPlansDay) + lookupOpPlan(code, mockData.prevOpPlansNight),
+						prevDayOutput: 0,
 						dayPlan: lookupOpPlan(code, mockData.opPlansDay),
 						nightPlan: lookupOpPlan(code, mockData.opPlansNight),
 						dayOutput: 0,
@@ -1197,11 +1251,13 @@
 			if (list[i] && list[i].code) oprnos.push(list[i].code);
 		}
 		if (!oprnos.length) return;
-		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'dayOutput');
-		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'nightOutput');
+		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'dayOutput', 0);
+		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'nightOutput', 0);
+		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'day', 'prevDayDay', -1);
+		fetchCalendarShiftCapacity(LINE_SN, oprnos, 'night', 'prevDayNight', -1);
 	}
 
-	function fetchCalendarShiftCapacity(lineSn, oprnos, shiftType, field) {
+	function fetchCalendarShiftCapacity(lineSn, oprnos, shiftType, field, dayOffset) {
 		$.ajax({
 			url: '${ctx}/mes/mesProductRecord/calendarShiftCapacityData',
 			type: 'POST',
@@ -1209,7 +1265,8 @@
 			data: {
 				lineSn: lineSn,
 				oprnos: oprnos.join(','),
-				shiftType: shiftType
+				shiftType: shiftType,
+				dayOffset: dayOffset || 0
 			},
 			success: function(resp) {
 				if (!resp || resp.result !== 'true' || !resp.data) return;
@@ -1219,6 +1276,9 @@
 					var code = list[i].code || '';
 					var formatted = code.length === 6 ? code.substring(0, 5) : code;
 					list[i][field] = Number(map[code] != null ? map[code] : map[formatted]) || 0;
+					if (field === 'prevDayDay' || field === 'prevDayNight') {
+						list[i].prevDayOutput = (Number(list[i].prevDayDay) || 0) + (Number(list[i].prevDayNight) || 0);
+					}
 				}
 				renderTable();
 			}
@@ -1411,7 +1471,9 @@
 		renderAlerts();
 		renderTable();
 		startOpTablePageRotate();
+		refreshHeaderShiftDate(true);
 		updateScreenConfigByApi();
+		updatePrevDayOpPlansByApi();
 		updateActualProductionByApi();
 		updateLineProcessTableByApi();
 		updateDeviceAlarmAlertsByApi();