93 lines
3.7 KiB
Java

package com.cim.idm.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cim.idm.service.Impl.MaterialUndoServiceImpl;
import com.cim.idm.service.MESToWMSService;
import com.cim.idm.service.Impl.MESToWMSServiceImpl;
import com.cim.idm.util.MessageLogUtil;
import com.cim.idm.utils.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Api("接收MES请求接口")
@RestController
@RequestMapping("/api/wms")
@Slf4j
public class MESToWMSController {
@Autowired
private MESToWMSServiceImpl mesToWMSService;
/**
* 转工单接口
*/
@ApiOperation(value = "物料转工单请求")
@RequestMapping(value = "/meswms_workorder_request", method = RequestMethod.POST)
public AjaxResult workOrder_Request(@RequestBody JSONArray in) {
log.info("Received work order request: {}", in.toJSONString());
try {
return mesToWMSService.workOrder_Request(in);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation(value = "物料消耗请求")
@RequestMapping(value = "/meswms_materialconsume_request", method = RequestMethod.POST)
public AjaxResult materialConsume_Request(@RequestBody JSONArray in) {
log.info("Received material consume request: {}", in.toJSONString());
try {
return mesToWMSService.materialConsume_Request(in);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation(value = "二次确认物料出库请求")
@RequestMapping(value = "/meswms_materialout_request", method = RequestMethod.POST)
public AjaxResult materialOutByMES(@RequestBody JSONArray in) {
log.info("Received material out request: {}", in.toJSONString());
try {
return mesToWMSService.materialOutByMES(in);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation(value = "物料冲销接口请求")
@RequestMapping(value = "/meswms_cancelship_request", method = RequestMethod.POST)
public AjaxResult cancelShipByMES(@RequestBody JSONArray in) {
log.info("Received cancel ship request: {}", in.toJSONString());
String undoId = in.getJSONObject(0).getString("undoId");
String userId = in.getJSONObject(0).getString("userId");
String payMentDate = in.getJSONObject(0).get("payMentDate") == null ? "" : in.getJSONObject(0).get("payMentDate").toString(); //过账日期
if (StringUtils.isBlank(payMentDate)) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).setMessage("payMentDate过账日期不能为空");
}
// return mesToWMSService.cancelShipByMES(in);
try {
return mesToWMSService.sapcprkUndo(undoId, userId, payMentDate);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation(value = "物料入库请求")
@RequestMapping(value = "/meswms_ship_request", method = RequestMethod.POST)
public AjaxResult shipByMES(@RequestBody JSONArray in) {
log.info("Received ship request: {}", in.toJSONString());
try {
return mesToWMSService.shipByMES(in);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}