|
@@ -26,8 +26,8 @@ public class Print {
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public static void printDuck(BaseDuckInfo duckInfo, List<DuckHealthInfo> healthInfos,
|
|
|
|
- List<DuckImmunityInfo> immunityInfos, List<EnvMoveCall> envMoveCalls) throws Exception {
|
|
|
|
|
|
+ public static void printDuck(List<PrintEntrty> printEntrties) throws Exception {
|
|
|
|
+
|
|
//准备数据
|
|
//准备数据
|
|
String path = "/opt/guowei/duck.xls";
|
|
String path = "/opt/guowei/duck.xls";
|
|
//获取模板文件,你自己当前模板的位置 我这里为当前项目下
|
|
//获取模板文件,你自己当前模板的位置 我这里为当前项目下
|
|
@@ -36,74 +36,103 @@ public class Print {
|
|
OutputStream os = new FileOutputStream(path);
|
|
OutputStream os = new FileOutputStream(path);
|
|
//绑定数据
|
|
//绑定数据
|
|
Context context = new Context();
|
|
Context context = new Context();
|
|
- context.putVar("duckCode", duckInfo.getDuckNum());
|
|
|
|
- if (duckInfo.getDuckBreed() == 1) {
|
|
|
|
- context.putVar("duckType", "北京鸭");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 2) {
|
|
|
|
- context.putVar("duckType", "连城白鸭");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 3) {
|
|
|
|
- context.putVar("duckType", "山麻鸭");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 4) {
|
|
|
|
- context.putVar("duckType", "攸县麻鸭");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 5) {
|
|
|
|
- context.putVar("duckType", "白改鸭");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 6) {
|
|
|
|
- context.putVar("duckType", "缙云麻鸭");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 7) {
|
|
|
|
- context.putVar("duckType", "绍兴鸭(带圈白翼梢)");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 8) {
|
|
|
|
- context.putVar("duckType", "绍兴鸭(红毛绿翼梢)");
|
|
|
|
- } else if (duckInfo.getDuckBreed() == 9) {
|
|
|
|
- context.putVar("duckType", "绍兴鸭(白羽绍鸭)");
|
|
|
|
- }
|
|
|
|
|
|
+ List<PrintEntrtyVo> list = new ArrayList<>();
|
|
|
|
+ for (PrintEntrty printEntrty : printEntrties) {
|
|
|
|
+ PrintEntrtyVo printEntrtyVo = new PrintEntrtyVo();
|
|
|
|
+ BaseDuckInfo duckInfo = printEntrty.getBaseDuckInfo();
|
|
|
|
+ printEntrtyVo.setDuckCode(duckInfo.getDuckNum());
|
|
|
|
|
|
- if (duckInfo.getDuckSex() == 0) {
|
|
|
|
- context.putVar("duckSex", "雌");
|
|
|
|
- } else {
|
|
|
|
- context.putVar("duckSex", "雄");
|
|
|
|
- }
|
|
|
|
|
|
+ if (duckInfo.getDuckBreed() == 1) {
|
|
|
|
+ printEntrtyVo.setDuckType("北京鸭");
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 2) {
|
|
|
|
+ printEntrtyVo.setDuckType("连城白鸭");
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 3) {
|
|
|
|
+ printEntrtyVo.setDuckType("山麻鸭");
|
|
|
|
+
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 4) {
|
|
|
|
+ printEntrtyVo.setDuckType("攸县麻鸭");
|
|
|
|
+
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 5) {
|
|
|
|
+ printEntrtyVo.setDuckType("白改鸭");
|
|
|
|
+
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 6) {
|
|
|
|
+ printEntrtyVo.setDuckType("缙云麻鸭");
|
|
|
|
+
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 7) {
|
|
|
|
+ printEntrtyVo.setDuckType("绍兴鸭(带圈白翼梢)");
|
|
|
|
+
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 8) {
|
|
|
|
+ printEntrtyVo.setDuckType("绍兴鸭(红毛绿翼梢)");
|
|
|
|
+
|
|
|
|
+ } else if (duckInfo.getDuckBreed() == 9) {
|
|
|
|
+ printEntrtyVo.setDuckType("绍兴鸭(白羽绍鸭)");
|
|
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
- context.putVar("duckDate", sdf.format(duckInfo.getDuckBirthday()));
|
|
|
|
- context.putVar("address", duckInfo.getDuckBirthplace());
|
|
|
|
- context.putVar("father", duckInfo.getFatherNum());
|
|
|
|
- context.putVar("father2", duckInfo.getFatherGenotype());
|
|
|
|
- context.putVar("mother", duckInfo.getMotherNum());
|
|
|
|
- context.putVar("mother2", duckInfo.getMotherGenotype());
|
|
|
|
- String s = "";
|
|
|
|
- String s1 = "";
|
|
|
|
- String s2 = "";
|
|
|
|
- //健康状况
|
|
|
|
- for (DuckHealthInfo healthInfo : healthInfos) {
|
|
|
|
- if ("".equals(healthInfo.getDiseaseName()) || null == healthInfo.getDiseaseName()) {
|
|
|
|
- s1 = sdf.format(healthInfo.getHealthDate()) + "无" + ";" + "\n" + s1;
|
|
|
|
- } else {
|
|
|
|
- s1 = sdf.format(healthInfo.getHealthDate()) +" "+healthInfo.getDiseaseName() + ";" + "\n" + s1;
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //日龄体重
|
|
|
|
- for (EnvMoveCall envMoveCall : envMoveCalls) {
|
|
|
|
- if ("".equals(envMoveCall.getDayage()) || null == envMoveCall.getDayage()) {
|
|
|
|
- s = "0" + "日龄 体重" + ":" + envMoveCall.getDuckWeight() + "KG;" + "\n" + s;
|
|
|
|
|
|
+
|
|
|
|
+ if (duckInfo.getDuckSex() == 0) {
|
|
|
|
+ printEntrtyVo.setDuckDate("雌");
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
- s = envMoveCall.getDayage() + "日龄 体重" + ":" + envMoveCall.getDuckWeight() + "KG;" + "\n" + s;
|
|
|
|
|
|
+ printEntrtyVo.setDuckSex("雄");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
- //免疫记录
|
|
|
|
- for (DuckImmunityInfo immunityInfo : immunityInfos) {
|
|
|
|
- if (("").equals(immunityInfo.getVaccination()) || null == immunityInfo.getVaccination()) {
|
|
|
|
- s2 = sdf.format(immunityInfo.getHealthDate()) + " 无;" + "\n" + s2;
|
|
|
|
- } else {
|
|
|
|
- s2 = sdf.format(immunityInfo.getHealthDate()) +" "+ immunityInfo.getVaccination() + ";" + "\n" + s2;
|
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
+ printEntrtyVo.setDuckDate(sdf.format(duckInfo.getDuckBirthday()));
|
|
|
|
+
|
|
|
|
+ printEntrtyVo.setAddress(duckInfo.getDuckBirthplace());
|
|
|
|
+
|
|
|
|
+ printEntrtyVo.setFather(duckInfo.getFatherNum());
|
|
|
|
+
|
|
|
|
+ printEntrtyVo.setFather2(duckInfo.getFatherGenotype());
|
|
|
|
+
|
|
|
|
+ printEntrtyVo.setMother(duckInfo.getMotherNum());
|
|
|
|
+
|
|
|
|
+ printEntrtyVo.setMother2(duckInfo.getMotherGenotype());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String s = "";
|
|
|
|
+ String s1 = "";
|
|
|
|
+ String s2 = "";
|
|
|
|
+ List<DuckHealthInfo> healthInfos = printEntrty.getDuckHealthInfos();
|
|
|
|
+ //健康状况
|
|
|
|
+ for (DuckHealthInfo healthInfo : healthInfos) {
|
|
|
|
+ if ("".equals(healthInfo.getDiseaseName()) || null == healthInfo.getDiseaseName()) {
|
|
|
|
+ s1 = sdf.format(healthInfo.getHealthDate()) + "无" + ";" + "\n" + s1;
|
|
|
|
+ } else {
|
|
|
|
+ s1 = sdf.format(healthInfo.getHealthDate()) + " " + healthInfo.getDiseaseName() + ";" + "\n" + s1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<EnvMoveCall> envMoveCalls = printEntrty.getEnvMoveCalls();
|
|
|
|
+ //日龄体重
|
|
|
|
+ for (EnvMoveCall envMoveCall : envMoveCalls) {
|
|
|
|
+ if ("".equals(envMoveCall.getDayage()) || null == envMoveCall.getDayage()) {
|
|
|
|
+ s = "0" + "日龄 体重" + ":" + envMoveCall.getDuckWeight() + "KG;" + "\n" + s;
|
|
|
|
+ } else {
|
|
|
|
+ s = envMoveCall.getDayage() + "日龄 体重" + ":" + envMoveCall.getDuckWeight() + "KG;" + "\n" + s;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ List<DuckImmunityInfo> immunityInfos = printEntrty.getDuckImmunityInfos();
|
|
|
|
+ //免疫记录
|
|
|
|
+ for (DuckImmunityInfo immunityInfo : immunityInfos) {
|
|
|
|
+ if (("").equals(immunityInfo.getVaccination()) || null == immunityInfo.getVaccination()) {
|
|
|
|
+ s2 = sdf.format(immunityInfo.getHealthDate()) + " 无;" + "\n" + s2;
|
|
|
|
+ } else {
|
|
|
|
+ s2 = sdf.format(immunityInfo.getHealthDate()) + " " + immunityInfo.getVaccination() + ";" + "\n" + s2;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ printEntrtyVo.setWeight(s);
|
|
|
|
+ printEntrtyVo.setNeed(duckInfo.getSpecialNeeds());
|
|
|
|
+ printEntrtyVo.setEnv(duckInfo.getBreedingEnv());
|
|
|
|
+ printEntrtyVo.setRecord(s1);
|
|
|
|
+ printEntrtyVo.setRecord2(s2);
|
|
|
|
+ list.add(printEntrtyVo);
|
|
}
|
|
}
|
|
- context.putVar("weight", s);
|
|
|
|
- context.putVar("need", duckInfo.getSpecialNeeds());
|
|
|
|
- context.putVar("env", duckInfo.getBreedingEnv());
|
|
|
|
- context.putVar("record", s1);
|
|
|
|
- context.putVar("record2", s2);
|
|
|
|
|
|
+
|
|
|
|
+ context.putVar("list", list);
|
|
//生成
|
|
//生成
|
|
JxlsHelper.getInstance().processTemplate(is, os, context);
|
|
JxlsHelper.getInstance().processTemplate(is, os, context);
|
|
}
|
|
}
|