diff --git a/parent/base.common/src/main/java/com/lyms/base/common/service/sys/SysDictService.java b/parent/base.common/src/main/java/com/lyms/base/common/service/sys/SysDictService.java index 791dc5f..c8133a0 100644 --- a/parent/base.common/src/main/java/com/lyms/base/common/service/sys/SysDictService.java +++ b/parent/base.common/src/main/java/com/lyms/base/common/service/sys/SysDictService.java @@ -32,5 +32,16 @@ public interface SysDictService extends BaseService { *
  • 修改时间: */ public List getDictListByTypeCode(Serializable typeCode); + + /** + *
  • @Description:根据ID获取字典中对应的记录名称 + *
  • @param id + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月21日 + *
  • 修改人: + *
  • 修改时间: + */ + public String getDictNameById(String id); } diff --git a/parent/base.common/src/main/java/com/lyms/base/common/service/sys/impl/SysDictServiceImpl.java b/parent/base.common/src/main/java/com/lyms/base/common/service/sys/impl/SysDictServiceImpl.java index 32646c2..9a38fc7 100644 --- a/parent/base.common/src/main/java/com/lyms/base/common/service/sys/impl/SysDictServiceImpl.java +++ b/parent/base.common/src/main/java/com/lyms/base/common/service/sys/impl/SysDictServiceImpl.java @@ -27,4 +27,10 @@ public class SysDictServiceImpl extends ServiceImpl impl public List getDictListByTypeCode(Serializable typeCode) { return baseMapper.getDictListByTypeCode(typeCode); } + + @Override + public String getDictNameById(String id) { + SysDict dic = baseMapper.selectById(id); + return dic==null?null:dic.getTxt(); + } } diff --git a/parent/core.sdk/src/main/java/com/lyms/util/DateUtil.java b/parent/core.sdk/src/main/java/com/lyms/util/DateUtil.java index 0a437b6..a3c7198 100644 --- a/parent/core.sdk/src/main/java/com/lyms/util/DateUtil.java +++ b/parent/core.sdk/src/main/java/com/lyms/util/DateUtil.java @@ -531,7 +531,10 @@ public class DateUtil { long time1 = cal.getTimeInMillis(); cal.setTime(bdate); long time2 = cal.getTimeInMillis(); - long between_days = (time2 - time1) / (1000 * 3600 * 24); + long between_days = (time2 - time1) / (1000L * 3600 * 24); + if(between_days<0){//add by xujiahong : we don't need to know the date sequence + between_days = 0-between_days; + } return Integer.parseInt(String.valueOf(between_days)); } catch (ParseException e) { e.printStackTrace(); diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.java index d053b78..fd78d98 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.java @@ -35,5 +35,16 @@ public interface WomanFetationRecordMapper extends BaseMapper> selectHistory(@Param("cardType") String cardType, @Param("cardNo") String cardNo, @Param("vcCardNo") String vcCardNo); + + /** + *
  • @Description:关联&合并省市区信息,避免接口多次建立SQL链接 + *
  • @param id + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月24日 + *
  • 修改人: + *
  • 修改时间: + */ + public WomanFetationRecord selectDetailById(String id); } \ No newline at end of file diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.xml b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.xml index 9288398..8401e81 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.xml +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/woman/WomanFetationRecordMapper.xml @@ -56,16 +56,25 @@ + + + + + + + - ID AS id, BASE_WOMAN_NAME AS baseWomanName, BASE_PAPERS_TYPE AS basePapersType, BASE_PAPERS_NUMBER AS basePapersNumber, BASE_WOMAN_COUNTRY AS baseWomanCountry, BASE_WOMAN_NATION AS baseWomanNation, BASE_WOMAN_BIRTH AS baseWomanBirth, BASE_REGISTER_TYPE AS baseRegisterType, BASE_DWELL_TYPE AS baseDwellType, BASE_OCCUPATION_TYPE AS baseOccupationType, BASE_WOMAN_CULTURE AS baseWomanCulture, BASE_FAMILY_INCOME AS baseFamilyIncome, CONTACT_WOMAN_WAY AS contactWomanWay, CONTACT_WORK_ADDRESS AS contactWorkAddress, CONTACT_DWELL_PROVINCE AS contactDwellProvince, CONTACT_DWELL_CITY AS contactDwellCity, CONTACT_DWELL_AREA AS contactDwellArea, CONTACT_DWELL_STREET AS contactDwellStreet, CONTACT_DWELL_DETAIL AS contactDwellDetail, CONTACT_REGISTER_PROVINCE AS contactRegisterProvince, CONTACT_REGISTER_CITY AS contactRegisterCity, CONTACT_REGISTER_AREA AS contactRegisterArea, CONTACT_REGISTER_STREET AS contactRegisterStreet, CONTACT_REGISTER_DETAIL AS contactRegisterDetail, CONTACT_POSTPARTUM_PROVINCE AS contactPostpartumProvince, CONTACT_POSTPARTUM_CITY AS contactPostpartumCity, CONTACT_POSTPARTUM_AREA AS contactPostpartumArea, CONTACT_POSTPARTUM_STREET AS contactPostpartumStreet, CONTACT_POSTPARTUM_DETAIL AS contactPostpartumDetail, HOSPITAL_LAST_MENSTRUATION AS hospitalLastMenstruation, HOSPITAL_CORRECT_LAST_MENSTRUATION AS hospitalCorrectLastMenstruation, HOSPITAL_EXPECTED_DATE AS hospitalExpectedDate, HOSPITAL_PATIENT_CARD AS hospitalPatientCard, HOSPITAL_BARCODE AS hospitalBarcode, HOSPITAL_RECORD_NUMBER AS hospitalRecordNumber, HOSPITAL_SERVICE_TYPE AS hospitalServiceType, HOSPITAL_SERVICE_STATUS AS hospitalServiceStatus, HOSPITAL_MEMBER AS hospitalMember, HOSPITAL_RECORD_DOCTOR AS hospitalRecordDoctor, HOSPITAL_RECORD_DATE AS hospitalRecordDate, HOSPITAL_RECORD_REMARK AS hospitalRecordRemark, HOSPITAL_MEMBER_DATE AS hospitalMemberDate, BUILD_DATE AS buildDate, HOSTPITAL_ID AS hostpitalId, BUILD_TYPE AS buildType, CREATE_ID AS createId, CREATE_TIME AS createTime, MODIFY_ID AS modifyId, MODIFY_TIME AS modifyTime, IFDEL AS ifdel, ENALBLE AS enalble, WOMAN_PERSON_ID AS womanPersonId + ID AS id, BASE_WOMAN_NAME AS baseWomanName, BASE_PAPERS_TYPE AS basePapersType, BASE_PAPERS_NUMBER AS basePapersNumber, BASE_WOMAN_COUNTRY AS baseWomanCountry, BASE_WOMAN_NATION AS baseWomanNation, BASE_WOMAN_BIRTH AS baseWomanBirth, BASE_REGISTER_TYPE AS baseRegisterType, BASE_DWELL_TYPE AS baseDwellType, BASE_OCCUPATION_TYPE AS baseOccupationType, BASE_WOMAN_CULTURE AS baseWomanCulture, BASE_FAMILY_INCOME AS baseFamilyIncome, CONTACT_WOMAN_WAY AS contactWomanWay, CONTACT_WORK_ADDRESS AS contactWorkAddress, CONTACT_DWELL_PROVINCE AS contactDwellProvince, CONTACT_DWELL_CITY AS contactDwellCity, CONTACT_DWELL_AREA AS contactDwellArea, CONTACT_DWELL_STREET AS contactDwellStreet, CONTACT_DWELL_DETAIL AS contactDwellDetail, CONTACT_REGISTER_PROVINCE AS contactRegisterProvince, CONTACT_REGISTER_CITY AS contactRegisterCity, CONTACT_REGISTER_AREA AS contactRegisterArea, CONTACT_REGISTER_STREET AS contactRegisterStreet, CONTACT_REGISTER_DETAIL AS contactRegisterDetail, CONTACT_POSTPARTUM_PROVINCE AS contactPostpartumProvince, CONTACT_POSTPARTUM_CITY AS contactPostpartumCity, CONTACT_POSTPARTUM_AREA AS contactPostpartumArea, CONTACT_POSTPARTUM_STREET AS contactPostpartumStreet, CONTACT_POSTPARTUM_DETAIL AS contactPostpartumDetail, HOSPITAL_LAST_MENSTRUATION AS hospitalLastMenstruation, HOSPITAL_CORRECT_LAST_MENSTRUATION AS hospitalCorrectLastMenstruation, HOSPITAL_EXPECTED_DATE AS hospitalExpectedDate, HOSPITAL_PATIENT_CARD AS hospitalPatientCard, HOSPITAL_BARCODE AS hospitalBarcode, HOSPITAL_RECORD_NUMBER AS hospitalRecordNumber, HOSPITAL_SERVICE_TYPE AS hospitalServiceType, HOSPITAL_SERVICE_STATUS AS hospitalServiceStatus, HOSPITAL_MEMBER AS hospitalMember, HOSPITAL_RECORD_DOCTOR AS hospitalRecordDoctor, HOSPITAL_RECORD_DATE AS hospitalRecordDate, HOSPITAL_RECORD_REMARK AS hospitalRecordRemark, HOSPITAL_MEMBER_DATE AS hospitalMemberDate, BUILD_DATE AS buildDate, HOSTPITAL_ID AS hostpitalId, BUILD_TYPE AS buildType, CREATE_ID AS createId, CREATE_TIME AS createTime, MODIFY_ID AS modifyId, MODIFY_TIME AS modifyTime, IFDEL AS ifdel, ENALBLE AS enalble, WOMAN_PERSON_ID AS womanPersonId, + WOMAN_TYPE AS womanType,DUE_STATUS AS dueStatus,SOURCE_ID AS sourceId + + diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/woman/WomanFetationRecord.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/woman/WomanFetationRecord.java index cae90ac..474acc9 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/woman/WomanFetationRecord.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/woman/WomanFetationRecord.java @@ -256,10 +256,8 @@ public class WomanFetationRecord implements Serializable { */ @TableField(value="WOMAN_PERSON_ID") private String womanPersonId; - - /** - * 孕妇出生============================================================================ + * 孕妇出生 */ @TableField(value="BASE_WOMAN_BIRTH") private Date baseWomanBirth; @@ -283,6 +281,16 @@ public class WomanFetationRecord implements Serializable { */ @TableField(value="HOSPITAL_RECORD_DATE") private Date hospitalRecordDate; + + //妇女类别:1孕妇,3产妇 + @TableField(value="WOMAN_TYPE") + private Integer womanType; + //分娩状态 0未终止妊娠 1终止妊娠 + @TableField(value="DUE_STATUS") + private Integer dueStatus; + //隐藏建档源ID + @TableField(value="SOURCE_ID") + private String sourceId; //格式化字段 @TableField(exist=false) @@ -295,6 +303,14 @@ public class WomanFetationRecord implements Serializable { private String hospitalExpectedDateStr;//预产期Str @TableField(exist=false) private String hospitalRecordDateStr;//建档日期Str + + //地址拼接字段 + @TableField(exist=false) + private String liveAddress;//居住地 + @TableField(exist=false) + private String registerAddress;//户籍地 + @TableField(exist=false) + private String postpartumAddress;//产后休养地 public String getId() { return id; @@ -751,6 +767,54 @@ public class WomanFetationRecord implements Serializable { public void setHospitalRecordDateStr(String hospitalRecordDateStr) { this.hospitalRecordDateStr = hospitalRecordDateStr; } + + public String getLiveAddress() { + return liveAddress; + } + + public void setLiveAddress(String liveAddress) { + this.liveAddress = liveAddress; + } + + public String getRegisterAddress() { + return registerAddress; + } + + public void setRegisterAddress(String registerAddress) { + this.registerAddress = registerAddress; + } + + public String getPostpartumAddress() { + return postpartumAddress; + } + + public void setPostpartumAddress(String postpartumAddress) { + this.postpartumAddress = postpartumAddress; + } + + public Integer getWomanType() { + return womanType; + } + + public void setWomanType(Integer womanType) { + this.womanType = womanType; + } + + public Integer getDueStatus() { + return dueStatus; + } + + public void setDueStatus(Integer dueStatus) { + this.dueStatus = dueStatus; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } } diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/enums/ServiceStatusEnums.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/enums/ServiceStatusEnums.java new file mode 100644 index 0000000..9a995d2 --- /dev/null +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/enums/ServiceStatusEnums.java @@ -0,0 +1,126 @@ +package com.lyms.hospital.enums; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by Administrator on 2016/6/21. + */ +public enum ServiceStatusEnums { + + //标准服务 + STANDARD_ALL(101,"全部",0), + STANDARD_OPEN(0,"开通",0), + NO_OPEN(1,"不开通",0), + STANDARD_OVERDUE(2,"过期",0), + + //增值服务 + ADD_ALL(102,"全部",1), + ADD_OPEN(3,"开通",1), + UNSUBSCRIBE(4,"退订",1), + ADD_OVERDUE(5,"过期",1), + SUSPEND(6,"暂停",1), + + //全部 + ALL(103,"全部",100), + ALL_OPEN(7,"开通",100), + ALL_NO_OPEN(8,"不开通",100), + ALL_OVERDUE(9,"过期",100); + + private ServiceStatusEnums(int id, String name,int pid){ + this.name=name; + this.id =id; + this.pid =pid; + } + private String name; + private int id; + private int pid; + + + public static List> getServiceStatusList() + { + List> list = new ArrayList<>(); + for(ServiceStatusEnums s : ServiceStatusEnums.values()) { + if (s.getId() < 100) + { + Map map = new HashMap<>(); + map.put("id", String.valueOf(s.getId())); + map.put("name", s.getName()); + map.put("pid", String.valueOf(s.getPid())); + list.add(map); + } + + } + return list; + } + + public static List> getServiceTypeList() + { + List> list = new ArrayList<>(); + Map stMap1 = new HashMap<>(); + stMap1.put("id", "0"); + stMap1.put("name", "标准服务"); + Map stMap2 = new HashMap<>(); + stMap2.put("id", "1"); + stMap2.put("name", "增值服务"); + list.add(stMap1); + list.add(stMap2); + return list; + } + + + public static List> getServiceStatusByPid(int pid) + { + List> list = new ArrayList<>(); + for(ServiceStatusEnums s : ServiceStatusEnums.values()) { + if (s.getPid() == pid) + { + Map map = new HashMap<>(); + map.put("id", String.valueOf(s.getId())); + map.put("name", s.getName()); + map.put("pid", String.valueOf(s.getPid())); + list.add(map); + } + + } + return list; + } + + public static String getNameById(Integer id) + { + for(ServiceStatusEnums s : ServiceStatusEnums.values()) { + if (id != null && s.getId() == id) + { + return s.getName(); + } + + } + return ""; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } +} diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/WomanFetationRecordService.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/WomanFetationRecordService.java index 450a78a..19ba8cd 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/WomanFetationRecordService.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/WomanFetationRecordService.java @@ -20,6 +20,17 @@ import com.lyms.web.service.BaseService; * @since 2017-03-31 */ public interface WomanFetationRecordService extends BaseService { + + /** + *
  • @Description:条件查询对象(未删除的)(主要用于验证条件下的存在性) + *
  • @param obj + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月24日 + *
  • 修改人: + *
  • 修改时间: + */ + public WomanFetationRecord queryOne(WomanFetationRecord obj); /** *
  • @Description:查询-查询历史建档记录(by证件信息和就诊卡号) @@ -100,4 +111,14 @@ public interface WomanFetationRecordService extends BaseService@Description:关联&合并省市区信息,避免接口多次建立SQL链接 + *
  • @param id + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月24日 + *
  • 修改人: + *
  • 修改时间: + */ + public WomanFetationRecord selectDetailById(String id); } diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/impl/WomanFetationRecordServiceImpl.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/impl/WomanFetationRecordServiceImpl.java index 9dbb81a..b446429 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/impl/WomanFetationRecordServiceImpl.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/woman/impl/WomanFetationRecordServiceImpl.java @@ -9,6 +9,7 @@ import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; @@ -43,7 +44,17 @@ public class WomanFetationRecordServiceImpl extends ServiceImpl map = new HashMap<>(); - WomanFetationRecord fetationRecord = this.selectById(id); + WomanFetationRecord fetationRecord = this.selectDetailById(id); if(fetationRecord!=null){ WomanHusband womanHusband = womanHusbandService.selectByTarget(WomanHusband.TARGET_TYPE_ARCHIVE, fetationRecord.getId()); map.put("fetationRecord", fetationRecord); @@ -129,4 +143,36 @@ public class WomanFetationRecordServiceImpl extends ServiceImpl> selectHistory(String cardType, String cardNo, String vcCardNo) { return fetationMapper.selectHistory(cardType, cardNo, vcCardNo); } + + @Override + public WomanFetationRecord queryOne(WomanFetationRecord obj) { + EntityWrapper ew = new EntityWrapper<>(); + ew.where("IFDEL={0}", IfdelEnum.NO.getStatus());//未被删除的 + if(obj.getEnalble()!=null){ + ew.and("ENALBLE={0}",obj.getEnalble()); + } + if(obj.getWomanType()!=null){ + ew.and("WOMAN_TYPE={0}",obj.getWomanType()); + } + if(obj.getDueStatus()!=null){ + ew.and("DUE_STATUS={0}",obj.getDueStatus()); + } + if(obj.getHostpitalId()!=null){ + ew.and("HOSTPITAL_ID={0}",obj.getHostpitalId()); + } + if(obj.getBuildType()!=null){ + ew.and("BUILD_TYPE={0}",obj.getBuildType()); + } + //证件号,联系方式,就诊卡 + if(obj.getBasePapersNumber()!=null){ + ew.and("BASE_PAPERS_NUMBER={0}",obj.getBasePapersNumber()); + } + if(obj.getContactWomanWay()!=null){ + ew.and("CONTACT_WOMAN_WAY={0}",obj.getContactWomanWay()); + } + if(obj.getHospitalPatientCard()!=null){ + ew.and("HOSPITAL_PATIENT_CARD={0}",obj.getHospitalPatientCard()); + } + return selectOne(ew); + } } diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/CommonApiController.java b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/CommonApiController.java new file mode 100644 index 0000000..26cc6db --- /dev/null +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/CommonApiController.java @@ -0,0 +1,110 @@ +package com.lyms.hospital.controller; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.lyms.base.common.entity.region.Regions; +import com.lyms.base.common.service.region.RegionsService; +import com.lyms.hospital.enums.ServiceStatusEnums; +import com.lyms.hospital.util.trans.OldDictionary; +import com.lyms.hospital.util.trans.XjhMapUtil; +import com.lyms.web.bean.AjaxResult; +import com.lyms.web.controller.BaseController; + +/** + *

    + * 公用接口-前端控制器 + *

    + * + * @author xujiahong + * @since 2017-04-21 + */ +@Controller +@RequestMapping("/commonApi") +public class CommonApiController extends BaseController { + + @Autowired + private RegionsService regionService; + + /** + *
  • @Description:查询省市区数据 + *
  • @param parentId + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月24日 + *
  • 修改人: + *
  • 修改时间: + */ + @RequestMapping(value = "/queryRegions", method = RequestMethod.GET) + @ResponseBody + public AjaxResult queryRegions (String parentId){ + List list = regionService.selectRegions(parentId); + return AjaxResult.returnSuccess(list); + } + + /** + *
  • @Description:查询字典数据 + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月24日 + *
  • 修改人: + *
  • 修改时间: + */ + @RequestMapping(value = "/queryDictionary", method = RequestMethod.GET) + @ResponseBody + public AjaxResult queryDictionary (){ + //TODO 模拟查询数据字典的数据 + Map dictionary = new HashMap<>(); + /*户口类型*/ + List> censusType = new ArrayList<>(); + censusType.add(XjhMapUtil.transBean2Map(new OldDictionary("001", "非农业户口"))); + censusType.add(XjhMapUtil.transBean2Map(new OldDictionary("002", "农业户口"))); + /*证件类型*/ + List> certeType = new ArrayList<>(); + certeType.add(XjhMapUtil.transBean2Map(new OldDictionary("003", "身份证"))); + certeType.add(XjhMapUtil.transBean2Map(new OldDictionary("004", "手机号"))); + /*国家*/ + List> country = new ArrayList<>(); + country.add(XjhMapUtil.transBean2Map(new OldDictionary("005", "中国"))); + country.add(XjhMapUtil.transBean2Map(new OldDictionary("006", "美国"))); + /*vip体验类型*/ + List> expYunEnums = new ArrayList<>(); + expYunEnums.add(XjhMapUtil.transBean2Map(new OldDictionary("007", "vip体验类型1"))); + expYunEnums.add(XjhMapUtil.transBean2Map(new OldDictionary("008", "vip体验类型2"))); + /*居住类型*/ + List> liveType = new ArrayList<>(); + liveType.add(XjhMapUtil.transBean2Map(new OldDictionary("009", "本地"))); + liveType.add(XjhMapUtil.transBean2Map(new OldDictionary("010", "非本地"))); + /*民族*/ + List> nation = new ArrayList<>(); + nation.add(XjhMapUtil.transBean2Map(new OldDictionary("011", "汉族"))); + nation.add(XjhMapUtil.transBean2Map(new OldDictionary("012", "白族"))); + /*职业类型*/ + List> professionType = new ArrayList<>(); + professionType.add(XjhMapUtil.transBean2Map(new OldDictionary("013", "医生"))); + professionType.add(XjhMapUtil.transBean2Map(new OldDictionary("014", "教师"))); + /*服务状态*/ + List> serviceStatus = ServiceStatusEnums.getServiceStatusList(); + /*服务类型*/ + List> serviceType = ServiceStatusEnums.getServiceTypeList(); + + dictionary.put("censusType", censusType); + dictionary.put("certeType", certeType); + dictionary.put("country", country); + dictionary.put("expYunEnums", expYunEnums); + dictionary.put("liveType", liveType); + dictionary.put("nation", nation); + dictionary.put("professionType", professionType); + dictionary.put("serviceStatus", serviceStatus); + dictionary.put("serviceType", serviceType); + return AjaxResult.returnSuccess(dictionary); + } +} diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/CommonApiController.java b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/CommonApiController.java deleted file mode 100644 index 6588895..0000000 --- a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/CommonApiController.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.lyms.hospital.controller.woman; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import com.lyms.hospital.util.trans.OldDictionary; -import com.lyms.hospital.util.trans.XjhMapUtil; -import com.lyms.web.bean.AjaxResult; -import com.lyms.web.controller.BaseController; - -/** - *

    - * 公用接口-前端控制器 - *

    - * - * @author xujiahong - * @since 2017-04-21 - */ -@Controller -@RequestMapping("/commonApi") -public class CommonApiController extends BaseController { - - @RequestMapping(value = "/queryDictionary", method = RequestMethod.GET) - @ResponseBody - public AjaxResult queryDictionary (){ - //TODO 模拟查询数据字典的数据 - Map dictionary = new HashMap<>(); - /*户口类型*/ - List> censusType = new ArrayList<>(); - censusType.add(XjhMapUtil.transBean2Map(new OldDictionary("001", "非农业户口"))); - censusType.add(XjhMapUtil.transBean2Map(new OldDictionary("002", "农业户口"))); - /*证件类型*/ - List> certeType = new ArrayList<>(); - certeType.add(XjhMapUtil.transBean2Map(new OldDictionary("003", "身份证"))); - certeType.add(XjhMapUtil.transBean2Map(new OldDictionary("004", "手机号"))); - /*国家*/ - List> country = new ArrayList<>(); - country.add(XjhMapUtil.transBean2Map(new OldDictionary("005", "中国"))); - country.add(XjhMapUtil.transBean2Map(new OldDictionary("006", "美国"))); - /*vip体验类型*/ - List> expYunEnums = new ArrayList<>(); - expYunEnums.add(XjhMapUtil.transBean2Map(new OldDictionary("007", "vip体验类型1"))); - expYunEnums.add(XjhMapUtil.transBean2Map(new OldDictionary("008", "vip体验类型2"))); - /*居住类型*/ - List> liveType = new ArrayList<>(); - liveType.add(XjhMapUtil.transBean2Map(new OldDictionary("009", "本地"))); - liveType.add(XjhMapUtil.transBean2Map(new OldDictionary("010", "非本地"))); - /*民族*/ - List> nation = new ArrayList<>(); - nation.add(XjhMapUtil.transBean2Map(new OldDictionary("011", "汉族"))); - nation.add(XjhMapUtil.transBean2Map(new OldDictionary("012", "白族"))); - /*职业类型*/ - List> professionType = new ArrayList<>(); - professionType.add(XjhMapUtil.transBean2Map(new OldDictionary("013", "医生"))); - professionType.add(XjhMapUtil.transBean2Map(new OldDictionary("014", "教师"))); - /*服务状态*/ - List> serviceStatus = new ArrayList<>(); - serviceStatus.add(XjhMapUtil.transBean2Map(new OldDictionary("015", "开通"))); - serviceStatus.add(XjhMapUtil.transBean2Map(new OldDictionary("016", "未开通"))); - /*服务类型*/ - List> serviceType = new ArrayList<>(); - serviceType.add(XjhMapUtil.transBean2Map(new OldDictionary("017", "标准服务"))); - serviceType.add(XjhMapUtil.transBean2Map(new OldDictionary("018", "增值服务"))); - dictionary.put("censusType", censusType); - dictionary.put("certeType", certeType); - dictionary.put("country", country); - dictionary.put("expYunEnums", expYunEnums); - dictionary.put("liveType", liveType); - dictionary.put("nation", nation); - dictionary.put("professionType", professionType); - dictionary.put("serviceStatus", serviceStatus); - dictionary.put("serviceType", serviceType); - return AjaxResult.returnSuccess(dictionary); - } -} diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/WomanPregnantController.java b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/WomanPregnantController.java index 7c271be..cd6d447 100644 --- a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/WomanPregnantController.java +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/WomanPregnantController.java @@ -7,33 +7,42 @@ import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; 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 com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.lyms.base.common.service.sys.SysDictService; import com.lyms.hospital.entity.woman.WomanFetationRecord; import com.lyms.hospital.entity.woman.WomanHusband; +import com.lyms.hospital.enums.IfdelEnum; +import com.lyms.hospital.enums.StatusEnum; import com.lyms.hospital.request.woman.WomanFetationRequest; import com.lyms.hospital.request.woman.WomanFetationRequestWrapper; import com.lyms.hospital.response.keymap.WomanFetationRecordKeymap; import com.lyms.hospital.response.woman.WomanFetationResponse; import com.lyms.hospital.service.token.TokenService; import com.lyms.hospital.service.woman.WomanFetationRecordService; +import com.lyms.hospital.util.HospitalUtil; +import com.lyms.hospital.util.UnitConstants; import com.lyms.hospital.util.trans.XjhMapUtil; import com.lyms.util.DateUtil; import com.lyms.web.bean.AjaxResult; import com.lyms.web.controller.BaseController; + /** *

    * 孕妇档案-前端控制器 *

    * * []依据cardNo或vcCardNo查询孕妇档案 - * []孕妇建档(新增或修改) - * 依据id得到“孕妇建档”表单详情 - * + * [--]孕妇建档(新增或修改) + * []依据id得到“孕妇建档”表单详情 + * []建档-查看页面数据 + * 删除档案 * @author xujiahong * @since 2017-04-17 */ @@ -45,6 +54,113 @@ public class WomanPregnantController extends BaseController { private WomanFetationRecordService fetationService; @Autowired private TokenService tokenService; + @Autowired + private SysDictService dictService; + + @RequestMapping(value = "/deletePregnant/{id}", method = RequestMethod.POST) + @ResponseBody + public AjaxResult deletePregnant(@PathVariable String id){ + Integer count = fetationService.deleteLogicById(id); + if(count>0){ + return AjaxResult.returnSuccess(); + }else{ + return AjaxResult.returnFail(); + } + } + + /** + *
  • @Description:建档-查看页面数据 + *
  • @param id + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月21日 + *
  • 修改人: + *
  • 修改时间: + */ + @RequestMapping(value = "/findPatientData", method = RequestMethod.GET) + @ResponseBody + public AjaxResult findPatientData(String id){ + //查询详情相关对象 + Map serviceMap = fetationService.selectWomanFetationMapById(id); + WomanFetationRecord f = (WomanFetationRecord)serviceMap.get("fetationRecord"); + WomanHusband w = (WomanHusband)serviceMap.get("womanHusband"); + /* + * 这里没有新建映射,拷贝 ViewFacade 的老代码 + */ + Map map = new HashMap<>(); + map.put("id", f.getId()); + /* 孕妇基础数据 */ + map.put("username", f.getBaseWomanName()); + map.put("pcerteType", dictService.getDictNameById(f.getBasePapersType()));//证件类型 + map.put("cardNo", f.getBasePapersNumber()); + map.put("phone", f.getContactWomanWay()); + map.put("pworkUnit", f.getContactWorkAddress()); + map.put("pcountry", dictService.getDictNameById(f.getBaseWomanCountry())); + map.put("pnation", dictService.getDictNameById(f.getBaseWomanNation())); + map.put("birth", DateUtil.getyyyy_MM_dd(f.getBaseWomanBirth())); + map.put("age", DateUtil.getAge(f.getBaseWomanBirth())+UnitConstants.SUI); + map.put("pcensusType", dictService.getDictNameById(f.getBaseRegisterType()));//户籍类型 + map.put("pliveType", dictService.getDictNameById(f.getBaseDwellType()));//居住类别 + map.put("pprofessionType", dictService.getDictNameById(f.getBaseOccupationType()));//职业类型 + map.put("plevelType", dictService.getDictNameById(f.getBaseWomanCulture()));// + map.put("baseFamilyIncome", f.getBaseFamilyIncome());//家庭人均收入 + + /* 孕妇联系方式 */ + map.put("residence", f.getLiveAddress()); + map.put("register", f.getRegisterAddress()); + map.put("postRest", f.getPostpartumAddress()); + + /* 丈夫信息 */ + map.put("husbandName", w.getHusbandName()); + map.put("hcertificateType", dictService.getDictNameById(w.getHusbandPapersType())); + map.put("hcertificateNum", w.getHusbandPapersNumber()); + map.put("hcountry", dictService.getDictNameById(w.getHusbandCountry())); + map.put("hnation", dictService.getDictNameById(w.getHusbandNation())); + map.put("husbandPhone", w.getHusbandWay()); + map.put("hprofessionType", dictService.getDictNameById(w.getHusbandOccupationType())); + map.put("hworkUnit", w.getHusbandWorkAddress()); + String province = w.getHusbandRegisterProvince(); + String city = w.getHusbandRegisterCity(); + String area = w.getHusbandRegisterArea(); + String street = w.getHusbandRegisterStreet(); + String detail = w.getHusbandRegisterDetail(); + map.put("hregister", (province==null?"":province) + +(city==null?"":city) + +(area==null?"":area) + +(street==null?"":street) + +(detail==null?"":detail) + ); + + /* 院内信息 */ + //末次月经 + map.put("lastMenses", DateUtil.getyyyy_MM_dd(f.getHospitalLastMenstruation())); + //孕周(用末次月经去计算) + map.put("lastMensesWeek", HospitalUtil.getPregnantWeek(f.getHospitalLastMenstruation())); + //纠正末次月经,取末次月经数据 + map.put("correctionLastMenses", DateUtil.getyyyy_MM_dd(f.getHospitalCorrectLastMenstruation())); + //纠正末次月经孕周 + map.put("correctionLastMensesWeek", HospitalUtil.getPregnantWeek(f.getHospitalCorrectLastMenstruation())); + + map.put("dueDate", DateUtil.getyyyy_MM_dd(f.getHospitalExpectedDate())); + map.put("vcCardNo", f.getHospitalPatientCard()); + //条码(暂时去掉) + //档案编号 + map.put("fileCode", f.getHospitalRecordNumber()); + //建档医生 + map.put("bookbuildingDoctor", "暂时写死的医生名称");//TODO 查询医生姓名 + //建档日期 + map.put("bookbuildingDate", DateUtil.getyyyy_MM_dd(f.getHospitalRecordDate())); + + map.put("mremark", f.getHospitalRecordRemark()); + //服务类型 + map.put("serviceType",f.getHospitalServiceType() ); + map.put("serviceStatus", f.getHospitalServiceStatus()); + + //建档孕周 + map.put("buildDueWeek",HospitalUtil.getPregnantWeek(f.getHospitalRecordDate())); + + return AjaxResult.returnSuccess(map); + } /** *
  • @Description:依据id得到“孕妇建档”表单详情 @@ -55,9 +171,9 @@ public class WomanPregnantController extends BaseController { *
  • 修改人: *
  • 修改时间: */ - @RequestMapping(value = "/queryPregnantBuildById", method = RequestMethod.GET) + @RequestMapping(value = "/queryPregnantBuildById/{id}", method = RequestMethod.GET) @ResponseBody - public AjaxResult queryPregnantBuildById(String id){ + public AjaxResult queryPregnantBuildById(@PathVariable String id){ //查询详情相关对象 Map map = fetationService.selectWomanFetationMapById(id); WomanFetationRecord fetationRecord = (WomanFetationRecord)map.get("fetationRecord"); @@ -69,8 +185,7 @@ public class WomanPregnantController extends BaseController { XjhMapUtil.getKeyMap(WomanFetationRecordKeymap.original, WomanFetationRecordKeymap.alias)); fetationRecordMap.putAll(womanHusbandMap); - System.out.println(fetationRecordMap); - WomanFetationResponse response = (WomanFetationResponse)XjhMapUtil.transMap2Bean(fetationRecordMap, new WomanFetationResponse()); + WomanFetationResponse response = (WomanFetationResponse)XjhMapUtil.transMap2Bean(fetationRecordMap, new WomanFetationResponse()); response.setId(fetationRecord.getId()); response.setPid(fetationRecord.getWomanPersonId()); return AjaxResult.returnSuccess(response); @@ -94,10 +209,12 @@ public class WomanPregnantController extends BaseController { //TODO 查询历史建档记录 List> history = fetationService.selectHistory(cardType, cardNo, vcCardNo); - Map dataMap = new HashMap<>(); dataMap.put("history", history); dataMap.put("now", DateUtil.getyyyy_MM_dd(new Date())); + //TODO 部分未涉及字段 + dataMap.put("initBuildDate", DateUtil.getyyyy_MM_dd(new Date())); + dataMap.put("rBType", true); return AjaxResult.returnSuccess(dataMap); } @@ -112,6 +229,13 @@ public class WomanPregnantController extends BaseController { @RequestMapping(value = "/addOrUpdateYunBuild", method = RequestMethod.POST) @ResponseBody public AjaxResult addOrUpdateYunBuild(@RequestBody WomanFetationRequest request) { + /* + * 需求: + * (1)同一孕妇在不同医院(orgId)对应两份档案,第一份为主档案,往后都是隐藏档案(sourceId=主档案ID) womanPersonId + * (2)TODO 同一医院同一孕妇,多个产程对应多个档案 + */ + + //TODO 登录 token 验证 /* * 转换业务对象 @@ -119,24 +243,71 @@ public class WomanPregnantController extends BaseController { WomanFetationRequestWrapper wrapper = new WomanFetationRequestWrapper(request); WomanFetationRecord womanFetationRecord = wrapper.getWomanFetationRecord(); WomanHusband womanHusband = wrapper.getWomanHusband(); - /* - * 需求: - * (1)同一孕妇在不同医院(orgId)对应两份档案 - * (2)TODO 同一医院同一孕妇,多个产程对应多个档案 - */ - //查询档案信息的存在性 - WomanFetationRecord dbObj = fetationService.findByCard( - request.getPregnantCertificateTypeId(), request.getPregnantCertificateNum(), - request.getVcCardNo(), request.getHospitalId()); + if(womanFetationRecord.getHostpitalId()==null){ + AjaxResult.returnFail("入参错误:缺少参数hostpitalId"); + } + + //新增或修改 boolean flag = false; if(request.getId()==null){//新增 - if(dbObj!=null){//本院已有档案,修改现有档案 - womanFetationRecord.setId(dbObj.getId()); - womanHusband.setTargetId(dbObj.getId()); - flag = fetationService.updatebuildRecord(womanFetationRecord, womanHusband); - }else{ - flag = fetationService.insertbuildRecord(womanFetationRecord, womanHusband); + + //用于重复性验证的查询对象(确保新建的档案在同医院同产程未重复) + WomanFetationRecord query = new WomanFetationRecord(); + query.setIfdel(IfdelEnum.NO.getStatus());//未被删除的 + query.setEnalble(StatusEnum.ENABLED.getStatus());//启用的 + query.setWomanType(1);//妇女类别:1孕妇,3产妇 + query.setDueStatus(0);//分娩状态 0未终止妊娠 1终止妊娠 + query.setHostpitalId(womanFetationRecord.getHostpitalId());//医院ID + query.setBuildType(0);//建档来源:0未分娩建档,1儿童建档时建档,2自动分娩类型,3转诊自动建档 ??? + //验证证件号是否重复 + if(womanFetationRecord.getBasePapersNumber()!=null){ + query.setBasePapersNumber(womanFetationRecord.getBasePapersNumber()); + WomanFetationRecord dbObj = fetationService.queryOne(query); + if(dbObj!=null){ + AjaxResult.returnFail("该证件在医院已经建档"); + } + } + //验证联系方式是否重复 + if(womanFetationRecord.getContactWomanWay()!=null){ + query.setBasePapersNumber(null); + query.setContactWomanWay(womanFetationRecord.getContactWomanWay()); + WomanFetationRecord dbObj = fetationService.queryOne(query); + if(dbObj!=null){ + AjaxResult.returnFail("该联系方式在医院已经建档"); + } + } + //验证就诊卡号是否重复 + if(womanFetationRecord.getHospitalPatientCard()!=null){ + query.setBasePapersNumber(null); + query.setContactWomanWay(null); + query.setHospitalPatientCard(womanFetationRecord.getHospitalPatientCard()); + WomanFetationRecord dbObj = fetationService.queryOne(query); + if(dbObj!=null){ + AjaxResult.returnFail("该就诊卡号在医院已经建档"); + } + } + //查询档案信息在外院的存在性(如存在,则建立sourceId一致的隐藏档案) + query.setHostpitalId(null); + query.setHospitalPatientCard(null); + String sourceId = ""; + if(womanFetationRecord.getBasePapersNumber()!=null){ + query.setBasePapersNumber(womanFetationRecord.getBasePapersNumber()); + WomanFetationRecord dbObj = fetationService.queryOne(query); + if(dbObj!=null){ + sourceId = dbObj.getId(); + } + } + if(womanFetationRecord.getContactWomanWay()!=null){ + query.setBasePapersNumber(null); + query.setContactWomanWay(womanFetationRecord.getContactWomanWay()); + WomanFetationRecord dbObj = fetationService.queryOne(query); + if(dbObj!=null){ + sourceId = dbObj.getId(); + } } + womanFetationRecord.setSourceId(sourceId); + + flag = fetationService.insertbuildRecord(womanFetationRecord, womanHusband); }else{//修改 flag = fetationService.updatebuildRecord(womanFetationRecord, womanHusband); } diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/response/woman/WomanFetationResponse.java b/parent/hospital.web/src/main/java/com/lyms/hospital/response/woman/WomanFetationResponse.java index 35b96ca..462f917 100644 --- a/parent/hospital.web/src/main/java/com/lyms/hospital/response/woman/WomanFetationResponse.java +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/response/woman/WomanFetationResponse.java @@ -135,9 +135,28 @@ public class WomanFetationResponse extends BaseResponseModule{ //分娩状态 0未终止妊娠 1终止妊娠 private Integer dueStatus; - - - public Integer getDueStatus() { + //1孕妇 3产妇 + private Integer type; // add by xujiahong since 2017-04-24 13:17:21 + + private String fmTime; + + public String getFmTime() { + return fmTime; + } + + public void setFmTime(String fmTime) { + this.fmTime = fmTime; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public Integer getDueStatus() { return dueStatus; } diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/util/HospitalUtil.java b/parent/hospital.web/src/main/java/com/lyms/hospital/util/HospitalUtil.java new file mode 100644 index 0000000..83bd174 --- /dev/null +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/util/HospitalUtil.java @@ -0,0 +1,39 @@ +package com.lyms.hospital.util; + +import java.util.Date; + +import com.lyms.util.DateUtil; + +/** + * 计算孕周
    + * a
    + * + * @author xujiahong + * + */ +public class HospitalUtil { + + /** + *
  • @Description: + *
  • @param date 末次月经日期 + *
  • @return + *
  • 创建人:xujiahong + *
  • 创建时间:2017年4月24日 + *
  • 修改人: + *
  • 修改时间: + */ + public static String getPregnantWeek(Date date) { + Date now = new Date(); + int days = DateUtil.daysBetween(date, now);//返回两个日期的间隔天数 + if (days < 0) { + return ""; + } + if (days >= 294) { + return "已分娩"; + } + int week = (days / 7); + int day = (days % 7); + return "孕" + week + "周" + day + "天"; + } + +} diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/util/UnitConstants.java b/parent/hospital.web/src/main/java/com/lyms/hospital/util/UnitConstants.java new file mode 100644 index 0000000..3dfbaaf --- /dev/null +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/util/UnitConstants.java @@ -0,0 +1,36 @@ +package com.lyms.hospital.util; + +/** + * + * 单位常量,用以返回值拼接 + * + * Created by Administrator on 2017/1/11 0011. + */ +public class UnitConstants { + + public static final String CM = " cm"; + public static final String KG = " kg"; + public static final String MMHG = " mmHg"; + public static final String CIFEN = " 次/分"; + public static final String GL = " g/L"; + public static final String MMOLL = " mmol/L"; + public static final String CI = " 次"; + public static final String UL = " U/L"; + public static final String TEN_LKG = "×109/L"; +// public static final String TEN_LKG = " 10^9/L"; + public static final String UMOLL = " umol/L"; + public static final String ZHEN = " 针"; + public static final String ML = " ml"; + public static final String G = " g"; + public static final String FEN = " 分"; + public static final String FZ = " 分钟"; + public static final String GE = " 个"; + public static final String SUI = " 岁"; + public static final String REN = " 人"; + public static final String HD = " 时/日"; + public static final String WENDU = " ℃"; + public static final String WSSD = " IU/日"; + public static final String DAY = " 天"; + + +} diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/XjhMapUtil.java b/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/XjhMapUtil.java index c71de01..4149ca1 100644 --- a/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/XjhMapUtil.java +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/XjhMapUtil.java @@ -27,10 +27,17 @@ public class XjhMapUtil { * @throws IllegalAccessException */ private static void invokeIgnoreType(PropertyDescriptor property,Object value,Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{ - Class keyType = property.getPropertyType(); - Class valueType = value.getClass(); + if(obj==null || property==null){ + return; + } // 得到property对应的setter方法 Method setter = property.getWriteMethod(); + if(value==null){//null值可匹配任何类型的对象 + setter.invoke(obj, value); + return; + } + Class keyType = property.getPropertyType(); + Class valueType = value.getClass(); //简单处理映射字段类型不匹配的情况 if (keyType.equals(valueType)) { setter.invoke(obj, value); @@ -49,6 +56,9 @@ public class XjhMapUtil { } public static Object transMap2Bean(Map map, Object obj) { + if(map==null || obj==null){ + return null; + } try { BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); @@ -62,12 +72,16 @@ public class XjhMapUtil { } catch (Exception e) { System.err.println("映射"+obj.getClass().getName()+"对象时发生错误"); System.err.println("transMap2Bean Error " + e); + e.printStackTrace(); } return obj; } // 自动处理时间字段和对应的字符串字段(Str结尾) public static Object transMap2FormatBean(Map map, Object obj) { + if(map==null || obj==null){ + return null; + } try { BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); @@ -103,11 +117,15 @@ public class XjhMapUtil { } catch (Exception e) { System.err.println("映射"+obj.getClass().getName()+"对象时发生错误"); System.err.println("transMap2FormatBean Error " + e); + e.printStackTrace(); } return obj; } public static Map transBean2Map(Object obj) { + if(obj==null){ + return null; + } Map map = new HashMap<>(); try { BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); @@ -125,6 +143,7 @@ public class XjhMapUtil { } catch (Exception e) { System.err.println("映射"+obj.getClass().getName()+"对象时发生错误"); System.err.println("transBean2Map Error " + e); + e.printStackTrace(); } return map; } @@ -154,6 +173,9 @@ public class XjhMapUtil { } public static Map transBean2AliasMap(Object obj, HashMap keyMap) { + if(keyMap==null || obj==null){ + return null; + } Map map = new HashMap<>(); try { BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); @@ -173,11 +195,15 @@ public class XjhMapUtil { } catch (Exception e) { System.err.println("映射"+obj.getClass().getName()+"对象时发生错误"); System.err.println("transBean2AliasMap Error " + e); + e.printStackTrace(); } return map; } public static Map transBean2FormatAliasMap(Object obj, HashMap keyMap) { + if(keyMap==null || obj==null){ + return null; + } Map map = new HashMap<>(); try { BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); @@ -208,24 +234,25 @@ public class XjhMapUtil { } catch (Exception e) { System.err.println("映射"+obj.getClass().getName()+"对象时发生错误"); System.err.println("transBean2FormatAliasMap Error " + e); + e.printStackTrace(); } return map; } - public static void mappingAlias(Object original, Object alias, HashMap keyMap) { - Map aliasMap = transBean2AliasMap(original, keyMap); - transMap2Bean(aliasMap, alias); - } - - public static void mappingFormatAlias(Object original, Object alias, HashMap keyMap) { - Map aliasMap = transBean2FormatAliasMap(original, keyMap); - transMap2FormatBean(aliasMap, alias); - } +// public static void mappingAlias(Object original, Object alias, HashMap keyMap) { +// Map aliasMap = transBean2AliasMap(original, keyMap); +// transMap2Bean(aliasMap, alias); +// } +// +// public static void mappingFormatAlias(Object original, Object alias, HashMap keyMap) { +// Map aliasMap = transBean2FormatAliasMap(original, keyMap); +// transMap2FormatBean(aliasMap, alias); +// } /* * 方便书写映射文件keyMap */ - public static void printField(Object obj) { + private static void printField(Object obj) { try { BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); @@ -237,14 +264,14 @@ public class XjhMapUtil { } } } catch (Exception e) { - System.err.println("printField Error " + e); + e.printStackTrace(); } } /* * 方便书写 json */ - public static void printJsonByArray(String[] args) { + private static void printJsonByArray(String[] args) { System.out.println("{"); for (int i = 0; i < args.length; i++) { String str = "\"" + args[i] + "\":\"666\""; @@ -257,7 +284,7 @@ public class XjhMapUtil { } public static void main(String[] args) { - // printField(new WomanHusband()); +// printField(new WomanHusband()); printJsonByArray(WomanFetationRecordKeymap.alias); }