1、创建一个maven项目erp
2、在这个erp目录下创建eureka-server注册中心
配置文件
3、最外的erp配置文件pom.xml,依赖
org.springframework.boot
spring-boot-starter-parent
2.1.5.RELEASE
1.8
Greenwich.SR1
2.1.5
5.1.46
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
tk.mybatis
mapper-spring-boot-starter
${mapper.starter.version}
mysql
mysql-connector-java
${mysql.version}
org.springframework.cloud
spring-cloud-starter-config
org.projectlombok
lombok
org.springframework.boot
spring-boot-maven-plugin
4、eureka-server配置中心pom.xml依赖
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
5、创建eureka注册中心启动类
com.erp.EurekaServerApplication.java
package com.erp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
//声明当前应用时Eureka服务
@EnableEurekaServer
@SpringBootApplication
@EnableDiscoveryClient //开启Eureka客户端发现功能
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
6、创建application.yml配置文件
server:
port: 8080
spring:
application:
name: eureka-server
eureka:
client:
service-url:
# eureka 服务地址,如果是集群的话;需要指定其它集群eureka地址
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
# 不注册自己
register-with-eureka: false
# 不拉取服务
fetch-registry: false
server:
# 服务失效剔除时间间隔,默认60秒
eviction-interval-timer-in-ms: 60000
# 关闭自我保护模式(默认是打开的)
enable-self-preservation: false
Long sj = System.currentTimeMillis();//时间戳
Long mingt = System.currentTimeMillis() + (1000 * 60 * 60 * 24); //第二天
转日期
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = dateformat.format(sj);
long userid = Integer.parseInt(pindex_id);
List
User user = userService.findById(userid);
List
if(!"".equals(searchMap.get("region")) || searchMap.get("region")!=null){
}
//判断相等
if(map.get("typa_butler").equals(1)){
}
if(searchMap.get("typa").equals("2")){
strs = "2";
}
List userMay = userService.listAll(userAll);
userMay.size()
var sj = parseInt(datesa[i].date);//转数字
function timestampToTime(timestamp) {
var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
var D = date.getDate() + ' ';
var h = date.getHours() + ':';
var m = date.getMinutes() + ':';
var s = date.getSeconds();
return Y + M + D + h + m + s;
}
/**
* 获得12个月时间戳
* */
public List getMonthStr() throws Exception {
List list = new ArrayList();
Long sj = System.currentTimeMillis();//时间戳
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy");
String dateStr = dateformat.format(sj);
for (int i=1;i<=12;i++){
List li = new ArrayList();
li.add(dateStr+"-"+i);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String mydate = dateStr+"-"+i;
Date datetime = sdf.parse(mydate);//将你的日期转换为时间戳
Long time = datetime.getTime();
time = time/1000;
li.add(time);
list.add(li);
}
return list;
}
Map map = new HashMap<>();
map.putIfAbsent("checked",true);
map.putIfAbsent("zhankai",true);
String merchantNo = pay.get(0).get("merchantNo").toString();
String mno = merchantNo.substring(merchantNo.length()-6);
@RequestMapping(value = "/orderGoodsAdd",method = RequestMethod.POST)
public static String getIpAddress(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
/**
* 报事报修和投诉建议查询接口
* */
@GetMapping("/houseid")
public Result houseid(@RequestParam Map searchMap){
String houseid = searchMap.get("houseid").toString();
String strs = null;
if(searchMap.get("typa").equals("1")){
strs = "typa<6 and (typa_butler=1 or typa_butler=4)";
}
if(searchMap.get("typa").equals("2")){
strs = "typa>=6 and (typa_butler=1 or typa_butler=4)";
}
List list = repairService.listHouseid(houseid,strs);
for(int i=0;i map = (HashMap) list.get(i);
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date;
if(map.get("typa_butler").equals(1)){
Long sj = Long.valueOf(map.get("date").toString());
date = dateformat.format(sj);
}else{
String sjs = map.get("date")+"000";
Long sj = Long.valueOf(sjs);
date = dateformat.format(sj);
}
map.put("date",date);
list.set(i,map);
}
return new Result(true,StatusCode.OK,"查询成功",list);
}