1
yangbin
2025-05-20 d10b270cf7513823556dd80034a93e4657a59cb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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("接收成功");
    }
 
}