Commit 2c146447912ddb09d42d2a7377f70662ab75f5bf
1 parent
174cb52119
Exists in
master
and in
6 other branches
系统升级
Showing 6 changed files with 126 additions and 8 deletions
- platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RemoteController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ViewController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ViewFacade.java
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
2c14644
... | ... | @@ -1556,7 +1556,7 @@ |
1556 | 1556 | // int weeks = daysBetween(baby, new Date()) / 7; |
1557 | 1557 | // String weekAge = String.valueOf(weeks); |
1558 | 1558 | |
1559 | - Date baby = parseDate("2018-04-07"); | |
1559 | + Date baby = parseDate("2018-07-15"); | |
1560 | 1560 | System.out.println(baby.getTime()); |
1561 | 1561 | } |
1562 | 1562 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RemoteController.java
View file @
2c14644
... | ... | @@ -159,8 +159,10 @@ |
159 | 159 | if (StringUtils.isNotEmpty(created)) |
160 | 160 | { |
161 | 161 | String[] arr = created.split(" - "); |
162 | - query.setCreatedStart(DateUtil.parseYMD(arr[0])); | |
163 | - query.setCreatedEnd(DateUtil.addDay((DateUtil.parseYMD(arr[1])), 1)); | |
162 | + Date start = DateUtil.parseYMD(arr[0]); | |
163 | + Date end = new Date(DateUtil.parseYMD(arr[1]).getTime() + 24 * 60 * 60 * 1000 - 1); | |
164 | + query.setCreatedStart(start); | |
165 | + query.setCreatedEnd(end); | |
164 | 166 | } |
165 | 167 | |
166 | 168 | query.setNeed("true"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java
View file @
2c14644
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ViewController.java
View file @
2c14644
... | ... | @@ -5,6 +5,7 @@ |
5 | 5 | import com.lyms.platform.common.base.BaseController; |
6 | 6 | import com.lyms.platform.common.base.LoginContext; |
7 | 7 | import com.lyms.platform.common.result.BaseObjectResponse; |
8 | +import com.lyms.platform.common.result.BaseResponse; | |
8 | 9 | import com.lyms.platform.common.utils.StringUtils; |
9 | 10 | import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; |
10 | 11 | import com.lyms.platform.operate.web.facade.MatdeliverFollowFacade; |
... | ... | @@ -12,6 +13,7 @@ |
12 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
13 | 14 | import org.springframework.stereotype.Controller; |
14 | 15 | import org.springframework.web.bind.annotation.*; |
16 | +import org.springframework.web.multipart.MultipartFile; | |
15 | 17 | |
16 | 18 | import javax.servlet.http.HttpServletRequest; |
17 | 19 | import javax.servlet.http.HttpServletResponse; |
... | ... | @@ -830,6 +832,35 @@ |
830 | 832 | return viewFacade.getPatientRiskInfo(cardNo, vcCardNo); |
831 | 833 | } |
832 | 834 | |
835 | + | |
836 | + /** | |
837 | + * 上传升级包 | |
838 | + * @param request | |
839 | + * @param file | |
840 | + * @return | |
841 | + */ | |
842 | + @RequestMapping(value="/uploadUpgradePackage",method=RequestMethod.POST) | |
843 | + @ResponseBody | |
844 | + public BaseResponse uploadUpgradePackage(HttpServletRequest request, | |
845 | + @RequestParam("file") MultipartFile file) { | |
846 | + | |
847 | + return viewFacade.uploadUpgradePackage(file); | |
848 | + | |
849 | + } | |
850 | + | |
851 | + | |
852 | + /** | |
853 | + * 执行升级 | |
854 | + * @param request | |
855 | + * @return | |
856 | + */ | |
857 | + @RequestMapping(value="/executeUpgrade",method=RequestMethod.GET) | |
858 | + @ResponseBody | |
859 | + public BaseResponse executeUpgrade(HttpServletRequest request) { | |
860 | + | |
861 | + return viewFacade.executeUpgrade(); | |
862 | + | |
863 | + } | |
833 | 864 | |
834 | 865 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java
View file @
2c14644
... | ... | @@ -1923,8 +1923,10 @@ |
1923 | 1923 | BabyCheckModelQuery query = new BabyCheckModelQuery(); |
1924 | 1924 | query.setHospitalId(hospitalId); |
1925 | 1925 | query.setYn(YnEnums.YES.getId()); |
1926 | + | |
1927 | + | |
1926 | 1928 | query.setCheckDateStart(currentDay); |
1927 | - query.setCheckDateEnd(currentDay); | |
1929 | + query.setCheckDateEnd(new Date(currentDay.getTime() + 24 * 60 * 60 * 1000 - 1)); | |
1928 | 1930 | |
1929 | 1931 | BabyModelQuery babyQuery = new BabyModelQuery(); |
1930 | 1932 | babyQuery.setYn(YnEnums.YES.getId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ViewFacade.java
View file @
2c14644
... | ... | @@ -7,10 +7,7 @@ |
7 | 7 | import com.lyms.platform.common.result.BaseObjectResponse; |
8 | 8 | import com.lyms.platform.common.result.BaseResponse; |
9 | 9 | import com.lyms.platform.common.result.RespBuilder; |
10 | -import com.lyms.platform.common.utils.DateUtil; | |
11 | -import com.lyms.platform.common.utils.ExceptionUtils; | |
12 | -import com.lyms.platform.common.utils.JsonUtil; | |
13 | -import com.lyms.platform.common.utils.SystemConfig; | |
10 | +import com.lyms.platform.common.utils.*; | |
14 | 11 | import com.lyms.platform.operate.web.request.AntExcAddOther; |
15 | 12 | import com.lyms.platform.operate.web.request.MatDeliverAddRequest; |
16 | 13 | import com.lyms.platform.operate.web.result.*; |
17 | 14 | |
... | ... | @@ -38,7 +35,12 @@ |
38 | 35 | import org.springframework.data.mongodb.core.query.Criteria; |
39 | 36 | import org.springframework.data.mongodb.core.query.Query; |
40 | 37 | import org.springframework.stereotype.Component; |
38 | +import org.springframework.web.multipart.MultipartFile; | |
41 | 39 | |
40 | +import java.io.BufferedReader; | |
41 | +import java.io.File; | |
42 | +import java.io.IOException; | |
43 | +import java.io.InputStreamReader; | |
42 | 44 | import java.math.RoundingMode; |
43 | 45 | import java.text.SimpleDateFormat; |
44 | 46 | import java.util.*; |
... | ... | @@ -5108,6 +5110,86 @@ |
5108 | 5110 | Element colorElement = checkElement.addElement("color"); |
5109 | 5111 | colorElement.addText(riskColor); |
5110 | 5112 | } |
5113 | + } | |
5114 | + | |
5115 | + public BaseResponse uploadUpgradePackage(MultipartFile file) { | |
5116 | + | |
5117 | + //如果文件不为空,写入上传路径 | |
5118 | + BaseObjectResponse objectResponse = new BaseObjectResponse(); | |
5119 | + if(file.isEmpty()) { | |
5120 | + objectResponse.setErrorcode(ErrorCodeConstants.NO_DATA); | |
5121 | + objectResponse.setErrormsg("没有上传数据"); | |
5122 | + return objectResponse; | |
5123 | + } | |
5124 | + try { | |
5125 | + | |
5126 | + String path = System.getProperty("catalina.home")+File.separator+"upgrade"+File.separator+DateUtil.getYmd(new Date()); | |
5127 | + | |
5128 | + String fileName = file.getOriginalFilename(); | |
5129 | + | |
5130 | + System.out.println("path = " + path + ";fileName = " + fileName); | |
5131 | + | |
5132 | + File filepath = new File(path+File.separator,fileName); | |
5133 | + | |
5134 | + //删除当天上传的文件 | |
5135 | + if (filepath.exists()) | |
5136 | + { | |
5137 | + filepath.delete(); | |
5138 | + } | |
5139 | + | |
5140 | + //判断路径是否存在,如果不存在就创建一个 | |
5141 | + if (!filepath.getParentFile().exists()) { | |
5142 | + filepath.getParentFile().mkdirs(); | |
5143 | + } | |
5144 | + file.transferTo(filepath); | |
5145 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
5146 | + objectResponse.setErrormsg("成功"); | |
5147 | + return objectResponse; | |
5148 | + } catch (IOException e) { | |
5149 | + ExceptionUtils.catchException(e,"上传文件发生异常"); | |
5150 | + objectResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); | |
5151 | + objectResponse.setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION); | |
5152 | + return objectResponse; | |
5153 | + } | |
5154 | + } | |
5155 | + | |
5156 | + | |
5157 | + public BaseObjectResponse executeUpgrade(){ | |
5158 | + | |
5159 | + BaseObjectResponse objectResponse = new BaseObjectResponse(); | |
5160 | + | |
5161 | + String path = System.getProperty("catalina.home"); | |
5162 | + Process process = null; | |
5163 | + String command1 = "/bin/sh "+path+"/upgrade.sh "; | |
5164 | + System.out.println(command1); | |
5165 | + try { | |
5166 | + process = Runtime.getRuntime().exec(command1); | |
5167 | + //必须等待该进程结束,否则时间设置就无法生效 | |
5168 | + process.waitFor(); | |
5169 | + | |
5170 | + | |
5171 | + BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
5172 | + StringBuffer sb = new StringBuffer(); | |
5173 | + String line; | |
5174 | + while ((line = br.readLine()) != null) { | |
5175 | + sb.append(line).append("\n"); | |
5176 | + } | |
5177 | + String result = sb.toString(); | |
5178 | + System.out.println(result); | |
5179 | + | |
5180 | + } catch (IOException | InterruptedException e) { | |
5181 | + objectResponse.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); | |
5182 | + objectResponse.setErrormsg(ErrorCodeConstants.SYSTEM_ERROR_DESCRIPTION); | |
5183 | + return objectResponse; | |
5184 | + }finally{ | |
5185 | + if(process!=null){ | |
5186 | + process.destroy(); | |
5187 | + } | |
5188 | + } | |
5189 | + | |
5190 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
5191 | + objectResponse.setErrormsg("成功"); | |
5192 | + return objectResponse; | |
5111 | 5193 | } |
5112 | 5194 | } |