|
|
@@ -0,0 +1,76 @@
|
|
|
+package com.poteviohealth.cgp.statistics.service.impl;
|
|
|
+
|
|
|
+import com.poteviohealth.cgp.common.facade.cache.CacheService;
|
|
|
+import com.poteviohealth.cgp.common.filter.TokenContext;
|
|
|
+import com.poteviohealth.cgp.common.integrated.OperatorIdParams;
|
|
|
+import com.poteviohealth.cgp.common.integrated.partner.PartnerFeignClient;
|
|
|
+import com.poteviohealth.cgp.common.integrated.partner.model.OperatorParamDTO;
|
|
|
+import com.poteviohealth.cgp.common.model.VaultsResponse;
|
|
|
+import com.poteviohealth.cgp.common.service.impl.BaseServiceImpl;
|
|
|
+import com.poteviohealth.cgp.common.utils.CgpTool;
|
|
|
+import com.poteviohealth.cgp.common.utils.DateUtils;
|
|
|
+import com.poteviohealth.cgp.common.utils.ImageUtils;
|
|
|
+import com.poteviohealth.cgp.statistics.mapper.DistinctionMapper;
|
|
|
+import com.poteviohealth.cgp.statistics.model.Distinction;
|
|
|
+import com.poteviohealth.cgp.statistics.service.IDistinctionService;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 图片处理
|
|
|
+ * @author Qin
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Log4j2
|
|
|
+public class DistinctionServiceImpl extends BaseServiceImpl<DistinctionMapper, Distinction> implements IDistinctionService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PartnerFeignClient partnerFeignClient;
|
|
|
+ @Resource
|
|
|
+ private CacheService cacheService;
|
|
|
+ @Value("${sync.dbName}")
|
|
|
+ private String dbName;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long checkImg(InputStream inputStream) {
|
|
|
+
|
|
|
+ if("0".equals(orderCacheVal(CgpTool.CACHE_ORDER_PHOTO_CHECK))){
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer day = Integer.parseInt(orderCacheVal(CgpTool.CACHE_ORDER_PHOTO_DAY));
|
|
|
+ Double threshold = Double.parseDouble(orderCacheVal(CgpTool.CACHE_ORDER_PHOTO_THRESHOLD));
|
|
|
+
|
|
|
+ String uid = ImageUtils.readImagePix(inputStream);
|
|
|
+ Long orderId = baseMapper.checkDis(TokenContext.cureOperatorId(),dbName,uid,ImageUtils.different(threshold),DateUtils.caculDays(new Date(), -day));
|
|
|
+ log.info("orderId==="+orderId);
|
|
|
+ return orderId;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private String orderCacheVal(String key){
|
|
|
+ Integer operatorId = TokenContext.cureOperatorId();
|
|
|
+ String val = cacheService.hget(key+":"+operatorId,operatorId.toString());
|
|
|
+ if(StringUtils.isEmpty(val)){
|
|
|
+ val = this.getParamValue(key);
|
|
|
+ cacheService.hset(key+":"+operatorId,operatorId.toString(),val);
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getParamValue(String key){
|
|
|
+ OperatorIdParams params = new OperatorIdParams();
|
|
|
+ params.setOperatorId(TokenContext.cureOperatorId());
|
|
|
+ params.setCode(key);
|
|
|
+ VaultsResponse<OperatorParamDTO> vaultsResponse = partnerFeignClient.getOperatorParamByCode(params);
|
|
|
+ return vaultsResponse.getData().getParamValue();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|