69 lines
2.1 KiB
Java
Raw Normal View History

2025-03-10 13:46:51 +08:00
package com.cim.idm.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cim.idm.model.MaterialUndoDto;
import com.cim.idm.service.Impl.MaterialUndoServiceImpl;
import com.cim.idm.utils.AjaxResult;
import com.cim.idm.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
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;
/**
* 物料冲销控制器
* @author ZXYGY17
*
*/
@RestController
@RequestMapping("/api/MaterialUndo")
@EnableAutoConfiguration
public class MaterialUndoController {
CommonUtils untils=new CommonUtils();
@Autowired
private MaterialUndoServiceImpl materialUndoServiceImpl;
@RequestMapping(value = "/commitUndo", method = RequestMethod.POST)
public AjaxResult commitUndo(@RequestBody JSONObject in ) {
MaterialUndoDto undoDto = JSON.toJavaObject(in, MaterialUndoDto.class);
String undoId = undoDto.getUndoId();
String userId = undoDto.getUserId();
String flag = undoDto.getFlag();
String inv_TYPE = undoDto.getINV_TYPE();
//根据物料凭证校验物料状态是否一致
try {
Boolean checkUndoCondition = untils.CheckUndoCondition(undoId);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.me().setSuccess(false).setMessage(e.toString());
}
//校验单据类型,根据单据类型判断逻辑
switch (inv_TYPE) {
case "45":
materialUndoServiceImpl.rkUndo(undoId, userId);
break;
case "46":
materialUndoServiceImpl.cprkUndo(undoId, userId);
break;
case "4C":
materialUndoServiceImpl.ckUndo(undoId, userId);
case "4Y" :
materialUndoServiceImpl.ckUndo(undoId, userId);
case "4I" :
materialUndoServiceImpl.ckUndo(undoId, userId);
break;
default :
return AjaxResult.me().setSuccess(false).setMessage("单据类型不支持冲销");
}
return AjaxResult.me().setSuccess(true).setMessage("冲销成功");
}
}