123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- package com.sooka.sponest.dataexchange.sendChange.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.ruoyi.common.core.domain.R;
- import com.ruoyi.common.core.utils.file.FilePrefixUtils;
- import com.ruoyi.common.security.utils.SecurityUtils;
- import com.ruoyi.system.api.RemoteConfigService;
- import com.ruoyi.system.api.RemoteFileService;
- import com.ruoyi.system.api.domain.SysFile;
- import com.sooka.sponest.dataexchange.exchange.domian.DataExchangeEntity;
- import com.sooka.sponest.dataexchange.remoteapi.service.center.data.RemoteDataBaseService;
- import com.sooka.sponest.dataexchange.remoteapi.service.center.event.RemoteEventBaseService;
- import com.sooka.sponest.dataexchange.sendChange.domian.CenterdataTKeyProjects;
- import com.sooka.sponest.dataexchange.sendChange.domian.CenterdataTKeyProjectsPictures;
- import com.sooka.sponest.dataexchange.util.RestUtil;
- import com.sooka.sponest.dataexchange.util.spring.SpringUtils;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.stereotype.Controller;
- import org.springframework.util.CollectionUtils;
- 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.ResponseBody;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.Resource;
- import java.util.ArrayList;
- import java.util.List;
- @Slf4j
- @Controller
- @RequestMapping("/sendChange")
- public class EngineeringController {
- @Resource
- private RemoteDataBaseService remoteDataBaseService;
- @Resource
- private RemoteConfigService remoteConfigService;
- // @Value("${}")
- private String url;
- /**
- * 重点工程
- * @param
- * @return
- */
- @PostMapping("/pushEngineeringData")
- @ResponseBody
- public R<?> pushEngineeringData(@RequestBody List<CenterdataTKeyProjects> list) {
- log.info("centerdataTKeyProjects:{}",list);
- if (StringUtils.isNotEmpty(SecurityUtils.getToken())) {
- log.info("SecurityUtils.getToken():{}",SecurityUtils.getToken());
- R<?> result = remoteDataBaseService.receivedMessage(list);
- if (result.getCode() == 200) {
- return R.ok("成功");
- } else {
- return R.fail(result.getCode(),result.getMsg());
- }
- } else {
- return R.fail(5005,"Token过期,请重新获取!");
- }
- }
- @PostMapping("/receiveEngineeringData")
- @ResponseBody
- public R<?> receiveEngineeringData(@RequestBody List<CenterdataTKeyProjectsPictures> list) {
- log.info("List<CenterdataTKeyProjectsPictures>:{}",list);
- R<String> appUrl = remoteConfigService.remotegetConfigKey("appUrl");
- List<CenterdataTKeyProjectsPictures> requestList = new ArrayList<>();
- for (CenterdataTKeyProjectsPictures var : list) {
- List<String> pictureList = new ArrayList<>();
- CenterdataTKeyProjectsPictures centerdataTKeyProjectsPictures = new CenterdataTKeyProjectsPictures();
- centerdataTKeyProjectsPictures.setProjectId(var.getProjectId());
- for (String str : var.getSchedulePictures()) {
- pictureList.add(appUrl.getData() + str);
- }
- centerdataTKeyProjectsPictures.setSchedulePictures(pictureList);
- requestList.add(var);
- }
- // TODO: 2024/1/16 0016 待修改
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("", requestList);
- try {
- RestUtil.post(url, jsonObject);
- } catch (Exception e) {
- log.info("重点工程报错");
- }
- return R.ok(null,"接收成功");
- }
- /**
- * 重点区域
- * @param
- * @return
- */
- // @PostMapping("/pushAreaData")
- // @ResponseBody
- // public R<?> pushAreaData(@RequestBody DataExchangeEntity dataExchangeEntity) {
- // log.info("dataExchangeEntity:{}",dataExchangeEntity);
- // List<String> pictureList = new ArrayList<>();
- // if (StringUtils.isNotEmpty(SecurityUtils.getToken()) && !CollectionUtils.isEmpty(dataExchangeEntity.getEventPicture())) {
- // for (String picture : dataExchangeEntity.getEventPicture()) {
- // if (!"image".equals(FilePrefixUtils.getUrlSuffix(picture))) {
- // log.error("事件图片必须为图片格式---{}", dataExchangeEntity);
- // return R.fail("事件图片必须为图片格式");
- // } else {
- // MultipartFile multipartFile = FilePrefixUtils.urlToMultipartFile(picture, System.currentTimeMillis() + ".jpg");
- // SysFile sysFile = SpringUtils.getBean(RemoteFileService.class).upload(multipartFile).getData();
- // pictureList.add(sysFile.getUrl());
- // }
- // }
- // dataExchangeEntity.setPictureUrlList(pictureList);
- // R<?> result = remoteDataBaseService.insert3rdSystemEvent(dataExchangeEntity);
- // if (result.getCode() == 200) {
- // return R.ok("推送成功");
- // } else {
- // return R.fail(result.getMsg());
- // }
- // } else {
- // return R.fail("推送失败");
- // }
- // }
- //
- //
- // @PostMapping("/receiveAreaData")
- // @ResponseBody
- // public R<?> receiveAreaData(@RequestBody DataExchangeEntity dataExchangeEntity) {
- // System.out.println(dataExchangeEntity);
- // R<String> appUrl = remoteConfigService.remotegetConfigKey("appUrl");
- // List<String> pictureList = new ArrayList<>();
- // for (String picture : dataExchangeEntity.getEventPicture()) {
- // pictureList.add(appUrl.getData().toString() + picture);
- // }
- // dataExchangeEntity.setEventPicture(pictureList);
- // // TODO: 2024/1/9 0009 待修改
- // JSONObject jsonObject = new JSONObject();
- // jsonObject.put("", dataExchangeEntity);
- // try {
- // RestUtil.post(url, jsonObject);
- // } catch (Exception e) {
- // log.info("远程调用119报错");
- // }
- // return R.ok("接收成功");
- // }
- }
|