diff --git a/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java b/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java index 6375a52..59a105b 100644 --- a/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java +++ b/platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java @@ -108,6 +108,7 @@ public enum SerialIdEnum { MatdeliverFollowPushModel("MatdeliverFollowPushModel", -5956731779920504355L), PreEugenicsBaseModel("PreEugenicsBaseModel", 7673224106500008116L), PregnantDeathModel("PregnantDeathModel", 7244731601920572967L), + BabyDeathModel("BabyDeathModel", 7244731601924572967L), CervicalCancerModel("CervicalCancerModel", 4302505773278441592L), DefectiveChildModel("DefectiveChildModel", 1684816144240073408L) ; diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/BabyDeathModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/BabyDeathModel.java new file mode 100644 index 0000000..3d21bf2 --- /dev/null +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/BabyDeathModel.java @@ -0,0 +1,328 @@ +package com.lyms.platform.pojo; + +import com.lyms.platform.beans.SerialIdEnum; +import com.lyms.platform.common.result.BaseModel; +import org.springframework.data.mongodb.core.mapping.Document; + +import java.util.Date; +import java.util.Map; + + +/** + * @author dongqin + * @description 儿童死亡报告单 + * @date 15:41 2019/11/29 + **/ +@Document(collection = "lyms_baby_death") +public class BabyDeathModel extends BaseModel { + + private static final long serialVersionUID = SerialIdEnum.BabyDeathModel.getCid(); + /** + * 主键 + */ + private String id; + + /** + * 死亡报告的的编号 + */ + private String number; + + private String phone; + + + /** + * 机构地址 + */ + private String orgProvince; + private String orgCity; + private String orgArea; + private String orgName; + + /** + * 居住地址 + */ + private String liveProvince; + private String liveCity; + private String liveArea; + private String liveStreet; + private String liveAddress; + + /** + * 父亲姓名 + */ + private String faterName; + + /** + * 母亲姓名 + */ + private String mommyName; + + /** + * 儿童姓名 + */ + private String babyName; + + /** + * 户籍 + */ + private String registerType; + + /** + * 性别 + */ + private Integer sex; + + /** + * 生日 + */ + private Date birth; + + /** + * 体重 + */ + private String weight; + + /** + * 体重测量类型 + */ + private String weightType; + + /** + * 孕周 + */ + private String week; + + /** + * 死亡日期 + */ + private Date deathDate; + + /** + * 表单数据,前端同事自定义 + */ + private Map formData; + + private String userId; + + private String hospitalId; + + private Date created; + + private Date modifed; + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getHospitalId() { + return hospitalId; + } + + public void setHospitalId(String hospitalId) { + this.hospitalId = hospitalId; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getModifed() { + return modifed; + } + + public void setModifed(Date modifed) { + this.modifed = modifed; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public String getOrgProvince() { + return orgProvince; + } + + public void setOrgProvince(String orgProvince) { + this.orgProvince = orgProvince; + } + + public String getOrgCity() { + return orgCity; + } + + public void setOrgCity(String orgCity) { + this.orgCity = orgCity; + } + + public String getOrgArea() { + return orgArea; + } + + public void setOrgArea(String orgArea) { + this.orgArea = orgArea; + } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public String getLiveProvince() { + return liveProvince; + } + + public void setLiveProvince(String liveProvince) { + this.liveProvince = liveProvince; + } + + public String getLiveCity() { + return liveCity; + } + + public void setLiveCity(String liveCity) { + this.liveCity = liveCity; + } + + public String getLiveArea() { + return liveArea; + } + + public void setLiveArea(String liveArea) { + this.liveArea = liveArea; + } + + public String getLiveStreet() { + return liveStreet; + } + + public void setLiveStreet(String liveStreet) { + this.liveStreet = liveStreet; + } + + public String getLiveAddress() { + return liveAddress; + } + + public void setLiveAddress(String liveAddress) { + this.liveAddress = liveAddress; + } + + public String getFaterName() { + return faterName; + } + + public void setFaterName(String faterName) { + this.faterName = faterName; + } + + public String getMommyName() { + return mommyName; + } + + public void setMommyName(String mommyName) { + this.mommyName = mommyName; + } + + public String getBabyName() { + return babyName; + } + + public void setBabyName(String babyName) { + this.babyName = babyName; + } + + public String getRegisterType() { + return registerType; + } + + public void setRegisterType(String registerType) { + this.registerType = registerType; + } + + public Integer getSex() { + return sex; + } + + public void setSex(Integer sex) { + this.sex = sex; + } + + public Date getBirth() { + return birth; + } + + public void setBirth(Date birth) { + this.birth = birth; + } + + public String getWeight() { + return weight; + } + + public void setWeight(String weight) { + this.weight = weight; + } + + public String getWeightType() { + return weightType; + } + + public void setWeightType(String weightType) { + this.weightType = weightType; + } + + public String getWeek() { + return week; + } + + public void setWeek(String week) { + this.week = week; + } + + public Date getDeathDate() { + return deathDate; + } + + public void setDeathDate(Date deathDate) { + this.deathDate = deathDate; + } + + public Map getFormData() { + return formData; + } + + public void setFormData(Map formData) { + this.formData = formData; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabayDeathController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabayDeathController.java new file mode 100644 index 0000000..fed35b0 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabayDeathController.java @@ -0,0 +1,101 @@ +package com.lyms.platform.operate.web.controller; + +import com.fasterxml.jackson.annotation.JsonAlias; +import com.lyms.platform.common.annotation.TokenRequired; +import com.lyms.platform.common.base.BaseController; +import com.lyms.platform.common.result.BaseListResponse; +import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.operate.web.request.*; +import com.lyms.platform.operate.web.service.IBabyDeathServer; +import com.lyms.platform.operate.web.service.IPregnantDeathServer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author dongqin + * @description 儿童死亡报告卡 + * @date 16:05 2019/11/29 + **/ +@Controller +@RequestMapping("/babyDeath") +public class BabayDeathController extends BaseController { + + @Autowired + private IBabyDeathServer babyDeathServer; + + /** + * + * 根据身份证号获取对应的建档信息 + * + * @param param + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/getPatientInfoByIdCard") + @ResponseBody + @TokenRequired + public BaseResponse getPatientInfoByIdCard(@JsonAlias CommonParamRequest param,HttpServletRequest request) { + return babyDeathServer.getPatientInfoByIdCard(param,getUserId(request)); + } + + + /** + * 保存单个 + * + * @param param + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "/add") + @ResponseBody + @TokenRequired + public BaseResponse add(@RequestBody BabyDeathRequest param, HttpServletRequest request) { + param.setUserId(getUserId(request).toString()); + return babyDeathServer.add(param,getUserId(request)); + } + + /** + * 编辑单个 + * + * @param param + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "/edit") + @ResponseBody + @TokenRequired + public BaseResponse edit( @RequestBody BabyDeathRequest param) { + return babyDeathServer.edit(param); + } + + /** + * 列表 + * + * @param param + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/listPage") + @ResponseBody + @TokenRequired + public BaseListResponse listPage(@JsonAlias BabyDeathListRequest param,HttpServletRequest request) { + return babyDeathServer.listPage(param,getUserId(request)); + } + + /** + * 单个查询 + * + * @param param + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "/detail") + @ResponseBody + @TokenRequired + public BaseResponse detail( @JsonAlias BabyDeathRequest param) { + return babyDeathServer.detail(param); + } + + +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyDeathListRequest.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyDeathListRequest.java new file mode 100644 index 0000000..ed46a6d --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyDeathListRequest.java @@ -0,0 +1,127 @@ +package com.lyms.platform.operate.web.request; + +import com.lyms.platform.common.dao.BaseQuery; + +public class BabyDeathListRequest extends BaseQuery { + + /** + * 死亡报告卡的编号 + */ + private String number; + + /** + * 母亲 父亲 儿童姓名 + */ + private String name; + + /** + * 手机号 + */ + private String phone; + + + /** + * 创建时间 + */ + private String startCreated; + private String endCreated; + private String deathDateStart; + private String endCreatedEnd; + + /** + * 居住地址 省市区街道详细地址 + */ + private String liveProvince; + private String liveCity; + private String liveArea; + private String liveStreet; + + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getStartCreated() { + return startCreated; + } + + public void setStartCreated(String startCreated) { + this.startCreated = startCreated; + } + + public String getEndCreated() { + return endCreated; + } + + public void setEndCreated(String endCreated) { + this.endCreated = endCreated; + } + + public String getDeathDateStart() { + return deathDateStart; + } + + public void setDeathDateStart(String deathDateStart) { + this.deathDateStart = deathDateStart; + } + + public String getEndCreatedEnd() { + return endCreatedEnd; + } + + public void setEndCreatedEnd(String endCreatedEnd) { + this.endCreatedEnd = endCreatedEnd; + } + + public String getLiveProvince() { + return liveProvince; + } + + public void setLiveProvince(String liveProvince) { + this.liveProvince = liveProvince; + } + + public String getLiveCity() { + return liveCity; + } + + public void setLiveCity(String liveCity) { + this.liveCity = liveCity; + } + + public String getLiveStreet() { + return liveStreet; + } + + public void setLiveStreet(String liveStreet) { + this.liveStreet = liveStreet; + } + + public String getLiveArea() { + return liveArea; + } + + public void setLiveArea(String liveArea) { + this.liveArea = liveArea; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyDeathRequest.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyDeathRequest.java new file mode 100644 index 0000000..7288a60 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyDeathRequest.java @@ -0,0 +1,7 @@ +package com.lyms.platform.operate.web.request; + +import com.lyms.platform.pojo.BabyDeathModel; + +public class BabyDeathRequest extends BabyDeathModel { + +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyDeathModelResult.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyDeathModelResult.java new file mode 100644 index 0000000..feb5b35 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/BabyDeathModelResult.java @@ -0,0 +1,57 @@ +package com.lyms.platform.operate.web.result; + +import com.lyms.platform.pojo.BabyDeathModel; + +public class BabyDeathModelResult extends BabyDeathModel { + /** + * 居住地址 省市区街道详细地址 + */ + private String liveAddressStr; + + /** + * 暂住地址 省市区街道详细地址 + */ + private String orgAddressStr; + + /** + * 填写单位 + */ + private String hospitalStr; + + /** + * 填写人 + */ + private String createUserStr; + + public String getLiveAddressStr() { + return liveAddressStr; + } + + public void setLiveAddressStr(String liveAddressStr) { + this.liveAddressStr = liveAddressStr; + } + + public String getOrgAddressStr() { + return orgAddressStr; + } + + public void setOrgAddressStr(String orgAddressStr) { + this.orgAddressStr = orgAddressStr; + } + + public String getHospitalStr() { + return hospitalStr; + } + + public void setHospitalStr(String hospitalStr) { + this.hospitalStr = hospitalStr; + } + + public String getCreateUserStr() { + return createUserStr; + } + + public void setCreateUserStr(String createUserStr) { + this.createUserStr = createUserStr; + } +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBabyDeathServer.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBabyDeathServer.java new file mode 100644 index 0000000..86189c5 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBabyDeathServer.java @@ -0,0 +1,8 @@ +package com.lyms.platform.operate.web.service; + +import com.lyms.platform.operate.web.request.BabyDeathListRequest; +import com.lyms.platform.operate.web.request.BabyDeathRequest; + +public interface IBabyDeathServer extends IFormReportService { + +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyDeathServerImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyDeathServerImpl.java new file mode 100644 index 0000000..d57d435 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BabyDeathServerImpl.java @@ -0,0 +1,252 @@ +package com.lyms.platform.operate.web.service.impl; + +import com.lyms.platform.biz.service.BasicConfigService; +import com.lyms.platform.common.result.BaseListResponse; +import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.common.utils.DateUtil; +import com.lyms.platform.common.utils.MongoConvertHelper; +import com.lyms.platform.common.utils.ReflectionUtils; +import com.lyms.platform.common.utils.StringUtils; +import com.lyms.platform.operate.web.facade.AutoMatchFacade; +import com.lyms.platform.operate.web.request.*; +import com.lyms.platform.operate.web.result.BabyDeathModelResult; +import com.lyms.platform.operate.web.service.IBabyDeathServer; +import com.lyms.platform.operate.web.utils.CommonsHelper; +import com.lyms.platform.permission.model.Organization; +import com.lyms.platform.permission.model.Users; +import com.lyms.platform.permission.service.OrganizationService; +import com.lyms.platform.permission.service.UsersService; +import com.lyms.platform.pojo.*; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +@Service +public class BabyDeathServerImpl implements IBabyDeathServer { + + @Autowired + private MongoTemplate mongoTemplate; + + @Autowired + private BasicConfigService basicConfigService; + + @Autowired + private OrganizationService organizationService; + + @Autowired + private UsersService usersService; + + + @Autowired + private AutoMatchFacade autoMatchFacade; + + + /** + * 保存单个 + * + * @param param + * @return + */ + @Override + public BaseResponse add(BabyDeathRequest param,Integer userId) { + param.setCreated(new Date()); + param.setHospitalId(autoMatchFacade.getHospitalId(userId)); + mongoTemplate.insert(param); + return new BaseResponse(); + } + + /** + * 编辑单个 + * + * @param param + * @return + */ + @Override + public BaseResponse edit(BabyDeathRequest param) { + Query query = Query.query(Criteria.where("id").is(param.getId())); + Update update = MongoConvertHelper + .convertToNativeUpdate(ReflectionUtils.getUpdateField(param)); + mongoTemplate.updateFirst(query, update, PregnantDeathModel.class); + return new BaseResponse(); + } + + /** + * 列表 + * + * @param param + * @return + */ + @Override + public BaseListResponse listPage(BabyDeathListRequest param,Integer userId) { + + String hospitalId = autoMatchFacade.getHospitalId(userId); + + Query query = new Query(); + // 编号 + String number = param.getNumber(); + if (StringUtils.isNotEmpty(number)) { + query.addCriteria(Criteria.where("number").is(number)); + } + // 姓名 + String name = param.getName(); + if (StringUtils.isNotEmpty(name)) { + query.addCriteria(new Criteria().orOperator(Criteria.where("fatherName").is(name), Criteria.where("mommyName").is(name), Criteria.where("babyName").is(name))); + } + // 手机号 + String phone = param.getPhone(); + if (StringUtils.isNotEmpty(phone)) { + query.addCriteria(Criteria.where("phone").is(phone)); + } + + // 填写单位 + query.addCriteria(Criteria.where("hospitalId").is(hospitalId)); + // 填写时间 + String startCreated = param.getStartCreated(); + String endCreated = param.getEndCreated(); + if (StringUtils.isNotEmpty(startCreated) && StringUtils.isNotEmpty(endCreated)) { + Date startDate = DateUtil.parseYMD(startCreated); + Date dayFirstSecond = DateUtil.getDayFirstSecond(startDate); + Date endDate = DateUtil.parseYMD(endCreated); + Date dayLastSecond = DateUtil.getDayLastSecond(endDate); + query.addCriteria(Criteria.where("created").gte(dayFirstSecond).lte(dayLastSecond)); + } + + + // 死亡时间 + String deathDateStart = param.getDeathDateStart(); + String deathDateEnd = param.getDeathDateStart(); + if (StringUtils.isNotEmpty(deathDateStart) && StringUtils.isNotEmpty(deathDateEnd)) { + Date startDate = DateUtil.parseYMD(deathDateStart); + Date dayFirstSecond = DateUtil.getDayFirstSecond(startDate); + Date endDate = DateUtil.parseYMD(deathDateEnd); + Date dayLastSecond = DateUtil.getDayLastSecond(endDate); + query.addCriteria(Criteria.where("deathDate").gte(dayFirstSecond).lte(dayLastSecond)); + } + + + // 居住地址 + String liveProvince = param.getLiveProvince(); + if (StringUtils.isNotEmpty(liveProvince)) { + query.addCriteria(Criteria.where("liveProvince").is(liveProvince)); + String liveCity = param.getLiveCity(); + if (StringUtils.isNotEmpty(liveCity)) { + query.addCriteria(Criteria.where("liveCity").is(liveCity)); + String liveArea = param.getLiveArea(); + if (StringUtils.isNotEmpty(liveArea)) { + query.addCriteria(Criteria.where("liveArea").is(liveArea)); + String liveStreet = param.getLiveStreet(); + if (StringUtils.isNotEmpty(liveStreet)) { + query.addCriteria(Criteria.where("liveStreet").is(liveStreet)); + } + } + } + } + + query.with(new Sort(Sort.Direction.DESC, "created")); + long count = mongoTemplate.count(query, BabyDeathModel.class); + param.mysqlBuild((int) count); + query.skip(param.getOffset()).limit(param.getLimit()); + List results = new LinkedList<>(); + List models = mongoTemplate.find(query, BabyDeathModel.class); + for (BabyDeathModel model : models) { + BabyDeathModelResult result = new BabyDeathModelResult(); + getOtherStr(result, model); + results.add(result); + } + + BaseListResponse baseListResponse = new BaseListResponse(); + baseListResponse.setData(results); + baseListResponse.setPageInfo(param.getPageInfo()); + return baseListResponse; + } + + /** + * 单个查询 + * + * @param param + * @return + */ + @Override + public BaseResponse detail(BabyDeathRequest param) { + String id = param.getId(); + if (StringUtils.isEmpty(id)) { + return new BaseResponse(); + } + BabyDeathModelResult result = new BabyDeathModelResult(); + BabyDeathModel model = mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), BabyDeathModel.class); + if (model != null) { + getOtherStr(result, model); + } + BaseResponse baseResponse = new BaseResponse(); + baseResponse.setObject(result); + return baseResponse; + } + + private void getOtherStr(BabyDeathModelResult result,BabyDeathModel model) { + BeanUtils.copyProperties(model, result); + result.setLiveAddressStr(CommonsHelper.getResidence( + result.getLiveProvince(), + result.getLiveCity(), + result.getLiveArea(), + result.getLiveStreet(), + result.getLiveAddress(), + basicConfigService)); + result.setOrgAddressStr(CommonsHelper.getResidence( + result.getOrgProvince(), + result.getOrgCity(), + result.getOrgArea(), + null, + null, + basicConfigService + )); + String createUser = result.getUserId(); + if (StringUtils.isNotEmpty(createUser)) { + Users users = usersService.getUsers(Integer.parseInt(createUser)); + if (users != null) { + result.setCreateUserStr(users.getName()); + } + } + String hospitalId = result.getHospitalId(); + if (StringUtils.isNotEmpty(hospitalId)) { + Organization organization = organizationService.getOrganization(Integer.parseInt(hospitalId)); + if (organization != null) { + result.setHospitalStr(organization.getName()); + } + } + } + + /** + * 根据身份证号获取对应的信息 + * + * @param param + * @return + */ + @Override + public BaseResponse getPatientInfoByIdCard(CommonParamRequest param,Integer userId) { + Query query = new Query(); + String code = param.getCode(); + if (StringUtils.isNotEmpty(code)) { + query.addCriteria(Criteria.where("code").is(code)); + } + BabyDeathModel model = mongoTemplate.findOne(query.with(new Sort(Sort.Direction.DESC, "created")), BabyDeathModel.class); + BabyDeathModelResult result = new BabyDeathModelResult(); + if (model != null) { + getOtherStr(result, model); + BaseResponse baseResponse = new BaseResponse(); + baseResponse.setObject(result); + return baseResponse; + } + BaseResponse baseResponse = new BaseResponse(); + baseResponse.setObject(result); + return baseResponse; + } +}