yangbin
2025-04-16 ddc0f14384619b9618f26a3f363f679833a68b3d
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
57
58
59
package org.jeecg.modules.msi.webapi.controller;
 
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.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 = "自动化线数据接收")
    @PostMapping(value = "/receiveAutomation")
    public Result<?> receiveSaveMsiWebApiJson(String data) {
        MsiWebapiJsonEntity entity = new MsiWebapiJsonEntity();
        if (StringUtils.isBlank(data)) {
            return Result.error("数据为空","");
        }
        entity.setModuleType("MDC");
        entity.setWebapiInfo(data);
        //后续进行其他业务关联
        JsonMapper mapper = new JsonMapper();
        try {
            List<MachineEquipentInfo> machineInfoList = mapper.fromJson(data, new TypeReference<List<MachineEquipentInfo>>(){});
            for (MachineEquipentInfo machineInfo : machineInfoList) {
 
                System.out.println(machineInfo);
                // Add additional processing logic here for each item
            }
        } catch (IOException e) {
            log.error("JSON parsing error: {}", e.getMessage());
            return Result.error("数据异常", e.getMessage());
 
        }
 
        service.save(entity);
        return Result.OK("接收成功");
    }
 
}