| | |
| | | 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 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.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; |
| | | |
| | |
| | | @RequestMapping("/msi/webapi") |
| | | public class MsiWebapiJsonController extends JeecgController<MsiWebapiJsonEntity, IMsiWebapiJsonService> { |
| | | |
| | | |
| | | |
| | | @AutoLog(value = "自动化线数据接收") |
| | | @ApiOperation(value = "自动化线数据接收 ", notes = "自动化线数据接收") |
| | | @PostMapping(value = "/receiveAutomation") |
| | | public void receiveSaveMsiWebApiJson(String data) { |
| | | @RequestMapping(value = "/receiveAutomation") |
| | | public Result<?> receiveSaveMsiWebApiJson(@RequestBody List<MachineEquipentInfo> data) { |
| | | MsiWebapiJsonEntity entity = new MsiWebapiJsonEntity(); |
| | | if (StringUtils.isBlank(data)) { |
| | | return; |
| | | if (StringUtils.isBlank(data.toString())) { |
| | | return Result.error("数据为空",""); |
| | | } |
| | | entity.setModuleType("MDC"); |
| | | entity.setWebapiInfo(data); |
| | | entity.setWebapiInfo(data.toString()); |
| | | //后续进行其他业务关联 |
| | | 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) { |
| | | service.saveTableAutomationOne(data); |
| | | } catch (Exception e) { |
| | | log.error("JSON parsing error: {}", e.getMessage()); |
| | | throw new RuntimeException("Invalid data format", e); |
| | | return Result.error("数据异常", e.getMessage()); |
| | | } |
| | | |
| | | service.save(entity); |
| | | return Result.OK("接收成功"); |
| | | } |
| | | |
| | | } |