|
|
@@ -114,8 +114,9 @@ public class MesProductReportController extends BaseController {
|
|
|
@RequiresPermissions("mes:mesProductReport:edit")
|
|
|
@RequestMapping(value = "mesToErp", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
- public String mesToErp(@RequestBody(required = false) String body, HttpServletRequest request) {
|
|
|
- MesProductReport mesProductReport = resolveMesProductReport(body, request.getParameter("id"));
|
|
|
+ public String mesToErp(@RequestBody(required = false) String body, MesProductReport mesProductReport, HttpServletRequest request) {
|
|
|
+ MesProductReport resolvedReport = resolveMesProductReport(body, mesProductReport, request.getParameter("id"));
|
|
|
+ mesProductReport = resolvedReport;
|
|
|
if (mesProductReport == null) {
|
|
|
return renderResult(Global.FALSE, text("参数错误!"));
|
|
|
}
|
|
|
@@ -197,8 +198,8 @@ public class MesProductReportController extends BaseController {
|
|
|
return DateUtils.formatDate(date, "yyyy-MM-dd");
|
|
|
}
|
|
|
|
|
|
- private MesProductReport resolveMesProductReport(String body, String idParam) {
|
|
|
- if (StringUtils.isNotBlank(body)) {
|
|
|
+ private MesProductReport resolveMesProductReport(String body, MesProductReport formReport, String idParam) {
|
|
|
+ if (isJsonBody(body)) {
|
|
|
try {
|
|
|
return parseMesProductReportBody(body);
|
|
|
} catch (Exception e) {
|
|
|
@@ -206,8 +207,12 @@ public class MesProductReportController extends BaseController {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(idParam)) {
|
|
|
- MesProductReport exist = mesProductReportService.get(new MesProductReport(idParam));
|
|
|
+ if (formReport != null && hasReportFormData(formReport)) {
|
|
|
+ return formReport;
|
|
|
+ }
|
|
|
+ String id = StringUtils.defaultIfBlank(idParam, formReport != null ? formReport.getId() : null);
|
|
|
+ if (StringUtils.isNotBlank(id)) {
|
|
|
+ MesProductReport exist = mesProductReportService.get(new MesProductReport(id));
|
|
|
if (exist != null && !exist.getIsNewRecord()) {
|
|
|
return exist;
|
|
|
}
|
|
|
@@ -215,6 +220,20 @@ public class MesProductReportController extends BaseController {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private boolean isJsonBody(String body) {
|
|
|
+ if (StringUtils.isBlank(body)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String trimmed = body.trim();
|
|
|
+ return trimmed.startsWith("{") || trimmed.startsWith("[");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean hasReportFormData(MesProductReport report) {
|
|
|
+ return StringUtils.isNotBlank(report.getMoDocNo())
|
|
|
+ || StringUtils.isNotBlank(report.getDocTypeCode())
|
|
|
+ || StringUtils.isNotBlank(report.getCompleteQty());
|
|
|
+ }
|
|
|
+
|
|
|
private MesProductReport parseMesProductReportBody(String body) throws ParseException {
|
|
|
String json = body.trim();
|
|
|
if (json.startsWith("\"") && json.endsWith("\"") && json.length() >= 2) {
|