Mysql测试语句

Query: {
	"machine_code": "007",
	"_time": {
		"$gte": "2020-05-10 22:50:12",
		"$lte": "2020-05-14 14:27:33"
	},
	"scheme_code": "0006",
	"param_code": "1#temp"
}, Fields: {}, Sort: {
	"_time": 1
}
	private static void getToken() {
		RestTemplate restTemplate = new RestTemplate();
		HttpHeaders headers = new HttpHeaders();
		headers.setContentType(MediaType.APPLICATION_JSON);
		DataVo rootTokenVo = new DataVo();
		rootTokenVo.setClientId("saber");
		rootTokenVo.setClientSecret("saber_secret");
		rootTokenVo.setUsername("admin");
		rootTokenVo.setPassword("tf888");
		String a = JSONArray.toJSONString(rootTokenVo);
		HttpEntity<String> requestEntity = new HttpEntity(a, headers);
		ResponseEntity<R> re = restTemplate
			.exchange("http://localhost:8080/api/blade-auth/oauth/token",
				HttpMethod.POST, requestEntity, R.class);
		R rootTokenDto = re.getBody();
		System.out.println(rootTokenDto.toString());
	}
 // 链接池数量
    private static final   String connectionsPerHost = "50";
    /**
     * 时间单位:毫秒~~
     * 例:最大等待时间 300000 实际计算等待为:300000/1000=300=5分钟
     */
    // 最大等待时间
    private static final  String maxWaitTime ="300000";
    // scoket超时时间
    private static final  String socketTimeout = "100000";
    // 设置连接池最长生命时间
    private static final  String maxConnectionLifeTime ="150000";
    // 连接超时时间
    private static final String connectTimeout = "25000";

    /**
     * 连接池获取MongoTemplate连接
     * @param serverAddresses
     * @return
     */
    public static MongoTemplate getMongoTemplate(List<ServerAddress> serverAddresses, List<MongoCredential> mongoCredentials,String fileDatabase){
        MongoClientOptions options = MongoClientOptions.builder()
                .connectionsPerHost(Integer.parseInt(connectionsPerHost))
                .maxWaitTime(Integer.parseInt(maxWaitTime))
                .socketTimeout(Integer.parseInt(socketTimeout))
                .maxConnectionLifeTime(Integer.parseInt(maxConnectionLifeTime))
                .connectTimeout(Integer.parseInt(connectTimeout)).build();
        MongoClient mongoClient=new MongoClient(serverAddresses, mongoCredentials,options);
        return new MongoTemplate(new SimpleMongoDbFactory(mongoClient,fileDatabase));
    }

**SELECT
s.tenant_code,
s.job_sheet_no,
s.machine_code,
s.order_sheet_no,
s.process_name,
s.prod_name,
s.color_name,
s.customer_name,
s.real_start_date,
s.real_end_date,
p.param_type,
p.param_code,
p.param_name,
p.real_value,
p.theory_value,
p.value_type,
CASE

	WHEN ( p.real_value != NULL OR p.real_value != '' ) 
	AND ( p.theory_value != NULL OR p.theory_value != '' ) THEN
		ROUND( ( p.real_value - p.theory_value ) / p.theory_value * 100, 2 ) 
		END AS diffValue 
FROM
	job_schedule s,
	job_schedule_params p 
WHERE
	p.parent_id = s.id 
	AND s.real_end_date BETWEEN '2020-04-01 00:00:00' 
	AND '2020-04-21 23:59:59'  and s.job_sheet_no='00412010'
ORDER BY
	s.real_end_date DESC 
LIMIT 0,
10**
db.TF_YR0086.find(
    {
        "$and": [
            {
                "machine_code": "006"
            },
            {
                "_time": {
                    "$gte": "2020-04-19 10:59:10"
                },
                "$and": [{
                    "_time": {
                       "$lte": "2020-04-19 10:59:25"
                    }
                }]
            },
            {
                "param_name": "前速度"
            }
        ]
    }
)

