AsController.java 3.19 KB
package com.huaheng.api.as.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.huaheng.api.as.service.AsService;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.ApiLogger;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.inventory.asmInventory.domain.AsmInventory;
import com.huaheng.pc.inventory.asmInventory.service.IAsmInventoryService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ASDocumentDetail;
import com.huaheng.pc.shipment.shipmentHeader.domain.ASDocumentHeader;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

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


/**
 * 升降柜系统控制层
 * @author xcq
 */
@RestController
@RequestMapping("/API/AS")
public class AsController extends BaseController {


    @Resource
    private AsService asService;

    @PostMapping("/executionResultFeedback")
    @ApiOperation("执行结果反馈")
    @ApiLogger(apiName = "执行结果反馈", from="AS")
    @Transactional(rollbackFor = Exception.class)
    @ResponseBody
    public AjaxResult executionResultFeedback(@RequestBody Map<String, String> map){
        if (map == null || map.size() == 0){
            return AjaxResult.error("请勿提交空数据!");
        }
        JSONObject jsonObj = JSONObject.parseObject(map.get("DATA"));
        // 判断表头是否存在
        if (jsonObj.containsKey("EXP_ORDINI") && jsonObj.containsKey("EXP_ORDINI_RIGHE")){
            List<ASDocumentHeader> asDocumentHeaderList = JSON.parseArray(jsonObj.getString("EXP_ORDINI"), ASDocumentHeader.class);
            List<ASDocumentDetail> asDocumentDetailList = JSON.parseArray(jsonObj.getString("EXP_ORDINI_RIGHE"), ASDocumentDetail.class);
            return asService.shipmentExecutionResult(asDocumentDetailList);
            //return asService.executionResultFeedbackService(asDocumentDetailList);
        }
        return AjaxResult.error("表头:EXP_ORDINI数据或者详情EXP_ORDINI_RIGHE:数据为空!");
    }

    @Resource
    private IAsmInventoryService iAsmInventoryService;

    @PostMapping("/inventorySync")
    @ApiOperation("库存同步")
    @ApiLogger(apiName = "库存同步", from="AS")
    @Transactional(rollbackFor = Exception.class)
    @ResponseBody
    public AjaxResult inventorySync(@RequestBody Map<String, String> map){
        if (map == null || map.size() == 0){
            return AjaxResult.error("请勿提交空数据!");
        }
        JSONObject jsonObj = JSONObject.parseObject(map.get("DATA"));
        // 判断库存数据是否存在
        if (jsonObj.containsKey("EXP_UBICAZIONI")){
            List<AsmInventory> asmInventoryList = JSON.parseArray(jsonObj.getString("EXP_UBICAZIONI"), AsmInventory.class);
            return iAsmInventoryService.inventorySyncService(asmInventoryList);
        }
        return AjaxResult.error("获取EXP_UBICAZIONI:"+jsonObj+"数据为空值!");
    }
}