浏览代码

报废功能.优化

sunxianglong 2 月之前
父节点
当前提交
44e95d6a28
共有 20 个文件被更改,包括 1087 次插入 和 133 次删除
  1. 15 0
      src/main/java/com/jeesite/modules/mes/dao/MesProductBfListDao.java
  2. 15 0
      src/main/java/com/jeesite/modules/mes/dao/MesProductBfrkDao.java
  3. 53 0
      src/main/java/com/jeesite/modules/mes/entity/MesProductBfList.java
  4. 101 0
      src/main/java/com/jeesite/modules/mes/entity/MesProductBfrk.java
  5. 100 0
      src/main/java/com/jeesite/modules/mes/service/MesProductBfListService.java
  6. 81 0
      src/main/java/com/jeesite/modules/mes/service/MesProductBfrkService.java
  7. 110 120
      src/main/java/com/jeesite/modules/mes/service/MesScrapService.java
  8. 107 0
      src/main/java/com/jeesite/modules/mes/web/MesProductBfListController.java
  9. 97 0
      src/main/java/com/jeesite/modules/mes/web/MesProductBfrkController.java
  10. 38 2
      src/main/java/com/jeesite/modules/mes/web/MesProductReportController.java
  11. 6 6
      src/main/java/com/jeesite/modules/mes/web/MesScrapController.java
  12. 3 2
      src/main/resources/config/application.yml
  13. 15 0
      src/main/resources/mappings/modules/mes/MesProductBfListDao.xml
  14. 15 0
      src/main/resources/mappings/modules/mes/MesProductBfrkDao.xml
  15. 66 0
      src/main/resources/views/modules/mes/mesProductBfListForm.html
  16. 65 0
      src/main/resources/views/modules/mes/mesProductBfListList.html
  17. 100 0
      src/main/resources/views/modules/mes/mesProductBfrkForm.html
  18. 94 0
      src/main/resources/views/modules/mes/mesProductBfrkList.html
  19. 2 2
      src/main/resources/views/modules/mes/mesScrapDetail.html
  20. 4 1
      src/main/resources/views/modules/mes/mesScrapList.html

+ 15 - 0
src/main/java/com/jeesite/modules/mes/dao/MesProductBfListDao.java

@@ -0,0 +1,15 @@
+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.MesProductBfList;
+
+/**
+ * 报废原因列表DAO接口
+ * @author sxl
+ * @version 2026-08-05
+ */
+@MyBatisDao
+public interface MesProductBfListDao extends CrudDao<MesProductBfList> {
+	
+}

+ 15 - 0
src/main/java/com/jeesite/modules/mes/dao/MesProductBfrkDao.java

@@ -0,0 +1,15 @@
+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.MesProductBfrk;
+
+/**
+ * 工件报废数量表DAO接口
+ * @author sxl
+ * @version 2026-08-05
+ */
+@MyBatisDao
+public interface MesProductBfrkDao extends CrudDao<MesProductBfrk> {
+	
+}

+ 53 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductBfList.java

@@ -0,0 +1,53 @@
+package com.jeesite.modules.mes.entity;
+
+import javax.validation.constraints.Size;
+
+import com.jeesite.common.entity.DataEntity;
+import com.jeesite.common.mybatis.annotation.Column;
+import com.jeesite.common.mybatis.annotation.Table;
+import com.jeesite.common.mybatis.mapper.query.QueryType;
+
+/**
+ * 报废原因列表Entity
+ * @author sxl
+ * @version 2026-08-05
+ */
+@Table(name="mes_product_bf_list", alias="a", label="报废原因列表信息", columns={
+		@Column(name="id", attrName="id", label="id", isPK=true),
+		@Column(name="product_type", attrName="productType", label="报废类型", comment="报废类型(1=压铸车间,2=精加工,3=装配全检包装,4=料工报废)", queryType=QueryType.EQ),
+		@Column(name="reason", attrName="reason", label="报废原因"),
+	}, orderBy="a.id ASC"
+)
+public class MesProductBfList extends DataEntity<MesProductBfList> {
+	
+	private static final long serialVersionUID = 1L;
+	private String productType;		// 报废类型(1=压铸车间,2=精加工,3=装配全检包装,4=料工报废)
+	private String reason;		// 报废原因
+
+	public MesProductBfList() {
+		this(null);
+	}
+	
+	public MesProductBfList(String id){
+		super(id);
+	}
+	
+	@Size(min=0, max=64, message="报废类型长度不能超过 64 个字符")
+	public String getProductType() {
+		return productType;
+	}
+
+	public void setProductType(String productType) {
+		this.productType = productType;
+	}
+	
+	@Size(min=0, max=64, message="报废原因长度不能超过 64 个字符")
+	public String getReason() {
+		return reason;
+	}
+
+	public void setReason(String reason) {
+		this.reason = reason;
+	}
+	
+}

+ 101 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductBfrk.java

