sunxianglong 3 hete
szülő
commit
60ed761a03

+ 2 - 1
src/main/java/com/jeesite/modules/mes/entity/MesScrap.java

@@ -4,6 +4,7 @@ import com.jeesite.common.collect.ListUtils;
 import com.jeesite.common.entity.DataEntity;
 import com.jeesite.common.mybatis.annotation.Column;
 import com.jeesite.common.mybatis.annotation.Table;
+import com.jeesite.common.mybatis.mapper.query.QueryType;
 import com.jeesite.common.utils.excel.annotation.ExcelField;
 import com.jeesite.common.utils.excel.annotation.ExcelFields;
 
@@ -17,7 +18,7 @@ import java.util.List;
  */
 @Table(name="mes_scrap", alias="a", label="报废记录信息", columns={
 		@Column(name="id", attrName="id", label="id", isPK=true),
-		@Column(name="sn", attrName="sn", label="工件码"),
+		@Column(name="sn", attrName="sn", label="工件码", queryType=QueryType.LIKE),
 		@Column(name="reason2", attrName="reason2", label="报废原因"),
 		@Column(name="reason", attrName="reason", label="报废原因备注"),
 		@Column(name="product_cate", attrName="productCate", label="报废类型"),

+ 35 - 4
src/main/java/com/jeesite/modules/mes/web/MesProductSaleController.java

@@ -1,5 +1,7 @@
 package com.jeesite.modules.mes.web;
 
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -8,10 +10,10 @@ 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.util.StreamUtils;
 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.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
@@ -163,20 +165,23 @@ public class MesProductSaleController extends BaseController {
 	 */
 	@RequestMapping(value = "listByShState")
 	@ResponseBody
-	public List<MesProductSale> listByShState() {
+	public String listByShState() {
 		MesProductSale query = new MesProductSale();
 		query.setShState("1");
-		return mesProductSaleService.findList(query);
+		List<MesProductSale> list = mesProductSaleService.findList(query);
+		return renderResult(Global.TRUE, text("查询成功!"), list);
 	}
 
 	/**
 	 * 回写ERP销售出货行(UpdateShipLine)
 	 * 入参示例:
 	 * {"OtherID":"","ID":0,"DocNo":"100SM2607310002","DocLineNo":"10","PrivateDescSeg1":"mes已完成扫码出库"}
+	 * 同时支持 application/json 与 application/x-www-form-urlencoded
 	 */
 	@PostMapping(value = "updateShipLine")
 	@ResponseBody
-	public String updateShipLine(@RequestBody JSONObject body) {
+	public String updateShipLine(HttpServletRequest request) {
+		JSONObject body = parseShipLineBody(request);
 		if (body == null) {
 			return renderResult(Global.FALSE, text("参数不能为空!"));
 		}
@@ -220,4 +225,30 @@ public class MesProductSaleController extends BaseController {
 		return renderResult(Global.TRUE, text("同步ERP成功!"));
 	}
 
+	private JSONObject parseShipLineBody(HttpServletRequest request) {
+		String contentType = StringUtils.defaultString(request.getContentType()).toLowerCase();
+		if (contentType.contains("application/json")) {
+			try {
+				String raw = StreamUtils.copyToString(request.getInputStream(), StandardCharsets.UTF_8);
+				if (StringUtils.isBlank(raw)) {
+					return null;
+				}
+				return JSONObject.parseObject(raw);
+			} catch (IOException e) {
+				logger.warn("解析updateShipLine JSON失败", e);
+				return null;
+			}
+		}
+		JSONObject body = new JSONObject(true);
+		body.put("OtherID", request.getParameter("OtherID"));
+		body.put("ID", request.getParameter("ID"));
+		body.put("DocNo", request.getParameter("DocNo"));
+		body.put("DocLineNo", request.getParameter("DocLineNo"));
+		body.put("PrivateDescSeg1", request.getParameter("PrivateDescSeg1"));
+		if (StringUtils.isBlank(body.getString("DocNo")) && StringUtils.isBlank(body.getString("DocLineNo"))) {
+			return null;
+		}
+		return body;
+	}
+
 }