db.TF_YR0086.find(
    {
        "$and": [
            {
                "machine_code": "006"
            },
            {
                "_time": "2020-04-18 05:02:54"
            },
            {
                "param_name": "前速度"
            }
        ]
    }
)
```java
   Properties prop = new Properties();
            prop.setProperty("mail.host", "smtp.qq.com"); //// 设置QQ邮件服务器
            prop.setProperty("mail.transport.protocol", "smtp"); // 邮件发送协议
            prop.setProperty("mail.smtp.auth", "true"); // 需要验证用户名密码
            // 关于QQ邮箱,还要设置SSL加密,加上以下代码即可
            MailSSLSocketFactory sf = new MailSSLSocketFactory();
            sf.setTrustAllHosts(true);
            prop.put("mail.smtp.ssl.enable", "true");
            prop.put("mail.smtp.ssl.socketFactory", sf);
            //使用JavaMail发送邮件的5个步骤
            //创建定义整个应用程序所需的环境信息的 Session 对象
            Session session = Session.getDefaultInstance(prop, new Authenticator() {
                public PasswordAuthentication getPasswordAuthentication() {
                    //发件人邮件用户名、授权码
                    return new PasswordAuthentication("[email protected]", "nvqtlvnkfuqfdjhf");
                }
            });
            //开启Session的debug模式,这样就可以查看到程序发送Email的运行状态
            session.setDebug(true);
            //2、通过session得到transport对象
            Transport ts = session.getTransport();
            //3、使用邮箱的用户名和授权码连上邮件服务器
            ts.connect("smtp.qq.com", "[email protected]", "nvqtlvnkfuqfdjhf");
            //4、创建邮件
            //创建邮件对象
            MimeMessage message = new MimeMessage(session);
            //指明邮件的发件人
            message.setFrom(new InternetAddress("[email protected]"));
            //指明邮件的收件人,现在发件人和收件人是一样的,那就是自己给自己发
            message.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
            //邮件的标题
            message.setSubject("云平台监听异常日志信息推送!");
            //message.setFileName("就是一个测试邮件,莫在意");
            //邮件的文本内容
            message.setContent(
                    "异常账号:admin
\n"
+ "所属服务:tfCloud-dye
\n"
+ "异常类型:debug
\n"
+ "请求类型:GET
\n"
+ "日志异常名称:org.mybatis.spring.MyBatisSystemException
\n"
+ "接口URL名称:/tenant/list
"
, "text/html;charset=UTF-8"); //5、发送邮件 ts.sendMessage(message, message.getAllRecipients()); ts.close();

SELECT
machine_code,
sum( CASE WHEN stop_cause = 0 THEN TRUNCATE ( TIMESTAMPDIFF( MINUTE, start_time, end_time ) / 60, 2 ) ELSE 0 END ) AS ‘sumRunSeconds’,
sum( CASE WHEN stop_cause > 0 THEN TRUNCATE ( TIMESTAMPDIFF( MINUTE, start_time, end_time ) / 60, 2 ) ELSE 0 END ) AS ‘sumStopSeconds’
FROM
m_stop_record
WHERE
date_format( curr_date, ‘%Y-%m-%d’ ) BETWEEN date_format( ‘2020-04-01 00:00:00’, ‘%Y-%m-%d’ )
AND date_format( ‘2020-04-08 23:59:59’, ‘%Y-%m-%d’ )
– AND machine_code = ‘016’
AND tenant_code = ‘YR0086’
GROUP BY
machine_code

SELECT
olddata.machine_code AS ‘machineCode’,
GROUP_CONCAT( olddata.param_type SEPARATOR ‘,’ ) AS ‘energyKinds’,
GROUP_CONCAT( olddata.real_qty SEPARATOR ‘,’ ) AS ‘realQtys’
FROM
(
SELECT
machine_code,
param_type,
real_qty
FROM
tfenergy.e_energy_shift
WHERE
is_deleted = ‘0’
AND machine_code IN ( ‘013’, ‘/’, ‘006’, ‘012’, ‘008’, ‘007’, ‘005’, ‘014’, ‘015’, ‘001’, ‘002’, ‘011’, ‘016’ )
GROUP BY
machine_code,
param_type
HAVING
MAX( curr_date )
) AS olddata
GROUP BY
olddata.machine_code

	Map> listMap = new HashMap<>();
		Map map=new HashMap<>();
		Map map2=new HashMap<>();
		map.put("是","值");
		map.put("李","额");
		map2.put("哦","人");
		map2.put("王","他");
		listMap.put("张三",map);
		listMap.put("李四",map2);
		List collects = (List)listMap.entrySet().stream().map(f -> {
			return new MachineAnalysisDto(f.getKey(), new ArrayList() {{
				this.add(new IndexValueDto(f.getValue().get("currDate"), f.getValue().get("paramValue")));
			}});
		}).collect(Collectors.toList());
		System.out.println(collects.toString());

你可能感兴趣的:(数据库)