|
|
@@ -8,14 +8,24 @@ import com.onemap.api.service.ZhxzService;
|
|
|
import com.onemap.common.core.constant.SecurityConstants;
|
|
|
import com.onemap.common.core.domain.R;
|
|
|
import com.onemap.common.core.utils.StringUtils;
|
|
|
+import com.onemap.common.core.web.domain.AjaxResult;
|
|
|
import com.onemap.common.core.web.domain.RequestResult;
|
|
|
+import com.onemap.common.core.web.domain.WebResult;
|
|
|
import com.onemap.common.security.service.TokenService;
|
|
|
+import com.onemap.system.api.RemoteAnalyseService;
|
|
|
import com.onemap.system.api.RemoteUserService;
|
|
|
+import com.onemap.system.api.RemoteFileService;
|
|
|
+import com.onemap.system.api.domain.FzssChscXmgxDTO;
|
|
|
+import com.onemap.system.api.domain.FzxzChscDTO;
|
|
|
import com.onemap.system.api.model.LoginUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@@ -27,22 +37,26 @@ public class ZhxzServiceImpl implements ZhxzService {
|
|
|
@Autowired
|
|
|
private RemoteUserService remoteUserService;
|
|
|
@Autowired
|
|
|
+ private RemoteFileService remoteFileService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteAnalyseService remoteAnalyseService;
|
|
|
+ @Autowired
|
|
|
private TokenService tokenService;
|
|
|
|
|
|
@Override
|
|
|
- public RequestResult authorize(AuthorizeDto authorizeDto, HttpServletRequest request) {
|
|
|
+ public AjaxResult authorize(AuthorizeDto authorizeDto, HttpServletRequest request) {
|
|
|
String appid = authorizeDto.getAppid();
|
|
|
String ip = request.getHeader("X-Forwarded-For");
|
|
|
if (StringUtils.isEmpty(appid)) {
|
|
|
- return RequestResult.error("APPID不能为空!");
|
|
|
+ return changeResponse(RequestResult.error("APPID不能为空!"));
|
|
|
}
|
|
|
QueryWrapper<TSysOpenUser> wrapper = new QueryWrapper();
|
|
|
wrapper.eq("appid", appid);
|
|
|
TSysOpenUser dto = tSysOpenUserMapper.selectOne(wrapper);
|
|
|
if (dto == null) {
|
|
|
- return RequestResult.error("应用不存在,请检查并重新输入!");
|
|
|
+ return changeResponse(RequestResult.error("应用不存在,请检查并重新输入!"));
|
|
|
} else if (dto.getState() == 0) {
|
|
|
- return RequestResult.error("当前应用已禁用,请联系管理员!");
|
|
|
+ return changeResponse(RequestResult.error("当前应用已禁用,请联系管理员!"));
|
|
|
}
|
|
|
// else if (!ip.equals(dto.getIp())) {//TODO wanger 需不需要校验访问的IP地址
|
|
|
// return RequestResult.error("非法登录!");
|
|
|
@@ -53,6 +67,83 @@ public class ZhxzServiceImpl implements ZhxzService {
|
|
|
R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
|
|
LoginUser userInfo = userResult.getData();
|
|
|
Map<String, Object> token = tokenService.createToken(userInfo);
|
|
|
- return RequestResult.success(token);
|
|
|
+ return changeResponse(RequestResult.success(token));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult upload(MultipartFile file) {
|
|
|
+ RequestResult res = remoteFileService.uploadZhxzZip(file);
|
|
|
+ return changeResponse(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult createxm(FzxzChscDTO fzxzChscDTO) {
|
|
|
+ WebResult res = remoteAnalyseService.create(fzxzChscDTO);
|
|
|
+ return changeResponse2(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult getjd(String bsm, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ WebResult res = remoteAnalyseService.getProgress(bsm);
|
|
|
+ return changeResponse2(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult downbg(String bsm, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ ResponseEntity<byte[]> data = remoteAnalyseService.download(bsm, response);
|
|
|
+ try {
|
|
|
+ response.getOutputStream().write(data.getBody());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ WebResult res = new WebResult();
|
|
|
+ res.put("code", 200);
|
|
|
+ return changeResponse2(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult xmjg(FzssChscXmgxDTO fzssChscXmgxDTO) {
|
|
|
+ WebResult res = remoteAnalyseService.xmjg(fzssChscXmgxDTO);
|
|
|
+ return changeResponse2(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult txt2shp(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ ResponseEntity<byte[]> data = remoteAnalyseService.txt2shp(file, response);
|
|
|
+ try {
|
|
|
+ response.getOutputStream().write(data.getBody());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ WebResult res = new WebResult();
|
|
|
+ res.put("code", 200);
|
|
|
+ return changeResponse2(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ public AjaxResult changeResponse(RequestResult res) {
|
|
|
+ AjaxResult ajax = null;
|
|
|
+ if (res.isSuccess()) {
|
|
|
+ ajax = AjaxResult.success(String.valueOf(res.get("message")), res.get("data"));
|
|
|
+ ajax.put("statuscode", 200);
|
|
|
+ } else {
|
|
|
+ ajax = AjaxResult.error(String.valueOf(res.get("message")), res.get("data"));
|
|
|
+ ajax.put("statuscode", ajax.get("code"));
|
|
|
+ }
|
|
|
+ ajax.put("message", res.get("message"));
|
|
|
+ ajax.put("success", res.isSuccess());
|
|
|
+ return ajax;
|
|
|
+ }
|
|
|
+
|
|
|
+ public AjaxResult changeResponse2(WebResult res) {
|
|
|
+ AjaxResult ajax = null;
|
|
|
+ if (res.isSuccess()) {
|
|
|
+ ajax = AjaxResult.success(String.valueOf(res.get("message")), res.get("data"));
|
|
|
+ ajax.put("statuscode", 200);
|
|
|
+ } else {
|
|
|
+ ajax = AjaxResult.error(String.valueOf(res.get("message")), res.get("data"));
|
|
|
+ ajax.put("statuscode", ajax.get("code"));
|
|
|
+ }
|
|
|
+ ajax.put("message", res.get("message"));
|
|
|
+ return ajax;
|
|
|
}
|
|
|
}
|