Commit 1e83b9cf authored by 周健威's avatar 周健威

Merge remote-tracking branch 'origin/dev' into dev

parents a9eefae3 cfea602b
......@@ -4,7 +4,6 @@
*/
package com.upyuns.platform.rs.gtdata;
import lombok.Data;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
......@@ -470,8 +469,8 @@ public class GtDataRestClient {
* @return
*
*/
public Map<String, Object> mkdirs(String path) {
return mkdirs(path, defaultSign, defaultTime);
public Map<String, Object> mkdirOnly(String path) {
return mkdirOnly(path, defaultSign, defaultTime);
}
/**
......@@ -484,7 +483,7 @@ public class GtDataRestClient {
* @return
*
*/
public Map<String, Object> mkdirs(String path, String sign, String time) {
public Map<String, Object> mkdirOnly(String path, String sign, String time) {
String resourceUrl = MessageFormat.format(
"{0}{1}?op=MKDIRS&sign={2}&time={3}", gtDataUrl, path, sign,
time);
......@@ -496,17 +495,17 @@ public class GtDataRestClient {
*
* @param path
*/
public Map<String, Object> mkdir(String path) {
public Map<String, Object> mkdirs(String path) {
String parentPath = StringUtils.substringBeforeLast(path, "/");
if (logger.isInfoEnabled()) {
logger.info("path:{},parentPath:{},isExist(parentPath):{},", path,parentPath,isExist(parentPath).get("exist"));
}
if ( isExist(parentPath).get("exist").toString().equals("true")) {
return mkdirs(path);
return mkdirOnly(path);
} else {
mkdir(parentPath);
return mkdirs(path);
mkdirs(parentPath);
return mkdirOnly(path);
}
}
......
......@@ -73,6 +73,11 @@ public class AppUserManageDTO {
* 真实姓名
*/
private String realName;
/**
* 状态:0-启用,1-禁用
*/
private Integer status;
// /**
// * 接收前台时间范围
// */
......
......@@ -12,6 +12,7 @@ import com.github.wxiaoqi.security.admin.vo.AppUserVo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.collections.CollectionUtils;
......@@ -37,113 +38,136 @@ import java.util.stream.Collectors;
@Slf4j
public class AppUserManageBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail> {
@Autowired
private AppUserLoginMapper appUserLoginMapper;
@Autowired
private AppUserDetailBiz appUserDetailBiz;
/**
* 根据条件查询
*
* @param appUserManageDTO 查询条件
* @return
*/
public PageInfo<AppUserManageVo> findAllByQuery(AppUserManageDTO appUserManageDTO) {
if (Objects.nonNull(appUserManageDTO.getRegistrationTimeEnd())){
long registerEndTime = appUserManageDTO.getRegistrationTimeEnd()+(24*60*60);
appUserManageDTO.setRegistrationTimeEnd(registerEndTime);
}
PageHelper.startPage(appUserManageDTO.getPage(), appUserManageDTO.getLimit());
List<AppUserManageVo> appUserManageVos = mapper.selectAppUser(appUserManageDTO);
PageInfo<AppUserManageVo> pageInfo = PageInfo.of(appUserManageVos);
if (pageInfo.getList()==null||pageInfo.getList().size()==0) {
return pageInfo;
}
throw new BaseException("User error!");
}
/**
* 禁用账户
* @param id
*/
@Transactional(rollbackFor =Exception.class)
public void deleteAppUser(Integer id,Integer isDel) {
AppUserLogin appUserLogin = new AppUserLogin();
//修改为禁用并设置修改时间
appUserLogin.setIsdel(isDel);
appUserLogin.setUpdatetime(System.currentTimeMillis());
Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
appUserLoginMapper.updateByExampleSelective(appUserLogin, example);
//设置
AppUserDetail appUserDetail = new AppUserDetail();
appUserDetail.setIsdel(isDel);
appUserDetail.setUpdatetime(System.currentTimeMillis());
Example detailExample = new Example(AppUserLogin.class);
Example.Criteria detailCriteria = detailExample.createCriteria();
criteria.andEqualTo("id", id);
mapper.updateByExampleSelective(appUserDetail, detailCriteria);
}
/**
* 查询一条
* @param id
* @return
*/
public AppUserVo findOneById(Integer id) {
return mapper.getUserInfo(id);
}
/**
*保存
* @param appUserVo
*/
@Transactional(rollbackFor =Exception.class)
public void save(AppUserVo appUserVo) {
AppUserLogin appUserLogin = new AppUserLogin();
AppUserDetail appUserDetail = new AppUserDetail();
try {
BeanUtilsBean.getInstance().copyProperties(appUserLogin, appUserVo);
BeanUtilsBean.getInstance().copyProperties(appUserDetail, appUserVo);
if (appUserVo.getUserid() == null || appUserVo.getUserid() == 0) {
//设置登录用户信息
appUserLogin.setIsdel(0);
appUserLogin.setCreatetime(System.currentTimeMillis());
appUserLogin.setCertificationStatus(0);
appUserLogin.setStatus(0);
//设置用户详情
appUserDetail.setIsdel(0);
if (appUserDetail.getIsMember() == null) {
appUserDetail.setIsMember(0);
}
appUserLoginMapper.insertSelective(appUserLogin);
mapper.insertSelective(appUserDetail);
} else {
appUserLogin.setUpdatetime(System.currentTimeMillis());
appUserDetail.setUpdatetime(System.currentTimeMillis());
appUserLoginMapper.updateByPrimaryKeySelective(appUserLogin);
mapper.updateByPrimaryKeySelective(appUserDetail);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
public AppUserManageVo findUserInfoById(Integer userId) {
AppUserManageVo appUserManageVo = new AppUserManageVo();
List<AppUserManageVo> appUserManageVos = mapper.selectAppUserManage(userId);
if (CollectionUtils.isEmpty(appUserManageVos)){
return appUserManageVo;
}
return appUserManageVos.get(0);
}
@Autowired
private AppUserLoginMapper appUserLoginMapper;
@Autowired
private AppUserDetailBiz appUserDetailBiz;
/**
* 根据条件查询
*
* @param appUserManageDTO 查询条件
* @return
*/
public PageInfo<AppUserManageVo> findAllByQuery(AppUserManageDTO appUserManageDTO) {
if (Objects.nonNull(appUserManageDTO.getRegistrationTimeEnd())) {
long registerEndTime = appUserManageDTO.getRegistrationTimeEnd() + (24 * 60 * 60);
appUserManageDTO.setRegistrationTimeEnd(registerEndTime);
}
PageHelper.startPage(appUserManageDTO.getPage(), appUserManageDTO.getLimit());
List<AppUserManageVo> appUserManageVos = mapper.selectAppUser(appUserManageDTO);
PageInfo<AppUserManageVo> pageInfo = PageInfo.of(appUserManageVos);
if (pageInfo.getList() == null || pageInfo.getList().size() == 0) {
return new PageInfo<>();
}
return pageInfo;
}
/**
* 禁用账户
*
* @param id
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAppUser(Integer id, Integer isDel) {
AppUserLogin appUserLogin = new AppUserLogin();
//修改为禁用并设置修改时间
appUserLogin.setIsdel(isDel);
appUserLogin.setUpdatetime(System.currentTimeMillis());
Example example = new Example(AppUserLogin.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
appUserLoginMapper.updateByExampleSelective(appUserLogin, example);
//设置
AppUserDetail appUserDetail = new AppUserDetail();
appUserDetail.setIsdel(isDel);
appUserDetail.setUpdatetime(System.currentTimeMillis());
Example detailExample = new Example(AppUserLogin.class);
Example.Criteria detailCriteria = detailExample.createCriteria();
criteria.andEqualTo("id", id);
mapper.updateByExampleSelective(appUserDetail, detailCriteria);
}
/**
* 查询一条
*
* @param id
* @return
*/
public AppUserVo findOneById(Integer id) {
return mapper.getUserInfo(id);
}
/**
* 启用禁用
*
* @param appUserLogin
* @return
*/
public ObjectRestResponse updateStatus(AppUserLogin appUserLogin) {
if (appUserLogin == null || appUserLogin.getId() == null || appUserLogin.getStatus() == null) {
return ObjectRestResponse.paramIsEmpty();
}
AppUserLogin old = appUserLoginMapper.selectByPrimaryKey(appUserLogin.getId());
if (old == null || old.getIsdel() == 1) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, ResultCode.getMsg(ResultCode.NOTEXIST_CODE));
}
old.setStatus(appUserLogin.getStatus());
appUserLoginMapper.updateByPrimaryKeySelective(old);
return ObjectRestResponse.succ();
}
/**
* 保存
*
* @param appUserVo
*/
@Transactional(rollbackFor = Exception.class)
public void save(AppUserVo appUserVo) {
AppUserLogin appUserLogin = new AppUserLogin();
AppUserDetail appUserDetail = new AppUserDetail();
try {
BeanUtilsBean.getInstance().copyProperties(appUserLogin, appUserVo);
BeanUtilsBean.getInstance().copyProperties(appUserDetail, appUserVo);
if (appUserVo.getUserid() == null || appUserVo.getUserid() == 0) {
//设置登录用户信息
appUserLogin.setIsdel(0);
appUserLogin.setCreatetime(System.currentTimeMillis());
appUserLogin.setCertificationStatus(0);
appUserLogin.setStatus(0);
//设置用户详情
appUserDetail.setIsdel(0);
if (appUserDetail.getIsMember() == null) {
appUserDetail.setIsMember(0);
}
appUserLoginMapper.insertSelective(appUserLogin);
mapper.insertSelective(appUserDetail);
} else {
appUserLogin.setUpdatetime(System.currentTimeMillis());
appUserDetail.setUpdatetime(System.currentTimeMillis());
appUserLoginMapper.updateByPrimaryKeySelective(appUserLogin);
mapper.updateByPrimaryKeySelective(appUserDetail);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
}
public AppUserManageVo findUserInfoById(Integer userId) {
AppUserManageVo appUserManageVo = new AppUserManageVo();
List<AppUserManageVo> appUserManageVos = mapper.selectAppUserManage(userId);
if (CollectionUtils.isEmpty(appUserManageVos)) {
return appUserManageVo;
}
return appUserManageVos.get(0);
}
}
......@@ -49,8 +49,6 @@ public class AppUsersManageController extends BaseController<AppUserManageBiz,Ap
@Autowired
protected UserAuthConfig userAuthConfig;
@Autowired
private PublicController publicController;
@Autowired
private UserAuthUtil userAuthUtil;
......@@ -63,15 +61,12 @@ public class AppUsersManageController extends BaseController<AppUserManageBiz,Ap
*/
@PostMapping("/findAll")
public ObjectRestResponse<PageInfo<AppUserManageVo>> findAllByQuery(@RequestBody AppUserManageDTO appUserManageDTO) throws Exception {
String token = userAuthConfig.getToken(request);
ObjectRestResponse objectRestResponse = publicController.userinfoByToken(token);
User user = (User) objectRestResponse.getData();
if (user==null){
throw new BaseException("User error!");
}
// if (ALL_PERMISSIONS.equals(user.getDataAll())) {
return ObjectRestResponse.succ(baseBiz.findAllByQuery(appUserManageDTO));
// }
}
@PostMapping(value = "updateStatus")
public ObjectRestResponse updateStatus(@RequestBody AppUserLogin appUserLogin) {
return baseBiz.updateStatus(appUserLogin);
}
/**
......
......@@ -217,6 +217,9 @@
<if test="userId!=null">
and l.id=#{userId}
</if>
<if test="status != null">
and l.status = #{status}
</if>
<if test="postionState != null">
<choose>
<when test="postionState == 6">
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ace-sidecar</artifactId>
<groupId>com.github.wxiaoqi</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ace-sidecar-client-demo</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--表示为web工程-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>
<!--暴露各种指标-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-all</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
Python服务端示例:
https://gitee.com/superjery/tornado_boilerplate
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
需以下根文件:
__init__.py
application.py
server.py
urls.py
需以下根文件夹:
handlers
model
static
templates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python 安装 3.5
tornado 安装 4.5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
运行python server.py即可启动Web
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
两种访问接口方式:
http://localhost:5689/ace-sidecar-client-demo/test/test
http://localhost:5689/ace-sidecar-client-demo/message/123
package com.github.wxiaoqi.security.sidecarclient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* ${DESCRIPTION}
*
* @author yangyongjie
* @create 2017-10-22 20:30
*/
@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@EnableFeignClients
public class PythonServerBootstrap {
public static void main(String[] args) {
SpringApplication.run(PythonServerBootstrap.class, args);
}
}
package com.github.wxiaoqi.security.sidecarclient.client;
import com.github.wxiaoqi.security.sidecarclient.entity.Message;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* ${DESCRIPTION}
*
* @author yangyongjie
* @create 2017-10-22 20:30
*/
@FeignClient(name = "ace-sidecar-server")
public interface PythonFeignClient {
//parse param like /message?id=12
@RequestMapping("/message/{id}")
List<Message> getMsg(@RequestParam("id") Long id);
//parse url like /test
@RequestMapping("/test")
String getTest();
}
\ No newline at end of file
package com.github.wxiaoqi.security.sidecarclient.entity;
/**
* ${DESCRIPTION}
*
* @author yangyongjie
* @create 2017-10-22 20:30
*/
public class Message {
private Long id;
private String msg;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
\ No newline at end of file
package com.github.wxiaoqi.security.sidecarclient.rest;
import com.github.wxiaoqi.security.sidecarclient.entity.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import com.github.wxiaoqi.security.sidecarclient.client.PythonFeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* ${DESCRIPTION}
*
* @author yangyongjie
* @create 2017-10-22 20:30
*/
@RestController
@RequestMapping("test")
public class PythonController {
@Autowired
private PythonFeignClient pythonFeignClient;
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String getTest() {
return pythonFeignClient.getTest();
}
@RequestMapping(value = "/message/{id}", method = RequestMethod.GET)
public List<Message> getMsg(@PathVariable Long id) {
return pythonFeignClient.getMsg(id);
}
}
\ No newline at end of file
server:
port: 5689 #启动端口
spring:
application:
name: ace-sidecar-client-demo
eureka:
instance:
statusPageUrlPath: /info
healthCheckUrlPath: /health
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
\ No newline at end of file
server:
port: 5689 #启动端口
spring:
application:
name: ace-sidecar-client-demo
eureka:
instance:
statusPageUrlPath: /info
healthCheckUrlPath: /health
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ace-sidecar</artifactId>
<groupId>com.github.wxiaoqi</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ace-sidecar-server</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--表示为web工程-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>
<!--暴露各种指标-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
使用Sidecar代理远程Python服务,端口为Python的Web端口
当然,换成Node的Web端口,即可代理Node的远程服务
远程服务需要实现一个接口,返回
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Node:
app.get('/health', (req, res) => {
res.json({
status: 'UP'
})
})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python:
class HealthHandler(tornado.web.RequestHandler):
def get(self):
self.set_header("content-type", "application/json")
self.render('health')
health:
{"status":"UP"}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
切记,通过此代理访问不到远程Python提供的服务,
需通过ace-sidecar-client-demo封装后才可访问到。
\ No newline at end of file
package com.github.wxiaoqi.security.sidecar;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.sidecar.EnableSidecar;
/**
* Created by ace on 2017/7/29.
*/
@EnableSidecar
@SpringBootApplication
public class SidercarBootstrap {
public static void main(String[] args) {
SpringApplication.run(SidercarBootstrap.class, args);
}
}
server:
port: 5688 #启动端口
spring:
application:
name: ace-sidecar-server
cloud:
consul:
enabled: true
host: 127.0.0.1
port: 8500
discovery:
healthCheckPath: /actuator/health
healthCheckInterval: 5s
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
register: true
enabled: true
sidecar:
port: 5680 #python接口
health:
uri: http://localhost:${sidecar.port}/health
eureka:
instance:
statusPageUrlPath: /info
healthCheckUrlPath: /health
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
\ No newline at end of file
server:
port: 5688 #启动端口
spring:
application:
name: ace-sidecar-server
cloud:
consul:
enabled: true
host: 127.0.0.1
port: 8500
discovery:
healthCheckPath: /actuator/health
healthCheckInterval: 5s
instanceId: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
register: true
enabled: true
sidecar:
port: 5680 #python接口
health:
uri: http://localhost:${sidecar.port}/health
eureka:
instance:
statusPageUrlPath: /info
healthCheckUrlPath: /health
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ace-security</artifactId>
<groupId>com.github.wxiaoqi</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ace-sidecar</artifactId>
<packaging>pom</packaging>
<modules>
<module>ace-sidecar-server</module>
<module>ace-sidecar-client-demo</module>
</modules>
</project>
\ No newline at end of file
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info */
/******************************************/
CREATE TABLE `config_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(255) DEFAULT NULL,
`content` longtext NOT NULL COMMENT 'content',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
`src_user` text COMMENT 'source user',
`src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
`app_name` varchar(128) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`c_desc` varchar(256) DEFAULT NULL,
`c_use` varchar(64) DEFAULT NULL,
`effect` varchar(64) DEFAULT NULL,
`type` varchar(64) DEFAULT NULL,
`c_schema` text,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_aggr */
/******************************************/
CREATE TABLE `config_info_aggr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(255) NOT NULL COMMENT 'group_id',
`datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
`content` longtext NOT NULL COMMENT '内容',
`gmt_modified` datetime NOT NULL COMMENT '修改时间',
`app_name` varchar(128) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_beta */
/******************************************/
CREATE TABLE `config_info_beta` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL COMMENT 'content',
`beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
`src_user` text COMMENT 'source user',
`src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_tag */
/******************************************/
CREATE TABLE `config_info_tag` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
`tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL COMMENT 'content',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
`src_user` text COMMENT 'source user',
`src_ip` varchar(20) DEFAULT NULL COMMENT 'source ip',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_tags_relation */
/******************************************/
CREATE TABLE `config_tags_relation` (
`id` bigint(20) NOT NULL COMMENT 'id',
`tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
`tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
`nid` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`nid`),
UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = group_capacity */
/******************************************/
CREATE TABLE `group_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = his_config_info */
/******************************************/
CREATE TABLE `his_config_info` (
`id` bigint(64) unsigned NOT NULL,
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`data_id` varchar(255) NOT NULL,
`group_id` varchar(128) NOT NULL,
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL,
`md5` varchar(32) DEFAULT NULL,
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00',
`src_user` text,
`src_ip` varchar(20) DEFAULT NULL,
`op_type` char(10) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
PRIMARY KEY (`nid`),
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`),
KEY `idx_did` (`data_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = tenant_capacity */
/******************************************/
CREATE TABLE `tenant_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
`gmt_create` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '创建时间',
`gmt_modified` datetime NOT NULL DEFAULT '2010-05-05 00:00:00' COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
CREATE TABLE `tenant_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`kp` varchar(128) NOT NULL COMMENT 'kp',
`tenant_id` varchar(128) default '' COMMENT 'tenant_id',
`tenant_name` varchar(128) default '' COMMENT 'tenant_name',
`tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
`create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
`gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
`gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
......@@ -16,5 +16,4 @@
<module>rs-datacenter-api</module>
<module>rs-datacenter-server</module>
</modules>
</project>
\ No newline at end of file
package com.upyuns.platform.rs.datacenter.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class ImageStorageVo {
//左上角经度
private BigDecimal leftTopLon;
//左上角维度
private BigDecimal leftTopLat;
//左下角经度
private BigDecimal leftBottomLon;
//左下角维度
private BigDecimal leftBottomLat;
//右下角经度
private BigDecimal rightBottomLon;
//右下角维度
private BigDecimal rightBottomLat;
//右上角经度
private BigDecimal rightTopLon;
//右上角维度
private BigDecimal rightTopLat;
//中心点经纬度
private BigDecimal imageCenterPointLat;
private BigDecimal imageCenterPointLon;
//数据名称
private String name;
//缩略图存储路径
private String thumbnailPath;
//影像存储地址目录
private String imageFilePath;
//文件名称
private List<String> files;
//光谱
private String imageSpectrumType;
//光谱名称
private String imageSpectrumTypeDisplay;
//卫星类型
private String imageSatelliteType;
//卫星名称
private String imageSatelliteTypeDisplay;
//传感器类型
private String imageSensorType;
//传感器id
private String imageSensorId;
//景id
private String imageSceneId;
//拍摄时间
private String imageTakeTime;
//影像开始时间
private String imageStartTime;
//影像结束时间
private String imageEndTime;
//影像中间时间
private String imageCenterTime;
//产品时间
private String imageProductTime;
//投影
private String imageProjection;
//云量
private BigDecimal imageCloudage;
//产品格式 GEOTIFF 、 TIFF
private String imageProductFormat;
//sat行号
private String imageSatPath;
//sat列号
private String imageSatRow;
//分辨率数组
private BigDecimal[] imageResolution;
//影像宽度
private Integer imageWidthInPixels;
//影像高度
private String imageHeightInPixels;
//卫星平台平均俯仰角
private String imagePitchSatellitessAngle;
//太阳方位角
private String imageSolarAzimuth;
//太阳高度角
private String imageSolarZenith;
//卫星方向角
private String imageSatelliteAzimuth;
//卫星高度角
private String imageSatelliteZenith;
//卫星平台平均偏航角
private String imageYawSatelliteAngle;
//供应商
private String supplier;
}
......@@ -19,6 +19,17 @@
<version>2.0-rscp-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>3.0.0</version>
</dependency>
<!-- XML解析包 -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<build>
......
package com.upyuns.platform.rs.datacenter.utils;
public class FileOperateUtil {
public static String getFileNameNotFormat(String filePath) {
filePath = filePath.replaceAll("\\\\", "/");
Integer indexOf = filePath.lastIndexOf("/");
String fileName = filePath.substring(indexOf);
String dirName = fileName;
indexOf = filePath.lastIndexOf(".");
if (indexOf > 0) {
dirName = dirName.substring(0, indexOf);
}
return dirName;
}
public static String getFileName(String filePath) {
filePath = filePath.replaceAll("\\\\", "/");
Integer indexOf = filePath.lastIndexOf("/");
String fileName = filePath.substring(indexOf);
return fileName;
}
}
package com.upyuns.platform.rs.datacenter.utils;
import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.upyuns.platform.rs.datacenter.vo.ImageStorageVo;
import com.upyuns.platform.rs.gtdata.GtDataRestClient;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public class ImageStorageParseUtil {
@Value("${localDirTemp.tarFileTemp}")
private static String tarFileTempDir;
@Autowired
private static GtDataRestClient gtDataRestClient;
public static ImageStorageVo tarFileParseGtData(String inputGtPath, String ouputGtDir)throws BaseException {
//将GT上压缩包下载到本地
Integer indexOf = inputGtPath.lastIndexOf("/");
String fileName = inputGtPath.substring(indexOf);
String dirName = fileName;
indexOf = inputGtPath.lastIndexOf(".");
if (indexOf > 0) {
dirName = dirName.substring(0, indexOf);
}
File localDir = new File(tarFileTempDir + "/" + dirName);
localDir.mkdirs();
String localInputPath = localDir + "/" + fileName;
Map<String,Object > result = gtDataRestClient.open(inputGtPath);
if ((Integer)result.get("HttpStatusCode") != 200) {
throw new BaseException("文件下载失败", ResultCode.FAILED_CODE);
}
try {
OutputStream outputStream = new FileOutputStream(new File(localInputPath));
outputStream.write((byte[])result.get("file"));
outputStream.flush();
outputStream.close();
}catch (Exception e) {
throw new BaseException("文件保存失败", ResultCode.FAILED_CODE);
}
return tarFileParse(localInputPath, localDir.getPath(), ouputGtDir);
}
public static ImageStorageVo tarFileParse(String inputLocalPath, String localOutputDir, String outputGtPath) throws BaseException {
if (inputLocalPath.endsWith("zip")) {
//Satellogic 压缩包解析
return satellogicParse(inputLocalPath, localOutputDir, outputGtPath);
}else if (inputLocalPath.endsWith("tar.gz")) {
throw new BaseException("tar.gz 压缩包未实现", ResultCode.FAILED_CODE);
}else {
throw new BaseException("压缩包格式不支持", ResultCode.FAILED_CODE);
}
}
//Satellogic 压缩包解析
public static ImageStorageVo satellogicParse(String inputLocalPath, String localOutputDir, String outputGtPath) throws BaseException {
//1、提取解析xml文件
List<String> xmlPathList = TarFileOperateUtil.zipFileRead(inputLocalPath, localOutputDir,".xml");
if (xmlPathList == null || xmlPathList.size() == 0) {
throw new BaseException("xml文件提取失败", ResultCode.FAILED_CODE);
}
ImageStorageVo imageStorageVo = new ImageStorageVo();
//初始基础或固定信息
imageStorageVo.setName(FileOperateUtil.getFileNameNotFormat(inputLocalPath));
imageStorageVo.setImageProductFormat("TIFF");
imageStorageVo.setImageSpectrumType("{QS,DGP}");
imageStorageVo.setImageSpectrumTypeDisplay("{全色,多光谱}");
imageStorageVo.setImageProjection("WGS-84");
Map<String, String> paramsMap = new HashedMap();
boolean xmlFlag = false;
for (String xmlPath : xmlPathList) {
paramsMap.clear();
XmlFileOperateUtil.xmlParse(xmlPath, paramsMap);
if (paramsMap.get("camera") != null && paramsMap.get("bounds") != null) {
//拍摄时间
imageStorageVo.setImageTakeTime(paramsMap.get("created_at"));
imageStorageVo.setImageProductTime(paramsMap.get("created_at"));
imageStorageVo.setImageEndTime(paramsMap.get("created_at"));
imageStorageVo.setImageStartTime(paramsMap.get("created_at"));
imageStorageVo.setImageCenterTime(paramsMap.get("created_at"));
//供应商
imageStorageVo.setSupplier(paramsMap.get("supplier"));
//卫星名称、类型
imageStorageVo.setImageSatelliteType(paramsMap.get("satellite_name"));
imageStorageVo.setImageSatelliteTypeDisplay(paramsMap.get("satellite_name"));
//云量
imageStorageVo.setImageCloudage(new BigDecimal(paramsMap.get("cloud_pctg")).intValue());
//传感器类型
imageStorageVo.setImageSensorType(paramsMap.get("camera"));
imageStorageVo.setImageSensorId(paramsMap.get("camera"));
xmlFlag = true;
break;
}
}
if (!xmlFlag) {
throw new BaseException("xml 解析失败", ResultCode.FAILED_CODE);
}
//2、提取tiff,生成缩略图
//3、转坐标系
return imageStorageVo;
}
}
package com.upyuns.platform.rs.datacenter.utils;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class TarFileOperateUtil {
/**
* 解压zip压缩包中,指定文件类型的文件
* @param file
* @param saveRootDirectory
* @param suffix
* @return 返回解压后的文件路径列表
* @throws Exception
*/
public static List<String> zipFileRead(String file, String saveRootDirectory, String suffix)throws BaseException {
try {
List<String> filePathList = new ArrayList<>();
String lowerCaseSuffix = suffix;
if (StringUtils.isBlank(lowerCaseSuffix)) {
lowerCaseSuffix = lowerCaseSuffix.toLowerCase();
}
ZipFile zipFile = new ZipFile(file);
@SuppressWarnings("unchecked")
Enumeration<ZipEntry> enu = (Enumeration<ZipEntry>) zipFile.entries();
while (enu.hasMoreElements()) {
ZipEntry zipElement = enu.nextElement();
InputStream read = zipFile.getInputStream(zipElement);
String fileName = zipElement.getName();
if (!zipElement.isDirectory() && fileName != null) {//是否为文件
if (StringUtils.isBlank(lowerCaseSuffix)) {
if (zipExecute(zipElement, read, saveRootDirectory)) {
filePathList.add(saveRootDirectory + "/" + fileName);
}
} else if (fileName.toLowerCase().endsWith(lowerCaseSuffix)) {//指定文件类型
if (zipExecute(zipElement, read, saveRootDirectory)) {
filePathList.add(saveRootDirectory + "/" + fileName);
}
}
}
}
return filePathList;
}catch (Exception e) {
throw new BaseException("xml解析失败", ResultCode.FAILED_CODE);
}
}
private static boolean zipExecute(ZipEntry ze, InputStream read, String saveRootDirectory) throws IOException {
String fileName = ze.getName();
File file = new File(saveRootDirectory + "/" + fileName);
if (!file.exists()) {
File rootDirectoryFile = new File(file.getParent());
//创建目录
if (!rootDirectoryFile.exists()) {
boolean ifSuccess = rootDirectoryFile.mkdirs();
if (ifSuccess) {
System.out.println("文件夹创建成功!");
} else {
return false;
}
}
//创建文件
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
//写入文件
BufferedOutputStream write = new BufferedOutputStream(new FileOutputStream(file));
int cha = 0;
while ((cha = read.read()) != -1) {
write.write(cha);
}
//要注意IO流关闭的先后顺序
write.flush();
write.close();
read.close();
return true;
}
}
package com.upyuns.platform.rs.datacenter.utils;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class XmlFileOperateUtil {
public static void xmlParse(String xmlPath, Map<String, String> paramsMap) throws BaseException{
try {
//1.创建Reader对象
SAXReader reader = new SAXReader();
//2.加载xml
Document document = reader.read(new File(xmlPath));
//3.获取根节点
Element rootElement = document.getRootElement();
Iterator iterator = rootElement.elementIterator();
while (iterator.hasNext()) {
Element stu = (Element) iterator.next();
List<Attribute> attributes = stu.attributes();
System.out.println("======获取属性值======");
for (Attribute attribute : attributes) {
System.out.println(attribute.getValue());
}
System.out.println("======遍历子节点======");
Iterator iterator1 = stu.elementIterator();
while (iterator1.hasNext()) {
Element stuChild = (Element) iterator1.next();
paramsMap.put(stuChild.getName(), stuChild.getStringValue());
}
}
}catch (Exception e) {
throw new BaseException("xml解析失败", ResultCode.FAILED_CODE);
}
}
}
package com.upyuns.platform.rs.datacenter.utils.gdal;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import org.gdal.gdal.Dataset;
import org.gdal.gdal.Driver;
import org.gdal.gdal.gdal;
import org.gdal.gdalconst.gdalconstConstants;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class ImageOperateTools {
/**
* tif 文件转 为图片
* @param inputPath
* @param outputPath
* @return
*/
public static Boolean tif2Pic(String inputPath, String outputPath) {
//注册GDAL
gdal.AllRegister();
//设置中文
gdal.SetConfigOption("gdal_FILENAME_IS_UTF8", "YES");
//只读方式读取数据
Dataset sourceData = gdal.Open(inputPath, gdalconstConstants.GA_ReadOnly);
if (sourceData == null) {
return false;
}
Driver hDriver = sourceData.GetDriver();
hDriver.CreateCopy(outputPath, sourceData);
hDriver.delete();
sourceData.delete();
return true;
}
//jpeg图片压缩处理
public static Boolean zipImageFile(String oldFile, String newFile, int width, int height, float quality) {
if (oldFile == null) {
return null;
}
try {
/**对服务器上的临时文件进行处理 */
Image srcFile = ImageIO.read(new File(oldFile));
/** 宽,高设定 */
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
tag.getGraphics().drawImage(srcFile, 0, 0, width, height, null);
/** 压缩之后临时存放位置 */
FileOutputStream out = new FileOutputStream(newFile);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam jep = JPEGCodec.getDefaultJPEGEncodeParam(tag);
/** 压缩质量 */
jep.setQuality(quality, true);
encoder.encode(tag, jep);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
}
......@@ -11,7 +11,7 @@ import lombok.Data;
@Data
public class ItemInfoDto {
Integer id;
Long id;
Integer number;
......
package com.upyuns.platform.rs.website.dto;
import com.github.wxiaoqi.security.common.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @ClassName : OrderInfoDto
......@@ -13,8 +15,40 @@ import java.math.BigDecimal;
*/
@Data
public class OrderInfoDto extends PageParam {
/**
* 订单备注
*/
@ApiModelProperty(value = "订单备注")
private String remark;
/**
* 配送方式:1、线上配送,2、快递配送
*/
@ApiModelProperty(value = "配送方式:1、线上配送,2、快递配送")
private Integer sendType;
/**
* 地址ID
*/
private Integer userAddressId;
/**
* 发票ID
*/
private Integer userInvoiceId;
/**
* 商品信息ID
*/
private List<ItemInfoDto> itemInfoDtoList;
/**
* 发票内容
*/
private String invoiceContent;
//详情ID
Integer detailId;
Long detailId;
//1、标准数据,2、影像图库,3、行业应用信息
Integer type;
......@@ -27,4 +61,5 @@ public class OrderInfoDto extends PageParam {
//文件地址
String filePath;
}
......@@ -4,13 +4,14 @@ import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 订单信息
*
*
* @author jiaoruizhen
* @email jiaoruizhen@126.com
* @date 2020-12-03 13:29:23
......@@ -19,166 +20,176 @@ import lombok.Data;
@Table(name = "order_info")
public class OrderInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
/**
*
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty("")
private Long orderId;
/**
* 订单号
*/
@Column(name = "order_no")
private Long orderId;
/**
* 订单号
*/
@Column(name = "order_no")
@ApiModelProperty(value = "订单号")
private String orderNo;
/**
* 单价
*/
@Column(name = "amount")
private String orderNo;
/**
* 单价
*/
@Column(name = "amount")
@ApiModelProperty(value = "单价")
private BigDecimal amount;
/**
* 数量
*/
@Column(name = "number")
private BigDecimal amount;
/**
* 数量
*/
@Column(name = "number")
@ApiModelProperty(value = "数量")
private Integer number;
/**
* 订单状态:1--创建订单,2--待付款,3--已支付,4--已发货,5--已完成 -1、删除,-2、取消
*/
@Column(name = "status")
@ApiModelProperty(value = " 订单状态:1--创建订单,2--待付款,3--已支付,4--已发货,5--已完成 -1、删除,-2、取消")
private Integer status;
private Integer number;
/**
* 订单状态:0、定制订单无价格 1--创建订单,2--待付款,3--已支付,4--已发货, 5--已收货, 6、已完成 -1、删除,-2、取消, -3 退款
*/
@Column(name = "status")
@ApiModelProperty(value = " 订单状态:0、定制订单无价格 1--创建订单,2--待付款,3--已支付,4--已发货, 5--已收货, 6、已完成 -1、删除,-2、取消, -3 退款")
private Integer status;
/**
* 发货状态0待发货,1已发货,2收货,3退货,
*/
private Integer shippingStatus;
/**
* 支付状态:1--未支付,2--已支付
* 1待付款,2已付款,3已退款
*/
private Integer payStatus;
/**
* 用户id
*/
@Column(name = "user_id")
/**
* 用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户id")
private Integer userId;
/**
* 用户手机号
*/
@Column(name = "phone")
private Integer userId;
/**
* 用户手机号
*/
@Column(name = "phone")
@ApiModelProperty(value = "用户手机号")
private String phone;
/**
* 用户昵称
*/
@Column(name = "nickname")
private String phone;
/**
* 用户昵称
*/
@Column(name = "nickname")
@ApiModelProperty(value = "用户昵称")
private String nickname;
/**
* 用户真实姓名
*/
@Column(name = "real_name")
private String nickname;
/**
* 用户真实姓名
*/
@Column(name = "real_name")
@ApiModelProperty(value = "用户真实姓名")
private String realName;
/**
* 头像
*/
@Column(name = "head_img")
private String realName;
/**
* 头像
*/
@Column(name = "head_img")
@ApiModelProperty(value = "头像")
private String headImg;
/**
* 1、微信支付,2、支付宝支付,3、对公支付
*/
@Column(name = "pay_type")
private String headImg;
/**
* 1、微信支付,2、支付宝支付,3、对公支付
*/
@Column(name = "pay_type")
@ApiModelProperty(value = "1、微信支付,2、支付宝支付,3、对公支付")
private Integer payType;
/**
* 下单时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "下单时间", hidden = true )
private Date crtTime;
/**
* 支付时间
*/
@Column(name = "pay_time")
private Integer payType;
/**
* 下单时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "下单时间", hidden = true)
private Date crtTime;
/**
* 支付时间
*/
@Column(name = "pay_time")
@ApiModelProperty(value = "支付时间")
private Date payTime;
/**
*
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "", hidden = true )
private Date updTime;
/**
* 运费
*/
@Column(name = "fee")
private Date payTime;
/**
*
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "", hidden = true)
private Date updTime;
/**
* 运费
*/
@Column(name = "fee")
@ApiModelProperty(value = "运费")
private BigDecimal fee;
/**
* 订单备注
*/
@Column(name = "remark")
private BigDecimal fee;
/**
* 订单备注
*/
@Column(name = "remark")
@ApiModelProperty(value = "订单备注")
private String remark;
/**
* 配送方式:1、线上配送,2、快递配送
*/
@Column(name = "send_type")
private String remark;
/**
* 配送方式:1、线上配送,2、快递配送
*/
@Column(name = "send_type")
@ApiModelProperty(value = "配送方式:1、线上配送,2、快递配送")
private Integer sendType;
/**
* 收货人姓名
*/
@Column(name = "receive_name")
private Integer sendType;
/**
* 收货人姓名
*/
@Column(name = "receive_name")
@ApiModelProperty(value = "收货人姓名")
private String receiveName;
/**
* 收货人电话
*/
@Column(name = "receive_phone")
private String receiveName;
/**
* 收货人电话
*/
@Column(name = "receive_phone")
@ApiModelProperty(value = "收货人电话")
private String receivePhone;
/**
* 收货地址
*/
@Column(name = "receive_address")
private String receivePhone;
/**
* 收货地址
*/
@Column(name = "receive_address")
@ApiModelProperty(value = "收货地址")
private String receiveAddress;
/**
*
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "")
private BigDecimal totalAmount;
/**
*
*/
@Column(name = "type")
private String receiveAddress;
/**
* 总金额
*/
@Column(name = "total_amount")
@ApiModelProperty(value = "")
private Integer type;
private BigDecimal totalAmount;
/**
* 1、普通订单,2、定制订单
*/
@Column(name = "type")
@ApiModelProperty(value = "1、普通订单,2、定制订单")
private Integer type;
/**
* 发票状态: 1、未开发票,2、已开发票, 3、已发货, 4、已收货、5、退回, 6、已完成
*/
private Integer invoiceStatus;
}
......@@ -47,7 +47,7 @@ public class OrderItem implements Serializable {
*/
@Column(name = "detail_id")
@ApiModelProperty(value = "详情id")
private Integer detailId;
private Long detailId;
/**
* 详情json信息
......
......@@ -40,7 +40,7 @@ public class ShoppingCartInfo implements Serializable {
*/
@Column(name = "detail_id")
@ApiModelProperty(value = "详情id")
private Integer detailId;
private Long detailId;
/**
* 详情json信息
......
......@@ -12,10 +12,12 @@ import java.math.BigDecimal;
*/
@Data
public class ItemInfoVo {
private Integer id;
private Long id;
private String detailJson;
private Integer number;
private BigDecimal price;
private Integer type;
private String img;
private String name;
}
......@@ -2,23 +2,35 @@ package com.upyuns.platform.rs.website.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.OrderUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.upyuns.platform.rs.universal.constant.DictionaryKey;
import com.upyuns.platform.rs.universal.entity.Dictionary;
import com.upyuns.platform.rs.universal.feign.ThirdFeign;
import com.upyuns.platform.rs.website.dto.ItemInfoDto;
import com.upyuns.platform.rs.website.dto.OrderInfoDto;
import com.upyuns.platform.rs.website.dto.UserOrderDto;
import com.upyuns.platform.rs.website.entity.OrderItem;
import com.upyuns.platform.rs.website.entity.ShoppingCartInfo;
import com.upyuns.platform.rs.website.entity.*;
import com.upyuns.platform.rs.website.mapper.OrderItemMapper;
import com.upyuns.platform.rs.website.type.OrderTypeEnum;
import com.upyuns.platform.rs.website.vo.ItemInfoVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.upyuns.platform.rs.website.entity.OrderInfo;
import com.upyuns.platform.rs.website.mapper.OrderInfoMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
/**
* 订单信息
......@@ -31,7 +43,36 @@ import java.util.List;
public class OrderInfoBiz extends BaseBiz<OrderInfoMapper, OrderInfo> {
@Autowired
OrderItemMapper orderItemMapper;
OrderItemBiz orderItemBiz;
@Autowired
IndustryApplicationInfoBiz industryApplicationInfoBiz;
@Autowired
ImageImgStorageBiz imageImgStorageBiz;
@Autowired
ShoppingCartInfoBiz shoppingCartInfoBiz;
@Autowired
ImageInfoRelationBiz imageInfoRelationBiz;
@Autowired
ThirdFeign thirdFeign;
@Autowired
UserFeign userFeign;
@Autowired
HttpServletRequest request;
@Autowired
UserAddressBiz userAddressBiz;
@Autowired
OrderEInvoiceBiz orderEInvoiceBiz;
@Autowired
UserInvoiceBiz userInvoiceBiz;
/**
* 添加订单
......@@ -115,4 +156,164 @@ public class OrderInfoBiz extends BaseBiz<OrderInfoMapper, OrderInfo> {
}
/**
* 提交订单
* @param orderInfoDto
* @return
*/
public ObjectRestResponse submitOrder(OrderInfoDto orderInfoDto) {
AppUserDTO appUserDTO = userFeign.userDetailByToken(request.getHeader("Authorization")).getData();
if (appUserDTO == null) {
return ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_EXPIRED_CODE, ResultCode.getMsg(ResultCode.RSTOKEN_EXPIRED_CODE));
}
if (orderInfoDto == null || orderInfoDto.getItemInfoDtoList() == null) {
return ObjectRestResponse.paramIsEmpty();
}
List<ItemInfoDto> itemInfoDtoList = orderInfoDto.getItemInfoDtoList();
List<OrderItem> orderItemList = new ArrayList<>();
AtomicReference<Integer> number = new AtomicReference<>(0);
AtomicReference<Double> amount = new AtomicReference<>((double) 0);
itemInfoDtoList.parallelStream().forEach(itemInfoDto -> {
switch (OrderTypeEnum.getByCode(itemInfoDto.getType())) {
//标准数据
case STANDARD_DATA:
break;
//行业应用
case INDUSTRY_INFO:
IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.getOneById(itemInfoDto.getId().intValue()).getData();
if (industryApplicationInfo != null) {
OrderItem orderItem = new OrderItem();
orderItem.setType(itemInfoDto.getType());
orderItem.setTotalAmount(industryApplicationInfo.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber())));
orderItem.setPrice(industryApplicationInfo.getPrice());
orderItem.setNumber(itemInfoDto.getNumber());
orderItem.setName(industryApplicationInfo.getTitle());
orderItem.setItemPic(industryApplicationInfo.getCoverImg());
orderItem.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
orderItem.setDetailId(Long.valueOf(industryApplicationInfo.getId()));
orderItemList.add(orderItem);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = industryApplicationInfo.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber()));
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
break;
//影像图库
case IMAGE_STORAGE:
ImageInfoRelation imageInfoRelation = imageInfoRelationBiz.selectById(itemInfoDto.getId());
if (imageInfoRelation != null ) {
ImageImgStorage imageImgStorage = imageImgStorageBiz.getDetail(itemInfoDto.getId().intValue()).getData();
if (imageImgStorage != null) {
List<ImageInfoRelation> imageInfoRelationList = new ArrayList<>();
imageInfoRelationList.add(imageInfoRelation);
imageImgStorage.setImageInfoRelationList(imageInfoRelationList);
OrderItem orderItem = new OrderItem();
orderItem.setType(itemInfoDto.getType());
orderItem.setTotalAmount(imageInfoRelation.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber())));
orderItem.setPrice(imageInfoRelation.getPrice());
orderItem.setNumber(itemInfoDto.getNumber());
orderItem.setName(imageImgStorage.getName());
orderItem.setItemPic(imageImgStorage.getCoverImg());
orderItem.setDetailJson(JSONObject.toJSONString(imageImgStorage));
orderItem.setDetailId(Long.valueOf(imageImgStorage.getId()));
orderItemList.add(orderItem);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = imageInfoRelation.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber()));
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
}
}
break;
//购物车
case SHOPPING_CART_INFO:
ShoppingCartInfo shoppingCartInfo = shoppingCartInfoBiz.selectById(itemInfoDto.getId());
if (shoppingCartInfo != null) {
OrderItem orderItem = new OrderItem();
orderItem.setType(itemInfoDto.getType());
orderItem.setTotalAmount(shoppingCartInfo.getPrice().multiply(new BigDecimal(itemInfoDto.getNumber())));
orderItem.setPrice(shoppingCartInfo.getPrice());
orderItem.setNumber(itemInfoDto.getNumber());
orderItem.setName(shoppingCartInfo.getName());
orderItem.setItemPic(shoppingCartInfo.getItemPic());
orderItem.setDetailJson(shoppingCartInfo.getDetailJson());
orderItem.setDetailId(shoppingCartInfo.getDetailId());
orderItemList.add(orderItem);
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = shoppingCartInfo.getTotalAmount();
amount.updateAndGet(v -> new Double((double) (v + totalAmount.doubleValue())));
//下单后删除购物车
shoppingCartInfo.setIsDel(1);
shoppingCartInfoBiz.updateSelectiveByIdRe(shoppingCartInfo);
}
break;
default:
break;
}
});
OrderInfo orderInfo = new OrderInfo();
orderInfo.setRealName(appUserDTO.getRealname());
orderInfo.setUserId(appUserDTO.getUserid());
orderInfo.setPhone(appUserDTO.getUsername());
orderInfo.setNickname(appUserDTO.getNickname());
orderInfo.setHeadImg(appUserDTO.getHeadimgurl());
if (orderInfoDto.getUserAddressId() != null) {
UserAddress userAddress = userAddressBiz.selectById(orderInfoDto.getUserAddressId());
if (userAddress != null) {
orderInfo.setReceiveName(userAddress.getConsigneeName());
orderInfo.setReceivePhone(userAddress.getConsigneePhone());
orderInfo.setReceiveAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getTown() + userAddress.getConsigneeAddress());
}
}
orderInfo.setRemark(orderInfoDto.getRemark());
orderInfo.setAmount(new BigDecimal(amount.get()));
orderInfo.setNumber(number.get());
Dictionary dictionary = thirdFeign.findDictionaryByTypeAndCode(DictionaryKey.APP_ORDER, DictionaryKey.SEND_FEE);
if (dictionary != null && StringUtils.isNotBlank(dictionary.getDetail())) {
orderInfo.setFee(new BigDecimal(dictionary.getDetail()));
}
if (orderInfo.getFee() != null) {
orderInfo.setTotalAmount(orderInfo.getAmount().add(orderInfo.getFee()));
}
orderInfo.setSendType(orderInfoDto.getSendType());
orderInfo.setType(1);
/**
* 新增订单
*/
orderInfo.setOrderNo(OrderUtil.GetOrderNumber("", OrderUtil.APP_MID));
generateOrder(orderInfo);
orderItemList.parallelStream().forEach(orderItem -> {
if (orderItem != null) {
orderItem.setOrderId(orderInfo.getOrderId());
orderItemBiz.insertSelective(orderItem);
}
});
//订单发票信息
if (orderInfoDto.getUserInvoiceId() != null) {
UserInvoice userInvoice = userInvoiceBiz.selectById(orderInfoDto.getUserInvoiceId());
if (userInvoice != null) {
OrderEInvoice orderEInvoice = new OrderEInvoice();
orderEInvoice.setAmount(orderInfo.getAmount());
orderEInvoice.setType(1);
orderEInvoice.setOrderIds(orderInfo.getOrderId() + "");
orderEInvoice.setTitleType(userInvoice.getTitleType());
orderEInvoice.setTitleName(userInvoice.getTitleName());
orderEInvoice.setTaxCode(userInvoice.getTaxCode());
orderEInvoice.setContentRemark(orderInfoDto.getRemark());
orderEInvoice.setContentAccount(userInvoice.getOpenBank() + " " + userInvoice.getAccount());
orderEInvoice.setContentContact(orderInfo.getReceiveAddress() + " " + orderInfo.getReceiveName() + " " + orderInfo.getReceivePhone());
//发票内容
if (StringUtils.isNotBlank(orderInfoDto.getInvoiceContent())) {
orderEInvoice.setContentTitle(orderInfoDto.getInvoiceContent());
}
orderEInvoiceBiz.addUpdate(orderEInvoice);
}
}
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
......@@ -5,6 +5,9 @@ import org.springframework.stereotype.Service;
import com.upyuns.platform.rs.website.entity.OrderItem;
import com.upyuns.platform.rs.website.mapper.OrderItemMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* 订单商品信息
......@@ -15,4 +18,16 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/
@Service
public class OrderItemBiz extends BaseBiz<OrderItemMapper,OrderItem> {
/**
* 根据订单号查询所有订单商品
* @param orderIdList
* @return
*/
public List<OrderItem> getAllByOrderId(List<Long> orderIdList) {
Example example = new Example(OrderItem.class);
example.createCriteria().andIn("orderId", orderIdList);
return mapper.selectByExample(example);
}
}
\ No newline at end of file
......@@ -126,7 +126,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin
updateSelectiveByIdRe(old);
} else {
ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(imageImgStorage.getId());
shoppingCartInfo.setDetailId(Long.valueOf(imageImgStorage.getId()));
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(imageImgStorage));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
......@@ -159,7 +159,7 @@ public class ShoppingCartInfoBiz extends BaseBiz<ShoppingCartInfoMapper, Shoppin
updateSelectiveByIdRe(old);
} else {
ShoppingCartInfo shoppingCartInfo = new ShoppingCartInfo();
shoppingCartInfo.setDetailId(industryApplicationInfo.getId());
shoppingCartInfo.setDetailId(Long.valueOf(industryApplicationInfo.getId()));
shoppingCartInfo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
shoppingCartInfo.setPrice(orderInfoDto.getPrice());
shoppingCartInfo.setFilePath(orderInfoDto.getFilePath());
......
......@@ -4,6 +4,7 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.upyuns.platform.rs.website.biz.OrderInfoBiz;
import com.upyuns.platform.rs.website.dto.ConfirmOrderDto;
import com.upyuns.platform.rs.website.dto.OrderInfoDto;
import com.upyuns.platform.rs.website.entity.OrderInfo;
import com.upyuns.platform.rs.website.service.ConfirmOrderService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -24,5 +25,8 @@ public class OrderInfoWebController extends BaseController<OrderInfoBiz,OrderInf
return confirmOrderService.confirmOrderInfo(confirmOrderDto);
}
@PostMapping(value = "submitOrder")
public ObjectRestResponse submitOrder(@RequestBody OrderInfoDto orderInfoDto) {
return baseBiz.submitOrder(orderInfoDto);
}
}
\ No newline at end of file
......@@ -70,15 +70,16 @@ public class ConfirmOrderService {
break;
//行业应用
case INDUSTRY_INFO:
IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.getOneById(itemInfoDto.getId()).getData();
IndustryApplicationInfo industryApplicationInfo = industryApplicationInfoBiz.getOneById(itemInfoDto.getId().intValue()).getData();
if (industryApplicationInfo != null) {
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(industryApplicationInfo.getId());
itemInfoVo.setId(Long.valueOf(industryApplicationInfo.getId()));
itemInfoVo.setDetailJson(JSONObject.toJSONString(industryApplicationInfo));
itemInfoVo.setImg(industryApplicationInfo.getCoverImg());
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setType(itemInfoDto.getType());
itemInfoVo.setPrice(industryApplicationInfo.getPrice());
itemInfoVo.setName(industryApplicationInfo.getTitle());
itemInfoVoList.add(itemInfoVo);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
......@@ -90,18 +91,19 @@ public class ConfirmOrderService {
case IMAGE_STORAGE:
ImageInfoRelation imageInfoRelation = imageInfoRelationBiz.selectById(itemInfoDto.getId());
if (imageInfoRelation != null ) {
ImageImgStorage imageImgStorage = imageImgStorageBiz.getDetail(itemInfoDto.getId()).getData();
ImageImgStorage imageImgStorage = imageImgStorageBiz.getDetail(itemInfoDto.getId().intValue()).getData();
if (imageImgStorage != null) {
List<ImageInfoRelation> imageInfoRelationList = new ArrayList<>();
imageInfoRelationList.add(imageInfoRelation);
imageImgStorage.setImageInfoRelationList(imageInfoRelationList);
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(imageImgStorage.getId());
itemInfoVo.setId(Long.valueOf(imageImgStorage.getId()));
itemInfoVo.setPrice(imageInfoRelation.getPrice());
itemInfoVo.setType(itemInfoDto.getType());
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setImg(imageImgStorage.getCoverImg());
itemInfoVo.setDetailJson(JSONObject.toJSONString(imageImgStorage));
itemInfoVo.setName(imageImgStorage.getName());
itemInfoVoList.add(itemInfoVo);
//总数量
number.updateAndGet(v -> v + itemInfoDto.getNumber());
......@@ -115,12 +117,13 @@ public class ConfirmOrderService {
ShoppingCartInfo shoppingCartInfo = shoppingCartInfoBiz.selectById(itemInfoDto.getId());
if (shoppingCartInfo != null) {
ItemInfoVo itemInfoVo = new ItemInfoVo();
itemInfoVo.setId(shoppingCartInfo.getCartId().intValue());
itemInfoVo.setId(shoppingCartInfo.getCartId());
itemInfoVo.setPrice(shoppingCartInfo.getPrice());
itemInfoVo.setType(shoppingCartInfo.getType());
itemInfoVo.setNumber(itemInfoDto.getNumber());
itemInfoVo.setImg(shoppingCartInfo.getItemPic());
itemInfoVo.setDetailJson(shoppingCartInfo.getDetailJson());
itemInfoVo.setName(shoppingCartInfo.getName());
itemInfoVoList.add(itemInfoVo);
number.updateAndGet(v -> v + itemInfoDto.getNumber());
BigDecimal totalAmount = shoppingCartInfo.getTotalAmount();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment