|
@@ -0,0 +1,141 @@
|
|
|
+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.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 RemoteEventBaseService remoteEventBaseService;
|
|
|
+ @Resource
|
|
|
+ private RemoteConfigService remoteConfigService;
|
|
|
+ // @Value("${}")
|
|
|
+ private String url;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重点工程
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/pushEngineeringData")
|
|
|
+ @ResponseBody
|
|
|
+ public R<?> pushEngineeringData(@RequestBody CenterdataTKeyProjects centerdataTKeyProjects) {
|
|
|
+ log.info("dataExchangeEntity:{}",centerdataTKeyProjects);
|
|
|
+ if (StringUtils.isNotEmpty(SecurityUtils.getToken())) {
|
|
|
+ R<?> result = remoteEventBaseService.projects(centerdataTKeyProjects);
|
|
|
+ if (result.getCode() == 200) {
|
|
|
+ return R.ok("推送成功");
|
|
|
+ } else {
|
|
|
+ return R.fail(result.getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return R.fail("推送失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/receiveEngineeringData")
|
|
|
+ @ResponseBody
|
|
|
+ public R<?> receiveEngineeringData(@RequestBody CenterdataTKeyProjectsPictures centerdataTKeyProjectsPictures) {
|
|
|
+ System.out.println(centerdataTKeyProjectsPictures);
|
|
|
+ R<String> appUrl = remoteConfigService.remotegetConfigKey("appUrl");
|
|
|
+ List<String> pictureList = new ArrayList<>();
|
|
|
+ for (String picture : centerdataTKeyProjectsPictures.getSchedulePictures()) {
|
|
|
+ pictureList.add(appUrl.getData().toString() + picture);
|
|
|
+ }
|
|
|
+ centerdataTKeyProjectsPictures.setSchedulePictures(pictureList);
|
|
|
+ // TODO: 2024/1/16 0016 待修改
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("", centerdataTKeyProjectsPictures);
|
|
|
+ try {
|
|
|
+ RestUtil.post(url, jsonObject);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("重点工程报错");
|
|
|
+ }
|
|
|
+ return R.ok("接收成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重点区域
|
|
|
+ * @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 = remoteEventBaseService.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("接收成功");
|
|
|
+ }
|
|
|
+}
|