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(
                    "<b>異常賬號:admin</b><br>\n" +
                    "<b>所屬服務:tfCloud-dye</b><br>\n" +
                    "<b>異常類型:debug</b><br>\n" +
                    "<b>請求類型:GET</b><br>\n" +
                    "<b>日誌異常名稱:org.mybatis.spring.MyBatisSystemException</b><br>\n" +
                    "<b>接口URL名稱:/tenant/list</b><br>", "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<String, Map<String, String>> listMap = new HashMap<>();
		Map<String,String> map=new HashMap<>();
		Map<String,String> map2=new HashMap<>();
		map.put("是","值");
		map.put("李","額");
		map2.put("哦","人");
		map2.put("王","他");
		listMap.put("張三",map);
		listMap.put("李四",map2);
		List<MachineAnalysisDto> collects = (List<MachineAnalysisDto>)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());
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章