package com.cim.idm.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cim.idm.model.po.MaterialReceiveRequest;
import com.cim.idm.utils.AjaxResult;
import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPacking;
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;

import com.cim.idm.service.ChargeSplitService;

import java.util.List;

/**
 * PC成品入库和批次拆分
 * @author ZXYGY17
 *
 */
@RestController
@RequestMapping("/api/SplitCharge")
@EnableAutoConfiguration
public class ChargeSplitController {
	
	@Autowired
	private ChargeSplitService ChargeSplitService;


	@RequestMapping(value = "/SplitCharge", method = RequestMethod.POST)
	public AjaxResult SplitCharge(@RequestBody JSONObject in ) throws Exception  {
	MaterialReceiveRequest sl = JSON.toJavaObject(in, MaterialReceiveRequest.class);
	String user = sl.getUser();
	List<MaterialPacking> boxList = sl.getBoxList();
		
		boolean moveTransformOut = ChargeSplitService.ChargeSplit(boxList, user);
		if (moveTransformOut != true) {
			throw new RuntimeException("NC返回"  + "过账数据为空");
		} else {
			return AjaxResult.me().setSuccess(true).setResultObj(null);
		}
	}
}
