|
@@ -1,5 +1,7 @@
|
|
|
package com.jeesite.modules.mes.web;
|
|
package com.jeesite.modules.mes.web;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
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.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.ui.Model;
|
|
|
|
|
+import org.springframework.util.StreamUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
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.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
@@ -163,20 +165,23 @@ public class MesProductSaleController extends BaseController {
|
|
|
*/
|
|
*/
|
|
|
@RequestMapping(value = "listByShState")
|
|
@RequestMapping(value = "listByShState")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<MesProductSale> listByShState() {
|
|
|
|
|
|
|
+ public String listByShState() {
|
|
|
MesProductSale query = new MesProductSale();
|
|
MesProductSale query = new MesProductSale();
|
|
|
query.setShState("1");
|
|
query.setShState("1");
|
|
|
- return mesProductSaleService.findList(query);
|
|
|
|
|
|
|
+ List<MesProductSale> list = mesProductSaleService.findList(query);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("查询成功!"), list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 回写ERP销售出货行(UpdateShipLine)
|
|
* 回写ERP销售出货行(UpdateShipLine)
|
|
|
* 入参示例:
|
|
* 入参示例:
|
|
|
* {"OtherID":"","ID":0,"DocNo":"100SM2607310002","DocLineNo":"10","PrivateDescSeg1":"mes已完成扫码出库"}
|
|
* {"OtherID":"","ID":0,"DocNo":"100SM2607310002","DocLineNo":"10","PrivateDescSeg1":"mes已完成扫码出库"}
|
|
|
|
|
+ * 同时支持 application/json 与 application/x-www-form-urlencoded
|
|
|
*/
|
|
*/
|
|
|
@PostMapping(value = "updateShipLine")
|
|
@PostMapping(value = "updateShipLine")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public String updateShipLine(@RequestBody JSONObject body) {
|
|
|
|
|
|
|
+ public String updateShipLine(HttpServletRequest request) {
|
|
|
|
|
+ JSONObject body = parseShipLineBody(request);
|
|
|
if (body == null) {
|
|
if (body == null) {
|
|
|
return renderResult(Global.FALSE, text("参数不能为空!"));
|
|
return renderResult(Global.FALSE, text("参数不能为空!"));
|
|
|
}
|
|
}
|
|
@@ -220,4 +225,30 @@ public class MesProductSaleController extends BaseController {
|
|
|
return renderResult(Global.TRUE, text("同步ERP成功!"));
|
|
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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|