SRMController.java 2.52 KB
package com.huaheng.api.srm.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import com.huaheng.api.srm.domain.ICSOrder;
import com.huaheng.api.srm.domain.SRMResult;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.srm.domain.ICSASN;
import com.huaheng.pc.srm.domain.ICSASNDetail;
import com.huaheng.pc.srm.domain.ICSITEMLot;
import com.huaheng.pc.srm.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;


@Controller
@RequestMapping("/api/srm")
public class SRMController {

    public static final Logger logger = LoggerFactory.getLogger(SRMController.class);

    @Resource
    private ICSASNService icsasnService;
    @Resource
    private ICSASNDetailService icsasnDetailService;
    @Resource
    private ICSITEMLotService icsitemLotService;
    @Resource
    private SrmHeaderService srmHeaderService;
    @Resource
    private FinishedProductService finishedProductService;


    /**
     *  送货单接收接口
     * @param map
     * @return
     */
    @PostMapping("/pushICSASNList")
    @ResponseBody
    public SRMResult pushICSASNList(@RequestBody HashMap<String,Object> map) {
        ICSASN icsasn = JSONObject.parseObject(JSON.toJSONString(map.get("icsasn")),ICSASN.class);
        List<ICSASNDetail> icsasnDetails= JSONObject.parseArray(JSON.toJSONString(map.get("icsasnDetails")),ICSASNDetail.class);
        ICSOrder icsOrder = new ICSOrder();
        icsOrder.setIcsasn(icsasn);
        icsOrder.setIcsasnDetailList(icsasnDetails);
        String json = JSON.toJSONString(icsOrder);
        logger.info("获取送货单:{}",json);
        return icsasnService.saveASNAndDetail(icsOrder);
    }


    /**
     *  物料条码
     *
     * @param
     * @return
     */
    @PostMapping("/pushICSITEMLot")
    @ResponseBody
    public SRMResult pushICSITEMLot(@RequestBody String icsitemLotListMessage) {
        List<ICSITEMLot> icsitemLotList = JSON.parseArray(icsitemLotListMessage, ICSITEMLot.class);
        String json = JSON.toJSONString(icsitemLotList);
        logger.info("获取物料条码:{}",json);
        return icsitemLotService.saveICSItemLotList(icsitemLotList);
    }


}