package com.cim.idm.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cim.idm.framework.IDMFrameServiceProxy;
import com.cim.idm.model.BarcodeListByInvoice;
import com.cim.idm.model.MoveTransformDetailDto;
import com.cim.idm.model.MoveTransformDto;
import com.cim.idm.response.BaseResponse;
import com.cim.idm.response.RespGenerator;
import com.cim.idm.service.MoveTransformService;
import com.cim.idm.utils.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("形态转换接口")
@RestController
@RequestMapping("/MoveTransform")
@Slf4j
@EnableAutoConfiguration
public class MoveTransformController {

	@Autowired
	private MoveTransformService moveTransformService;


	@RequestMapping(value = "/AssignOrDessign", method = RequestMethod.POST)
	public BaseResponse<Object> AssignOrDessign(HttpServletRequest request,
											  HttpServletResponse response,
											  @ApiParam(value = "形态转换提交参数", required = true)
											  @RequestBody BarcodeListByInvoice barcodeListByInvoice){
		log.info("MoveTransformController AssignOrDessign {}", barcodeListByInvoice);

        try {
            moveTransformService.AssignOrDessign(barcodeListByInvoice);
			return RespGenerator.returnOK(null);
        } catch (Exception e) {
			e.printStackTrace();
			return RespGenerator.returnError(e.toString());
        }

	}




	 
	@RequestMapping(value = "/MoveTransform", method = RequestMethod.POST)
	public BaseResponse<Object> MoveTransform(HttpServletRequest request,
											  HttpServletResponse response,
											  @ApiParam(value = "形态转换提交参数", required = true)
												  @RequestBody BarcodeListByInvoice barcodeListByInvoice){
		log.info("MoveTransformController MoveTransform {}", barcodeListByInvoice);
        try {
            moveTransformService.MoveTransform(barcodeListByInvoice);
			return RespGenerator.returnOK(null);
        } catch (Exception e) {
			e.printStackTrace();
			return RespGenerator.returnError(e.toString());
        }
	}
}
