Ver código fonte

feat(工序计件): 重建 CZ060/CZ061 首次完工与返修计件体系

原报表按工序主记录的当前结果和最后更新时间统计。返修、重复提交或人工改判
会覆盖这条记录,导致历史件数、合格数和日期随之变化。本次将计件依据改为
独立保存的实际完工记录,汇总、明细和导出统一从计件明细取数。

首次加工
- 工序主结果首次有效地由 UDF 变为 OK/NG 时,固定完成时间和当次结果。
  按产线、工件码、主工序只计一次,首次 NG 后再报 OK 仍保留原来的 NG 和时间。
- 覆盖常规报工、PDA 正常报工、气密、OP170 螺套两枪、CCD、首站建码
  和包装等主结果写入路径。螺套等主结果落库,CCD 等实际过站,才触发计件。
- 根据报工入口区分实际完工和人工操作。MES 辅助置 OK、PDA 手工改判、
  配置跳站和返修审核回写不记件,后续真实报工仍可正常计件。

返修计件
- 审核通过只表示允许回归。工件在指定回归工位实际提交 OK 后,
  才确认同一产线、同一工件、此前已放行的返修单。
- 一次有效 OK 可确认多张返修单,每张单只计一次。未完成、不可返修、
  还没实际回归过站的单不计。已计返修件按首次确认它的过站时间归日,
  后续重传不增加件数,也不改变历史归属。

双产线报表与历史迁移
- 在「工序件数统计」下新增 CZ060 和 CZ061 两个子菜单,服务端锁定产线。
  同码跨线分别计数,汇总、明细和 Excel 导出使用同一日期和计件口径。
- 汇总显示首次加工、返修、合计、合格数和不良数,默认查询当天。
  明细显示实际完成时间、计件类型及返修单号。
- 迁移脚本根据已有提交日志和返修单回填可核实的历史。
  OP035 直接建出 OK 的有效建码记录单独处理,普通工位缺少依据时留空。
wangxichen 5 dias atrás
pai
commit
d0ec896021

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

@@ -1,5 +1,6 @@
 package com.jeesite.modules.mes.dao;
 
+import java.util.Date;
 import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
@@ -7,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
 import com.jeesite.common.dao.CrudDao;
 import com.jeesite.common.mybatis.annotation.MyBatisDao;
 import com.jeesite.modules.mes.entity.MesProcessCnt;
+import com.jeesite.modules.mes.entity.MesProductRecord;
 
 /**
  * 工序件数统计DAO接口
@@ -40,4 +42,11 @@ public interface MesProcessCntDao extends CrudDao<MesProcessCnt> {
 	 * 按工序汇总件数(导出,不分页)
 	 */
 	List<MesProcessCnt> findStatListAll(@Param("q") MesProcessCnt q);
+	int confirmRepairs(@Param("r") MesProductRecord record, @Param("process") String process, @Param("at") Date completedAt);
+
+	int insertFirstCompletion(@Param("r") MesProductRecord record, @Param("process") String process, @Param("at") Date completedAt);
+
+	int setFirstCompletionDate(@Param("r") MesProductRecord record, @Param("process") String process);
+
+	String findRepairLine(@Param("sn") String sn, @Param("process") String process);
 }

+ 14 - 46
src/main/java/com/jeesite/modules/mes/entity/MesProcessCnt.java

