Commit fd1e5130 authored by 周健威's avatar 周健威

修改代码

parent 48c34b34
package com.github.wxiaoqi.security.common.biz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.Page;
......@@ -12,6 +13,7 @@ import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.ReflectionUtils;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.Fn;
......@@ -51,6 +53,24 @@ public abstract class BaseBiz<M extends Mapper<T>, T> {
return mapper.selectByPrimaryKey(id);
}
public int selectCountByWeekend(Function<WeekendSqls<T>, WeekendSqls<T>> where) {
WeekendSqls whereSqls = where.apply(WeekendSqls.<T>custom());
Example.Builder builder = new Example.Builder(entityClass)
.where(whereSqls);
Example example = builder.build();
return mapper.selectCountByExample(example);
}
public void logicDelByWeekendSelective(Function<WeekendSqls<T>, WeekendSqls<T>> where) {
WeekendSqls whereSqls = where.apply(WeekendSqls.<T>custom());
Example.Builder builder = new Example.Builder(entityClass)
.where(whereSqls);
Example example = builder.build();
Map<String, Object> map = CollUtil.newHashMap();
map.put("isDel", 1);
mapper.updateByExampleSelective(BeanUtil.mapToBean(map, entityClass, Boolean.TRUE), example);
}
public void updateByWeekendSelective(T target, Function<WeekendSqls<T>, WeekendSqls<T>> where) {
WeekendSqls whereSqls = where.apply(WeekendSqls.<T>custom());
Example.Builder builder = new Example.Builder(entityClass)
......
......@@ -13,6 +13,10 @@ public class RscpImageStatistics implements java.io.Serializable {
/** 版本号 */
private static final long serialVersionUID = 678376971319983494L;
public static final int TYPE_ALL = 1;
public static final int TYPE_SEVEN = 2;
public static final int TYPE_YEAR = 3;
/* This code was generated by TableGo tools, mark 1 begin. */
/** id标识 */
......@@ -20,7 +24,7 @@ public class RscpImageStatistics implements java.io.Serializable {
private String id;
/** 统计类型 1--全部;2--最近七天 */
@ApiModelProperty(value = "统计类型 1--全部;2--最近七天")
@ApiModelProperty(value = "统计类型 1--全部;2--最近七天; 3--年份")
private Integer type;
/** 统计条件 */
......
......@@ -29,4 +29,6 @@ public class ImageTotalInputDTO extends RscpImageDataTotal {
//rangeJson
private String rangeJson;
private Long id;
}
......@@ -14,4 +14,6 @@ public class BgImageQueryDTO extends PageParam {
String name;
String imageSatelliteType;
BigDecimal resolution;
String startDateTime;
String endDateTime;
}
\ No newline at end of file
package com.upyuns.platform.rs.datacenter.vo;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import java.math.BigDecimal;
......@@ -108,4 +109,18 @@ public class ImageInputVO {
//供应商
private String supplier;
//几何范围
String range;
public void clearBracket(){
if(StrUtil.isNotBlank(this.getImageSpectrumType())) {
this.setImageSpectrumType(this.getImageSpectrumType()
.replace("{", "").replace("}", ""));
}
if(StrUtil.isNotBlank(this.getImageSpectrumTypeDisplay())) {
this.setImageSpectrumTypeDisplay(this.getImageSpectrumTypeDisplay()
.replace("{", "").replace("}", ""));
}
}
}
......@@ -35,7 +35,7 @@ public class RscpAreaImageTotalBiz extends BaseBiz<RscpAreaImageTotalMapper, Rsc
return mapper.queryDataList(dto);
}
public void bbb(ImageTotalInputDTO dto) {
public void inStorageAreaDeal(ImageTotalInputDTO dto) {
// 第二步:判断是否已有区域影像信息,存在则删除
//areaImageTotalManagement.deleteAreaImageTotalByDataId(imageDataId);
......@@ -48,7 +48,7 @@ public class RscpAreaImageTotalBiz extends BaseBiz<RscpAreaImageTotalMapper, Rsc
// String geometryJson = areaInfoManagement.getGeometryJsonByWkt(imageData.getRange());
// postgis查询区域交集
List<RscpAreaInfo> imageAreaInfoList = rscpAreaInfoMapper.getIntersectAreaInfo(dto.getRange());
List<RscpAreaInfo> imageAreaInfoList = rscpAreaInfoMapper.getIntersectAreaInfo(dto.getLeftTopLon(), dto.getLeftTopLat(), dto.getLeftBottomLon(), dto.getLeftBottomLat(), dto.getRightBottomLon(), dto.getRightBottomLat(), dto.getRightTopLon(), dto.getRightTopLat());
if (CollUtil.isNotEmpty(imageAreaInfoList)) {
// 第四步:拼接影像所属省、市
......
......@@ -4,32 +4,88 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.upyuns.platform.rs.datacenter.entity.RscpAreaImageTotal;
import com.upyuns.platform.rs.datacenter.entity.RscpAreaInfo;
import com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal;
import com.upyuns.platform.rs.datacenter.entity.RscpImageInputLog;
import com.upyuns.platform.rs.datacenter.mapper.RscpAreaInfoMapper;
import com.upyuns.platform.rs.datacenter.mapper.RscpImageDataTotalMapper;
import com.upyuns.platform.rs.datacenter.pojo.ImageTotalInputDTO;
import com.upyuns.platform.rs.datacenter.pojo.imagedata.BgImageQueryDTO;
import com.upyuns.platform.rs.datacenter.rest.RscpImageDataTotalController;
import com.upyuns.platform.rs.datacenter.vo.ImageInputVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.github.wxiaoqi.security.common.util.process.ResultCode.PARAM_ILLEGAL_CODE;
@Service
@Slf4j
public class RscpImageDataTotalBiz extends BaseBiz<RscpImageDataTotalMapper, RscpImageDataTotal> {
@Autowired
RscpImageInputLogBiz rscpImageInputLogBiz;
@Autowired
RscpImageDataTotalBiz rscpImageDataTotalBiz;
@Autowired
RscpAreaImageTotalBiz rscpAreaImageTotalBiz;
@Autowired
RscpAreaInfoMapper rscpAreaInfoMapper;
public void inStorage(ImageInputVO ii) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.execute(() -> {
try {
//查询数据是否存在
RscpImageDataTotal rscpImageDataTotal = rscpImageDataTotalBiz.selectOne(new RscpImageDataTotal(){{
setName(ii.getName());
}});
ImageTotalInputDTO imageTotalInputDTO = BeanUtil.toBean(ii, ImageTotalInputDTO.class);
if(null != rscpImageDataTotal) {
//更新
BeanUtil.copyProperties(ii, rscpImageDataTotal);
// rscpImageDataTotal.setImageResolution(null);
rscpImageDataTotalBiz.updateSelectiveById(rscpImageDataTotal);
}else {
rscpImageDataTotal = BeanUtil.toBean(ii, RscpImageDataTotal.class);
rscpImageDataTotalBiz.insertSelective(rscpImageDataTotal);
RscpImageDataTotal finalRscpImageDataTotal = rscpImageDataTotal;
rscpImageDataTotalBiz.updateSelectiveById(new RscpImageDataTotal(){{
setId(finalRscpImageDataTotal.getId());
setDataId(finalRscpImageDataTotal.getId());
}});
}
imageTotalInputDTO.setId(rscpImageDataTotal.getId());
//更新几何范围
updateGeom(imageTotalInputDTO);
//更新地区信息
rscpAreaImageTotalBiz.inStorageAreaDeal(imageTotalInputDTO);
}catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
});
}
public List<RscpImageDataTotal> queryDataList(RscpImageDataTotalController.QueryDTO dto) {
return mapper.queryDataList(dto);
}
......@@ -66,14 +122,18 @@ public class RscpImageDataTotalBiz extends BaseBiz<RscpImageDataTotalMapper, Rsc
// String param = StrUtil.format("MULTIPOLYGON((({} {} ,{} {} , {} {} ,#{rightTopLon} #{rightTopLat}, #{leftTopLon} #{leftTopLat})))");
return mapper.getBinNameByGId(dto.getLeftTopLon(), dto.getLeftTopLat(), dto.getLeftBottomLon(), dto.getLeftBottomLat(), dto.getRightBottomLon(), dto.getRightBottomLat(), dto.getRightTopLon(), dto.getRightTopLat());
}
public Integer updateGeom(ImageTotalInputDTO dto){
return mapper.updateGeom(dto.getLeftTopLon(), dto.getLeftTopLat(), dto.getLeftBottomLon(), dto.getLeftBottomLat(), dto.getRightBottomLon(), dto.getRightBottomLat(), dto.getRightTopLon(), dto.getRightTopLat(), dto.getId());
}
public String geoJsonByRange(String rangeMeta){
return mapper.geoJsonByRange(rangeMeta);
}
public void aaa(ImageInputVO vo) {
ImageTotalInputDTO dto = BeanUtil.toBean(vo, ImageTotalInputDTO.class);
// RscpImageDataTotal rscpImageDataTotal = BeanUtil.toBean(vo, RscpImageDataTotal.class);
dto.setRange(getBinNameByGId(dto));
List<RscpAreaInfo> imageAreaInfoList = rscpAreaInfoMapper.getIntersectAreaInfo(dto.getRange());
// dto.setRange(getBinNameByGId(dto));
List<RscpAreaInfo> imageAreaInfoList = rscpAreaInfoMapper.getIntersectAreaInfo(dto.getLeftTopLon(), dto.getLeftTopLat(), dto.getLeftBottomLon(), dto.getLeftBottomLat(), dto.getRightBottomLon(), dto.getRightBottomLat(), dto.getRightTopLon(), dto.getRightTopLat());
}
}
package com.upyuns.platform.rs.datacenter.job;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.upyuns.platform.rs.datacenter.biz.RscpImageDataTotalBiz;
import com.upyuns.platform.rs.datacenter.biz.RscpImagePriceBiz;
import com.upyuns.platform.rs.datacenter.biz.RscpImageStatisticsBiz;
import com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal;
import com.upyuns.platform.rs.datacenter.entity.RscpImagePrice;
import com.upyuns.platform.rs.datacenter.entity.RscpImageStatistics;
import com.upyuns.platform.rs.datacenter.pojo.imagedata.BgImageQueryDTO;
import com.upyuns.platform.rs.datacenter.rest.RscpImagePriceController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
//@Configuration //1.主要用于标记配置类,兼备Component的效果。
//@EnableScheduling // 2.开启定时任务
//@Slf4j
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_FALSE;
import static com.github.wxiaoqi.security.common.constant.CommonConstants.SYS_TRUE;
@Configuration //1.主要用于标记配置类,兼备Component的效果。
@EnableScheduling // 2.开启定时任务
@Slf4j
public class SaticScheduleTask {
// //3.添加定时任务
// @Scheduled(cron = "0/5 * * * * ?")
// //或直接指定时间间隔,例如:5秒
// //@Scheduled(fixedRate=5000)
// public void configureTasks() {
// //查询是否有线上并且代发货的订单
// //log.info("执行静态定时任务时间: " + LocalDateTime.now());
// }
@Autowired
RscpImagePriceBiz rscpImagePriceBiz;
@Autowired
RscpImageDataTotalBiz rscpImageDataTotalBiz;
@Autowired
RscpImageStatisticsBiz rscpImageStatisticsBiz;
//定时统计影像数量
@Scheduled(cron = "0 0 1 * * ?")
//或直接指定时间间隔,例如:5秒
//@Scheduled(fixedRate=5000)
public void configureTasks() {
//定时统计数据
//查询卫星列表
List<RscpImagePrice> list = rscpImagePriceBiz.selectByWeekend(w -> {
w.andEqualTo(RscpImagePrice::getStatus, SYS_TRUE);
w.andEqualTo(RscpImagePrice::getIsDel, SYS_FALSE);
return w;
}, " daily_sort asc");
List<String> satelliteTypes = list.stream().map(RscpImagePrice::getImageSatelliteType).distinct().collect(Collectors.toList());
int sort = 0;
for(String satelliteType : satelliteTypes) {
sort = sort+1;
//逻辑删除已有的
rscpImageStatisticsBiz.logicDelByWeekendSelective(w ->{
w.andEqualTo(RscpImageStatistics::getName, satelliteType);
return w;
}
);
//统计最近七天数据
String start = DateUtil.beginOfDay(DateUtil.offsetDay(DateUtil.date(), -7)).toString();
String end = DateUtil.endOfDay(DateUtil.offsetDay(DateUtil.date(), -1)).toString();
Integer count7 = rscpImageDataTotalBiz.selectCountByWeekend(w-> {
w.andGreaterThanOrEqualTo(RscpImageDataTotal::getImageTakeTime, start);
w.andLessThanOrEqualTo(RscpImageDataTotal::getImageTakeTime, end);
w.andEqualTo(RscpImageDataTotal::getImageSatelliteType, satelliteType);
return w;
});
//添加
insertPart(sort, satelliteType, count7, RscpImageStatistics.TYPE_SEVEN);
//统计全部
Integer countAll = rscpImageDataTotalBiz.selectCountByWeekend(w-> {
w.andEqualTo(RscpImageDataTotal::getImageSatelliteType, satelliteType);
return w;
});
//添加
insertPart(sort, satelliteType, countAll, RscpImageStatistics.TYPE_ALL);
//统计年份
//获取最近三年
for(int i = 0; i < 3; i++) {
String yearStr = DateUtil.offset(DateUtil.date(), DateField.YEAR, -i).year()+"";
yearInsert(yearStr, satelliteType, sort);
}
}
}
private void insertPart(int sort, String satelliteType, Integer countAll, int type) {
RscpImageStatistics rscpImageStatisticsAll = new RscpImageStatistics();
rscpImageStatisticsAll.setName(satelliteType);
rscpImageStatisticsAll.setNum(countAll);
rscpImageStatisticsAll.setSort(sort);
rscpImageStatisticsAll.setType(type);
rscpImageStatisticsBiz.insertSelective(rscpImageStatisticsAll);
}
private void yearInsert(String year, String satelliteType, Integer sort) {
Integer countYear = rscpImageDataTotalBiz.selectCountByWeekend(w-> {
w.andEqualTo(RscpImageDataTotal::getImageSatelliteType, satelliteType);
w.andEqualTo(RscpImageDataTotal::getImageYear, year);
return w;
});
//添加
insertPart(sort, satelliteType, countYear, RscpImageStatistics.TYPE_YEAR);
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.upyuns.platform.rs.datacenter.entity.RscpImagePrice;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -14,8 +15,9 @@ public interface RscpAreaInfoMapper extends Mapper<RscpAreaInfo> {
public List<RscpAreaInfo> getDirectSubAreas(String parentId);
@Select("select adminCode,proadcode,cityadcode,name,cityname,proname from rscm_area_info where st_intersects(geom, #{range})")
public List<RscpAreaInfo> getIntersectAreaInfo(String range);
@Select("select adminCode,proadcode,cityadcode,name,cityname,proname from rscp_area_info where st_intersects(geom" +
", st_GeomFromText('MULTIPOLYGON(((${leftTopLon} ${leftTopLat} ,${leftBottomLon} ${leftBottomLat} , ${rightBottomLon} ${rightBottomLat} ,${rightTopLon} ${rightTopLat}, ${leftTopLon} ${leftTopLat})))',4326))")
public List<RscpAreaInfo> getIntersectAreaInfo(BigDecimal leftTopLon, BigDecimal leftTopLat, BigDecimal leftBottomLon, BigDecimal leftBottomLat, BigDecimal rightBottomLon, BigDecimal rightBottomLat, BigDecimal rightTopLon, BigDecimal rightTopLat);
@Select(" select t1.proadcode,string_agg(t1.adminCode, ',') as admin_code_ary,"
+ " string_agg(t1.is_cover, ',') as is_cover_ary,string_agg(t1.image_area, ',') as image_area_ary "
......
......@@ -5,6 +5,7 @@ import com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal;
import com.upyuns.platform.rs.datacenter.pojo.imagedata.BgImageQueryDTO;
import com.upyuns.platform.rs.datacenter.rest.RscpImageDataTotalController;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.RequestParam;
import tk.mybatis.mapper.common.Mapper;
......@@ -46,4 +47,7 @@ public interface RscpImageDataTotalMapper extends Mapper<RscpImageDataTotal> {
@Select("SELECT st_GeomFromText('MULTIPOLYGON(((${leftTopLon} ${leftTopLat} ,${leftBottomLon} ${leftBottomLat} , ${rightBottomLon} ${rightBottomLat} ,${rightTopLon} ${rightTopLat}, ${leftTopLon} ${leftTopLat})))',4326)")
String getBinNameByGId(BigDecimal leftTopLon, BigDecimal leftTopLat, BigDecimal leftBottomLon, BigDecimal leftBottomLat, BigDecimal rightBottomLon, BigDecimal rightBottomLat, BigDecimal rightTopLon, BigDecimal rightTopLat);
@Update("update rscp_image_data_total set range = st_GeomFromText('MULTIPOLYGON(((${leftTopLon} ${leftTopLat} ,${leftBottomLon} ${leftBottomLat} , ${rightBottomLon} ${rightBottomLat} ,${rightTopLon} ${rightTopLat}, ${leftTopLon} ${leftTopLat})))',4326) where id = #{id}")
Integer updateGeom(BigDecimal leftTopLon, BigDecimal leftTopLat, BigDecimal leftBottomLon, BigDecimal leftBottomLat, BigDecimal rightBottomLon, BigDecimal rightBottomLat, BigDecimal rightTopLon, BigDecimal rightTopLat, Long id);
}
\ No newline at end of file
......@@ -4,10 +4,12 @@ package com.upyuns.platform.rs.datacenter.mqhandler;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.rabbitmq.client.Channel;
import com.upyuns.platform.rs.datacenter.biz.RscpAreaImageTotalBiz;
import com.upyuns.platform.rs.datacenter.biz.RscpImageDataTotalBiz;
import com.upyuns.platform.rs.datacenter.biz.RscpImageInputLogBiz;
import com.upyuns.platform.rs.datacenter.entity.RscpImageDataTotal;
import com.upyuns.platform.rs.datacenter.entity.RscpImageInputLog;
import com.upyuns.platform.rs.datacenter.pojo.ImageTotalInputDTO;
import com.upyuns.platform.rs.datacenter.vo.ImageInputVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
......@@ -34,6 +36,9 @@ public class ImageInputLogMQHandler {
@Autowired
RscpImageDataTotalBiz rscpImageDataTotalBiz;
@Autowired
RscpAreaImageTotalBiz rscpAreaImageTotalBiz;
/**
* 同步门店信息
* @param
......@@ -47,36 +52,17 @@ public class ImageInputLogMQHandler {
String messageId = message.getMessageProperties().getMessageId();
String msg = new String(message.getBody(), "UTF-8");
ImageInputVO ii = JSONUtil.toBean(msg, ImageInputVO.class);
ii.clearBracket();
RscpImageInputLog insertLog = new RscpImageInputLog(){{
setContextJson(JSONUtil.toJsonStr(ii));
setStatus(STATU_ING);
}};
rscpImageInputLogBiz.insertSelective(insertLog);
rscpImageDataTotalBiz.inStorage(ii);
executorService.shutdown();
Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
// 手动签收
channel.basicAck(deliveryTag, false);
ExecutorService executorService2 = Executors.newCachedThreadPool();
executorService2.execute(() -> {
try {
//查询数据是否存在
Long count = rscpImageDataTotalBiz.selectCount(new RscpImageDataTotal(){{
setName(ii.getName());
}});
// ImageTotalInputDTO imageTotalInputDTO = BeanUtil.toBean(ii, ImageTotalInputDTO.class);
// //生成几何范围
if(count > 0L) {
//更新
}
}catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
}
});
} catch (Exception e) {
log.info("接收到的消息失败");
try {
......
......@@ -63,8 +63,10 @@ public class RscpImageDataTotalController extends BaseController<RscpImageDataTo
@RequestMapping(value = "/app/unauth/aaa", method = RequestMethod.GET)
@IgnoreUserToken
public ObjectRestResponse unauthAaaa(PageParam pageParam) {
ImageInputVO vo = JSONUtil.toBean("{\"rightTopLon\":87.33106598951404,\"leftBottomLon\":87.26891697286784,\"imageCloudage\":0.18,\"imageSensorType\":\"micro\",\"imageWidthInPixels\":5001,\"imageSpectrumTypeDisplay\":\"{全色,多光谱}\",\"imageSatelliteTypeDisplay\":\"newsat8\",\"supplier\":\"Satellogic\",\"imageSensorId\":\"micro\",\"imageProductTime\":\"2020-09-14 04:42:05\",\"leftTopLat\":44.022589860423246,\"imageResolution\":[1,1],\"rightBottomLon\":87.33106598951404,\"imageStartTime\":\"2020-09-14 04:42:05\",\"imageCenterTime\":\"2020-09-14 04:42:05\",\"imageProjection\":\"WGS-84\",\"imageFilePath\":\"/rscloudmart/data/sateLLogic/20201220/20200914_044205_SN8_L1_Changji-China/20200914_044205_SN8_L1_Changji-China.zip\",\"imageSpectrumType\":\"{QS,DGP}\",\"imageSatelliteType\":\"newsat8\",\"imageSceneId\":\"newsat8_micro_L1_radiance_dca17df4-754d-4f02-ac65-3de4bfc66254_0_11_0\",\"imageCenterPointLon\":87.29999148119094,\"imageTakeTime\":\"2020-09-14 04:42:05\",\"leftTopLon\":87.26891697286784,\"imageEndTime\":\"2020-09-14 04:42:05\",\"rightTopLat\":44.022589860423246,\"leftBottomLat\":43.9774001602467,\"name\":\"20200914_044205_SN8_L1_Changji-China\",\"thumbnailPath\":\"/users/rscloudmart/thumbnail/data/sateLLogic/20201220/20200914_044205_SN8_L1_Changji-China\",\"imageCenterPointLat\":43.99999501033497,\"files\":[\"/20200914_044205_SN8_L1_Metadata.xml\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_800_800.png\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_800_800.jpeg\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_205_205.jpeg\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_98_98.jpeg\"],\"imageProductFormat\":\"TIFF\",\"imageHeightInPixels\":\"5001\",\"rightBottomLat\":43.9774001602467}", ImageInputVO.class);
baseBiz.aaa(vo);
// ImageInputVO vo = JSONUtil.toBean("{\"rightTopLon\":87.33106598951404,\"leftBottomLon\":87.26891697286784,\"imageCloudage\":0.18,\"imageSensorType\":\"micro\",\"imageWidthInPixels\":5001,\"imageSpectrumTypeDisplay\":\"{全色,多光谱}\",\"imageSatelliteTypeDisplay\":\"newsat8\",\"supplier\":\"Satellogic\",\"imageSensorId\":\"micro\",\"imageProductTime\":\"2020-09-14 04:42:05\",\"leftTopLat\":44.022589860423246,\"imageResolution\":[1,1],\"rightBottomLon\":87.33106598951404,\"imageStartTime\":\"2020-09-14 04:42:05\",\"imageCenterTime\":\"2020-09-14 04:42:05\",\"imageProjection\":\"WGS-84\",\"imageFilePath\":\"/rscloudmart/data/sateLLogic/20201220/20200914_044205_SN8_L1_Changji-China/20200914_044205_SN8_L1_Changji-China.zip\",\"imageSpectrumType\":\"{QS,DGP}\",\"imageSatelliteType\":\"newsat8\",\"imageSceneId\":\"newsat8_micro_L1_radiance_dca17df4-754d-4f02-ac65-3de4bfc66254_0_11_0\",\"imageCenterPointLon\":87.29999148119094,\"imageTakeTime\":\"2020-09-14 04:42:05\",\"leftTopLon\":87.26891697286784,\"imageEndTime\":\"2020-09-14 04:42:05\",\"rightTopLat\":44.022589860423246,\"leftBottomLat\":43.9774001602467,\"name\":\"20200914_044205_SN8_L1_Changji-China\",\"thumbnailPath\":\"/users/rscloudmart/thumbnail/data/sateLLogic/20201220/20200914_044205_SN8_L1_Changji-China\",\"imageCenterPointLat\":43.99999501033497,\"files\":[\"/20200914_044205_SN8_L1_Metadata.xml\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_800_800.png\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_800_800.jpeg\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_205_205.jpeg\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_98_98.jpeg\"],\"imageProductFormat\":\"TIFF\",\"imageHeightInPixels\":\"5001\",\"rightBottomLat\":43.9774001602467}", ImageInputVO.class);
ImageInputVO vo = JSONUtil.toBean("{\"files\":[\"/20200914_044205_SN8_L1_Metadata.xml\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_800_800.png\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_800_800.jpeg\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_205_205.jpeg\",\"/20200914_044205_SN8_L1_RGB_Changji-China_showcase_Quicklook_98_98.jpeg\"],\"imageCenterPointLat\":87.2999914811909,\"imageCenterPointLon\":43.999995010329178,\"imageCenterTime\":\"2020-09-14 04:42:05\",\"imageCloudage\":0.18,\"imageEndTime\":\"2020-09-14 04:42:05\",\"imageFilePath\":\"/rscloudmart/data/sateLLogic/20200914/20200914_044205_SN8_L1_Changji-China//20200914_044205_SN8_L1_Changji-China.zip\",\"imageHeightInPixels\":5001,\"imageProductFormat\":\"TIFF\",\"imageProductTime\":\"2020-09-14 04:42:05\",\"imageProjection\":\"WGS-84\",\"imageResolution\":[1,1],\"imageSatelliteType\":\"newsat8\",\"imageSatelliteTypeDisplay\":\"newsat8\",\"imageSceneId\":\"newsat8_micro_L1_radiance_dca17df4-754d-4f02-ac65-3de4bfc66254_0_11_0\",\"imageSensorId\":\"micro\",\"imageSensorType\":\"micro\",\"imageSpectrumType\":\"{QS,DGP}\",\"imageSpectrumTypeDisplay\":\"{全色,多光谱}\",\"imageStartTime\":\"2020-09-14 04:42:05\",\"imageTakeTime\":\"2020-09-14 04:42:05\",\"imageWidthInPixels\":5001,\"leftBottomLat\":87.331065989514,\"leftBottomLon\":44.02258986041743,\"leftTopLat\":87.2689169728678,\"leftTopLon\":44.02258986041743,\"name\":\"20200914_044205_SN8_L1_Changji-China\",\"rightBottomLat\":87.331065989514,\"rightBottomLon\":43.977400160240926,\"rightTopLat\":87.2689169728678,\"rightTopLon\":43.977400160240926,\"supplier\":\"Satellogic\",\"thumbnailPath\":\"/rscloudmart/thumbnail/data/sateLLogic/20200914/20200914_044205_SN8_L1_Changji-China\"}", ImageInputVO.class);
vo.clearBracket();
baseBiz.inStorage(vo);
return ObjectRestResponse.succ();
}
......@@ -202,4 +204,9 @@ public class RscpImageDataTotalController extends BaseController<RscpImageDataTo
String satellite;
List<String> sensors = CollUtil.newArrayList();
}
public static void main(String[] args) {
String str = StrUtil.sub("UPDATE rscp_image_data_total SET name = '20200914_044205_SN8_L1_Changji-China',range = '0106000020E6100000010000000103000000010000000500000067DB7B39E40246409EF388EF35D1554067DB7B39E4024640F471672F30D5554083ABCD721BFD4540F471672F30D5554083ABCD721BFD45409EF388EF35D1554067DB7B39E40246409EF388EF35D15540',thumbnail_path = '/rscloudmart/thumbnail/data/sateLLogic/20200914/20200914_044205_SN8_L1_Changji-China',image_resolution = [1, 1],image_spectrum_type = [{QS, DGP}],image_spectrum_type_display = [{全色, 多光谱}],image_file_path = '/rscloudmart/data/sateLLogic/20200914/20200914_044205_SN8_L1_Changji-China//20200914_044205_SN8_L1_Changji-China.zip',image_projection = ?,image_satellite_type = ?,image_satellite_type_display = ?,image_take_time = ?,image_cloudage = ?,image_sensor_type = ?,files = ?,image_sensor_id = ?,image_scene_id = ?,image_product_format = ?,image_product_time = ?,image_start_time = ?,image_end_time = ?,image_center_time = ?,image_width_in_pixels = ?,image_height_in_pixels = ? WHERE id = ?", 569, 589);
System.out.println(str);
}
}
\ No newline at end of file
......@@ -109,6 +109,15 @@
<if test="resolution != null">
and #{resolution} = any(image_resolution)
</if>
<if test="startDateTime != null">
and image_take_time &gt;= #{startDateTime}
</if>
<if test="endDateTime != null">
and image_take_time &lt;= #{endDateTime}
</if>
<if test="imageSatelliteType != null">
image_satellite_type = #{imageSatelliteType}
</if>
</where>
</select>
......
package com.upyuns.platform.rs.universal.biz;
import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.ServiceHelper;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.Notification;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.upyuns.platform.rs.universal.mapper.MessagePushMapper;
import com.upyuns.platform.rs.universal.constant.PushJumpType;
import com.upyuns.platform.rs.universal.constant.PushSendType;
import com.upyuns.platform.rs.universal.entity.MessagePush;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class JPushBiz extends BaseBiz<MessagePushMapper, MessagePush> {
@Value("${universal.MASTER_SECRET}")
private String MASTER_SECRET;
@Value("${universal.APP_KEY}")
private String APP_KEY;
public static final String ALERT = "Test from API Example - alert";
//推送给所有平台设备
public ObjectRestResponse jpushToAllPlat(String title){
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
PushPayload payload = PushPayload.alertAll(title);
try {
PushResult result = jpushClient.sendPush(payload);
log.debug("\n推送结果:"+result);
return ObjectRestResponse.succ();
} catch (APIConnectionException e) {
// Connection error, should retry later
log.debug("\nConnection error, should retry later"+e);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
} catch (APIRequestException e) {
// Should review the error, and fix the request
log.debug("\nShould review the error, and fix the request"+ e);
log.debug("\nHTTP Status: " + e.getStatus());
log.debug("\nError Code: " + e.getErrorCode());
log.debug("\nError Message: " + e.getErrorMessage());
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
}
}
//推送给所有平台设备
public ObjectRestResponse jpushToAllPlat1(){
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
PushPayload payload = buildPushObject_android_newly_support();
try {
PushResult result = jpushClient.sendPush(payload);
log.debug("\n推送结果:"+result);
return ObjectRestResponse.succ();
} catch (APIConnectionException e) {
// Connection error, should retry later
log.debug("\nConnection error, should retry later"+e);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
} catch (APIRequestException e) {
// Should review the error, and fix the request
log.debug("\nShould review the error, and fix the request"+ e);
log.debug("\nHTTP Status: " + e.getStatus());
log.debug("\nError Code: " + e.getErrorCode());
log.debug("\nError Message: " + e.getErrorMessage());
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
}
}
public static PushPayload buildPushObject_android_newly_support() {
JsonObject inbox = new JsonObject();
inbox.add("line1", new JsonPrimitive("line1 string"));
inbox.add("line2", new JsonPrimitive("line2 string"));
inbox.add("contentTitle", new JsonPrimitive("title string"));
inbox.add("summaryText", new JsonPrimitive("+3 more"));
JsonObject intent = new JsonObject();
intent.add("url", new JsonPrimitive("intent:#Intent;component=com.jiguang.push/com.example.jpushdemo.SettingActivity;end"));
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert("测试通知内容")
.setBigPicPath("https://xxtest.upyuns.com/image/app/oyI48qqcy3m38iCFffFc3UeZLcm1s3.png")
.setBigText("long text")
.setBuilderId(1)
.setCategory("CATEGORY_SOCIAL")
.setInbox(inbox)
.setStyle(3)
.setTitle("测试通知标题")
.setPriority(1)
.setLargeIcon("https://xxtest.upyuns.com/image/admin/stock.jpg")
.setIntent(intent)
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
}
//推送
public ObjectRestResponse jpushToAlias(Integer id,String userIds,String orderNo){
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
PushPayload payload = buildPushObject_android_id(id,userIds,orderNo);
if (payload==null){
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"参数无效");
}
try {
PushResult result = jpushClient.sendPush(payload);
log.debug("\n推送结果:"+result);
return ObjectRestResponse.succ();
} catch (APIConnectionException e) {
// Connection error, should retry later
log.debug("\nConnection error, should retry later"+e);
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
} catch (APIRequestException e) {
// Should review the error, and fix the request
log.debug("\nShould review the error, and fix the request"+ e);
log.debug("\nHTTP Status: " + e.getStatus());
log.debug("\nError Code: " + e.getErrorCode());
log.debug("\nError Message: " + e.getErrorMessage());
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,e.getMessage());
}
}
public PushPayload buildPushObject_android_id(Integer id,String userIds,String orderNo) {
Example example =new Example(MessagePush.class);
example.createCriteria().andEqualTo("id",id).andEqualTo("isDel",0);
MessagePush messagePush=mapper.selectOneByExample(example);
if (messagePush==null||messagePush.getType()==null){
log.info("无有效数据--id=="+id);
return null;
}
Audience audience=Audience.all();
if (messagePush.getType()==2){
if (StringUtils.isBlank(userIds)){
log.info("无有效数据--type=="+messagePush.getType()+"------userId=="+userIds);
return null;
}
audience=Audience.alias(userIds);
}
JsonObject intent = new JsonObject();
if (StringUtils.isNotBlank(messagePush.getIntent())){
intent= getJsonObject(messagePush.getIntent());
}
Map<String, String> extras = new HashMap<String, String>();
extras.put("onclickType",messagePush.getJumpType()+"");
if (StringUtils.isNotBlank(orderNo)){
extras.put("orderNo",orderNo);
}
String urlJson=messagePush.getUrlJson();
String url="";
String title="";
if (StringUtils.isNotBlank(messagePush.getUrlJson())){
JSONObject jsonObject=JSONObject.parseObject(urlJson);
url=jsonObject.getString("url");
title=jsonObject.getString("title");
}
extras.put("url",url);
extras.put("title",title);
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(messagePush.getAlert())
.setBigPicPath(messagePush.getBigPicPath())
.setBigText(messagePush.getBigText())
.setBuilderId(1)
.setCategory("CATEGORY_SOCIAL")
.setInbox(messagePush.getInbox())
.setStyle(messagePush.getStyle())
.setTitle(messagePush.getTitle())
.setPriority(1)
.setIntent(intent)
.addExtras(extras)
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(audience)
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
}
//字符串转JsonObject
public JsonObject getJsonObject(String json){
Gson g = new Gson();
return g.fromJson(json, JsonObject.class);
}
//编辑推送内容
public ObjectRestResponse updMessagePush(MessagePush messagePush){
Integer id= messagePush.getId();
if (id==null){
insertSelective(messagePush);
}else {
updateSelectiveById(messagePush);
}
return ObjectRestResponse.succ();
}
//删除推送内容
public ObjectRestResponse delMessagePush(Integer id){
MessagePush messagePush=new MessagePush();
messagePush.setId(id);
messagePush.setIsDel(1);
updateSelectiveById(messagePush);
return ObjectRestResponse.succ();
}
//获取列表
public ObjectRestResponse getList(Integer page,Integer limit,String title,Integer type){
Example example =new Example(MessagePush.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("isDel",0);
if (StringUtils.isNotBlank(title)){
criteria.andLike("title","%"+title+"%");
}
if (type!=null&&type!=0){
criteria.andEqualTo("type",type);
}
example.setOrderByClause("id desc ");
return ObjectRestResponse.succ(PageDataVO.pageInfo(page, limit, ()->mapper.selectByExample(example)));
}
//获取枚举列表
public List<Map<String,Object>> getSendTypes(){
return PushSendType.getList();
}
//获取枚举列表
public List<Map<String,Object>> getJumpTypes(){
return PushJumpType.getList();
}
}
......@@ -70,9 +70,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
@Value("${universal.url}")
String weixinHost;
@Value("${wx.appid}")
private String wy_appid;
@Value("${wx.appSercet}")
private String wy_secret;
......
package com.upyuns.platform.rs.universal.biz;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.upyuns.platform.rs.universal.utils.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@Service
@Slf4j
public class WeixinService {
/**
* 网页
*/
@Value("${wx.appid}")
private String wy_appid;
@Value("${wx.appSercet}")
private String wy_secret;
public static final String frontSessionKey = "frontWeixKey";
public JSONObject getAccessToken(String code){
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?";
String params = "appid="+wy_appid+"&secret="+wy_secret+"&code="+code+"&grant_type=authorization_code";
String result = HttpRequestUtil.httpGet(url + params);
JSONObject data = JSON.parseObject(result);
return data;
}
public JSONObject getValidateData(String access_token,String openid){
String url = "https://api.weixin.qq.com/sns/auth?access_token=" + access_token + "&openid=" + openid;
String result = HttpRequestUtil.httpGet(url);
JSONObject data = JSON.parseObject(result);
return data;
}
public JSONObject getRefreshToken(String refresh_token){
String url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" + wy_appid + "&grant_type=refresh_token&refresh_token=" + refresh_token;
String result = HttpRequestUtil.httpGet(url);
JSONObject data = JSON.parseObject(result);
return data;
}
public JSONObject getUserInfo(String access_token,String openid){
String url = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid + "&lang=zh_CN";
String result = HttpRequestUtil.httpGet(url);
JSONObject data = JSON.parseObject(result);
return data;
}
public String getAuthorize(String redirec_url){
String oauth_api = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={APPID}&redirect_uri={REDIRECT_URI}&response_type=code&scope={SCOPE}&state={STATE}#wechat_redirect";
oauth_api = oauth_api.replace("{APPID}", wy_appid)
.replace("{REDIRECT_URI}", redirec_url)
.replace("{SCOPE}", "snsapi_base").replace("{STATE}", "state");
log.info("---oauth_api===="+oauth_api);
return oauth_api;
}
//获取缓存
public String getSession(HttpServletRequest request){
try {
HttpSession session = request.getSession();
String frontSessionValue1 = (String) session.getAttribute(frontSessionKey);
log.info("---session获取===="+frontSessionValue1+"---sessionId==="+session.getId());
if (StringUtils.isBlank(frontSessionValue1)) {
return null;
}
String openId = Base64.decodeStr(frontSessionValue1);
return openId;
}catch (Exception e){
log.error(e.getMessage(), e);
return null;
}
}
}
......@@ -3,7 +3,6 @@ package com.upyuns.platform.rs.universal.config;
import com.github.wxiaoqi.security.auth.client.interceptor.ServiceAuthRestInterceptor;
import com.github.wxiaoqi.security.auth.client.interceptor.UserAuthRestInterceptor;
import com.github.wxiaoqi.security.common.handler.GlobalExceptionHandler;
import com.upyuns.platform.rs.universal.interceptor.WeChatH5LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
......@@ -44,10 +43,6 @@ public class WebConfiguration implements WebMvcConfigurer {
return new UserAuthRestInterceptor();
}
@Bean
WeChatH5LoginInterceptor getWeChatH5LoginInterceptor() { return new WeChatH5LoginInterceptor();
}
/**
* 需要用户和服务认证判断的路径
* @return
......
package com.upyuns.platform.rs.universal.controller;
import com.alibaba.druid.util.StringUtils;
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.config.rabbit.RabbitConstant;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.upyuns.platform.rs.universal.biz.MQServiceBiZ;
import com.upyuns.platform.rs.universal.entity.IdInformation;
import com.upyuns.platform.rs.universal.service.CertificationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.task.TaskExecutor;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 实名认证
*/
@RestController
@RequestMapping("certif")
@Slf4j
public class CertificationController {
@Autowired
private CertificationService certificationService;
@Autowired
private UserFeign userFeign;
@Qualifier("applicationTaskExecutor")
@Autowired
private TaskExecutor executor;
@Autowired
private MQServiceBiZ mqServiceBiZ;
private ExecutorService executorService = Executors.newCachedThreadPool();
/**
* 实名认证
* @param idInformation
* @param request
* @return
*/
@PostMapping("/app/certificate")
public ObjectRestResponse certificate(@RequestBody IdInformation idInformation, HttpServletRequest request) {
if (idInformation == null) {
ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA,"无法识别,请重新上传");
}
String token = request.getHeader("Authorization");
log.info("------token======"+token);
if (StringUtils.isEmpty(token)) {
ObjectRestResponse.createFailedResult(ResultCode.RSTOKEN_NULL_CODE,"无法识别,请重新上传");
}
//获得用户信息
ObjectRestResponse<AppUserDTO> appUserDTOObjectRestResponse= userFeign.userDetailByToken(token);
log.info("----用户信息========="+appUserDTOObjectRestResponse.getData());
if (appUserDTOObjectRestResponse==null||appUserDTOObjectRestResponse.getData()==null||appUserDTOObjectRestResponse.getData().getId()==0) {
return ObjectRestResponse.createFailedResult(ResultCode.GET_APPUSER_FAILED_CODE,"无法识别,请重新上传");
}
AppUserDTO appUserDTO = appUserDTOObjectRestResponse.getData();
idInformation.setUserLoginId(appUserDTO.getUserid());
//获取用户认证信息
ObjectRestResponse orr = null;
try {
orr = userFeign.authentication(idInformation.getUserLoginId(), null,null, 0);
} catch (Exception e) {
log.error(e.getMessage(), e);;
}
if (orr==null) {
return ObjectRestResponse.createFailedResult(ResultCode.GET_AUTH_INFO_FAILED_CODE,"无法识别,请重新上传");
}
Integer type = idInformation.getCertificateType();
log.info("----type========="+type);
try {
if (type!=null&&type==0){
ObjectRestResponse<Integer> result = certificationService.certificate(idInformation);
if (result.getRel()) {
CompletableFuture.supplyAsync(()->{
setIntegral(appUserDTO.getUserid(),result.getData());
return null;
},executorService);
// Thread thread = new Thread(new Runnable() {
// @Override
// public void run() {
// setIntegral(appUserDTO.getUserid(),result.getData());
// }
// });
// thread.start();
}
return result ;
}
} catch (Exception e) {
log.error(e.getMessage(), e);;
}
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"无法识别,请重新上传");
}
private void setIntegral(Integer userid, Integer iId){
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", userid);
jsonObject.put("integralRuleCode", "CRETIFICATION");
jsonObject.put("channelId", iId);
//mqServiceBiZ.sendMessage(RabbitConstant.INTEGRAL_TOPIC, RabbitConstant.INTEGRAL_ROUTING_KEY, jsonObject.toJSONString());
}
@GetMapping(value = "/app/unauth/selectByUser")
public IdInformation getOneByUserId(Integer userId) {
return certificationService.getByUser(userId);
}
}
package com.upyuns.platform.rs.universal.controller;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.upyuns.platform.rs.universal.biz.JPushBiz;
import com.upyuns.platform.rs.universal.entity.MessagePush;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 极光推送
*/
@RestController
@RequestMapping("jpush")
@IgnoreUserToken
public class JPushController {
@Autowired
JPushBiz jPushBiz;
@RequestMapping(value = "/app/unauth/all", method = RequestMethod.GET) //匹配的是href中的download请求
public ObjectRestResponse sendSms(@RequestParam("title") String title) throws Exception {
return jPushBiz.jpushToAllPlat(title);
}
@RequestMapping(value = "/app/unauth/alls", method = RequestMethod.GET) //匹配的是href中的download请求
public ObjectRestResponse alls() throws Exception {
return jPushBiz.jpushToAllPlat1();
}
@RequestMapping(value = "/stype", method = RequestMethod.GET)
public ObjectRestResponse stype(@RequestParam(value = "id",defaultValue = "0") Integer id,
@RequestParam(value = "userIds",defaultValue = "") String userIds,
@RequestParam(value = "orderNo",defaultValue = "") String orderNo) throws Exception {
return jPushBiz.jpushToAlias(id,userIds,orderNo);
}
@RequestMapping(value = "/addMessagePush", method = RequestMethod.POST)
public ObjectRestResponse addMessagePush(@RequestBody MessagePush messagePush){
return jPushBiz.updMessagePush(messagePush);
}
@RequestMapping(value = "/udpMessagePush", method = RequestMethod.POST)
public ObjectRestResponse udpMessagePush(@RequestBody MessagePush messagePush){
return jPushBiz.updMessagePush(messagePush);
}
@RequestMapping(value = "/del/{id}", method = RequestMethod.DELETE)
public ObjectRestResponse delMessagePush(@PathVariable Integer id){
return jPushBiz.delMessagePush(id);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ObjectRestResponse getList(@RequestParam(value = "page",defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "10") Integer limit,
@RequestParam(value = "title",defaultValue = "") String title,
@RequestParam(value = "type",defaultValue = "0") Integer type){
return jPushBiz.getList(page,limit,title,type);
}
@RequestMapping(value = "/getOne/{id}", method = RequestMethod.GET)
public ObjectRestResponse getOne(@PathVariable Integer id){
return ObjectRestResponse.succ(jPushBiz.selectById(id));
}
@RequestMapping(value = "/sendTpyes", method = RequestMethod.GET)
public ObjectRestResponse sendTpyes(){
return ObjectRestResponse.succ(jPushBiz.getSendTypes());
}
@RequestMapping(value = "/jumpTpyes", method = RequestMethod.GET)
public ObjectRestResponse jumpTpyes(){
return ObjectRestResponse.succ(jPushBiz.getJumpTypes());
}
}
......@@ -230,18 +230,5 @@ public class UploadController{
@RequestParam(value = "prefix",defaultValue = "summit")String prefix) throws Exception {
return uploadZipService.uploadPictureZip(file,prefix);
}
// @PostMapping(value="/app/unauth/uploadVideo")
// public ObjectRestResponse video(
// @RequestParam("file")MultipartFile file,
// @RequestParam(value = "prefix",defaultValue = "summit")String prefix) throws Exception {
// String filename = file.getOriginalFilename();
// String suffixName = filename.substring(filename.lastIndexOf("."));
// if (!VideoConstant.forms.contains(suffixName)) {
// return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"只能上传MP4格式");
// }
// return ObjectRestResponse.succ(uploadService.uploadVideo(file,prefix));
// }
}
......@@ -7,15 +7,10 @@ import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.UserAgentUtil;
import com.upyuns.platform.rs.universal.biz.OrderPayBiz;
import com.upyuns.platform.rs.universal.biz.WeixinService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* 用户
......@@ -26,36 +21,9 @@ import javax.servlet.http.HttpServletRequest;
@Slf4j
public class UserInfoController {
@Autowired
WeixinService weixinService;
@Autowired
OrderPayBiz orderPayBiz;
@Value("${wx.sendUrl}")
private String sendUrl;
@RequestMapping(value = "getOpenId", method = RequestMethod.GET) //匹配的是href中的download请求
public ObjectRestResponse getOpenId(HttpServletRequest request) throws Exception {
boolean isWx = UserAgentUtil.isWexinBrowser(request);
if (isWx) {
//session里面获取用户信息
String openId=weixinService.getSession(request);
log.info("---进入方法getOpenId----openId===="+openId);
if (StringUtils.isBlank(openId)){
JSONObject json = new JSONObject();
json.put("sendUrl",sendUrl);
return ObjectRestResponse.createFailedResultWithObj(1001,"",json);
}
return ObjectRestResponse.succ(openId);
}
return ObjectRestResponse.succ();
}
@GetMapping("/app/unauth/getAliPayUserInfo")
public ObjectRestResponse<String> getAliPayUserInfo(String code) {
try {
......
package com.upyuns.platform.rs.universal.controller;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.upyuns.platform.rs.universal.biz.WeixinService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.mockito.internal.util.collections.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* @author Administrator
*/
@Controller
@RequestMapping("/auth")
@Slf4j
public class WeixinController {
public static final String WECHAT_AUTOLOGIN_CALLBACKURL_KEY = "callback";
public static final String frontSessionKey = "frontWeixKey";
@Autowired
WeixinService weixinService;
@Value("${wx.url}")
private String url;
@RequestMapping(value ="/app/unauth/wxLogin",method = RequestMethod.GET)
@IgnoreUserToken
public String wxLogin(@RequestParam(value = "redirec_url")String redirec_url){
log.info("-----微信wxLogin---redirec_url=="+redirec_url);
if (StringUtils.isBlank(redirec_url)){
redirec_url="";
}
try {
String encrypt_curr_url = Base64.encode(redirec_url.getBytes("utf-8"));
redirec_url=url+"?" + WECHAT_AUTOLOGIN_CALLBACKURL_KEY+ "=" + encrypt_curr_url;
String oauth_api=weixinService.getAuthorize(redirec_url);
return String.format("redirect:"+oauth_api);
}catch (Exception e){
log.error(e.getMessage(), e);
log.info("网络异常===" + e.getMessage());
return String.format("网络异常");
}
}
/**
* 微信浏览器获取用户信息
* @param code
* @param callback
* @return
*/
@GetMapping(value = "/app/unauth/userInfo")
public String getUserInformation(String code, String callback, HttpServletRequest request) {
log.info("-----微信回调userInfo---code=="+code+"----redirec_url==="+callback);
try {
authUser(code,request);
callback =new String(Base64.decode(callback), "utf-8");
log.info("callback===" + callback);
}catch (Exception e){
log.error(e.getMessage(), e);
log.info("网络异常===" + e.getMessage());
}
return String.format("redirect:"+callback);
}
public void authUser(String code,HttpServletRequest request){
if (StringUtils.isBlank(code)){
log.info("----code为空---");
throw new BaseException(ResultCode.FAILED_CODE, Sets.newSet("code为空"));
}
String openid = null;
String access_token = null;
try {
JSONObject jsonData = weixinService.getAccessToken(code);
openid = jsonData.getString("openid");
access_token = jsonData.getString("access_token");
String refresh_token = jsonData.getString("refresh_token");
log.info("-----微信回调userInfo---openid=="+openid+"----access_token==="+access_token);
//验证access_token是否失效
JSONObject validateData = weixinService.getValidateData(access_token, openid);
if (!"0".equals(validateData.getString("errcode"))){
//刷新access_token
JSONObject refreshData= weixinService.getRefreshToken(refresh_token);
access_token = refreshData.getString("access_token");
}
String encode = Base64.encode(openid);
HttpSession session = request.getSession();
session.removeAttribute(frontSessionKey);
session.setAttribute(frontSessionKey, encode);
}catch (Exception e){
log.error(e.getMessage(), e);
log.info("网络异常===" + e.getMessage());
throw new BaseException(ResultCode.FAILED_CODE, Sets.newSet("网络异常"));
}
}
}
package com.upyuns.platform.rs.universal.interceptor;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.util.UserAgentUtil;
import com.upyuns.platform.rs.universal.biz.WeixinService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* 微信登陆拦截器
*
* @author
*
*/
@Slf4j
public class WeChatH5LoginInterceptor extends HandlerInterceptorAdapter {
@Value("${wx.sendUrl}")
private String sendUrl;
@Autowired
WeixinService weixinService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String curr_domain = request.getServerName();
log.info("curr_domain:" + curr_domain);
log.info("address:" + request.getRequestURL().toString());
log.info("params:" + request.getQueryString());
boolean isWx = UserAgentUtil.isWexinBrowser(request);
if (isWx) {
//session里面获取用户信息
String openId=weixinService.getSession(request);
if (StringUtils.isNotBlank(openId)){
return true;
}
Map<String,Object> result=new HashMap<>();
result.put("status",1001);
JSONObject json = new JSONObject();
json.put("sendUrl",sendUrl);
result.put("data",json);
response.getWriter().write(result.toString());
return false;
}
return true;
}
}
package com.upyuns.platform.rs.universal.service;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.upyuns.platform.rs.universal.service.PictureParsing.UserPictureParsing;
import com.upyuns.platform.rs.universal.service.authenticationInterface.UserAuthentication;
import com.upyuns.platform.rs.universal.biz.UserMessage;
import com.upyuns.platform.rs.universal.entity.IDCardInformation;
import com.upyuns.platform.rs.universal.entity.IdInformation;
import com.upyuns.platform.rs.universal.mapper.IdInformationMapper;
import com.upyuns.platform.rs.universal.utils.CertifHttpUtils;
import com.upyuns.platform.rs.universal.utils.Validation;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 认证业务
*
* @author Administrator
*/
@Service
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class CertificationService {
@Value("${certification.frequency:2}")
private Integer FREQUENCY;
@Autowired
private UserAuthentication authentication;
@Autowired
private IdInformationMapper idInformationMapper;
@Autowired
private UserFeign userFeign;
@Autowired
private ApplicationContext applicationContext;
@Autowired
private UserPictureParsing userPictureParsing;
private String AUTHENTICATION_TYPE="100";
/**
* 一、身份证图片进行实名认证
*
* @param idInformation
* @return
*/
public ObjectRestResponse<Integer> certificate(IdInformation idInformation) {
//1.认证前数据判断
//判断是否bean是否为null
if (idInformation == null) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "无法识别,请重新上传");
}
//判断是否有填写身份证号
if (StringUtils.isBlank(idInformation.getIdNumber())) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请填写证件号");
}
if (!Validation.isIdCard(idInformation.getIdNumber())) {
return ObjectRestResponse.createFailedResult(ResultCode.WRONG_FORMAT_OF_ID_CARD, "证件格式错误");
}
//判断是有否填写名字
if (StringUtils.isBlank(idInformation.getName())) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请填写姓名");
}
//判断是否有正面照片
if (StringUtils.isBlank(idInformation.getFrontUrl())) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请上传正面照");
}
//判断是否有背面照片
if (StringUtils.isBlank(idInformation.getBackUrl())) {
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "请上传背面照");
}
//2.解析
IDCardInformation credentialsData = userPictureParsing.analysis(idInformation.getFrontUrl(), idInformation.getBackUrl());
//验证证件信息是否和填入的客户信息一致
String name = credentialsData.getName();
String number = credentialsData.getCode();
if (!idInformation.getName().replaceAll(" ","").equals(name)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "姓名不一致");
}
if (!idInformation.getIdNumber().replaceAll(" ","").equals(number)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致");
}
//判断是否超过认证次数
Example exa = new Example(IdInformation.class);
exa.createCriteria().andEqualTo("idNumber", number);
List<IdInformation> idInformatics = idInformationMapper.selectByExample(exa);
//3.验证
boolean result = authentication.certificate(new UserMessage() {{
setIdNumber(number);
setName(name);
}});
log.info("----认证结果result=========" + result);
//认证返回的参数是否为空
if (result) {
//认证成功后存入保存到数据库
//获得身份证正面记录的身份证号和真实姓名
//设置姓名
idInformation.setName(name);
//设置身份证号
idInformation.setIdNumber(number);
//获得到期时间
String endDate = credentialsData.getExpiryDate();
log.info("----获得到期时间endDate=========" + endDate);
if (StringUtils.isBlank(endDate)) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "图片识别失败,请重新上传");
}
Date expirationDate = new Date();
if (!Validation.isDate(endDate)) {
Date date = new Date();
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.YEAR, 100);
expirationDate = c.getTime();
} else {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
formatter.setLenient(false);
try {
expirationDate = formatter.parse(endDate);
} catch (ParseException e) {
log.error(e.getMessage(), e);
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "无法识别,请重新上传");
}
}
idInformation.setExpirationDate(expirationDate);
CertificationService cs = applicationContext.getBean(this.getClass());
return cs.addIdInformation(idInformation);
}
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "网络异常,请稍后再试");
}
/**
* 二、认证通过保存到数据库当中
*
* @param idInformation
* @return
*/
@Transactional(rollbackFor = Exception.class)
public ObjectRestResponse<Integer> addIdInformation(IdInformation idInformation) {
log.info("----idInformation=========" + idInformation);
//保存认证信息
try {
idInformationMapper.insertSelective(idInformation);
log.info("----addIdInformation---userid===" + idInformation.getUserLoginId() + "----name====" + idInformation.getName() + "---IdNumber===" + idInformation.getIdNumber());
//认证成功后修改用户,用户认证状态
userFeign.authentication(idInformation.getUserLoginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
return ObjectRestResponse.succ(idInformation.getId());
} catch (Exception e) {
log.error(e.getMessage(), e);
TransactionAspectSupport.currentTransactionStatus();
return ObjectRestResponse.createFailedResult(ResultCode.INCOMPLETE_DATA, "无法识别,请重新上传");
}
}
public IdInformation getByUser(Integer userId) {
return idInformationMapper.selectByUserId(userId);
}
}
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