Commit 82fd9ee5 authored by 廖旭伟's avatar 廖旭伟

临时改为无须注册服务

parent 24ab5575
......@@ -30,9 +30,7 @@
<profiles.kafka.brokers>192.168.0.251:9092</profiles.kafka.brokers>
<profiles.rabbitmq.host>192.168.0.98</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.nacos.server-addr>192.168.0.252:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>easy-affair-show</profiles.nacos.namespace>
<profiles.log.path>/mortals/app/logs</profiles.log.path>
</properties>
</profile>
......
......@@ -8,7 +8,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ImportResource;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableFeignClients
@SpringBootApplication(scanBasePackages = {"com.mortals"})
@ServletComponentScan("com.mortals")
@ImportResource(locations = {"classpath:config/spring-config.xml"})
......
......@@ -6,7 +6,6 @@ import java.net.URLDecoder;
import javax.sql.DataSource;
import com.mortals.framework.springcloud.config.mybatis.AbstractMybatisConfiguration;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.io.VFS;
......
package com.mortals.xhx.module.home.model;
import lombok.Data;
@Data
public class MaterialStatisticsVO {
/**
* 图片类型,0:普通图片,1:素材,2:背景图片。默认:0
*/
private Integer pictureType;
private Integer pictureCount;
}
package com.mortals.xhx.module.home.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.util.DateUtils;
import com.mortals.xhx.common.code.EvaluateType;
import com.mortals.xhx.common.code.PictureTypeEnum;
import com.mortals.xhx.common.code.ReplyStatusEnum;
import com.mortals.xhx.module.customer.dao.CustomerDao;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.model.CustomerQuery;
import com.mortals.xhx.module.design.dao.DesignMasterplateDao;
import com.mortals.xhx.module.design.model.DesignMasterplateEntity;
import com.mortals.xhx.module.font.dao.FontMaterialDao;
import com.mortals.xhx.module.font.model.FontMaterialEntity;
import com.mortals.xhx.module.help.dao.HelpDao;
import com.mortals.xhx.module.help.dao.HelpEvaluateDao;
import com.mortals.xhx.module.help.model.HelpEntity;
import com.mortals.xhx.module.help.model.HelpEvaluateEntity;
import com.mortals.xhx.module.home.model.MaterialStatisticsVO;
import com.mortals.xhx.module.picture.dao.PictureMaterialDao;
import com.mortals.xhx.module.proposal.dao.ProposalDao;
import com.mortals.xhx.module.proposal.model.ProposalEntity;
import com.mortals.xhx.module.question.dao.QuestionDao;
import com.mortals.xhx.module.question.model.QuestionEntity;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
@Service
public class HomePageService {
@Autowired
private PictureMaterialDao pictureMaterialDao;
@Autowired
private FontMaterialDao fontMaterialDao;
@Autowired
private DesignMasterplateDao designMasterplateDao;
@Autowired
private QuestionDao questionDao;
@Autowired
private HelpDao helpDao;
@Autowired
private HelpEvaluateDao helpEvaluateDao;
@Autowired
private ProposalDao proposalDao;
@Autowired
private CustomerDao customerDao;
public Map<String, Object> customerStatistics() throws AppException {
List<CustomerEntity> sumList = customerDao.getList(new CustomerEntity());
CustomerQuery query = new CustomerQuery();
query.setCreateTimeStart(DateUtils.addCurrDateToStr("yyyy-MM-dd",-1)+" 00:00:01");
List<CustomerEntity> yesterdayList = customerDao.getList(query);
Map<String, Object> map = new HashMap<>();
Map<Integer,Long> sumMap = sumList.stream().collect(Collectors.groupingBy(CustomerEntity::getMemberLevel,Collectors.counting()));
if(!sumMap.containsKey(1)){
sumMap.put(1,0l);
}
if(!sumMap.containsKey(2)){
sumMap.put(2,0l);
}
if(!sumMap.containsKey(3)){
sumMap.put(3,0l);
}
map.put("customerTotal",sumList.size());
map.put("trialTotal",sumMap.get(1));
map.put("vipTotal",sumMap.get(2));
map.put("designTotal",sumMap.get(3));
if(CollectionUtils.isEmpty(yesterdayList)){
map.put("totalAdd",0);
map.put("totalChange","0.00%");
map.put("trialAdd",0);
map.put("trialChange","0.00%");
map.put("vipAdd",0);
map.put("vipChange","0.00%");
map.put("designAdd",0);
map.put("designChange","0.00%");
}else {
Map<Integer,Long> yMap = yesterdayList.stream().collect(Collectors.groupingBy(CustomerEntity::getMemberLevel,Collectors.counting()));
if(!yMap.containsKey(1)){
yMap.put(1,0l);
}
if(!yMap.containsKey(2)){
yMap.put(2,0l);
}
if(!yMap.containsKey(3)){
yMap.put(3,0l);
}
map.put("totalAdd",yesterdayList.size());
map.put("totalChange",percentage((long)yesterdayList.size(),(long)sumList.size()));
map.put("trialAdd",yMap.get(1));
map.put("trialChange",percentage(yMap.get(1),sumMap.get(1)));
map.put("vipAdd",yMap.get(2));
map.put("vipChange",percentage(yMap.get(2),sumMap.get(2)));
map.put("designAdd",yMap.get(3));
map.put("designChange",percentage(yMap.get(3),sumMap.get(3)));
}
return map;
}
private static String percentage(Long num1,Long num2){
String rate="0.00%";
String format="0.00";
if(num2 != 0 && num1 != 0){
DecimalFormat dec = new DecimalFormat(format);
rate = dec.format((double) num1 / num2 * 100)+"%";
while(true){
if(rate.equals(format+"%")){
format=format+"0";
DecimalFormat dec1 = new DecimalFormat(format);
rate = dec1.format((double) num1 / num2 *100)+"%";
}else {
break;
}
}
}else if(num1 != 0 && num2 == 0){
rate = "100%";
}
return rate;
}
public Map<String,Object> resourceCensus(){
Map<String,Object> result = new HashMap<>();
List<MaterialStatisticsVO> materialStatisticsVOS = pictureMaterialDao.selectPictureCensus();
if(CollectionUtils.isNotEmpty(materialStatisticsVOS)){
materialStatisticsVOS.forEach(e->{
if(e.getPictureType()== PictureTypeEnum.PICTURE.getValue()){
result.put("pictureCount",e.getPictureCount());
}
if(e.getPictureType()== PictureTypeEnum.ELEMENT.getValue()){
result.put("elementCount",e.getPictureCount());
}
if(e.getPictureType()== PictureTypeEnum.BACKGROUND.getValue()){
result.put("backgroundCount",e.getPictureCount());
}
});
}
if(!result.containsKey("pictureCount")){
result.put("pictureCount",0);
}
if(!result.containsKey("elementCount")){
result.put("elementCount",0);
}
if(!result.containsKey("backgroundCount")){
result.put("backgroundCount",0);
}
int fontCount = fontMaterialDao.getCount(new FontMaterialEntity());
result.put("fontCount",fontCount);
int designCount = designMasterplateDao.getCount(new DesignMasterplateEntity());
result.put("masterplate",designCount);
DesignMasterplateEntity query = new DesignMasterplateEntity();
Map<String,String> orderCols = new HashMap<>();
orderCols.put("masterplateUseNum", "DESC");
orderCols.put("createTime", "DESC");
query.setOrderCols(orderCols);
query.setPage(1);
query.setSize(5);
List<DesignMasterplateEntity> list = designMasterplateDao.getList(query,0,5);
result.put("top5",list);
return result;
}
public Map<String,Object> feedbackCensus(){
Map<String,Object> result = new HashMap<>();
int questionCount = questionDao.getCount(new QuestionEntity());
result.put("questionCount",questionCount);
int helpCount = helpDao.getCount(new HelpEntity());
result.put("helpCount",helpCount);
HelpEvaluateEntity hq = new HelpEvaluateEntity();
hq.setEvaluateType(EvaluateType.USEFUL.getValue());
int helpUsefulCount = helpEvaluateDao.getCount(hq);
result.put("helpUseful",percentage((long)helpUsefulCount,(long)helpCount));
hq.setEvaluateType(EvaluateType.USELESS.getValue());
int helpUselessCount = helpEvaluateDao.getCount(hq);
result.put("helpUseless",percentage((long)helpUselessCount,(long)helpCount));
int proposalCount = proposalDao.getCount(new ProposalEntity());
result.put("proposalCount",proposalCount);
ProposalEntity pquery = new ProposalEntity();
pquery.setReplyStatus(ReplyStatusEnum.REPLY.getValue());
int proposalReplyCount = proposalDao.getCount(pquery);
result.put("proposalReplyCount",proposalReplyCount);
return result;
}
public JSONArray creatData(){
JSONArray list = new JSONArray();
Random random = new Random();
random.setSeed(10000L);
int i=0;
while (true){
if(i>=30){
break;
}
String dateTime = DateUtils.addCurrDateToStr("yyyy-MM-dd",(0-i));
JSONObject json = new JSONObject();
json.put("dateTime",dateTime);
json.put("count",random.nextInt(1000));
list.add(json);
i++;
}
return list;
}
public JSONArray creatCustomerData() {
JSONArray list = new JSONArray();
Random random = new Random();
random.setSeed(10000L);
JSONObject json = new JSONObject();
json.put("areaName","成都");
json.put("count",random.nextInt(1000));
list.add(json);
JSONObject json1 = new JSONObject();
json1.put("areaName","眉山");
json1.put("count",random.nextInt(1000));
list.add(json1);
JSONObject json2 = new JSONObject();
json2.put("areaName","绵阳");
json2.put("count",random.nextInt(1000));
list.add(json2);
JSONObject json3 = new JSONObject();
json3.put("areaName","宜宾");
json3.put("count",random.nextInt(1000));
list.add(json3);
JSONObject json4 = new JSONObject();
json4.put("areaName","乐山");
json4.put("count",random.nextInt(1000));
list.add(json4);
JSONObject json5 = new JSONObject();
json5.put("areaName","雅安");
json5.put("count",random.nextInt(1000));
list.add(json5);
return list;
}
}
package com.mortals.xhx.module.home.web;
import com.alibaba.fastjson.JSONArray;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseJsonBodyController;
import com.mortals.xhx.module.customer.service.CustomerService;
import com.mortals.xhx.module.home.service.HomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("home")
public class HomePageController extends BaseJsonBodyController {
@Autowired
private HomePageService homePageService;
@PostMapping({"customer/census"})
@UnAuth
public Rest<Object> customerCensus() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "客流统计";
int code = 1;
try {
Map<String, Object> result = this.homePageService.customerStatistics();
model.put("data", result);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"resource/census"})
@UnAuth
public Rest<Object> resourceCensus() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "资源统计";
int code = 1;
try {
Map<String, Object> result = this.homePageService.resourceCensus();
model.put("data", result);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"feedback/census"})
@UnAuth
public Rest<Object> feedbackCensus() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "反馈统计";
int code = 1;
try {
Map<String, Object> result = this.homePageService.feedbackCensus();
model.put("data", result);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"nearly/login/census"})
@UnAuth
public Rest<Object> nearlyLoginCensus() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "近30日登录人数趋势统计";
int code = 1;
try {
JSONArray list = this.homePageService.creatData();
model.put("data", list);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"nearly/design/census"})
@UnAuth
public Rest<Object> nearlyDesignCensus() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "近30日作品数统计";
int code = 1;
try {
JSONArray list = this.homePageService.creatData();
model.put("data", list);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"customer/distribution"})
@UnAuth
public Rest<Object> customerDistribution() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "客户区域分布统计";
int code = 1;
try {
JSONArray list = this.homePageService.creatCustomerData();
model.put("data", list);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
package com.mortals.xhx.module.picture.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.home.model.MaterialStatisticsVO;
import com.mortals.xhx.module.picture.model.PictureMaterialEntity;
import com.mortals.xhx.module.picture.model.vo.PictureGroupCountVo;
......@@ -19,4 +20,10 @@ public interface PictureMaterialDao extends ICRUDDao<PictureMaterialEntity,Long
* @return
*/
List<PictureGroupCountVo> selectPictureGroupCount(int pictureType);
/**
* 素材统计
* @return
*/
List<MaterialStatisticsVO> selectPictureCensus();
}
package com.mortals.xhx.module.picture.dao.ibatis;
import com.mortals.xhx.module.home.model.MaterialStatisticsVO;
import com.mortals.xhx.module.picture.model.vo.PictureGroupCountVo;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.picture.dao.PictureMaterialDao;
......@@ -22,4 +23,9 @@ public class PictureMaterialDaoImpl extends BaseCRUDDaoMybatis<PictureMaterialEn
public List<PictureGroupCountVo> selectPictureGroupCount(int pictureType) {
return this.getSqlSession().selectList(this.getSqlId("selectPictureGroupCount"),pictureType);
}
@Override
public List<MaterialStatisticsVO> selectPictureCensus() {
return this.getSqlSession().selectList(this.getSqlId("selectPictureCensus"));
}
}
server:
port: 17001
servlet:
context-path: /eas
tomcat:
uri-encoding: utf-8
spring:
......@@ -13,19 +16,27 @@ spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
cloud:
nacos:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
discovery:
server-addr: @profiles.nacos.server-addr@ # Nacos 服务器地址
group: @profiles.nacos.group@
namespace: @profiles.nacos.namespace@
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务器地址
group: ${spring.cloud.nacos.discovery.group}
namespace: ${spring.cloud.nacos.discovery.namespace} # Nacos 命名空间 dev 的编号
file-extension: yaml
security:
enable: true
user:
name: admin
password: 1
redis:
host: 127.0.0.1
port: 6379
database: 6
timeout: 30000
pool:
max-idle: 30
min-idle: 0
max-active: 100
max-wait: 1000
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/yi_zheng_xiu?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong
username: root
password: 12345678
mybatis:
root-path: com.mortals
type-aliases-package: com.mortals.framework.model,com.mortals.xhx.common.**.model,com.mortals.xhx.**.model
......@@ -38,5 +49,12 @@ application:
uncheckUrl: /refresh,/error,/login/login,/login/index,/login/logout,/customer/login/login,/customer/login/logout,/securitycode/createCode,/customer/trial/save,/file/common/*,/file/preview/*,/test*,/api/asset/*,/api/*,/zwfw/*,/ws/*,/swagger-ui*,/topic/*,/uploads/*
workflow:
tenantId: ${spring.application.name}
cookie:
ssoServerUrl: http://sso.testnew.com
key: 026db82420614469897fcc2dc1b4ce38
domain: base.testnew.com
port: 111
token:
head: mortal
upload:
path: /mortals/app/data
......@@ -27,4 +27,14 @@
GROUP BY
p.id,p.paramKey,p.paramValue
</select>
<select id="selectPictureCensus" parameterType="int" resultType="com.mortals.xhx.module.home.model.MaterialStatisticsVO">
SELECT
pictureType,
count(id) AS pictureCount
FROM
mortals_xhx_picture_material
GROUP BY
pictureType
</select>
</mapper>
\ No newline at end of file
......@@ -50,14 +50,14 @@
</dependency>
<!-- 引入 Spring Cloud Alibaba Nacos Config 相关依赖,将 Nacos 作为配置中心,并实现对其的自动配置 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>-->
<!-- </dependency>-->
</dependencies>
......
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