@@ -33,13 +33,11 @@ public class MesProcessCnt extends DataEntity<MesProcessCnt> {
 	@ExcelFields({
 		@ExcelField(title="工序号", attrName="oprno", align=Align.CENTER, sort=10),
 		@ExcelField(title="工序名称", attrName="processTitle", align=Align.CENTER, sort=20),
-		@ExcelField(title="件数(有判定)", attrName="cnt", align=Align.CENTER, sort=30),
+		@ExcelField(title="首次加工", attrName="firstCount", align=Align.CENTER, sort=28),
+		@ExcelField(title="返修", attrName="repairCount", align=Align.CENTER, sort=29),
+		@ExcelField(title="合计", attrName="cnt", align=Align.CENTER, sort=30),
 		@ExcelField(title="合格数", attrName="okCount", align=Align.CENTER, sort=40),
-		@ExcelField(title="不良数", attrName="ngCount", align=Align.CENTER, sort=50),
-		@ExcelField(title="未判定数", attrName="otherCount", align=Align.CENTER, sort=60),
-		@ExcelField(title="合格率", attrName="okRate", align=Align.CENTER, sort=70),
-		@ExcelField(title="首件时间", attrName="firstTime", align=Align.CENTER, sort=80, dataFormat="yyyy-MM-dd HH:mm:ss"),
-		@ExcelField(title="末件时间", attrName="lastTime", align=Align.CENTER, sort=90, dataFormat="yyyy-MM-dd HH:mm:ss")
+		@ExcelField(title="不良数", attrName="ngCount", align=Align.CENTER, sort=50)
 	})
 
 	/* 汇总字段 */
@@ -48,9 +46,9 @@ public class MesProcessCnt extends DataEntity<MesProcessCnt> {
 	private Long cnt;				// 件数(有 OK/NG 判定结果的去重产品数)
 	private Long okCount;			// 合格数
 	private Long ngCount;			// 不良数
-	private Long otherCount;		// 未判定数(仅有预生成空记录,无判定结果)
-	private Date firstTime;			// 首件时间(最早判定写回时间)
-	private Date lastTime;			// 末件时间(最晚判定写回时间)
+	private Long firstCount;
+	private Long repairCount;
+	private String repairId;
 
 	/* 明细字段 */
 	private String sn;				// 产品二维码
@@ -73,6 +71,13 @@ public class MesProcessCnt extends DataEntity<MesProcessCnt> {
 		super(id);
 	}
 
+	public Long getFirstCount() { return firstCount; }
+	public void setFirstCount(Long firstCount) { this.firstCount = firstCount; }
+	public Long getRepairCount() { return repairCount; }
+	public void setRepairCount(Long repairCount) { this.repairCount = repairCount; }
+	public String getRepairId() { return repairId; }
+	public void setRepairId(String repairId) { this.repairId = repairId; }
+
 	public String getOprno() {
 		return oprno;
 	}
@@ -113,31 +118,6 @@ public class MesProcessCnt extends DataEntity<MesProcessCnt> {
 		this.ngCount = ngCount;
 	}
 
-	public Long getOtherCount() {
-		return otherCount;
-	}
-
-	public void setOtherCount(Long otherCount) {
-		this.otherCount = otherCount;
-	}
-
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getFirstTime() {
-		return firstTime;
-	}
-
-	public void setFirstTime(Date firstTime) {
-		this.firstTime = firstTime;
-	}
-
-	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	public Date getLastTime() {
-		return lastTime;
-	}
-
-	public void setLastTime(Date lastTime) {
-		this.lastTime = lastTime;
-	}
 
 	public String getSn() {
 		return sn;
@@ -212,16 +192,4 @@ public class MesProcessCnt extends DataEntity<MesProcessCnt> {
 		this.endDate = endDate;
 	}
 
-	/**
-	 * 合格率 = 合格 / 已判定(OK+NG),待定(UDF)不计入分母
-	 */
-	public String getOkRate() {
-		long ok = okCount == null ? 0L : okCount;
-		long ng = ngCount == null ? 0L : ngCount;
-		long judged = ok + ng;
-		if (judged <= 0) {
-			return "-";
-		}
-		return String.format("%.2f", ok * 100.0 / judged) + "%";
-	}
 }

+ 10 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductRepair.java

@@ -26,6 +26,7 @@ import com.jeesite.common.utils.excel.annotation.ExcelFields;
 @Table(name="mes_product_repair", alias="a", label="返修记录信息", columns={
 		@Column(name="id", attrName="id", label="id", isPK=true),
 		@Column(name="sn", attrName="sn", label="工件码"),
+		@Column(name="line_sn", attrName="lineSn", label="产线"),
 		@Column(name="product_model_id", attrName="productModelId", label="产品型号"),
 		@Column(name="reason", attrName="reason", label="问题描述"),
 		@Column(name="state", attrName="state", label="状态"),
@@ -54,6 +55,7 @@ import com.jeesite.common.utils.excel.annotation.ExcelFields;
 public class MesProductRepair extends DataEntity<MesProductRepair> {
 
 	private static final long serialVersionUID = 1L;
+	private String lineSn;
 	private String sn;		// 工件码
 	private String hmb; //后面板码
 	private String productModelId;		// 产品型号
@@ -100,6 +102,14 @@ public class MesProductRepair extends DataEntity<MesProductRepair> {
 
 	@NotBlank(message="工件码不能为空")
 	@Size(min=0, max=100, message="工件码长度不能超过 100 个字符")
+	public String getLineSn() {
+		return lineSn;
+	}
+
+	public void setLineSn(String lineSn) {
+		this.lineSn = lineSn;
+	}
+
 	public String getSn() {
 		return sn;
 	}

+ 6 - 8
src/main/java/com/jeesite/modules/mes/service/MesProcessCntService.java

@@ -1,8 +1,8 @@
 package com.jeesite.modules.mes.service;
 
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -86,15 +86,13 @@ public class MesProcessCntService extends CrudService<MesProcessCntDao, MesProce
 	}
 
 	/**
-	 * 未指定日期时默认查询本月(按 create_date 分区裁剪,避免全表扫描)
+	 * 未指定日期时默认查询北京时间当天。
 	 */
 	public void applyDefaultDate(MesProcessCnt mesProcessCnt) {
 		if (StringUtils.isBlank(mesProcessCnt.getStartDate()) && StringUtils.isBlank(mesProcessCnt.getEndDate())) {
-			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-			Calendar cal = Calendar.getInstance();
-			mesProcessCnt.setEndDate(sdf.format(cal.getTime()));
-			cal.set(Calendar.DAY_OF_MONTH, 1);
-			mesProcessCnt.setStartDate(sdf.format(cal.getTime()));
+			String today = LocalDate.now(ZoneId.of("Asia/Shanghai")).toString();
+			mesProcessCnt.setStartDate(today);
+			mesProcessCnt.setEndDate(today);
 		}
 	}
 }

+ 2 - 5
src/main/java/com/jeesite/modules/mes/service/MesProductQmwyService.java

@@ -91,12 +91,9 @@ public class MesProductQmwyService extends CrudService<MesProductQmwyDao, MesPro
 			MesProductRecord mesProductRecord = mesProductRecordService.findInfo(mesProductRecord1);
 			if(!ObjectUtils.isEmpty(mesProductRecord)){
 				mesProductRecord.setOprno(mesProductQmwy.getOprno());
-				mesProductRecord.setContent("NG");
-				if(mesProductQmwy.getTestResult().equals("OK")){
-					mesProductRecord.setContent("OK");
-				}
+				String result = "OK".equals(mesProductQmwy.getTestResult()) ? "OK" : "NG";
+				mesProductRecordService.saveStationResult(mesProductRecord, result);
 			}
-			mesProductRecordService.update(mesProductRecord);
 		}
 	}
 	

+ 2 - 5
src/main/java/com/jeesite/modules/mes/service/MesProductQmxdService.java

@@ -112,12 +112,9 @@ public class MesProductQmxdService extends CrudService<MesProductQmxdDao, MesPro
 			MesProductRecord mesProductRecord = mesProductRecordService.findInfo(mesProductRecord1);
 			if(!ObjectUtils.isEmpty(mesProductRecord)){
 				mesProductRecord.setOprno(mesProductQmxd.getOprno());
-				mesProductRecord.setContent("NG");
-				if(mesProductQmxd.getTestResult().equals("OK")){
-					mesProductRecord.setContent("OK");
-				}
+				String result = "OK".equals(mesProductQmxd.getTestResult()) ? "OK" : "NG";
+				mesProductRecordService.saveStationResult(mesProductRecord, result);
 			}
-			mesProductRecordService.update(mesProductRecord);
 		}
 	}
 	

+ 53 - 3
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -168,6 +168,9 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
     @Autowired
     private MesProductPreService mesProductPreService;
 
+	@Autowired
+	private MesPieceworkService mesPieceworkService;
+
 	@Override
 	public void save(MesProductRecord mesProductRecord) {
 		if (StringUtils.isEmpty(mesProductRecord.getSource())) {
@@ -183,6 +186,15 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 		}
 		super.save(mesProductRecord);
 	}
+	@Transactional
+	public void saveStationResult(MesProductRecord record, String result) {
+		String previousResult = record.getContent();
+		String previousSource = record.getSource();
+		record.setContent(result);
+		save(record);
+		mesPieceworkService.recordCompletion(record, previousResult, previousSource);
+	}
+
 	public Long insertBatch(List<MesProductRecord> mesProductRecordList,int num) {
 		boolean needPlan = false;
 		String sn = null;
@@ -583,6 +595,14 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 				throw new ServiceException(text("操作失败!"));
 			}
 
+			if ("0".equals(source)) {
+				for (MesProductRecord record : records) {
+					if (mesProductRecord.getOprno().equals(record.getOprno())) {
+						mesPieceworkService.recordCompletion(record, "UDF", null);
+					}
+				}
+			}
+
 			MesProduct mesProduct = new MesProduct();
 			mesProduct.setSn(mesProductRecord.getSn());
 			mesProduct.setState("0");
