Commit 359e994097e991a170b0a5d23d745bae84e7d23f
1 parent
4563017575
Exists in
master
and in
6 other branches
体重营养配置
Showing 4 changed files with 288 additions and 13 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
- platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java
- platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java
- platform-dal/src/main/java/com/lyms/platform/pojo/WeightManageConfigModel.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
View file @
359e994
... | ... | @@ -23,6 +23,10 @@ |
23 | 23 | import com.lyms.platform.pojo.*; |
24 | 24 | import com.lyms.platform.query.*; |
25 | 25 | import com.qiniu.util.Json; |
26 | +import jxl.Cell; | |
27 | +import jxl.Sheet; | |
28 | +import jxl.Workbook; | |
29 | +import jxl.read.biff.BiffException; | |
26 | 30 | import org.apache.commons.codec.binary.Base64; |
27 | 31 | import org.apache.commons.httpclient.HttpClient; |
28 | 32 | import org.apache.commons.httpclient.NameValuePair; |
29 | 33 | |
30 | 34 | |
31 | 35 | |
32 | 36 | |
33 | 37 | |
34 | 38 | |
... | ... | @@ -785,27 +789,82 @@ |
785 | 789 | } |
786 | 790 | |
787 | 791 | |
788 | - public static void weightMange() | |
792 | + public static void weightMange(String fileName) | |
789 | 793 | { |
794 | + | |
795 | + WeightManageConfigModel model = new WeightManageConfigModel(); | |
796 | + File file = new File(fileName); | |
797 | + Workbook wb = null; | |
790 | 798 | try { |
791 | - List<String> list = FileUtils.readLines(new File("F:\\体重与营养管理1.csv")); | |
792 | - for (String line : list) { | |
793 | - if (line != null) { | |
794 | - String[] array = line.split(","); | |
795 | - System.out.println(array.length); | |
796 | - for (int i = 0; i < array.length ;i++ ) | |
797 | - { | |
798 | - System.out.println("--->"+array[i]); | |
799 | + wb = Workbook.getWorkbook(file); | |
800 | + Sheet[] sheets = wb.getSheets(); | |
801 | + | |
802 | + for(Sheet s : sheets){ | |
803 | + System.out.println(s.getName() + " : "); | |
804 | + int rows = s.getRows(); | |
805 | + if(rows > 0){ | |
806 | + //遍历每行 | |
807 | + for(int i = 1 ;i < rows ; i++){ | |
808 | + Cell[] cells = s.getRow(i); | |
809 | + if(cells.length > 0){ | |
810 | + //遍历每行中的每列 | |
811 | + for (int j = 0 ; j < cells.length ; j ++) | |
812 | + { | |
813 | + String str = cells[j].getContents().trim(); | |
814 | + switch (j) | |
815 | + { | |
816 | + case 0: | |
817 | + model.setWeek(str); | |
818 | + case 1: | |
819 | + model.setExample(str); | |
820 | + case 2: | |
821 | + model.setBreakfast(str); | |
822 | + case 3: | |
823 | + model.setBreakfastAdd(str); | |
824 | + case 4: | |
825 | + model.setLunch(str); | |
826 | + case 5: | |
827 | + model.setLunchAdd(str); | |
828 | + case 6: | |
829 | + model.setDinner(str); | |
830 | + case 7: | |
831 | + model.setDinnerAdd(str); | |
832 | + case 8: | |
833 | + model.setVegetable(str); | |
834 | + case 9 : | |
835 | + model.setFoodMaterial(str); | |
836 | + case 10: | |
837 | + List<String> list = Arrays.asList(str.split("\n")); | |
838 | + model.setMakeMethod(list); | |
839 | + case 11: | |
840 | + model.setWeightType(str); | |
841 | + case 12: | |
842 | + List<String> list1 = Arrays.asList(str.split("\n")); | |
843 | + model.setSuggests(list1); | |
844 | + } | |
845 | + } | |
846 | + | |
847 | + } | |
799 | 848 | } |
800 | 849 | } |
801 | 850 | } |
851 | + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); | |
852 | + MongoTemplate mongoTemplate | |
853 | + = (MongoTemplate) applicationContext.getBean("mongoTemplate"); | |
854 | + mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray()); | |
855 | + | |
856 | + mongoTemplate.save(model); | |
857 | + System.out.println(model); | |
802 | 858 | } catch (IOException e) { |
803 | 859 | e.printStackTrace(); |
860 | + } catch (BiffException e) { | |
861 | + e.printStackTrace(); | |
804 | 862 | } |
863 | + | |
805 | 864 | } |
806 | 865 | |
807 | 866 | public static void main(String[] args) { |
808 | - weightMange(); | |
867 | + weightMange("F:\\1.xls"); | |
809 | 868 | } |
810 | 869 | |
811 | 870 | public static void addBaby(ApplicationContext applicationContext) { |
platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java
View file @
359e994
... | ... | @@ -3,14 +3,15 @@ |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.IOException; |
5 | 5 | import java.io.OutputStream; |
6 | -import java.util.Iterator; | |
7 | -import java.util.List; | |
8 | -import java.util.Map; | |
6 | +import java.util.*; | |
9 | 7 | |
10 | 8 | |
9 | +import jxl.Cell; | |
10 | +import jxl.Sheet; | |
11 | 11 | import jxl.Workbook; |
12 | 12 | import jxl.format.Colour; |
13 | 13 | import jxl.format.UnderlineStyle; |
14 | +import jxl.read.biff.BiffException; | |
14 | 15 | import jxl.write.Label; |
15 | 16 | import jxl.write.WritableCellFormat; |
16 | 17 | import jxl.write.WritableFont; |
17 | 18 | |
... | ... | @@ -191,7 +192,54 @@ |
191 | 192 | return out; |
192 | 193 | } |
193 | 194 | |
195 | + public static void readExcl(String fileName) | |
196 | + { | |
197 | + File file = new File(fileName); | |
198 | + Workbook wb = null; | |
199 | + try { | |
200 | + wb = Workbook.getWorkbook(file); | |
201 | + Sheet[] sheets = wb.getSheets(); | |
194 | 202 | |
203 | + for(Sheet s : sheets){ | |
204 | + System.out.println(s.getName() + " : "); | |
205 | + int rows = s.getRows(); | |
206 | + if(rows > 0){ | |
207 | + //遍历每行 | |
208 | + for(int i = 1 ;i < rows ; i++){ | |
209 | + Cell[] cells = s.getRow(i); | |
210 | + if(cells.length > 0){ | |
211 | + //遍历每行中的每列 | |
212 | + for (int j = 0 ; j < cells.length ; j ++) | |
213 | + { | |
214 | + String str = cells[j].getContents().trim(); | |
215 | + if (j == 10 || j == 12) | |
216 | + { | |
217 | + List<String> list = Arrays.asList(str.split("\n")); | |
218 | + System.out.println(j+"=content="+list); | |
219 | + } | |
220 | + else | |
221 | + { | |
222 | + System.out.println(j+"=content="+str); | |
223 | + } | |
224 | + | |
225 | + } | |
226 | + | |
227 | + } | |
228 | + } | |
229 | + } | |
230 | + } | |
231 | + | |
232 | + } catch (IOException e) { | |
233 | + e.printStackTrace(); | |
234 | + } catch (BiffException e) { | |
235 | + e.printStackTrace(); | |
236 | + } | |
237 | + | |
238 | + } | |
239 | + | |
240 | + public static void main(String[] args) { | |
241 | + ExcelUtil.readExcl("F:\\1.xls"); | |
242 | + } | |
195 | 243 | |
196 | 244 | } |
platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java
View file @
359e994
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | public enum SerialIdEnum { |
7 | 7 | AntenatalExaminationModel("AntenatalExaminationModel", 97531000010L), |
8 | 8 | AntExChuModel("AntExChuModel", 97531000020L), |
9 | + WeightManageConfigModel("WeightManageConfigModel", 97534000020L), | |
9 | 10 | OperateLogModel("OperateLogModel", 97531000121L), |
10 | 11 | AntExRecordModel("AntExRecordModel", 97531000030L), |
11 | 12 | ArchiveData("ArchiveData", 97531000040L), |
platform-dal/src/main/java/com/lyms/platform/pojo/WeightManageConfigModel.java
View file @
359e994
1 | +package com.lyms.platform.pojo; | |
2 | + | |
3 | +import com.lyms.platform.beans.SerialIdEnum; | |
4 | +import com.lyms.platform.common.result.BaseModel; | |
5 | +import org.springframework.data.mongodb.core.mapping.Document; | |
6 | + | |
7 | +import java.util.Date; | |
8 | +import java.util.LinkedHashMap; | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | + | |
12 | +/** | |
13 | + * 体重营养管理基础配置数据模型 | |
14 | + * | |
15 | + */ | |
16 | +@Document(collection = "lyms_weight_config") | |
17 | +public class WeightManageConfigModel extends BaseModel { | |
18 | + | |
19 | + private static final long serialVersionUID = SerialIdEnum.WeightManageConfigModel.getCid(); | |
20 | + private String id; | |
21 | + private String week;//孕周 | |
22 | + private String example;//营养食谱举例 | |
23 | + private String breakfast;//早餐 | |
24 | + private String breakfastAdd;//上午加餐 | |
25 | + private String lunch;//午餐 | |
26 | + private String lunchAdd;//下午加餐 | |
27 | + private String dinner;//晚餐 | |
28 | + private String dinnerAdd;//晚加餐 | |
29 | + | |
30 | + private String vegetable;//菜名称 | |
31 | + private String foodMaterial; //食材 | |
32 | + private List<String> makeMethod;//制作方法 | |
33 | + private String weightType;//体重类型 | |
34 | + private List<String> suggests;//建议 | |
35 | + | |
36 | + public String getId() { | |
37 | + return id; | |
38 | + } | |
39 | + | |
40 | + public void setId(String id) { | |
41 | + this.id = id; | |
42 | + } | |
43 | + | |
44 | + public String getWeek() { | |
45 | + return week; | |
46 | + } | |
47 | + | |
48 | + public void setWeek(String week) { | |
49 | + this.week = week; | |
50 | + } | |
51 | + | |
52 | + public String getExample() { | |
53 | + return example; | |
54 | + } | |
55 | + | |
56 | + public void setExample(String example) { | |
57 | + this.example = example; | |
58 | + } | |
59 | + | |
60 | + public String getBreakfast() { | |
61 | + return breakfast; | |
62 | + } | |
63 | + | |
64 | + public void setBreakfast(String breakfast) { | |
65 | + this.breakfast = breakfast; | |
66 | + } | |
67 | + | |
68 | + public String getBreakfastAdd() { | |
69 | + return breakfastAdd; | |
70 | + } | |
71 | + | |
72 | + public void setBreakfastAdd(String breakfastAdd) { | |
73 | + this.breakfastAdd = breakfastAdd; | |
74 | + } | |
75 | + | |
76 | + public String getLunch() { | |
77 | + return lunch; | |
78 | + } | |
79 | + | |
80 | + public void setLunch(String lunch) { | |
81 | + this.lunch = lunch; | |
82 | + } | |
83 | + | |
84 | + public String getLunchAdd() { | |
85 | + return lunchAdd; | |
86 | + } | |
87 | + | |
88 | + public void setLunchAdd(String lunchAdd) { | |
89 | + this.lunchAdd = lunchAdd; | |
90 | + } | |
91 | + | |
92 | + public String getDinner() { | |
93 | + return dinner; | |
94 | + } | |
95 | + | |
96 | + public void setDinner(String dinner) { | |
97 | + this.dinner = dinner; | |
98 | + } | |
99 | + | |
100 | + public String getDinnerAdd() { | |
101 | + return dinnerAdd; | |
102 | + } | |
103 | + | |
104 | + public void setDinnerAdd(String dinnerAdd) { | |
105 | + this.dinnerAdd = dinnerAdd; | |
106 | + } | |
107 | + | |
108 | + public String getVegetable() { | |
109 | + return vegetable; | |
110 | + } | |
111 | + | |
112 | + public void setVegetable(String vegetable) { | |
113 | + this.vegetable = vegetable; | |
114 | + } | |
115 | + | |
116 | + public String getFoodMaterial() { | |
117 | + return foodMaterial; | |
118 | + } | |
119 | + | |
120 | + public void setFoodMaterial(String foodMaterial) { | |
121 | + this.foodMaterial = foodMaterial; | |
122 | + } | |
123 | + | |
124 | + public List<String> getMakeMethod() { | |
125 | + return makeMethod; | |
126 | + } | |
127 | + | |
128 | + public void setMakeMethod(List<String> makeMethod) { | |
129 | + this.makeMethod = makeMethod; | |
130 | + } | |
131 | + | |
132 | + public String getWeightType() { | |
133 | + return weightType; | |
134 | + } | |
135 | + | |
136 | + public void setWeightType(String weightType) { | |
137 | + this.weightType = weightType; | |
138 | + } | |
139 | + | |
140 | + public List<String> getSuggests() { | |
141 | + return suggests; | |
142 | + } | |
143 | + | |
144 | + public void setSuggests(List<String> suggests) { | |
145 | + this.suggests = suggests; | |
146 | + } | |
147 | + | |
148 | + @Override | |
149 | + public String toString() { | |
150 | + return "WeightManageConfigModel{" + | |
151 | + "id='" + id + '\'' + | |
152 | + ", week='" + week + '\'' + | |
153 | + ", example='" + example + '\'' + | |
154 | + ", breakfast='" + breakfast + '\'' + | |
155 | + ", breakfastAdd='" + breakfastAdd + '\'' + | |
156 | + ", lunch='" + lunch + '\'' + | |
157 | + ", lunchAdd='" + lunchAdd + '\'' + | |
158 | + ", dinner='" + dinner + '\'' + | |
159 | + ", dinnerAdd='" + dinnerAdd + '\'' + | |
160 | + ", vegetable='" + vegetable + '\'' + | |
161 | + ", foodMaterial=" + foodMaterial + | |
162 | + ", makeMethod=" + makeMethod + | |
163 | + ", weightType='" + weightType + '\'' + | |
164 | + ", suggests='" + suggests + '\'' + | |
165 | + '}'; | |
166 | + } | |
167 | +} |