diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java index 7f3e3b2..5aab2c9 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/AntenatalExaminationDaoImpl.java @@ -63,7 +63,7 @@ public class AntenatalExaminationDaoImpl extends BaseMongoDAOImpl queryYuyueAntenatalExamination(Date yuYueDate,String hospitalId) { AggregationOperation match = Aggregation.match(Criteria.where("nextCheckTime").gte(yuYueDate).lte(yuYueDate).and("hospitalId").is(hospitalId)); - AggregationOperation group = Aggregation.group("parentId").max("modified").as("modified"); + AggregationOperation group = Aggregation.group("parentId").max("created").as("created"); Aggregation aggregation = Aggregation.newAggregation(match, group); AggregationResults result = this.mongoTemplate.aggregate(aggregation, "lyms_antex", AntenatalExaminationModel.class); return result.getMappedResults(); @@ -71,8 +71,8 @@ public class AntenatalExaminationDaoImpl extends BaseMongoDAOImpl queryYuyueAntenatalExamination(Date startDate,String hospitalId,String pid) { - AggregationOperation match = Aggregation.match(Criteria.where("nextCheckTime").gte("startDate").and("parentId").is("pid").and("hospitalId").is(hospitalId)); - AggregationOperation group = Aggregation.group("parentId").max("modified").as("modified"); + AggregationOperation match = Aggregation.match(Criteria.where("nextCheckTime").gte("startDate").lte(startDate).and("parentId").is("pid").and("hospitalId").is(hospitalId)); + AggregationOperation group = Aggregation.group("parentId").max("created").as("created"); Aggregation aggregation = Aggregation.newAggregation(match, group); AggregationResults result = this.mongoTemplate.aggregate(aggregation, "lyms_antex", AntenatalExaminationModel.class); return result.getMappedResults(); diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/BabyBookbuildingDaoImpl.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/BabyBookbuildingDaoImpl.java index 5442319..55e7eb1 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/BabyBookbuildingDaoImpl.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/BabyBookbuildingDaoImpl.java @@ -48,8 +48,8 @@ public class BabyBookbuildingDaoImpl extends BaseMongoDAOImpl impleme @Override public List queryBabyYuYueRecord(Date yuYueDate, String hospitalId) { - AggregationOperation match = Aggregation.match(Criteria.where("nextDate").gte(yuYueDate).and("hospitalId").is(hospitalId)); - AggregationOperation group = Aggregation.group("buildId").max("modified").as("modified"); + AggregationOperation match = Aggregation.match(Criteria.where("nextDate").gte(yuYueDate).lte(yuYueDate).and("hospitalId").is(hospitalId)); + AggregationOperation group = Aggregation.group("buildId").max("created").as("created"); Aggregation aggregation = Aggregation.newAggregation(match, group); AggregationResults result = this.mongoTemplate.aggregate(aggregation, "lyms_babycheck", BabyCheckModel.class); return result.getMappedResults(); @@ -57,8 +57,8 @@ public class BabyBookbuildingDaoImpl extends BaseMongoDAOImpl impleme @Override public List queryBabyOrder(Date startDate, String hospitalId, String buildId) { - AggregationOperation match = Aggregation.match(Criteria.where("nextDate").gte(startDate).and("hospitalId").is(hospitalId).and("buildId").is(buildId)); - AggregationOperation group = Aggregation.group("buildId").max("modified").as("modified"); + AggregationOperation match = Aggregation.match(Criteria.where("nextDate").gte(startDate).lte(startDate).and("buildId").is(buildId)); + AggregationOperation group = Aggregation.group("buildId").max("created").as("created"); Aggregation aggregation = Aggregation.newAggregation(match, group); AggregationResults result = this.mongoTemplate.aggregate(aggregation, "lyms_babycheck", BabyCheckModel.class); return result.getMappedResults(); diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PostReviewDaoImpl.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PostReviewDaoImpl.java index c262a0f..8a511ab 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PostReviewDaoImpl.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PostReviewDaoImpl.java @@ -78,16 +78,16 @@ public class PostReviewDaoImpl extends BaseMongoDAOImpl impleme @Override public List queryPostOrder(Date orderDate, String hospitalId) { - AggregationOperation match = Aggregation.match(Criteria.where("nextCheckDate").gte(orderDate).and("nextCheckDate").lte(orderDate).and("hospitalId").is(hospitalId)); - AggregationOperation group = Aggregation.group("parentId").max("modified").as("modified"); + AggregationOperation match = Aggregation.match(Criteria.where("nextCheckDate").gte(orderDate).lte(orderDate).and("hospitalId").is(hospitalId)); + AggregationOperation group = Aggregation.group("parentId").max("created").as("created"); Aggregation aggregation = Aggregation.newAggregation(match, group); AggregationResults result = this.mongoTemplate.aggregate(aggregation, "lyms_postreview", PostReviewModel.class); return result.getMappedResults(); } @Override - public List queryPostOrder(Date orderDate, String hospitalId,String pid) { - AggregationOperation match = Aggregation.match(Criteria.where("nextCheckDate").gte(orderDate).and("nextCheckDate").lte(orderDate).and("hospitalId").is(hospitalId).and("parentId")); - AggregationOperation group = Aggregation.group("parentId").max("modified").as("modified"); + public List queryPostOrder(Date orderDate, String hospitalId,String parentId) { + AggregationOperation match = Aggregation.match(Criteria.where("nextCheckDate").gte(orderDate).lte(orderDate).and("hospitalId").is(hospitalId).and("parentId").is(parentId)); + AggregationOperation group = Aggregation.group("parentId").max("created").as("created"); Aggregation aggregation = Aggregation.newAggregation(match, group); AggregationResults result = this.mongoTemplate.aggregate(aggregation, "lyms_postreview", PostReviewModel.class); return result.getMappedResults(); diff --git a/platform-common/pom.xml b/platform-common/pom.xml index ccb0d0e..04012d4 100644 --- a/platform-common/pom.xml +++ b/platform-common/pom.xml @@ -19,6 +19,13 @@ pinyin4j 2.5.0 + + + net.sourceforge.jexcelapi + jxl + 2.6.12 + + diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java index e6a55f8..3e6700b 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java @@ -714,8 +714,8 @@ public class DateUtil { // Date lastLmess = parseYMD("2016-07-02"); // Date startDate = DateUtil.getRangeDate(lastLmess, 1, "周", -2); - Date startDate = DateUtil.addDay(new Date(), -100); - System.out.println(getyyyy_MM_dd(startDate)); +// Date startDate = DateUtil.addDay(new Date(), -100); +// System.out.println(getyyyy_MM_dd(startDate)); try { // Date startDate = DateUtil.addMonth(new Date(), -1); @@ -738,10 +738,14 @@ public class DateUtil { // String st = md.format(new Date()); // System.out.print(st); - int s = getBabyMonthAge1(parseYMD("2016-09-07"), new Date()); - System.out.println(s); +// int s = getBabyMonthAge1(parseYMD("2016-09-07"), new Date()); +// System.out.println(s); // Date s = addDay(parseYMD("2016-02-26"), 168); -// System.out.println(getyyyy_MM_dd(s)); + + Date startDate = DateUtil.getNewDate(-0,"天",0); + Date endDate = DateUtil.getNewDate(-5,"天",0); + + System.out.println(startDate + "==="+ endDate); } catch (Exception e) { diff --git a/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java b/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java new file mode 100644 index 0000000..57e2040 --- /dev/null +++ b/platform-common/src/main/java/com/lyms/platform/common/utils/ExcelUtil.java @@ -0,0 +1,102 @@ +package com.lyms.platform.common.utils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + + +import jxl.SheetSettings; +import jxl.Workbook; +import jxl.format.Colour; +import jxl.format.UnderlineStyle; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; +import jxl.write.biff.RowsExceededException; + +/** + * Excel 工具类 + * + * @author lqy + * + */ +public class ExcelUtil +{ + + static File from_file; + + static WritableWorkbook to_wwb; // 创建可写入workbook对象 + + public static OutputStream toExcel(OutputStream out, List> data, Map columName) + { + WritableWorkbook wwb; + try + { + wwb = Workbook.createWorkbook(out); + WritableSheet ws = wwb.createSheet("sheet", 0); // 创建一个工作表 + /** + * 设置单元格样式 + */ + WritableFont wf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); + WritableCellFormat wcf = new WritableCellFormat(wf); + ws.setRowView(0, 300); // 设置指定行高 + // 设置列宽 + for (int j = 0, columLen = columName.size(); j < columLen; j++) + { + ws.setColumnView(j, 15); + } + // 填充数据的内容 + Map map; + for (int i = 0, len = data.size(); i < len; i++) + { + map = data.get(i); + Iterator ite = columName.keySet().iterator(); + int j = 0; + String keyORvalue = ""; + String keyName = ""; + while (ite.hasNext()) + { + keyName = ite.next(); + if (i > 0) + { // 类容数据 + keyORvalue = map.get(keyName).toString(); + } + else + { // 第一行列名 + keyORvalue = map.get(keyName).toString(); + keyName = columName.get(keyName); + ws.addCell(new Label(j, 0, keyName, wcf)); + } + ws.addCell(new Label(j, 1 + i, keyORvalue)); + j++; + } + } + + wwb.write(); + wwb.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + catch (RowsExceededException e) + { + e.printStackTrace(); + } + catch (WriteException e) + { + e.printStackTrace(); + } + return out; + } + + + +} diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/BabyCheckModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/BabyCheckModel.java index 89fff7e..e3dc592 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/BabyCheckModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/BabyCheckModel.java @@ -220,6 +220,15 @@ public class BabyCheckModel extends BaseModel { //创建时间 private Date created; + private String hospitalId; + + public String getHospitalId() { + return hospitalId; + } + + public void setHospitalId(String hospitalId) { + this.hospitalId = hospitalId; + } public String getDrugGllergic() { return drugGllergic; diff --git a/platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java index 367f489..73319ef 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java @@ -130,15 +130,9 @@ public class AntExChuQuery extends BaseQuery implements IConvertToNativeQuery { isAddStart = Boolean.TRUE; } - if (null != nextCheckTimeStart) { - if (c == null) - { - c = Criteria.where("nextCheckTime").gte(nextCheckTimeStart); - } - else - { - c.and("nextCheckTime").gte(nextCheckTimeStart); - } + if (null != nextCheckTimeStart && nextCheckTimeEnd != null) { + Criteria nc = Criteria.where("nextCheckTime").gte(nextCheckTimeStart).lte(nextCheckTimeEnd); + condition= condition.andCondition(new MongoCondition(nc)); } if (isAddStart) { diff --git a/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java b/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java index cc4a89d..3c9b9f1 100644 --- a/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java +++ b/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java @@ -622,7 +622,8 @@ public class SmsServiceImpl implements SmsService{ public void productTemplateSms() { SmsConfigQuery configQuery = new SmsConfigQuery(); configQuery.setYn(YnEnums.YES.getId()); - configQuery.setPrefixTypes(new Integer[]{0,1}); + configQuery.setPrefixTypes(new Integer[]{0, 1}); + configQuery.setHospitalId(221+""); //查询出对应医院配置 List configs = smsConfigService.querySmsConfig(configQuery); @@ -763,7 +764,7 @@ public class SmsServiceImpl implements SmsService{ if (start != null && end != null) { - Date startDate = DateUtil.getNewDate(-end,"周",sendTimeType); + Date startDate = DateUtil.getNewDate(-end-1,"周",sendTimeType); Date endDate = DateUtil.getNewDate(-start,"周",sendTimeType); patientsQuery.setLastMensesStart(startDate); patientsQuery.setLastMensesEnd(endDate); @@ -989,7 +990,7 @@ public class SmsServiceImpl implements SmsService{ if (end != null && start != null) { - Date startDate = DateUtil.getNewDate(-end,"周",sendTimeType); + Date startDate = DateUtil.getNewDate(-end-1,"周",sendTimeType); Date endDate = DateUtil.getNewDate(-start,"周",sendTimeType); patientsQuery.setLastMensesStart(startDate); patientsQuery.setLastMensesEnd(endDate); @@ -1020,6 +1021,7 @@ public class SmsServiceImpl implements SmsService{ if (smsType == SmsServiceEnums.EBYYTX.getId()) { Date yuYueDate = DateUtil.addDay(new Date(), sendTimeType); + yuYueDate = DateUtil.formatDate(yuYueDate); List checkModels = babyBookbuildingService.queryBabyYuYueRecord(yuYueDate, tempHid); if (CollectionUtils.isNotEmpty(checkModels)) { @@ -1028,10 +1030,10 @@ public class SmsServiceImpl implements SmsService{ BabyModelQuery query = new BabyModelQuery(); query.setYn(YnEnums.YES.getId()); - query.setId(checkModel.getBuildId()); + query.setId(checkModel.getId()); //这里返回的id就是buildId //查询符合条件儿童 - List babyModels = babyBookbuildingService.queryBabyBuildByCond(babyModelQuery); + List babyModels = babyBookbuildingService.queryBabyBuildByCond(query); if (CollectionUtils.isNotEmpty(babyModels)) { for (BabyModel model : babyModels) @@ -1383,7 +1385,7 @@ public class SmsServiceImpl implements SmsService{ { PatientsQuery query = new PatientsQuery(); query.setYn(YnEnums.YES.getId()); - query.setId(orderModel.getParentId()); + query.setId(orderModel.getId()); //id就是parentId //查询符合条件的产妇 List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); @@ -1847,7 +1849,7 @@ public class SmsServiceImpl implements SmsService{ List models = postReviewService.queryPostOrder(startDate, tempHid, pid); for (PostReviewModel model : models) { - idset.add(model.getParentId()); + idset.add(model.getId()); //这里的id就是parentid } return idset.size() > 0; } @@ -1874,7 +1876,7 @@ public class SmsServiceImpl implements SmsService{ List models = babyBookbuildingService.queryBabyOrder(startDate, tempHid, pid); for (BabyCheckModel model : models) { - idset.add(model.getBuildId()); + idset.add(model.getId()); } return idset.size() > 0; } @@ -2110,6 +2112,7 @@ public class SmsServiceImpl implements SmsService{ antExChuQuery.setYn(YnEnums.YES.getId()); antExChuQuery.setNextCheckTimeStart(yuYueDate); antExChuQuery.setNextCheckTimeEnd(yuYueDate); + antExChuQuery.setHospitalId(tempHid); List chus = antenatalExaminationService.queryAntExChu(antExChuQuery); for (AntExChuModel chu : chus) { @@ -2119,7 +2122,7 @@ public class SmsServiceImpl implements SmsService{ for (AntenatalExaminationModel f : fuzs) { - idset.add(f.getParentId()); + idset.add(f.getId()); //这里的id就是parentid } return idset; } diff --git a/platform-data-api/src/main/java/com/lyms/platform/data/util/AmsMessageService.java b/platform-data-api/src/main/java/com/lyms/platform/data/util/AmsMessageService.java index f7e6c1f..ddb8df2 100644 --- a/platform-data-api/src/main/java/com/lyms/platform/data/util/AmsMessageService.java +++ b/platform-data-api/src/main/java/com/lyms/platform/data/util/AmsMessageService.java @@ -181,7 +181,7 @@ public class AmsMessageService { public static void main(String[] args) { - getMessageTemplateMap("8be01f59-ad25-4ae6-968d-8450c9421e0b", + getMessageTemplateMap("241", AmsServiceTypeEnum.CHILD_GUIDE); } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java index 5d69cf3..0fddcdc 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyCheckFacade.java @@ -212,6 +212,18 @@ public class BabyCheckFacade { bm.setNextDate(DateUtil.parseYMD(request.getNextDate())); + String hospitalId = ""; + + //得到当前登录的医院id + if (userId != null) + { + Users dbuser = usersService.getUsers(userId); + if (dbuser != null) { + hospitalId = String.valueOf(dbuser.getOrgId()); + } + } + + if (CollectionUtils.isNotEmpty(request.getDiagnose())) { BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); @@ -231,6 +243,7 @@ public class BabyCheckFacade { babyBookbuildingService.updateBabyBuild(bm, request.getBuildId()); BabyCheckModel model = getBabyCheckModel(request); + model.setHospitalId(hospitalId); model.setCreated(new Date()); model = babyCheckService.addBabyCheck(model); BaseObjectResponse br = new BaseObjectResponse(); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsTemplateFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsTemplateFacade.java index 82cdca8..57f2bdb 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsTemplateFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsTemplateFacade.java @@ -236,7 +236,7 @@ public class SmsTemplateFacade { //发送频次 Integer sendFreq = temp.getSendFrequency(); - String sendDate = SendDateEnums.getNameById(temp.getSendDateType()); + String sendDate = temp.getSendDateType() == null ? "" : SendDateEnums.getNameById(temp.getSendDateType()); String dateRange = temp.getStart() == null ? "" : (temp.getStart() + " "+ temp.getEnd());