





<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency>
package tw.com.xxx.analysis; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication @EnableSwagger2 public class AnalysisApplication { public static void main(String[] args) { SpringApplication.run(AnalysisApplication.class, args); } }
No.
|
與系統共舞的方法
|
說明
|
1
|
跟上系統的節拍
|
如果可以的話,找出系統的實際資料,並繪製出 time graph。去了解系統的行為,別相信人們的記憶,因為那是不可靠的
|
2
|
把你的心智模式攤開在陽光下
|
你知道的任何事情,與每個人知道的每件事情,都只是個 model。將你的 model 攤開來,邀請別人來挑戰你的假設,與挑戰別人的假設。正所謂真理越辯越明,謹慎分析假設,透過證據來驗證,若未通過驗證就將其揚棄
|
3
|
相信、尊重並分享資訊
|
大部分出錯的系統,都是因為錯誤 (biased)、延遲 (delay) 與缺乏 (missing) 的資訊。若你想改善系統的運作,試著讓資訊更即時 (timely)、更精確 (accurate)、更完整 (complete),你將會收到令你驚訝的成效
|
4
|
謹慎地使用語言,並用系統的概念去豐富語言
|
尊重資訊代表避免語言汙染 (language pollution, 即用最清楚的語言避免誤解),這樣才能討論複雜系統的問題。
|
5
|
關注重要的,而不只是容易衡量的
|
若因為某些事物難以量化,就假裝它不存在,會導致 faulty models。若以此態度來設定目標,就導致僅考量容易量化的事物,而非重要的的事物此系統陷阱 (seeking the wrong goals)
|
6
|
為反饋系統制定帶有反饋功能的政策
|
建立新的 feedback loops 來解決系統問題,例如若美國能協助墨西哥改善經濟,而非花錢建築圍牆、增派軍警巡邏,非法移民的問題就能解決
|
7
|
追求整體利益
|
組織的層級架構 (hierarchies) 的存在是用來服務 bottom layers 而非 top layers。不要過度放大某個部分或子系統的利益,卻忽略了整體系統的利益
|
8
|
聆聽系統的智慧
|
先傾聽系統現況 (即 hierarchy 底部有哪些力量與結構維持現有系統),再思考改善方法
|
9
|
界定系統的職責
|
內在責任是指系統設計用來針對決策結果產生的回饋,對於決策者是最直接的。例如開 A380 的機師,坐在駕駛艙內,將最直接經歷其所做的決策所產生的後果。
|
10
|
保持謙遜,做一名學習者
|
當你遇到不懂的事物時,不需要虛張聲勢、不需要呆住,去學習就是了,透過實驗與試誤法 (trial and error) 不斷地學習,並且堅持到底 (stay the course)
|
11
|
慶祝複雜性
|
這個世界就是一團亂、非線性、突然地改變與動態的。其產生了多樣性與一致性,讓我們所處的世界既有趣、又美麗
|
12
|
擴展時間的範圍
|
當你走在難以應付、蜿蜒、未知、未預期與荊棘遍佈的道路,傻子都只是頭低低的往前走,你應該看清楚前方的道路後再往前邁進。你需要關注整體的系統狀態,包含短期與長期
|
13
|
打破各種清規戒律
|
讓跨領域的人聚在一起、互相討論、共同解決一個真實問題,彼此間必須坦承先前忽略了什麼、樂意被教導。
|
14
|
擴大關切的範圍
|
在真實系統,元素間是互相相連的,例如:當人體的肺部失能時,心臟無法持續跳動;當你個員工表現低落,企業是無法成功的;當全球環境崩壞,全球經濟是無法達到預期目標的
|
15
|
不要降低「善」的標準
|
降低標準 (drift to low performance) 是系統最具破壞性的典型的例子,這也是在現代工業化的文化中最常見的 -- 不斷降低善的標準。不要過度重視壞消息,將標準設為不可改變的絕對值。
|
package test.util; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import org.apache.commons.io.FilenameUtils; import org.springframework.stereotype.Component; import lombok.extern.slf4j.Slf4j; @Slf4j @Component public class ImageUtils { /** * Magnify image * * @param oFile * original file * @param times * magnification times * @param mFile * magnified image * @throws IOException */ public void magnifyImage(File oFile, Integer times, File mFile) throws IOException { try { BufferedImage originalImage = ImageIO.read(oFile); int width = originalImage.getWidth() * times; int height = originalImage.getHeight() * times; BufferedImage newImage = new BufferedImage(width, height, originalImage.getType()); Graphics g = newImage.getGraphics(); g.drawImage(originalImage, 0, 0, width, height, null); g.dispose(); ImageIO.write(newImage, FilenameUtils.getExtension(mFile.getName()), mFile); log.debug("magnified image successfully to {}", mFile.getAbsolutePath()); } catch (IOException e) { throw new IOException("fail to magnify image", e); } } /** * Shrink image * * @param oFile * original file * @param times * shrink times * @param sFile * shrinked image * @throws IOException */ public void shrinkImage(File oFile, Integer times, File sFile) throws IOException { try { BufferedImage originalImage = ImageIO.read(oFile); int width = originalImage.getWidth() / times; int height = originalImage.getHeight() / times; BufferedImage newImage = new BufferedImage(width, height, originalImage.getType()); Graphics g = newImage.getGraphics(); g.drawImage(originalImage, 0, 0, width, height, null); g.dispose(); ImageIO.write(newImage, FilenameUtils.getExtension(sFile.getName()), sFile); log.debug("shinked image successfully to {}", sFile.getAbsolutePath()); } catch (IOException e) { throw new IOException("fail to shrink image", e); } } }
package test.util; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest public class ImageUtilsTest { private File originalFile = new File("C:\\Users\\user\\Downloads\\originalFile.jpg"); private File shrinkFile = new File("C:\\Users\\user\\Downloads\\shrinkFile.jpg"); private File magnificationFile = new File("C:\\Users\\user\\Downloads\\manificationFile.jpg"); @Autowired private ImageUtils imageUtils; @Test public void testShrinkImage() throws IOException { imageUtils.shrinkImage(originalFile, 10, shrinkFile); assertThat(shrinkFile.exists()).isTrue(); } @Test public void testMagnifyImage() throws IOException { imageUtils.magnifyImage(shrinkFile, 2, magnificationFile); assertThat(magnificationFile.exists()).isTrue(); } }