zhangherong
2025-06-25 23855599412c4d61b38d78f0f3abd3430a48b5b1
lxzn-module-msi/src/main/java/org/jeecg/modules/msi/webapi/controller/MsiWebapiJsonController.java
对比新文件
@@ -0,0 +1,56 @@
package org.jeecg.modules.msi.webapi.controller;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import liquibase.pro.packaged.S;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.msi.utils.JsonMapper;
import org.jeecg.modules.msi.webapi.entity.MsiWebapiJsonEntity;
import org.jeecg.modules.msi.webapi.service.IMsiWebapiJsonService;
import org.jeecg.modules.msi.webapi.vo.MachineEquipentInfo;
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.RestController;
import java.io.IOException;
import java.util.List;
@Slf4j
@Api(tags = "鑷姩鍖栫嚎鏁版嵁")
@RestController
@RequestMapping("/msi/webapi")
public class MsiWebapiJsonController extends JeecgController<MsiWebapiJsonEntity, IMsiWebapiJsonService> {
    @AutoLog(value = "鑷姩鍖栫嚎鏁版嵁鎺ユ敹")
    @ApiOperation(value = "鑷姩鍖栫嚎鏁版嵁鎺ユ敹 ", notes = "鑷姩鍖栫嚎鏁版嵁鎺ユ敹")
    @RequestMapping(value = "/receiveAutomation")
    public Result<?> receiveSaveMsiWebApiJson(@RequestBody List<MachineEquipentInfo> data) {
        MsiWebapiJsonEntity entity = new MsiWebapiJsonEntity();
        if (StringUtils.isBlank(data.toString())) {
            return Result.error("鏁版嵁涓虹┖","");
        }
        entity.setModuleType("MDC");
        entity.setWebapiInfo(data.toString());
        //鍚庣画杩涜鍏朵粬涓氬姟鍏宠仈
        JsonMapper mapper = new JsonMapper();
        try {
            service.saveTableAutomationOne(data);
        } catch (Exception e) {
            log.error("JSON parsing error: {}", e.getMessage());
            return Result.error("鏁版嵁寮傚父", e.getMessage());
        }
        service.save(entity);
        return Result.OK("鎺ユ敹鎴愬姛");
    }
}