@@ -0,0 +1,101 @@
+package com.jeesite.modules.mes.entity;
+
+import javax.validation.constraints.Size;
+
+import com.jeesite.common.entity.DataEntity;
+import com.jeesite.common.mybatis.annotation.Column;
+import com.jeesite.common.mybatis.annotation.Table;
+import com.jeesite.common.mybatis.mapper.query.QueryType;
+
+/**
+ * 工件报废数量表Entity
+ * @author sxl
+ * @version 2026-08-05
+ */
+@Table(name="mes_product_bfrk", alias="a", label="工件报废数量表信息", columns={
+		@Column(name="id", attrName="id", label="id", isPK=true),
+		@Column(name="cp_qty", attrName="cpQty", label="成品入库数量"),
+		@Column(name="order_id", attrName="orderId", label="生产订单号"),
+		@Column(name="cp_bf_qty", attrName="cpBfQty", label="成品报废数量"),
+		@Column(name="cp_code", attrName="cpCode", label="成品码", comment="成品码(B开头=半成品,N开头=成品)"),
+		@Column(name="bcp_qty", attrName="bcpQty", label="半成品入库数量"),
+		@Column(name="bcp_bf_qty", attrName="bcpBfQty", label="半成品报废数量"),
+		@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="更新人", isQuery=false),
+		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false, isUpdateForce=true),
+	}, orderBy="a.update_date DESC"
+)
+public class MesProductBfrk extends DataEntity<MesProductBfrk> {
+	
+	private static final long serialVersionUID = 1L;
+	private String cpQty;		// 成品入库数量
+	private String orderId;		// 生产订单号
+	private String cpBfQty;		// 成品报废数量
+	private String cpCode;		// 成品码(B开头=半成品,N开头=成品)
+	private String bcpQty;		// 半成品入库数量
+	private String bcpBfQty;		// 半成品报废数量
+
+	public MesProductBfrk() {
+		this(null);
+	}
+	
+	public MesProductBfrk(String id){
+		super(id);
+	}
+	
+	@Size(min=0, max=64, message="成品入库数量长度不能超过 64 个字符")
+	public String getCpQty() {
+		return cpQty;
+	}
+
+	public void setCpQty(String cpQty) {
+		this.cpQty = cpQty;
+	}
+	
+	@Size(min=0, max=64, message="生产订单号长度不能超过 64 个字符")
+	public String getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(String orderId) {
+		this.orderId = orderId;
+	}
+	
+	@Size(min=0, max=64, message="成品报废数量长度不能超过 64 个字符")
+	public String getCpBfQty() {
+		return cpBfQty;
+	}
+
+	public void setCpBfQty(String cpBfQty) {
+		this.cpBfQty = cpBfQty;
+	}
+	
+	@Size(min=0, max=64, message="成品码长度不能超过 64 个字符")
+	public String getCpCode() {
+		return cpCode;
+	}
+
+	public void setCpCode(String cpCode) {
+		this.cpCode = cpCode;
+	}
+	
+	@Size(min=0, max=64, message="半成品入库数量长度不能超过 64 个字符")
+	public String getBcpQty() {
+		return bcpQty;
+	}
+
+	public void setBcpQty(String bcpQty) {
+		this.bcpQty = bcpQty;
+	}
+	
+	@Size(min=0, max=64, message="半成品报废数量长度不能超过 64 个字符")
+	public String getBcpBfQty() {
+		return bcpBfQty;
+	}
+
+	public void setBcpBfQty(String bcpBfQty) {
+		this.bcpBfQty = bcpBfQty;
+	}
+	
+}

+ 100 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductBfListService.java

@@ -0,0 +1,100 @@
+package com.jeesite.modules.mes.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.lang.StringUtils;
+import com.jeesite.common.service.CrudService;
+import com.jeesite.modules.mes.entity.MesProductBfList;
+import com.jeesite.modules.mes.dao.MesProductBfListDao;
+
+/**
+ * 报废原因列表Service
+ * @author sxl
+ * @version 2026-08-05
+ */
+@Service
+public class MesProductBfListService extends CrudService<MesProductBfListDao, MesProductBfList> {
+	
+	/**
+	 * 获取单条数据
+	 * @param mesProductBfList
+	 * @return
+	 */
+	@Override
+	public MesProductBfList get(MesProductBfList mesProductBfList) {
+		return super.get(mesProductBfList);
+	}
+	
+	/**
+	 * 查询分页数据
+	 * @param mesProductBfList 查询条件
+	 * @param mesProductBfList.page 分页对象
+	 * @return
+	 */
+	@Override
+	public Page<MesProductBfList> findPage(MesProductBfList mesProductBfList) {
+		return super.findPage(mesProductBfList);
+	}
+	
+	/**
+	 * 查询列表数据
+	 * @param mesProductBfList
+	 * @return
+	 */
+	@Override
+	public List<MesProductBfList> findList(MesProductBfList mesProductBfList) {
+		return super.findList(mesProductBfList);
+	}
+	
+	/**
+	 * 保存数据(插入或更新)
+	 * @param mesProductBfList
+	 */
+	@Override
+	@Transactional
+	public void save(MesProductBfList mesProductBfList) {
+		super.save(mesProductBfList);
+	}
+	
+	/**
+	 * 更新状态
+	 * @param mesProductBfList
+	 */
+	@Override
+	@Transactional
+	public void updateStatus(MesProductBfList mesProductBfList) {
+		super.updateStatus(mesProductBfList);
+	}
+	
+	/**
+	 * 删除数据
+	 * @param mesProductBfList
+	 */
+	@Override
+	@Transactional
+	public void delete(MesProductBfList mesProductBfList) {
+		super.delete(mesProductBfList);
+	}
+
+	/**
+	 * 按报废类型查询报废原因字符串列表
+	 */
+	public List<String> findReasonList(MesProductBfList mesProductBfList) {
+		List<String> reasons = new ArrayList<>();
+		List<MesProductBfList> list = this.findList(mesProductBfList);
+		if (list == null || list.isEmpty()) {
+			return reasons;
+		}
+		for (MesProductBfList item : list) {
+			if (item != null && StringUtils.isNotBlank(item.getReason())) {
+				reasons.add(item.getReason());
+			}
+		}
+		return reasons;
+	}
+	
+}

+ 81 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductBfrkService.java

@@ -0,0 +1,81 @@
+package com.jeesite.modules.mes.service;
+
+import java.util.List;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.service.CrudService;
+import com.jeesite.modules.mes.entity.MesProductBfrk;
+import com.jeesite.modules.mes.dao.MesProductBfrkDao;
+
+/**
+ * 工件报废数量表Service
+ * @author sxl
+ * @version 2026-08-05
+ */
+@Service
+public class MesProductBfrkService extends CrudService<MesProductBfrkDao, MesProductBfrk> {
+	
+	/**
+	 * 获取单条数据
+	 * @param mesProductBfrk
+	 * @return
+	 */
+	@Override
+	public MesProductBfrk get(MesProductBfrk mesProductBfrk) {
+		return super.get(mesProductBfrk);
+	}
+	
+	/**
+	 * 查询分页数据
+	 * @param mesProductBfrk 查询条件
+	 * @param mesProductBfrk.page 分页对象
+	 * @return
+	 */
+	@Override
+	public Page<MesProductBfrk> findPage(MesProductBfrk mesProductBfrk) {
+		return super.findPage(mesProductBfrk);
+	}
+	
+	/**
+	 * 查询列表数据
+	 * @param mesProductBfrk
+	 * @return
+	 */
+	@Override
+	public List<MesProductBfrk> findList(MesProductBfrk mesProductBfrk) {
+		return super.findList(mesProductBfrk);
+	}
+	
+	/**
+	 * 保存数据(插入或更新)
+	 * @param mesProductBfrk
+	 */
+	@Override
+	@Transactional
+	public void save(MesProductBfrk mesProductBfrk) {
+		super.save(mesProductBfrk);
+	}
+	
+	/**
+	 * 更新状态
+	 * @param mesProductBfrk
+	 */
+	@Override
+	@Transactional
+	public void updateStatus(MesProductBfrk mesProductBfrk) {
+		super.updateStatus(mesProductBfrk);
+	}
+	
+	/**
+	 * 删除数据
+	 * @param mesProductBfrk
+	 */
+	@Override
+	@Transactional
+	public void delete(MesProductBfrk mesProductBfrk) {
+		super.delete(mesProductBfrk);
+	}
+	
+}