@@ -846,6 +866,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 	/**
 	 * @param checkPlan 是否校验生产计划。产线 pcresult 传 false:上料 pccheck 已校验过,提交时跨了班次不应再拦。
 	 */
+	@Transactional
 	public void updateRecordResult(HttpServletRequest request,String sn, String oprno, String craft, String materielSn, String content, String userCode, List<ParamsResp> paramsResps,String lineSn,Boolean optime,List<BindMaterialResp> bmlists,String isRepair, boolean checkPlan) {
 		String oldOprno = oprno;
 		oprno = CommonUitl.formatOprno(oprno);
@@ -855,8 +876,9 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 		mesProductRecord1.setSn(sn);
 		// 兼容 OP180 / OP180A 等侧别工位
 		mesProductRecord1.getSqlMap().getWhere().and("a.oprno", QueryType.LIKE, oprno + "%");
-		// 忽略line_sn要求,兼容多线:查记录不再按产线过滤(客户端仍可传lineSn,不改写记录上的line_sn)
-		// mesProductRecord1.setLineSn(lineSn);
+		if (MesPieceworkService.supports(lineSn)) {
+			mesProductRecord1.setLineSn(lineSn);
+		}
 		List<MesProductRecord> lists = findList(mesProductRecord1);
 		if(ListUtils.isEmpty(lists)){
 			throw new ServiceException(text("记录不存在!"));
@@ -966,6 +988,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 				mesProductRecord.setMaterielSn(materielSn);
 				mesProductRecord.setContent(content);
 				super.update(mesProductRecord);
+				mesPieceworkService.recordCompletion(mesProductRecord, oldcontent, mesProductRecord.getSource());
 
 				FileUploadUtils.saveFileUpload(mesProductRecord, mesProductRecord.getId(), "mesProductRecord_image");
 				FileUploadUtils.saveFileUpload(mesProductRecord, mesProductRecord.getId(), "mesProductRecord_file");
@@ -1276,9 +1299,32 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 	 */
 	@Transactional
 	public void updateRecord(String sn, String oprno, String craft, String materielSn, String content,String userCode,String lineSn) {
+		updateRecord(sn, oprno, craft, materielSn, content, userCode, lineSn, false);
+	}
+
+	@Transactional
+	public void submitStationRecord(String sn, String oprno, String craft, String materielSn,
+			String content, String userCode, String lineSn) {
+		updateRecord(sn, oprno, craft, materielSn, content, userCode, lineSn, true);
+	}
+
+	private void updateRecord(String sn, String oprno, String craft, String materielSn,
+			String content, String userCode, String lineSn, boolean stationCompletion) {
 		String oldOprno = oprno;
 		oprno = CommonUitl.formatOprno(oprno);
-		MesProductRecord mesProductRecord = findByUpdateCate(sn,oprno,craft,lineSn);
+		MesProductRecord mesProductRecord;
+		if (stationCompletion && MesPieceworkService.supports(lineSn)) {
+			MesProductRecord query = new MesProductRecord();
+			query.setSn(sn);
+			query.setCraft(craft);
+			query.setLineSn(lineSn);
+			query.getSqlMap().getWhere().and("a.oprno", QueryType.LIKE, oprno + "%");
+			List<MesProductRecord> records = findList(query);
+			mesProductRecord = records.stream().filter(r -> oldOprno.equals(r.getOprno())).findFirst()
+					.orElse(records.size() == 1 ? records.get(0) : null);
+		} else {
+			mesProductRecord = findByUpdateCate(sn,oprno,craft,lineSn);
+		}
 		if(ObjectUtils.isEmpty(mesProductRecord)){
 			throw new ServiceException(text("记录不存在!"));
 		}
@@ -1294,10 +1340,14 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 			mesProductRecord.setUpdateBy(userCode);
 		}
 		String oldcontent = mesProductRecord.getContent();
+		String oldSource = mesProductRecord.getSource();
 		mesProductRecord.setMaterielSn(materielSn);
 		mesProductRecord.setContent(content);
 		mesProductRecord.setSource("0");
 		super.update(mesProductRecord);
+		if (stationCompletion) {
+			mesPieceworkService.recordCompletion(mesProductRecord, oldcontent, oldSource);
+		}
 
 		// 修改记录
 		MesProductModifyRecord mesProductModifyRecord1 = new MesProductModifyRecord();

+ 28 - 12
src/main/java/com/jeesite/modules/mes/web/MesProcessCntController.java

@@ -9,6 +9,8 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
@@ -28,6 +30,15 @@ import com.jeesite.modules.mes.service.MesProcessCntService;
 @RequestMapping(value = "${adminPath}/mes/mesProcessCnt")
 public class MesProcessCntController extends BaseController {
 
+	@Value("${adminPath}")
+	private String adminPath;
+
+	@RequiresPermissions("mes:mesProcessCnt:view")
+	@RequestMapping(value = {"list", ""})
+	public String legacyList() {
+		return "redirect:" + adminPath + "/mes/mesProcessCnt/CZ060/list";
+	}
+
 	@Autowired
 	private MesProcessCntService mesProcessCntService;
 
@@ -35,8 +46,9 @@ public class MesProcessCntController extends BaseController {
 	 * 按工序展示件数(汇总)
 	 */
 	@RequiresPermissions("mes:mesProcessCnt:view")
-	@RequestMapping(value = {"list", ""})
-	public String list(MesProcessCnt mesProcessCnt, Model model) {
+	@RequestMapping(value = {"{line:CZ060|CZ061}/list", "{line:CZ060|CZ061}"})
+	public String list(@PathVariable("line") String line, MesProcessCnt mesProcessCnt, Model model) {
+		mesProcessCnt.setLineSn(line);
 		mesProcessCntService.applyDefaultDate(mesProcessCnt);
 		model.addAttribute("mesProcessCnt", mesProcessCnt);
 		return "modules/mes/mesProcessCntList";
@@ -46,9 +58,10 @@ public class MesProcessCntController extends BaseController {
 	 * 汇总数据
 	 */
 	@RequiresPermissions("mes:mesProcessCnt:view")
-	@RequestMapping(value = "listData")
+	@RequestMapping(value = "{line:CZ060|CZ061}/listData")
 	@ResponseBody
-	public Page<MesProcessCnt> listData(MesProcessCnt mesProcessCnt, HttpServletRequest request, HttpServletResponse response) {
+	public Page<MesProcessCnt> listData(@PathVariable("line") String line, MesProcessCnt mesProcessCnt, HttpServletRequest request, HttpServletResponse response) {
+		mesProcessCnt.setLineSn(line);
 		mesProcessCnt.setPage(new Page<>(request, response));
 		return mesProcessCntService.findPage(mesProcessCnt);
 	}
@@ -57,8 +70,9 @@ public class MesProcessCntController extends BaseController {
 	 * 某道工序的件数明细
 	 */
 	@RequiresPermissions("mes:mesProcessCnt:view")
-	@RequestMapping(value = "detail")
-	public String detail(MesProcessCnt mesProcessCnt, Model model) {
+	@RequestMapping(value = "{line:CZ060|CZ061}/detail")
+	public String detail(@PathVariable("line") String line, MesProcessCnt mesProcessCnt, Model model) {
+		mesProcessCnt.setLineSn(line);
 		model.addAttribute("mesProcessCnt", mesProcessCnt);
 		return "modules/mes/mesProcessCntDetail";
 	}
@@ -67,9 +81,10 @@ public class MesProcessCntController extends BaseController {
 	 * 明细数据
 	 */
 	@RequiresPermissions("mes:mesProcessCnt:view")
-	@RequestMapping(value = "detailData")
+	@RequestMapping(value = "{line:CZ060|CZ061}/detailData")
 	@ResponseBody
-	public Page<MesProcessCnt> detailData(MesProcessCnt mesProcessCnt, HttpServletRequest request, HttpServletResponse response) {
+	public Page<MesProcessCnt> detailData(@PathVariable("line") String line, MesProcessCnt mesProcessCnt, HttpServletRequest request, HttpServletResponse response) {
+		mesProcessCnt.setLineSn(line);
 		mesProcessCnt.setPage(new Page<>(request, response));
 		return mesProcessCntService.findDetailPage(mesProcessCnt);
 	}
@@ -78,11 +93,12 @@ public class MesProcessCntController extends BaseController {
 	 * 导出汇总数据
 	 */
 	@RequiresPermissions("mes:mesProcessCnt:view")
-	@RequestMapping(value = "exportData")
-	public void exportData(MesProcessCnt mesProcessCnt, HttpServletResponse response) {
+	@RequestMapping(value = "{line:CZ060|CZ061}/exportData")
+	public void exportData(@PathVariable("line") String line, MesProcessCnt mesProcessCnt, HttpServletResponse response) {
+		mesProcessCnt.setLineSn(line);
 		List<MesProcessCnt> list = mesProcessCntService.findList(mesProcessCnt);
-		String fileName = "工序件数统计_" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
-		try (ExcelExport ee = new ExcelExport("工序件数统计", MesProcessCnt.class)) {
+		String fileName = line + "_工序件数统计_" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
+		try (ExcelExport ee = new ExcelExport(line + " 工序件数统计", MesProcessCnt.class)) {
 			ee.setDataList(list).write(response, fileName);
 		}
 	}

+ 5 - 8
src/main/java/com/jeesite/modules/mes/web/MesProductPackController.java

@@ -174,9 +174,9 @@ public class MesProductPackController extends BaseController {
 			p.setState("1");
 			mesProductService.save(p);
 			if (CZ060_LINE_SN.equals(lineSn)) {
-				passPackOprno(p.getSn(), BOX_PACK_OPRNO);
+				passPackOprno(p.getSn(), BOX_PACK_OPRNO, lineSn);
 			}
-			passPackOprno(p.getSn(), PACK_OPRNO);
+			passPackOprno(p.getSn(), PACK_OPRNO, lineSn);
 		}
 
 		// 重新读取最新 nums,满额封箱
@@ -373,13 +373,10 @@ public class MesProductPackController extends BaseController {
 		return null;
 	}
 
-	private void passPackOprno(String shortSn, String oprno) {
+	private void passPackOprno(String shortSn, String oprno, String lineSn) {
 		findRecords(shortSn, oprno).stream()
-				.filter(r -> isStation(r, oprno))
-				.forEach(r -> {
-					r.setContent("OK");
-					mesProductRecordService.save(r);
-				});
+				.filter(r -> isStation(r, oprno) && lineSn.equals(r.getLineSn()))
+				.forEach(r -> mesProductRecordService.saveStationResult(r, "OK"));
 	}
 
 	private boolean isStation(MesProductRecord record, String oprno) {

+ 20 - 5
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -2361,7 +2361,14 @@ public class MesProductRecordController extends BaseController {
 		MesProductRecord mesProductRecord = new MesProductRecord();
 		mesProductRecord.setSn(sn);
 		mesProductRecord.setOprno(CommonUitl.formatOprno(oprno));
+		String requestedLine = request.getParameter("lineSn");
+		if (StringUtils.isNotBlank(requestedLine)) {
+			mesProductRecord.setLineSn(requestedLine.trim());
+		}
 		List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord);
+		if (lists.stream().map(MesProductRecord::getLineSn).distinct().limit(2).count() > 1) {
+			return renderResult(Global.FALSE, text("工件在多条产线有记录,请指定产线!"));
+		}
 		if(ListUtils.isEmpty(lists)){
 			return renderResult(Global.FALSE, text("记录不存在!"));
 		}
@@ -2416,7 +2423,9 @@ public class MesProductRecordController extends BaseController {
 
 		// 更新追溯记录
 		for(MesProductRecord mesProductRecord1 : lists){
-			if(!mesProductRecord1.getCraft().equals("200000")){
+			if ("100000".equals(mesProductRecord1.getCraft())) {
+				mesProductRecordService.saveStationResult(mesProductRecord1, content);
+			} else if(!mesProductRecord1.getCraft().equals("200000")){
 				mesProductRecord1.setContent(content);
 
 				if(mesProductRecord1.getCraft().equals("400001")){ // 人员绑定
@@ -3652,7 +3661,7 @@ public class MesProductRecordController extends BaseController {
 		try{
 
 			sn = mesProductHmbService.formatHmbSn(sn);
-			mesProductRecordService.updateRecord(sn,oldOprno,"100000","","OK",userCode,lineSn);
+			mesProductRecordService.submitStationRecord(sn,oldOprno,"100000","","OK",userCode,lineSn);
 		}catch (Exception e){
 			logger.info(e.getMessage());
 			resp.setMessage("操作失败");
@@ -3965,7 +3974,7 @@ public class MesProductRecordController extends BaseController {
 			// 仅两枪齐了才回写本站 OK
 			if(allOk){
 				sn = mesProductHmbService.formatHmbSn(sn);
-				mesProductRecordService.updateRecord(sn,oprno,"100000","","OK",oprno,lineSn);
+				mesProductRecordService.submitStationRecord(sn,oprno,"100000","","OK",oprno,lineSn);
 			}
 		}catch (Exception e){
 			logger.info(e.getMessage());
@@ -5140,7 +5149,14 @@ public class MesProductRecordController extends BaseController {
 		mesProductRecord.getSqlMap().getWhere().and("a.sn",QueryType.EQ,sn);
 
 		mesProductRecord.setOprno(CommonUitl.formatOprno(oprno));
+		String requestedLine = request.getParameter("lineSn");
+		if (StringUtils.isNotBlank(requestedLine)) {
+			mesProductRecord.setLineSn(requestedLine.trim());
+		}
 		List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord);
+		if (lists.stream().map(MesProductRecord::getLineSn).distinct().limit(2).count() > 1) {
+			return renderResult(Global.FALSE, text("工件在多条产线有记录,请指定产线!"));
+		}
 		if(ListUtils.isEmpty(lists)){
 			return renderResult(Global.FALSE, text("记录不存在!"));
 		}
@@ -5211,8 +5227,7 @@ public class MesProductRecordController extends BaseController {
 
 		for(MesProductRecord mesProductRecord1 : lists){
 			if(mesProductRecord1.getCraft().equals("100000")){
-				mesProductRecord1.setContent("OK");
-				mesProductRecordService.save(mesProductRecord1);
+				mesProductRecordService.saveStationResult(mesProductRecord1, "OK");
 			}
 		}
 

+ 5 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductRepairController.java

@@ -13,6 +13,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
 import com.jeesite.modules.file.entity.FileUpload;
 import com.jeesite.modules.file.service.FileUploadService;
 import com.jeesite.modules.file.utils.FileUploadUtils;
+import com.jeesite.modules.mes.service.MesPieceworkService;
 import com.jeesite.modules.mes.entity.*;
 import com.jeesite.modules.mes.resp.CommonResp;
 import com.jeesite.modules.mes.service.*;
@@ -50,6 +51,9 @@ import com.jeesite.common.web.BaseController;
 public class MesProductRepairController extends BaseController {
 
 	@Autowired
+	private MesPieceworkService mesPieceworkService;
+
+	@Autowired
 	private MesProductRepairService mesProductRepairService;
 
 	@Autowired
@@ -380,6 +384,7 @@ public class MesProductRepairController extends BaseController {
 		}
 
 		mesProductRepair.setOprno(mesRepairItems.getOprno());
+		mesProductRepair.setLineSn(mesPieceworkService.findRepairLine(sn, mesProductRepair.getOprno()));
 
 		if("黑名单".equals(mesRepairItems.getHeiBaiDistinction())){
 			mesProductRepair.setState("3");

+ 2 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductRepairQualityController.java

@@ -329,6 +329,7 @@ public class MesProductRepairQualityController extends BaseController {
 				MesProductRecord mpr = new MesProductRecord();
 				mpr.setCraft("100000");
 				mpr.setSn(mesProduct.getSn());
+				mpr.setLineSn(mesProductRepair.getLineSn());
 				mpr.setContent("NG");
 				List<MesProductRecord> lists = mesProductRecordService.findList(mpr);
 				if(!ListUtils.isEmpty(lists)){
@@ -356,6 +357,7 @@ public class MesProductRepairQualityController extends BaseController {
 				if(!StringUtils.isEmpty(backOprno)){
 					MesProductRecord backRecord = new MesProductRecord();
 					backRecord.setSn(sn);
+					backRecord.setLineSn(mesProductRepair.getLineSn());
 					backRecord.setOprno(backOprno);
 					backRecord.setCraft("100000");
 					MesProductRecord record = mesProductRecordService.findInfo(backRecord);

+ 81 - 135
src/main/resources/mappings/modules/mes/MesProcessCntDao.xml

@@ -1,157 +1,103 @@
 <?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.MesProcessCntDao">
+	<sql id="processNo">CONCAT('OP', LPAD(CAST(SUBSTRING(TRIM(${station}), 3, GREATEST(0, CHAR_LENGTH(TRIM(${station})) - 2 - IF(RIGHT(TRIM(${station}), 1) REGEXP '[0-9]', 0, 1))) AS UNSIGNED), 3, '0'))</sql>
 
-	<!--
-		工序件数统计(口径说明)
-		1) mes_product_record 里每个产品建档时会预生成整条工艺路线的空记录(content='UDF',update_date=create_date),
-		   所以 COUNT(*) 恒等于建档件数(本月 2850),不是产量。件数一律按"有判定结果"的去重产品数统计:
-		   件数 = content IN ('OK','NG') 的去重 sn;未判定 = 仍为 UDF 的去重 sn(数据缺口)。
-		2) 真实过站时间取 update_date(判定写回时间),create_date 只是建档时间(同一产品 49 行完全相同)。
-		3) 工序名称必须限定在产品所属产线:CZ060 / CZ061 存在同名工序号但名称不同的情况(如 OP100),
-		   不限定产线会取到另一条线的名称。本线无维护时才回退到其它线的名称。
-	-->
-	<sql id="statFrom">
-		FROM mes_product_record r
-		LEFT JOIN (
-			SELECT ml.sn AS line_sn, LEFT(lp.oprno, 5) AS oprno, MAX(lp.title) AS title
-			FROM mes_line_process lp
-			INNER JOIN mes_line ml ON ml.id = lp.line_id
-			GROUP BY ml.sn, LEFT(lp.oprno, 5)
-		) p ON p.oprno = LEFT(r.oprno, 5) AND p.line_sn = r.line_sn
-		LEFT JOIN (
-			SELECT LEFT(oprno, 5) AS oprno, MAX(title) AS title
-			FROM mes_line_process GROUP BY LEFT(oprno, 5)
-		) pf ON pf.oprno = LEFT(r.oprno, 5)
-	</sql>
+	<select id="findRepairLine" resultType="string">
+		SELECT COALESCE(IF(COUNT(DISTINCT line_sn) = 1, MAX(line_sn), NULL),
+			IF(COUNT(DISTINCT CASE WHEN <include refid="processNo"><property name="station" value="oprno"/></include>
+				= #{process} THEN line_sn END) = 1,
+			MAX(CASE WHEN <include refid="processNo"><property name="station" value="oprno"/></include>
+				= #{process} THEN line_sn END), NULL))
+		FROM mes_product_record WHERE sn = #{sn} AND craft = '100000' AND NULLIF(line_sn,'') IS NOT NULL
+	</select>
 
-	<sql id="statWhere">
-		<where>
-			r.craft = '100000'
-			<if test="q.oprno != null and q.oprno != ''">
-				AND r.oprno LIKE CONCAT(#{q.oprno}, '%')
-			</if>
-			<if test="q.processTitle != null and q.processTitle != ''">
-				AND COALESCE(p.title, pf.title) LIKE CONCAT('%', #{q.processTitle}, '%')
-			</if>
-			<if test="q.lineSn != null and q.lineSn != ''">
-				AND r.line_sn = #{q.lineSn}
-			</if>
-			<if test="q.startDate != null and q.startDate != ''">
-				AND r.create_date &gt;= CONCAT(#{q.startDate}, ' 00:00:00')
-			</if>
-			<if test="q.endDate != null and q.endDate != ''">
-				AND r.create_date &lt;= CONCAT(#{q.endDate}, ' 23:59:59')
-			</if>
-		</where>
-	</sql>
+	<insert id="confirmRepairs">
+		INSERT INTO mes_process_piecework (line_sn, sn, process_no, repair_key, oprno, cate_sn, result, completed_at)
+		SELECT #{r.lineSn}, r.sn, #{process}, r.id, #{r.oprno}, #{r.cateSn}, 'OK', #{at}
+		FROM mes_product_repair r
+		JOIN mes_product_repair_quality q ON q.repair_id = r.id
+		WHERE r.sn = #{r.sn} AND r.line_sn = #{r.lineSn} AND r.state = '2' AND r.result = '1'
+			AND q.result = '1' AND q.back_oprno = r.back_oprno AND UPPER(q.back_oprno) REGEXP '^OP[0-9]{2,3}[A-Z]?$'
+			AND <include refid="processNo"><property name="station" value="q.back_oprno"/></include> = #{process}
+		GROUP BY r.id, r.sn HAVING MAX(q.update_date) &lt; #{at}
+		ON DUPLICATE KEY UPDATE completed_at = mes_process_piecework.completed_at
+	</insert>
 
-	<!-- 明细:按工序号前缀取该工序下所有工位的记录,名称取"本产线"的工位配置(避免取到另一条线同名工位) -->
-	<sql id="detailFrom">
-		FROM mes_product_record r
-		LEFT JOIN (
-			SELECT ml.sn AS line_sn, lp.oprno AS oprno, MAX(lp.title) AS title
-			FROM mes_line_process lp
-			INNER JOIN mes_line ml ON ml.id = lp.line_id
-			GROUP BY ml.sn, lp.oprno
-		) p ON p.oprno = r.oprno AND p.line_sn = r.line_sn
-		LEFT JOIN (
-			SELECT oprno, MAX(title) AS title FROM mes_line_process GROUP BY oprno
-		) pf ON pf.oprno = r.oprno
-	</sql>
+	<insert id="insertFirstCompletion">
+		INSERT INTO mes_process_piecework (line_sn, sn, process_no, repair_key, oprno, cate_sn, result, completed_at)
+		SELECT #{r.lineSn}, #{r.sn}, #{process}, '', #{r.oprno}, #{r.cateSn}, #{r.content}, #{at}
+		FROM DUAL WHERE NOT EXISTS (
+			SELECT 1 FROM mes_process_piecework p WHERE p.line_sn = #{r.lineSn} AND p.sn = #{r.sn}
+				AND p.process_no = #{process} AND p.repair_key &lt;&gt; ''
+		)
+		ON DUPLICATE KEY UPDATE completed_at = mes_process_piecework.completed_at
+	</insert>
+
+	<update id="setFirstCompletionDate">
+		UPDATE mes_product_record r JOIN mes_process_piecework p
+			ON p.line_sn = r.line_sn AND p.sn = r.sn AND p.process_no = #{process} AND p.repair_key = ''
+		SET r.first_completed_at = p.completed_at
+		WHERE r.sn = #{r.sn} AND r.line_sn = #{r.lineSn} AND r.craft = '100000'
+			AND r.first_completed_at IS NULL AND UPPER(r.oprno) REGEXP '^OP[0-9]{2,3}[A-Z]?$'
+			AND <include refid="processNo"><property name="station" value="r.oprno"/></include> = #{process}
+	</update>
 
-	<sql id="detailWhere">
+	<sql id="workWhere">
+		WHERE w.line_sn = #{q.lineSn}
+		<if test="q.startDate != null and q.startDate != ''">AND w.completed_at &gt;= #{q.startDate}</if>
+		<if test="q.endDate != null and q.endDate != ''">AND w.completed_at &lt; DATE_ADD(#{q.endDate}, INTERVAL 1 DAY)</if>
+		<if test="q.oprno != null and q.oprno != ''">AND w.process_no LIKE CONCAT(#{q.oprno}, '%')</if>
+	</sql>
+	<sql id="stationNames">
+		SELECT <include refid="processNo"><property name="station" value="lp.oprno"/></include> AS process_no,
+			MAX(lp.title) AS title
+		FROM mes_line_process lp JOIN mes_line l ON l.id = lp.line_id AND l.sn = #{q.lineSn}
+		WHERE UPPER(lp.oprno) REGEXP '^OP[0-9]{2,3}[A-Z]?$'
+		GROUP BY process_no
+	</sql>
+	<sql id="stationFilter">
 		<where>
-			r.craft = '100000'
-			<if test="q.oprno != null and q.oprno != ''">
-				AND r.oprno LIKE CONCAT(#{q.oprno}, '%')
-			</if>
-			<if test="q.sn != null and q.sn != ''">
-				AND r.sn LIKE CONCAT('%', #{q.sn}, '%')
-			</if>
-			<if test="q.content != null and q.content != ''">
-				AND r.content = #{q.content}
-			</if>
-			<!-- 未指定结果时默认只看有判定的记录,保证与列表"件数"一致;要看未判定请在下拉里选 UDF -->
-			<if test="q.content == null or q.content == ''">
-				AND r.content IN ('OK','NG')
-			</if>
-			<if test="q.lineSn != null and q.lineSn != ''">
-				AND r.line_sn = #{q.lineSn}
-			</if>
-			<if test="q.startDate != null and q.startDate != ''">
-				AND r.create_date &gt;= CONCAT(#{q.startDate}, ' 00:00:00')
-			</if>
-			<if test="q.endDate != null and q.endDate != ''">
-				AND r.create_date &lt;= CONCAT(#{q.endDate}, ' 23:59:59')
-			</if>
+			<if test="q.oprno != null and q.oprno != ''">AND p.process_no LIKE CONCAT(#{q.oprno}, '%')</if>
+			<if test="q.processTitle != null and q.processTitle != ''">AND p.title LIKE CONCAT('%',#{q.processTitle},'%')</if>
 		</where>
 	</sql>
-
-	<!-- 汇总列(件数=有判定的去重件数,时间=判定写回时间) -->
-	<sql id="statCols">
-			LEFT(r.oprno, 5) AS oprno,
-			MAX(COALESCE(p.title, pf.title)) AS processTitle,
-			MAX(r.line_sn) AS lineSn,
-			COUNT(DISTINCT CASE WHEN r.content IN ('OK','NG') THEN r.sn END) AS cnt,
-			COUNT(DISTINCT CASE WHEN r.content = 'OK' THEN r.sn END) AS okCount,
-			COUNT(DISTINCT CASE WHEN r.content = 'NG' THEN r.sn END) AS ngCount,
-			COUNT(DISTINCT CASE WHEN r.content IS NULL OR r.content NOT IN ('OK','NG') THEN r.sn END) AS otherCount,
-			MIN(CASE WHEN r.content IN ('OK','NG') THEN r.update_date END) AS firstTime,
-			MAX(CASE WHEN r.content IN ('OK','NG') THEN r.update_date END) AS lastTime
+	<sql id="summary">
+		SELECT p.process_no AS oprno, p.title AS processTitle, #{q.lineSn} AS lineSn,
+			COALESCE(a.cnt,0) AS cnt, COALESCE(a.firstCount,0) AS firstCount,
+			COALESCE(a.repairCount,0) AS repairCount, COALESCE(a.okCount,0) AS okCount,
+			COALESCE(a.ngCount,0) AS ngCount
+		FROM (<include refid="stationNames"/>) p
+		LEFT JOIN (
+			SELECT w.process_no, COUNT(*) AS cnt, SUM(w.repair_key = '') AS firstCount,
+				SUM(w.repair_key &lt;&gt; '') AS repairCount, SUM(w.result = 'OK') AS okCount,
+				SUM(w.result = 'NG') AS ngCount
+			FROM mes_process_piecework w <include refid="workWhere"/> GROUP BY w.process_no
+		) a ON a.process_no = p.process_no
+		<include refid="stationFilter"/> ORDER BY p.process_no
 	</sql>
-
-	<!-- 按工序汇总件数 -->
 	<select id="findStatList" resultType="com.jeesite.modules.mes.entity.MesProcessCnt">
-		SELECT
-		<include refid="statCols"/>
-		<include refid="statFrom"/>
-		<include refid="statWhere"/>
-		GROUP BY LEFT(r.oprno, 5), r.line_sn
-		ORDER BY LEFT(r.oprno, 5) ASC, r.line_sn ASC
-		LIMIT #{offset}, #{limit}
+		<include refid="summary"/> LIMIT #{offset}, #{limit}
 	</select>
-
 	<select id="findStatListAll" resultType="com.jeesite.modules.mes.entity.MesProcessCnt">
-		SELECT
-		<include refid="statCols"/>
-		<include refid="statFrom"/>
-		<include refid="statWhere"/>
-		GROUP BY LEFT(r.oprno, 5), r.line_sn
-		ORDER BY LEFT(r.oprno, 5) ASC, r.line_sn ASC
+		<include refid="summary"/>
 	</select>
-
 	<select id="findStatCount" resultType="long">
-		SELECT COUNT(*) FROM (
-			SELECT LEFT(r.oprno, 5) AS oprno, r.line_sn
-			<include refid="statFrom"/>
-			<include refid="statWhere"/>
-			GROUP BY LEFT(r.oprno, 5), r.line_sn
-		) t
+		SELECT COUNT(*) FROM (<include refid="stationNames"/>) p <include refid="stationFilter"/>
 	</select>
-
-	<!-- 指定工序的件数明细(每行一个实际工位) -->
+	<sql id="detailFilter">
+		<include refid="workWhere"/>
+		<if test="q.sn != null and q.sn != ''">AND w.sn LIKE CONCAT('%',#{q.sn},'%')</if>
+		<if test="q.content != null and q.content != ''">AND w.result = #{q.content}</if>
+	</sql>
 	<select id="findDetailList" resultType="com.jeesite.modules.mes.entity.MesProcessCnt">
-		SELECT
-			r.sn AS sn,
-			r.oprno AS oprno,
-			COALESCE(p.title, pf.title) AS processTitle,
-			r.cate_sn AS cateSn,
-			r.line_sn AS lineSn,
-			r.content AS content,
-			r.craft AS craft,
-			r.remark AS remark,
-			COALESCE(r.update_date, r.create_date) AS workTime
-		<include refid="detailFrom"/>
-		<include refid="detailWhere"/>
-		ORDER BY COALESCE(r.update_date, r.create_date) DESC, r.sn ASC
-		LIMIT #{offset}, #{limit}
+		SELECT w.sn, w.oprno, p.title AS processTitle, w.cate_sn AS cateSn, w.line_sn AS lineSn,
+			w.result AS content, w.completed_at AS workTime, NULLIF(w.repair_key,'') AS repairId
+		FROM mes_process_piecework w LEFT JOIN (<include refid="stationNames"/>) p ON p.process_no = w.process_no
+		<include refid="detailFilter"/>
+		ORDER BY w.completed_at DESC, w.sn, w.process_no, w.repair_key LIMIT #{offset}, #{limit}
 	</select>
-
 	<select id="findDetailCount" resultType="long">
-		SELECT COUNT(*)
-		<include refid="detailFrom"/>
-		<include refid="detailWhere"/>
+		SELECT COUNT(*) FROM mes_process_piecework w <include refid="detailFilter"/>
 	</select>
-
 </mapper>

+ 6 - 4
src/main/resources/views/modules/mes/mesProcessCntDetail.html

@@ -16,7 +16,7 @@
 					<span class="pc-oprno">${mesProcessCnt.oprno!}</span>
 					<span>${mesProcessCnt.processTitle!}</span>
 				</span>
-				<span class="pc-tip">${text('默认只显示有 OK/NG 判定结果的记录(与列表件数一致);查未判定的请把结果选为 UDF')}</span>
+				<span class="pc-tip">${text('每行是一笔计件。返修件显示返修单号。')}</span>
 			</div>
 			<div class="box-tools pull-right">
 				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
@@ -24,7 +24,7 @@
 			</div>
 		</div>
 		<div class="box-body">
-			<#form:form id="searchForm" model="${mesProcessCnt}" action="${ctx}/mes/mesProcessCnt/detailData" method="post" class="form-inline hide"
+			<#form:form id="searchForm" model="${mesProcessCnt}" action="${ctx}/mes/mesProcessCnt/${mesProcessCnt.lineSn}/detailData" method="post" class="form-inline hide"
 					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
 				<#form:hidden path="oprno"/>
 				<#form:hidden path="lineSn"/>
@@ -43,7 +43,6 @@
 							<option value="">${text('全部(有判定)')}</option>
 							<option value="OK">OK</option>
 							<option value="NG">NG</option>
-							<option value="UDF">${text('未判定(UDF)')}</option>
 						</select>
 					</div>
 				</div>
@@ -79,7 +78,10 @@ $('#dataGrid').dataGrid({
 		{header:'${text("工序时间")}', name:'workTime', width:170, align:"center", sortable:false, formatter: function(val){
 			return val ? val : '-';
 		}},
-		{header:'${text("备注")}', name:'remark', width:200, align:"left", sortable:false, formatter: function(val){
+		{header:'${text("计件类型")}', name:'pieceworkType', width:100, align:"center", sortable:false, formatter: function(val, obj, row){
+			return row.repairId ? '${text("返修")}' : '${text("首次加工")}';
+		}},
+		{header:'${text("返修单号")}', name:'repairId', width:185, align:"center", sortable:false, formatter: function(val){
 			return val ? val : '';
 		}}
 	]

+ 9 - 31
src/main/resources/views/modules/mes/mesProcessCntList.html

@@ -11,8 +11,8 @@
 	<div class="box box-main">
 		<div class="box-header">
 			<div class="box-title">
-				<i class="fa fa-bar-chart"></i> ${text('工序件数统计')}
-				<span class="pc-tip">${text('件数 = 有 OK/NG 判定结果的去重件数(同工序多工位合并);未判定 = 仅有预生成空记录;首末件 = 判定写回时间;件数为 0 表示该工序未采集到判定数据')}</span>
+				<i class="fa fa-bar-chart"></i> ${mesProcessCnt.lineSn} ${text('工序件数统计')}
+				<span class="pc-tip">${text('合计 = 首次加工 + 返修,按实际完工日期查询。')}</span>
 			</div>
 			<div class="box-tools pull-right">
 				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
@@ -23,7 +23,7 @@
 			</div>
 		</div>
 		<div class="box-body">
-			<#form:form id="searchForm" model="${mesProcessCnt}" action="${ctx}/mes/mesProcessCnt/listData" method="post" class="form-inline hide"
+			<#form:form id="searchForm" model="${mesProcessCnt}" action="${ctx}/mes/mesProcessCnt/${mesProcessCnt.lineSn}/listData" method="post" class="form-inline hide"
 					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
 				<div class="form-group">
 					<label class="control-label">${text('工序号')}:</label>
@@ -38,12 +38,6 @@
 					</div>
 				</div>
 				<div class="form-group">
-					<label class="control-label">${text('产线')}:</label>
-					<div class="control-inline">
-						<#form:input path="lineSn" maxlength="20" class="form-control width-100"/>
-					</div>
-				</div>
-				<div class="form-group">
 					<label class="control-label">${text('开始日期')}:</label>
 					<div class="control-inline width-120">
 						<!-- 日期为 String 类型(用于 create_date 分区裁剪),不能用 form:input 的 dataFormat,否则 Beetl 日期格式化报错 -->
@@ -81,14 +75,15 @@ $('#dataGrid').dataGrid({
 		{header:'${text("工序名称")}', name:'processTitle', width:220, align:"left", sortable:false, formatter: function(val, obj, row, act){
 			return val ? val : '<span style="color:#aaa;">未维护工序名称</span>';
 		}},
-		{header:'${text("件数")}', name:'cnt', width:110, align:"center", sortable:false, formatter: function(val, obj, row, act){
+		{header:'${text("首次加工")}', name:'firstCount', width:100, align:"center", sortable:false},
+		{header:'${text("返修")}', name:'repairCount', width:90, align:"center", sortable:false},
+		{header:'${text("合计")}', name:'cnt', width:110, align:"center", sortable:false, formatter: function(val, obj, row, act){
 			var n = (val === null || val === undefined) ? 0 : val;
 			if(n === 0){
 				return '<span style="color:#bbb;" title="${text("该工序无判定数据")}">0</span>';
 			}
-			var url = '${ctx}/mes/mesProcessCnt/detail?oprno=' + encodeURIComponent(row.oprno || '')
+			var url = '${ctx}/mes/mesProcessCnt/${mesProcessCnt.lineSn}/detail?oprno=' + encodeURIComponent(row.oprno || '')
 				+ '&processTitle=' + encodeURIComponent(row.processTitle || '')
-				+ '&lineSn=' + encodeURIComponent(row.lineSn || '')
 				+ '&startDate=' + encodeURIComponent($('#startDate').val() || '')
 				+ '&endDate=' + encodeURIComponent($('#endDate').val() || '');
 			return '<a href="' + url + '" class="btnList pc-cnt" data-title="${text("工序件数明细")}" title="${text("查看明细")}">' + n + '</a>';
@@ -100,26 +95,9 @@ $('#dataGrid').dataGrid({
 			var n = (val === null || val === undefined) ? 0 : val;
 			return n > 0 ? '<span class="pc-ng">' + n + '</span>' : '0';
 		}},
-		{header:'${text("未判定")}', name:'otherCount', width:100, align:"center", sortable:false, formatter: function(val, obj, row, act){
-			var n = (val === null || val === undefined) ? 0 : val;
-			return n > 0 ? '<span class="pc-other" title="${text("仅有预生成空记录,未采集到判定结果")}">' + n + '</span>' : '0';
-		}},
-		{header:'${text("合格率")}', name:'okRate', width:100, align:"center", sortable:false, formatter: function(val, obj, row, act){
-			if(!val || val === '-'){ return '-'; }
-			var rate = parseFloat(val);
-			var color = rate >= 99 ? '#27ae60' : (rate >= 95 ? '#e67e22' : '#e74c3c');
-			return '<span style="color:' + color + ';font-weight:600;">' + val + '</span>';
-		}},
-		{header:'${text("首件时间")}', name:'firstTime', width:160, align:"center", sortable:false, formatter: function(val){
-			return val ? val : '-';
-		}},
-		{header:'${text("末件时间")}', name:'lastTime', width:160, align:"center", sortable:false, formatter: function(val){
-			return val ? val : '-';
-		}},
 		{header:'${text("操作")}', name:'actions', width:90, align:"center", sortable:false, formatter: function(val, obj, row, act){
-			var url = '${ctx}/mes/mesProcessCnt/detail?oprno=' + encodeURIComponent(row.oprno || '')
+			var url = '${ctx}/mes/mesProcessCnt/${mesProcessCnt.lineSn}/detail?oprno=' + encodeURIComponent(row.oprno || '')
 				+ '&processTitle=' + encodeURIComponent(row.processTitle || '')
-				+ '&lineSn=' + encodeURIComponent(row.lineSn || '')
 				+ '&startDate=' + encodeURIComponent($('#startDate').val() || '')
 				+ '&endDate=' + encodeURIComponent($('#endDate').val() || '');
 			return '<a href="' + url + '" class="btnList" data-title="${text("工序件数明细")}" title="${text("明细")}"><i class="fa fa-list-alt"></i> ${text("明细")}</a>';
@@ -130,7 +108,7 @@ $('#dataGrid').dataGrid({
 // 导出按钮事件
 $('#btnExport').click(function(){
 	js.ajaxSubmitForm($('#searchForm'), {
-		url:'${ctx}/mes/mesProcessCnt/exportData',
+		url:'${ctx}/mes/mesProcessCnt/${mesProcessCnt.lineSn}/exportData',
 		downloadFile:true
 	});
 });