+ 110 - 120
src/main/java/com/jeesite/modules/mes/service/MesScrapService.java

@@ -7,7 +7,7 @@ import com.jeesite.common.service.CrudService;
 import com.jeesite.common.web.CookieUtils;
 import com.jeesite.modules.file.utils.FileUploadUtils;
 import com.jeesite.modules.mes.dao.MesScrapDao;
-import com.jeesite.modules.mes.entity.MesProduct;
+import com.jeesite.modules.mes.entity.MesProductBfrk;
 import com.jeesite.modules.mes.entity.MesScrap;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
@@ -22,15 +22,11 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.servlet.http.HttpServletResponse;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 /**
  * 报废记录Service
@@ -42,17 +38,15 @@ public class MesScrapService extends CrudService<MesScrapDao, MesScrap> {
 
 	/** 生产报废数据库模板列数 */
 	private static final int COL_COUNT = 53;
-	/** 缺陷列(不含报废数/比例/汇总列) */
-	private static final int[] DEFECT_COLS = {
-			9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
-			21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
-			41, 42, 43, 44, 45, 46
-	};
-	/** 未匹配原因时默认归入精加工-其它 */
-	private static final int DEFAULT_OTHER_COL = 38;
+	/** 压铸车间缺陷列 */
+	private static final int[] DEFECT_COLS_TYPE1 = {9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
+	/** 精加工缺陷列 */
+	private static final int[] DEFECT_COLS_TYPE2 = {21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38};
+	/** 装配全检包装缺陷列 */
+	private static final int[] DEFECT_COLS_TYPE3 = {41, 42, 43, 44, 45, 46};
 
 	@Autowired
-	private MesProductService mesProductService;
+	private MesProductBfrkService mesProductBfrkService;
 
 	/**
 	 * 获取单条数据
@@ -131,7 +125,7 @@ public class MesScrapService extends CrudService<MesScrapDao, MesScrap> {
 	}
 
 	/**
-	 * 按「生产报废数据库」模板导出报废统计
+	 * 按「生产报废数据库」模板导出报废统计(一行汇总各报废原因数量)
 	 */
 	public void exportScrapDatabase(List<MesScrap> list, HttpServletResponse response, String fileName) {
 		try (InputStream in = new ClassPathResource("templates/mes/scrap_export.xls").getInputStream();
@@ -151,47 +145,36 @@ public class MesScrapService extends CrudService<MesScrapDao, MesScrap> {
 				}
 			}
 
-			Map<String, MesProduct> productBySn = loadProducts(list);
-			Map<String, double[]> rows = new LinkedHashMap<>();
-
-			for (MesScrap scrap : list) {
-				String productName = resolveProductName(scrap, productBySn);
-				double[] values = rows.computeIfAbsent(productName, k -> new double[COL_COUNT]);
-				int col = matchDefectColumn(scrap.getReason(), headers);
-				if (col < 0) {
-					col = DEFAULT_OTHER_COL;
+			// 汇总到一行:各报废原因列累计数量
+			double[] values = new double[COL_COUNT];
+			if (list != null) {
+				for (MesScrap scrap : list) {
+					int col = matchDefectColumn(scrap.getProductCate(), scrap.getReason(), headers);
+					if (col >= 0) {
+						values[col] += 1;
+					}
 				}
-				values[col] += 1;
 			}
 
-			int rowIndex = 2;
-			for (Map.Entry<String, double[]> entry : rows.entrySet()) {
-				double[] values = entry.getValue();
-				// 各车间报废数
-				values[19] = sumRange(values, 9, 18);
-				values[39] = sumRange(values, 21, 38);
-				values[47] = sumRange(values, 41, 46);
-				// 成品报废总数
-				values[4] = values[19] + values[39] + values[47];
-				// 毛坯报废总数按压铸合计
-				values[7] = values[19];
-				// 料工报废:工=精加工+装配,料=压铸
-				values[49] = values[39] + values[47];
-				values[51] = values[19];
+			// 各车间报废数
+			values[19] = sumRange(values, 9, 18);
+			values[39] = sumRange(values, 21, 38);
+			values[47] = sumRange(values, 41, 46);
+			// 料工报废:工=精加工+装配,料=压铸
+			values[49] = values[39] + values[47];
+			values[51] = values[19];
 
-				Row row = sheet.createRow(rowIndex++);
-				setCellString(row, 1, entry.getKey());
-				setCellString(row, 2, "/");
-				for (int c = 0; c < COL_COUNT; c++) {
-					if (c == 1 || c == 2) {
-						continue;
-					}
-					if (c == 0) {
-						setCellString(row, 0, "");
-						continue;
-					}
-					setCellNumber(row, c, values[c]);
+			Row row = sheet.createRow(2);
+			setCellString(row, 0, "");
+			setCellString(row, 1, "合计");
+			setCellString(row, 2, "/");
+			// 成品/毛坯入库与报废、报废率:来自 MesProductBfrk 汇总,不按报废原因计数
+			fillBfrkSummary(row);
+			for (int c = 3; c < COL_COUNT; c++) {
+				if (c >= 3 && c <= 8) {
+					continue;
 				}
+				setCellNumber(row, c, values[c]);
 			}
 
 			response.reset();
@@ -208,97 +191,104 @@ public class MesScrapService extends CrudService<MesScrapDao, MesScrap> {
 		}
 	}
 
-	private Map<String, MesProduct> loadProducts(List<MesScrap> list) {
-		Map<String, MesProduct> map = new HashMap<>();
-		if (list == null || list.isEmpty()) {
-			return map;
-		}
-		Set<String> sns = new HashSet<>();
-		for (MesScrap scrap : list) {
-			if (StringUtils.isNotBlank(scrap.getSn())) {
-				sns.add(scrap.getSn().trim());
-			}
-		}
-		if (sns.isEmpty()) {
-			return map;
-		}
-		MesProduct query = new MesProduct();
-		query.getSqlMap().getWhere().and("sn", QueryType.IN, new ArrayList<>(sns));
-		List<MesProduct> products = mesProductService.findList(query);
-		if (products != null) {
-			for (MesProduct product : products) {
-				if (product != null && StringUtils.isNotBlank(product.getSn())) {
-					map.put(product.getSn(), product);
+	/**
+	 * 从 MesProductBfrk 汇总并填入:
+	 * 成品入库数、成品报废总数、成品总报废率、毛坯入库数、毛坯报废总数、毛坯总报废率
+	 * 报废率 = (报废总数 / 入库总数) * 100%,保留两位小数
+	 */
+	private void fillBfrkSummary(Row row) {
+		double cpQty = 0;      // 成品入库数
+		double cpBfQty = 0;    // 成品报废总数
+		double bcpQty = 0;     // 毛坯(半成品)入库数
+		double bcpBfQty = 0;   // 毛坯(半成品)报废总数
+		List<MesProductBfrk> bfrkList = mesProductBfrkService.findList(new MesProductBfrk());
+		if (bfrkList != null) {
+			for (MesProductBfrk item : bfrkList) {
+				if (item == null) {
+					continue;
 				}
+				cpQty += parseQty(item.getCpQty());
+				cpBfQty += parseQty(item.getCpBfQty());
+				bcpQty += parseQty(item.getBcpQty());
+				bcpBfQty += parseQty(item.getBcpBfQty());
 			}
 		}
-		return map;
+		setCellNumber(row, 3, cpQty);
+		setCellNumber(row, 4, cpBfQty);
+		setCellString(row, 5, calcScrapRate(cpBfQty, cpQty));
+		setCellNumber(row, 6, bcpQty);
+		setCellNumber(row, 7, bcpBfQty);
+		setCellString(row, 8, calcScrapRate(bcpBfQty, bcpQty));
 	}
 
-	private String resolveProductName(MesScrap scrap, Map<String, MesProduct> productBySn) {
-		if (scrap != null && StringUtils.isNotBlank(scrap.getSn())) {
-			MesProduct product = productBySn.get(scrap.getSn().trim());
-			if (product != null && StringUtils.isNotBlank(product.getTitle())) {
-				return product.getTitle().trim();
-			}
+	private double parseQty(String qty) {
+		if (StringUtils.isBlank(qty)) {
+			return 0;
 		}
-		if (scrap != null && StringUtils.isNotBlank(scrap.getProductCate())) {
-			return scrap.getProductCate().trim();
+		try {
+			return Double.parseDouble(qty.trim());
+		} catch (NumberFormatException e) {
+			return 0;
 		}
-		if (scrap != null && StringUtils.isNotBlank(scrap.getSn())) {
-			return scrap.getSn().trim();
+	}
+
+	/**
+	 * (报废数 / 入库数) * 100%,保留两位小数;入库为0时返回空
+	 */
+	private String calcScrapRate(double scrapQty, double inboundQty) {
+		if (inboundQty <= 0) {
+			return "";
 		}
-		return "未知产品";
+		BigDecimal rate = BigDecimal.valueOf(scrapQty)
+				.multiply(BigDecimal.valueOf(100))
+				.divide(BigDecimal.valueOf(inboundQty), 2, RoundingMode.HALF_UP);
+		return rate.toPlainString() + "%";
 	}
 
 	/**
-	 * 按报废原因匹配模板缺陷列:精确匹配优先,其次包含匹配;同名列按精加工 > 压铸 > 装配顺序。
+	 * 按报废类型 + 报废原因匹配模板缺陷列
+	 * productCate: 1=压铸车间, 2=精加工, 3=装配全检包装
 	 */
-	private int matchDefectColumn(String reason, String[] headers) {
+	private int matchDefectColumn(String productCate, String reason, String[] headers) {
+		int[] cols = defectColsByType(productCate);
+		int defaultOther = defaultOtherCol(productCate);
 		if (StringUtils.isBlank(reason)) {
-			return -1;
+			return defaultOther;
 		}
 		String target = reason.trim();
-		List<Integer> exact = new ArrayList<>();
-		List<Integer> contains = new ArrayList<>();
-		for (int col : DEFECT_COLS) {
+		for (int col : cols) {
 			String header = headers[col];
-			if (StringUtils.isBlank(header)) {
-				continue;
+			if (StringUtils.isNotBlank(header) && header.equals(target)) {
+				return col;
 			}
-			if (header.equals(target)) {
-				exact.add(col);
-			} else if (header.contains(target) || target.contains(header)) {
-				contains.add(col);
+		}
+		for (int col : cols) {
+			String header = headers[col];
+			if (StringUtils.isNotBlank(header) && (header.contains(target) || target.contains(header))) {
+				return col;
 			}
 		}
-		if (!exact.isEmpty()) {
-			return preferColumn(exact);
+		return defaultOther;
+	}
+
+	private int[] defectColsByType(String productCate) {
+		if ("1".equals(productCate)) {
+			return DEFECT_COLS_TYPE1;
 		}
-		if (!contains.isEmpty()) {
-			return preferColumn(contains);
+		if ("3".equals(productCate)) {
+			return DEFECT_COLS_TYPE3;
 		}
-		return -1;
+		return DEFECT_COLS_TYPE2;
 	}
 
-	private int preferColumn(List<Integer> cols) {
-		Integer best = null;
-		int bestScore = -1;
-		for (Integer col : cols) {
-			int score;
-			if (col >= 21 && col <= 38) {
-				score = 3; // 精加工
-			} else if (col >= 9 && col <= 18) {
-				score = 2; // 压铸
-			} else {
-				score = 1; // 装配
-			}
-			if (score > bestScore) {
-				bestScore = score;
-				best = col;
-			}
+	private int defaultOtherCol(String productCate) {
+		if ("1".equals(productCate)) {
+			return 18;
+		}
+		if ("3".equals(productCate)) {
+			return 46;
 		}
-		return best == null ? cols.get(0) : best;
+		return 38;
 	}
 
 	private double sumRange(double[] values, int from, int to) {

+ 107 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductBfListController.java

@@ -0,0 +1,107 @@
+package com.jeesite.modules.mes.web;
+
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.jeesite.common.config.Global;
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.web.BaseController;
+import com.jeesite.modules.mes.entity.MesProductBfList;
+import com.jeesite.modules.mes.service.MesProductBfListService;
+
+/**
+ * 报废原因列表Controller
+ * @author sxl
+ * @version 2026-08-05
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/mes/mesProductBfList")
+public class MesProductBfListController extends BaseController {
+
+	@Autowired
+	private MesProductBfListService mesProductBfListService;
+
+	/**
+	 * 获取数据
+	 */
+	@ModelAttribute
+	public MesProductBfList get(String id, boolean isNewRecord) {
+		return mesProductBfListService.get(id, isNewRecord);
+	}
+
+	/**
+	 * 查询列表
+	 */
+	@RequiresPermissions("mes:mesProductBfList:view")
+	@RequestMapping(value = {"list", ""})
+	public String list(MesProductBfList mesProductBfList, Model model) {
+		model.addAttribute("mesProductBfList", mesProductBfList);
+		return "modules/mes/mesProductBfListList";
+	}
+
+	/**
+	 * 查询列表数据
+	 */
+	@RequiresPermissions("mes:mesProductBfList:view")
+	@RequestMapping(value = "listData")
+	@ResponseBody
+	public Page<MesProductBfList> listData(MesProductBfList mesProductBfList, HttpServletRequest request, HttpServletResponse response) {
+		mesProductBfList.setPage(new Page<>(request, response));
+		Page<MesProductBfList> page = mesProductBfListService.findPage(mesProductBfList);
+		return page;
+	}
+
+	/**
+	 * 查看编辑表单
+	 */
+	@RequiresPermissions("mes:mesProductBfList:view")
+	@RequestMapping(value = "form")
+	public String form(MesProductBfList mesProductBfList, Model model) {
+		model.addAttribute("mesProductBfList", mesProductBfList);
+		return "modules/mes/mesProductBfListForm";
+	}
+
+	/**
+	 * 保存数据
+	 */
+	@RequiresPermissions("mes:mesProductBfList:edit")
+	@PostMapping(value = "save")
+	@ResponseBody
+	public String save(@Validated MesProductBfList mesProductBfList) {
+		mesProductBfListService.save(mesProductBfList);
+		return renderResult(Global.TRUE, text("保存报废原因列表成功!"));
+	}
+
+	/**
+	 * 删除数据
+	 */
+	@RequiresPermissions("mes:mesProductBfList:edit")
+	@RequestMapping(value = "delete")
+	@ResponseBody
+	public String delete(MesProductBfList mesProductBfList) {
+		mesProductBfListService.delete(mesProductBfList);
+		return renderResult(Global.TRUE, text("删除报废原因列表成功!"));
+	}
+
+	/**
+	 * 按报废类型查询报废原因列表
+	 */
+	@RequestMapping(value = "reasonList")
+	@ResponseBody
+	public String reasonList(MesProductBfList mesProductBfList) {
+		List<String> reasons = mesProductBfListService.findReasonList(mesProductBfList);
+		return renderResult(Global.TRUE, text("查询成功!"), reasons);
+	}
+
+}

+ 97 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductBfrkController.java

@@ -0,0 +1,97 @@
+package com.jeesite.modules.mes.web;
+
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.jeesite.common.config.Global;
+import com.jeesite.common.entity.Page;
+import com.jeesite.common.web.BaseController;
+import com.jeesite.modules.mes.entity.MesProductBfrk;
+import com.jeesite.modules.mes.service.MesProductBfrkService;
+
+/**
+ * 工件报废数量表Controller
+ * @author sxl
+ * @version 2026-08-05
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/mes/mesProductBfrk")
+public class MesProductBfrkController extends BaseController {
+
+	@Autowired
+	private MesProductBfrkService mesProductBfrkService;
+	
+	/**
+	 * 获取数据
+	 */
+	@ModelAttribute
+	public MesProductBfrk get(String id, boolean isNewRecord) {
+		return mesProductBfrkService.get(id, isNewRecord);
+	}
+	
+	/**
+	 * 查询列表
+	 */
+	@RequiresPermissions("mes:mesProductBfrk:view")
+	@RequestMapping(value = {"list", ""})
+	public String list(MesProductBfrk mesProductBfrk, Model model) {
+		model.addAttribute("mesProductBfrk", mesProductBfrk);
+		return "modules/mes/mesProductBfrkList";
+	}
+	
+	/**
+	 * 查询列表数据
+	 */
+	@RequiresPermissions("mes:mesProductBfrk:view")
+	@RequestMapping(value = "listData")
+	@ResponseBody
+	public Page<MesProductBfrk> listData(MesProductBfrk mesProductBfrk, HttpServletRequest request, HttpServletResponse response) {
+		mesProductBfrk.setPage(new Page<>(request, response));
+		Page<MesProductBfrk> page = mesProductBfrkService.findPage(mesProductBfrk);
+		return page;
+	}
+
+	/**
+	 * 查看编辑表单
+	 */
+	@RequiresPermissions("mes:mesProductBfrk:view")
+	@RequestMapping(value = "form")
+	public String form(MesProductBfrk mesProductBfrk, Model model) {
+		model.addAttribute("mesProductBfrk", mesProductBfrk);
+		return "modules/mes/mesProductBfrkForm";
+	}
+
+	/**
+	 * 保存数据
+	 */
+	@RequiresPermissions("mes:mesProductBfrk:edit")
+	@PostMapping(value = "save")
+	@ResponseBody
+	public String save(@Validated MesProductBfrk mesProductBfrk) {
+		mesProductBfrkService.save(mesProductBfrk);
+		return renderResult(Global.TRUE, text("保存工件报废数量表成功!"));
+	}
+	
+	/**
+	 * 删除数据
+	 */
+	@RequiresPermissions("mes:mesProductBfrk:edit")
+	@RequestMapping(value = "delete")
+	@ResponseBody
+	public String delete(MesProductBfrk mesProductBfrk) {
+		mesProductBfrkService.delete(mesProductBfrk);
+		return renderResult(Global.TRUE, text("删除工件报废数量表成功!"));
+	}
+	
+}

+ 38 - 2
src/main/java/com/jeesite/modules/mes/web/MesProductReportController.java

@@ -30,7 +30,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import com.jeesite.common.config.Global;
 import com.jeesite.common.entity.Page;
 import com.jeesite.common.web.BaseController;
+import com.jeesite.modules.mes.entity.MesProductBfrk;
 import com.jeesite.modules.mes.entity.MesProductReport;
+import com.jeesite.modules.mes.service.MesProductBfrkService;
 import com.jeesite.modules.mes.service.MesProductReportService;
 
 /**
@@ -46,6 +48,8 @@ public class MesProductReportController extends BaseController {
 	private MesProductReportService mesProductReportService;
 	@Autowired
 	private MesProductOrderService mesProductOrderService;
+	@Autowired
+	private MesProductBfrkService mesProductBfrkService;
 
 	/**
 	 * 获取数据
@@ -111,7 +115,7 @@ public class MesProductReportController extends BaseController {
 	/**
 	 * 同步数据到 ERP
 	 */
-	@RequiresPermissions("mes:mesProductReport:edit")
+//	@RequiresPermissions("mes:mesProductReport:edit")
 	@RequestMapping(value = "mesToErp", method = {RequestMethod.GET, RequestMethod.POST})
 	@ResponseBody
 	public String mesToErp(@RequestBody(required = false) String body, MesProductReport mesProductReport, HttpServletRequest request) {
@@ -156,10 +160,16 @@ public class MesProductReportController extends BaseController {
 		MesProductOrder mesProductOrder = new MesProductOrder();
 		mesProductOrder.setSn(mesProductReport.getMoDocNo());
 		List<MesProductOrder> list = mesProductOrderService.findList(mesProductOrder);
-		mesProductOrder=list.get(0);
+		if (list == null || list.isEmpty()) {
+			return renderResult(Global.FALSE, text("同步ERP成功,但未找到对应生产订单!"));
+		}
+		mesProductOrder = list.get(0);
 		mesProductOrder.setNowNums(Integer.parseInt(mesProductReport.getCompleteQty()));
 		mesProductOrderService.update(mesProductOrder);
 
+		// 同步成功后写入报废/入库数量统计表
+		saveProductBfrk(mesProductReport, mesProductOrder.getLineSn());
+
 		String docId = data.getString("ID");
 		StringBuilder successMsg = new StringBuilder(text("同步ERP成功!"));
 		successMsg.append(" ").append(code);
@@ -170,6 +180,32 @@ public class MesProductReportController extends BaseController {
 	}
 
 	/**
+	 * 按产线编号写入半成品/成品入库与报废数量
+	 * lineSn 以 B 开头:半成品;以 N 开头:成品
+	 */
+	private void saveProductBfrk(MesProductReport mesProductReport, String lineSn) {
+		if (mesProductReport == null || StringUtils.isBlank(lineSn)) {
+			return;
+		}
+		MesProductBfrk bfrk = new MesProductBfrk();
+		bfrk.setOrderId(mesProductReport.getMoDocNo());
+		bfrk.setCpCode(lineSn);
+		String completeQty = StringUtils.defaultIfBlank(mesProductReport.getCompleteQty(), "0");
+		String scrapQty = StringUtils.defaultIfBlank(mesProductReport.getScrapQty(), "0");
+		if (lineSn.startsWith("B") || lineSn.startsWith("b")) {
+			bfrk.setBcpQty(completeQty);
+			bfrk.setBcpBfQty(scrapQty);
+		} else if (lineSn.startsWith("N") || lineSn.startsWith("n")) {
+			bfrk.setCpQty(completeQty);
+			bfrk.setCpBfQty(scrapQty);
+		} else {
+			logger.warn("产线编号既非B也非N开头,跳过写入MesProductBfrk,lineSn={}", lineSn);
+			return;
+		}
+		mesProductBfrkService.save(bfrk);
+	}
+
+	/**
 	 * 构造 CreateCompleteDoc 接口请求 JSON
 	 */
 	private String buildCreateCompleteDocJson(MesProductReport mesProductReport) {

+ 6 - 6
src/main/java/com/jeesite/modules/mes/web/MesScrapController.java

@@ -148,13 +148,13 @@ public class MesScrapController extends BaseController {
 
 		MesProduct mesProduct1 = new MesProduct();
 		mesProduct1.setSn(mesScrap.getSn());
-		mesProduct1.setCate(mesScrap.getProductCate());
-		MesProduct mesProduct = mesProductService.findInfo(mesProduct1);
-		if(ObjectUtils.isEmpty(mesProduct)){
+//		mesProduct1.setCate(mesScrap.getProductCate());
+		List<MesProduct> list = mesProductService.findList(mesProduct1);
+		if(list.isEmpty()){
 			resp.setMessage("产品信息不存在");
 			return resp;
 		}
-		if(mesProduct.getState().equals("3")){
+		if(list.get(0).getState().equals("3")){
 			resp.setMessage("产品已报废");
 			return resp;
 		}
@@ -168,8 +168,8 @@ public class MesScrapController extends BaseController {
 		FileUploadUtils.saveFileUpload(mesScrap, mesScrap.getId(), "mesScrap_image");
 
 		// 更新产品状态
-		mesProduct.setState("3");
-		mesProductService.update(mesProduct);
+		list.get(0).setState("3");
+		mesProductService.update(list.get(0));
 
 		resp.setResult(Global.TRUE);
 		return resp;

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

@@ -53,8 +53,8 @@ jdbc:
   # Mysql 数据库配置
   type: mysql
   driver: com.mysql.cj.jdbc.Driver
-#  url: jdbc:mysql://127.0.0.1:3306/mes_cloud_ljr?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
-  url: jdbc:mysql://10.0.20.10:3306/mes_cloud_ljr?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
+  url: jdbc:mysql://127.0.0.1:3306/mes_cloud_ljr?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
+#  url: jdbc:mysql://10.0.20.10:3306/mes_cloud_ljr?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
 #  url: jdbc:mysql://192.168.22.99:3306/mes_cloud?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
 #  username: mes_cloud
 #  password: YD57bSRabiyWBwkZ
@@ -739,6 +739,7 @@ shiro:
     ${adminPath}/mes/mesProductRecord/pdaRcl= anon
     ${adminPath}/mes/mesMaterialRk/jxCode= anon
     ${adminPath}/mes/mesMaterialRk/mesToErp= anon
+    ${adminPath}/mes/mesProductReport/mesToErp= anon
     ${adminPath}/erp/mesProductOrder/receiveOrder= anon
     ${adminPath}/erp/mesProductOrder/orderList= anon
     ${adminPath}/erp/mesProductOrder/orderInfo= anon

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

@@ -0,0 +1,15 @@
+<?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.MesProductBfListDao">
+	
+	<!-- 查询数据
+	<select id="findList" resultType="MesProductBfList">
+		SELECT ${sqlMap.column.toSql()}
+		FROM ${sqlMap.table.toSql()}
+		<where>
+			${sqlMap.where.toSql()}
+		</where>
+		ORDER BY ${sqlMap.order.toSql()}
+	</select> -->
+	
+</mapper>

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

@@ -0,0 +1,15 @@
+<?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.MesProductBfrkDao">
+	
+	<!-- 查询数据
+	<select id="findList" resultType="MesProductBfrk">
+		SELECT ${sqlMap.column.toSql()}
+		FROM ${sqlMap.table.toSql()}
+		<where>
+			${sqlMap.where.toSql()}
+		</where>
+		ORDER BY ${sqlMap.order.toSql()}
+	</select> -->
+	
+</mapper>

+ 66 - 0
src/main/resources/views/modules/mes/mesProductBfListForm.html

@@ -0,0 +1,66 @@
+<% layout('/layouts/default.html', {title: '报废原因列表管理', libs: ['validate']}){ %>
+<div class="main-content">
+	<div class="box box-main">
+		<div class="box-header with-border">
+			<div class="box-title">
+				<i class="fa icon-note"></i> ${text(mesProductBfList.isNewRecord ? '新增报废原因列表' : '编辑报废原因列表')}
+			</div>
+			<div class="box-tools pull-right">
+				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
+			</div>
+		</div>
+		<#form:form id="inputForm" model="${mesProductBfList}" action="${ctx}/mes/mesProductBfList/save" method="post" class="form-horizontal">
+			<div class="box-body">
+				<div class="form-unit">${text('基本信息')}</div>
+				<#form:hidden path="id"/>
+				<div class="row">
+					<div class="col-xs-12">
+						<div class="form-group">
+							<label class="control-label col-sm-2" title="">
+								<span class="required hide">*</span> ${text('报废类型')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-4">
+								<#form:input path="productType" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+				</div>
+				<div class="row">
+					<div class="col-xs-12">
+						<div class="form-group">
+							<label class="control-label col-sm-2" title="">
+								<span class="required hide">*</span> ${text('报废原因')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-4">
+								<#form:input path="reason" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+				</div>
+			</div>
+			<div class="box-footer">
+				<div class="row">
+					<div class="col-sm-offset-2 col-sm-10">
+						<% if (hasPermi('mes:mesProductBfList:edit')){ %>
+							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
+						<% } %>
+						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
+					</div>
+				</div>
+			</div>
+		</#form:form>
+	</div>
+</div>
+<% } %>
+<script>
+$("#inputForm").validate({
+	submitHandler: function(form){
+		js.ajaxSubmitForm($(form), function(data){
+			js.showMessage(data.message);
+			if(data.result == Global.TRUE){
+				js.closeCurrentTabPage(function(contentWindow){
+					contentWindow.page();
+				});
+			}
+		}, "json");
+    }
+});
+</script>

+ 65 - 0
src/main/resources/views/modules/mes/mesProductBfListList.html

@@ -0,0 +1,65 @@
+<% layout('/layouts/default.html', {title: '报废原因列表管理', libs: ['dataGrid']}){ %>
+<div class="main-content">
+	<div class="box box-main">
+		<div class="box-header">
+			<div class="box-title">
+				<i class="fa icon-notebook"></i> ${text('报废原因列表管理')}
+			</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>
+				<% if(hasPermi('mes:mesProductBfList:edit')){ %>
+					<a href="${ctx}/mes/mesProductBfList/form" class="btn btn-default btnTool" title="${text('新增报废原因列表')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
+				<% } %>
+				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
+			</div>
+		</div>
+		<div class="box-body">
+			<#form:form id="searchForm" model="${mesProductBfList}" action="${ctx}/mes/mesProductBfList/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>
+					<div class="control-inline">
+						<#form:input path="productType" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<label class="control-label">${text('报废原因')}:</label>
+					<div class="control-inline">
+						<#form:input path="reason" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
+					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
+				</div>
+			</#form:form>
+			<table id="dataGrid"></table>
+			<div id="dataGridPage"></div>
+		</div>
+	</div>
+</div>
+<% } %>
+<script>
+// 初始化DataGrid对象
+$('#dataGrid').dataGrid({
+	searchForm: $("#searchForm"),
+	columnModel: [
+		{header:'${text("报废类型")}', name:'productType', index:'a.product_type', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
+			return '<a href="${ctx}/mes/mesProductBfList/form?id='+row.id+'" class="btnList" data-title="${text("编辑报废原因列表")}">'+(val||row.id)+'</a>';
+		}},
+		{header:'${text("报废原因")}', name:'reason', index:'a.reason', width:150, align:"left"},
+		{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
+			var actions = [];
+			//<% if(hasPermi('mes:mesProductBfList:edit')){ %>
+				actions.push('<a href="${ctx}/mes/mesProductBfList/form?id='+row.id+'" class="btnList" title="${text("编辑报废原因列表")}"><i class="fa fa-pencil"></i></a>&nbsp;');
+				actions.push('<a href="${ctx}/mes/mesProductBfList/delete?id='+row.id+'" class="btnList" title="${text("删除报废原因列表")}" data-confirm="${text("确认要删除该报废原因列表吗?")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
+			//<% } %>
+			return actions.join('');
+		}}
+	],
+	// 加载成功后执行事件
+	ajaxSuccess: function(data){
+		
+	}
+});
+</script>

+ 100 - 0
src/main/resources/views/modules/mes/mesProductBfrkForm.html

@@ -0,0 +1,100 @@
+<% layout('/layouts/default.html', {title: '工件报废数量表管理', libs: ['validate']}){ %>
+<div class="main-content">
+	<div class="box box-main">
+		<div class="box-header with-border">
+			<div class="box-title">
+				<i class="fa icon-note"></i> ${text(mesProductBfrk.isNewRecord ? '新增工件报废数量表' : '编辑工件报废数量表')}
+			</div>
+			<div class="box-tools pull-right">
+				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
+			</div>
+		</div>
+		<#form:form id="inputForm" model="${mesProductBfrk}" action="${ctx}/mes/mesProductBfrk/save" method="post" class="form-horizontal">
+			<div class="box-body">
+				<div class="form-unit">${text('基本信息')}</div>
+				<#form:hidden path="id"/>
+				<div class="row">
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
+								<span class="required hide">*</span> ${text('成品入库数量')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<#form:input path="cpQty" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
+								<span class="required hide">*</span> ${text('生产订单号')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<#form:input path="orderId" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
+								<span class="required hide">*</span> ${text('成品报废数量')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<#form:input path="cpBfQty" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
+								<span class="required hide">*</span> ${text('成品码')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<#form:input path="cpCode" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
+								<span class="required hide">*</span> ${text('半成品入库数量')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<#form:input path="bcpQty" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
+								<span class="required hide">*</span> ${text('半成品报废数量')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<#form:input path="bcpBfQty" maxlength="64" class="form-control"/>
+							</div>
+						</div>
+					</div>
+				</div>
+			</div>
+			<div class="box-footer">
+				<div class="row">
+					<div class="col-sm-offset-2 col-sm-10">
+						<% if (hasPermi('mes:mesProductBfrk:edit')){ %>
+							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
+						<% } %>
+						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
+					</div>
+				</div>
+			</div>
+		</#form:form>
+	</div>
+</div>
+<% } %>
+<script>
+$("#inputForm").validate({
+	submitHandler: function(form){
+		js.ajaxSubmitForm($(form), function(data){
+			js.showMessage(data.message);
+			if(data.result == Global.TRUE){
+				js.closeCurrentTabPage(function(contentWindow){
+					contentWindow.page();
+				});
+			}
+		}, "json");
+    }
+});
+</script>

+ 94 - 0
src/main/resources/views/modules/mes/mesProductBfrkList.html

@@ -0,0 +1,94 @@
+<% layout('/layouts/default.html', {title: '工件报废数量表管理', libs: ['dataGrid']}){ %>
+<div class="main-content">
+	<div class="box box-main">
+		<div class="box-header">
+			<div class="box-title">
+				<i class="fa icon-notebook"></i> ${text('工件报废数量表管理')}
+			</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>
+				<% if(hasPermi('mes:mesProductBfrk:edit')){ %>
+					<a href="${ctx}/mes/mesProductBfrk/form" class="btn btn-default btnTool" title="${text('新增工件报废数量表')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
+				<% } %>
+				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
+			</div>
+		</div>
+		<div class="box-body">
+			<#form:form id="searchForm" model="${mesProductBfrk}" action="${ctx}/mes/mesProductBfrk/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>
+					<div class="control-inline">
+						<#form:input path="cpQty" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<label class="control-label">${text('生产订单号')}:</label>
+					<div class="control-inline">
+						<#form:input path="orderId" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<label class="control-label">${text('成品报废数量')}:</label>
+					<div class="control-inline">
+						<#form:input path="cpBfQty" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<label class="control-label">${text('成品码')}:</label>
+					<div class="control-inline">
+						<#form:input path="cpCode" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<label class="control-label">${text('半成品入库数量')}:</label>
+					<div class="control-inline">
+						<#form:input path="bcpQty" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<label class="control-label">${text('半成品报废数量')}:</label>
+					<div class="control-inline">
+						<#form:input path="bcpBfQty" maxlength="64" class="form-control width-120"/>
+					</div>
+				</div>
+				<div class="form-group">
+					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
+					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
+				</div>
+			</#form:form>
+			<table id="dataGrid"></table>
+			<div id="dataGridPage"></div>
+		</div>
+	</div>
+</div>
+<% } %>
+<script>
+// 初始化DataGrid对象
+$('#dataGrid').dataGrid({
+	searchForm: $("#searchForm"),
+	columnModel: [
+		{header:'${text("成品入库数量")}', name:'cpQty', index:'a.cp_qty', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
+			return '<a href="${ctx}/mes/mesProductBfrk/form?id='+row.id+'" class="btnList" data-title="${text("编辑工件报废数量表")}">'+(val||row.id)+'</a>';
+		}},
+		{header:'${text("生产订单号")}', name:'orderId', index:'a.order_id', width:150, align:"left"},
+		{header:'${text("成品报废数量")}', name:'cpBfQty', index:'a.cp_bf_qty', width:150, align:"left"},
+		{header:'${text("成品码")}', name:'cpCode', index:'a.cp_code', width:150, align:"left"},
+		{header:'${text("半成品入库数量")}', name:'bcpQty', index:'a.bcp_qty', width:150, align:"left"},
+		{header:'${text("半成品报废数量")}', name:'bcpBfQty', index:'a.bcp_bf_qty', width:150, align:"left"},
+		{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:150, align:"center"},
+		{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
+			var actions = [];
+			//<% if(hasPermi('mes:mesProductBfrk:edit')){ %>
+				actions.push('<a href="${ctx}/mes/mesProductBfrk/form?id='+row.id+'" class="btnList" title="${text("编辑工件报废数量表")}"><i class="fa fa-pencil"></i></a>&nbsp;');
+				actions.push('<a href="${ctx}/mes/mesProductBfrk/delete?id='+row.id+'" class="btnList" title="${text("删除工件报废数量表")}" data-confirm="${text("确认要删除该工件报废数量表吗?")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
+			//<% } %>
+			return actions.join('');
+		}}
+	],
+	// 加载成功后执行事件
+	ajaxSuccess: function(data){
+		
+	}
+});
+</script>

+ 2 - 2
src/main/resources/views/modules/mes/mesScrapDetail.html

@@ -34,8 +34,8 @@
 					<td>${mesScrap.reason}</td>
 				</tr>
 				<tr>
-					<th class="mpc-header">产品类型</th>
-					<td>${mesScrap.productCate}</td>
+					<th class="mpc-header">报废类型</th>
+					<td>${mesScrap.productCate == '1' ? '压铸车间' : (mesScrap.productCate == '2' ? '精加工' : (mesScrap.productCate == '3' ? '装配全检包装' : mesScrap.productCate))}</td>
 				</tr>
 				<tr>
 					<th class="mpc-header">创建时间</th>

+ 4 - 1
src/main/resources/views/modules/mes/mesScrapList.html

@@ -50,7 +50,10 @@ $('#dataGrid').dataGrid({
 			//
 			return val||row.id;
 		}},
-		{header:'${text("报废类型")}', name:'productCate', index:'a.product_cate', width:150, align:"center"},
+		{header:'${text("报废类型")}', name:'productCate', index:'a.product_cate', width:150, align:"center", formatter: function(val){
+			var map = {'1':'压铸车间','2':'精加工','3':'装配全检包装'};
+			return map[val] || val || '';
+		}},
 		{header:'${text("报废原因")}', name:'reason', index:'a.reason', width:150, align:"center"},
 		{header:'${text("操作人")}', name:'createBy', index:'a.create_by', width:150, align:"center"},
 		{header:'${text("日期")}', name:'updateDate', index:'a.update_date', width:150, align:"center"},