From 17f7a5e85f2234503b6ae22ad966a73cf3ac7ede Mon Sep 17 00:00:00 2001
From: xujiahong
Date: Fri, 21 Apr 2017 16:02:28 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=8E=A5=E5=8F=A3=EF=BC=88?=
=?UTF-8?q?=E7=AE=80=E5=8D=95=E5=AF=B9=E6=8E=A5=E7=89=88=EF=BC=89=EF=BC=9A?=
=?UTF-8?q?=E5=AD=95=E5=A6=87=E5=BB=BA=E6=A1=A3=EF=BC=8C=E8=BA=AB=E4=BB=BD?=
=?UTF-8?q?=E8=AF=81=E6=9F=A5=E8=AF=A2=E5=8E=86=E5=8F=B2=E5=BB=BA=E6=A1=A3?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8CID=E6=9F=A5=E8=AF=A2=E5=BB=BA?=
=?UTF-8?q?=E6=A1=A3=E8=AF=A6=E6=83=85=EF=BC=9B=E5=B0=81=E8=A3=85=E6=96=B0?=
=?UTF-8?q?=E6=97=A7=E7=B3=BB=E7=BB=9F=E5=AD=97=E6=AE=B5=E6=98=A0=E5=B0=84?=
=?UTF-8?q?=E5=B7=A5=E5=85=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dao/woman/WomanFetationRecordMapper.java | 21 +-
.../dao/woman/WomanFetationRecordMapper.xml | 20 ++
.../hospital/entity/woman/WomanFetationRecord.java | 187 +++++++++------
.../lyms/hospital/entity/woman/WomanHusband.java | 14 ++
.../service/woman/WomanFetationRecordService.java | 128 +++++-----
.../woman/impl/WomanFetationRecordServiceImpl.java | 23 +-
.../woman/impl/WomanHusbandServiceImpl.java | 5 +-
.../controller/woman/CommonApiController.java | 82 +++++++
.../controller/woman/WomanPregnantController.java | 76 +++++-
.../request/woman/WomanFetationRequest.java | 50 +++-
.../request/woman/WomanFetationRequestWrapper.java | 20 +-
.../response/keymap/WomanFetationRecordKeymap.java | 215 +++++++++++++++++
.../lyms/hospital/util/trans/OldDictionary.java | 65 +++++
.../com/lyms/hospital/util/trans/XjhMapUtil.java | 264 +++++++++++++++++++++
14 files changed, 1017 insertions(+), 153 deletions(-)
create mode 100644 parent/hospital.web/src/main/java/com/lyms/hospital/controller/woman/CommonApiController.java
create mode 100644 parent/hospital.web/src/main/java/com/lyms/hospital/response/keymap/WomanFetationRecordKeymap.java
create mode 100644 parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/OldDictionary.java
create mode 100644 parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/XjhMapUtil.java
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 71012db..d053b78 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
@@ -2,8 +2,13 @@ package com.lyms.hospital.dao.woman;
import com.lyms.hospital.entity.woman.WomanFetationRecord;
import com.baomidou.mybatisplus.mapper.BaseMapper;
+
+import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
/**
*
* Mapper接口
@@ -15,6 +20,20 @@ import java.io.Serializable;
@Repository
public interface WomanFetationRecordMapper extends BaseMapper {
- public Integer deleteLogicById(Serializable id);
+ public Integer deleteLogicById(Serializable id);
+
+ /**
+ * @Description:查询-查询历史建档记录(by证件信息和就诊卡号)
+ * @param cardType
+ * @param cardNo
+ * @param vcCardNo
+ * @return
+ * 创建人:xujiahong
+ * 创建时间:2017年4月20日
+ * 修改人:
+ * 修改时间:
+ */
+ public List
*
* @author fangcheng,xujiahong
* @since 2017-03-31
*/
public interface WomanFetationRecordService extends BaseService {
-
-
+
+ /**
+ * @Description:查询-查询历史建档记录(by证件信息和就诊卡号)
+ * @param cardType
+ * @param cardNo
+ * @param vcCardNo
+ * @return
+ * 创建人:xujiahong
+ * 创建时间:2017年4月20日
+ * 修改人:
+ * 修改时间:
+ */
+ public List
*
- * 依据cardNo或vcCardNo查询孕妇档案
- * 孕妇建档(新增或修改)
+ * []依据cardNo或vcCardNo查询孕妇档案
+ * []孕妇建档(新增或修改)
* 依据id得到“孕妇建档”表单详情
*
* @author xujiahong
@@ -38,6 +47,36 @@ public class WomanPregnantController extends BaseController {
private TokenService tokenService;
/**
+ * @Description:依据id得到“孕妇建档”表单详情
+ * @param id
+ * @return
+ * 创建人:xujiahong
+ * 创建时间:2017年4月20日
+ * 修改人:
+ * 修改时间:
+ */
+ @RequestMapping(value = "/queryPregnantBuildById", method = RequestMethod.GET)
+ @ResponseBody
+ public AjaxResult queryPregnantBuildById(String id){
+ //查询详情相关对象
+ Map map = fetationService.selectWomanFetationMapById(id);
+ WomanFetationRecord fetationRecord = (WomanFetationRecord)map.get("fetationRecord");
+ WomanHusband womanHusband = (WomanHusband)map.get("womanHusband");
+ //转换为与前端对接的response对象
+ Map fetationRecordMap = XjhMapUtil.transBean2FormatAliasMap(fetationRecord,
+ XjhMapUtil.getKeyMap(WomanFetationRecordKeymap.original, WomanFetationRecordKeymap.alias));
+ Map womanHusbandMap = XjhMapUtil.transBean2FormatAliasMap(womanHusband,
+ XjhMapUtil.getKeyMap(WomanFetationRecordKeymap.original, WomanFetationRecordKeymap.alias));
+ fetationRecordMap.putAll(womanHusbandMap);
+
+ System.out.println(fetationRecordMap);
+ WomanFetationResponse response = (WomanFetationResponse)XjhMapUtil.transMap2Bean(fetationRecordMap, new WomanFetationResponse());
+ response.setId(fetationRecord.getId());
+ response.setPid(fetationRecord.getWomanPersonId());
+ return AjaxResult.returnSuccess(response);
+ }
+
+ /**
* @Description:依据cardNo或vcCardNo查询孕妇档案
* @param cardNo
* @param vcCardNo
@@ -49,9 +88,17 @@ public class WomanPregnantController extends BaseController {
*/
@RequestMapping(value = "/queryPregnantBuildRecord", method = RequestMethod.GET)
@ResponseBody
- public AjaxResult queryPregnantBuildRecord(String cardNo,String vcCardNo){
- //TODO
- return AjaxResult.returnFail();
+ public AjaxResult queryPregnantBuildRecord(String cardType,String cardNo,String vcCardNo){
+
+// System.out.println("cardType:"+cardType+"cardNo:"+cardNo+"vcCardNo:"+vcCardNo);
+
+ //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()));
+ return AjaxResult.returnSuccess(dataMap);
}
/**
@@ -73,17 +120,24 @@ public class WomanPregnantController extends BaseController {
WomanFetationRecord womanFetationRecord = wrapper.getWomanFetationRecord();
WomanHusband womanHusband = wrapper.getWomanHusband();
/*
- * 业务逻辑:
- * (1)查询档案信息的存在性
- * (2)若不存在则新增,若存在则修改
+ * 需求:
+ * (1)同一孕妇在不同医院(orgId)对应两份档案
+ * (2)TODO 同一医院同一孕妇,多个产程对应多个档案
*/
+ //查询档案信息的存在性
WomanFetationRecord dbObj = fetationService.findByCard(
request.getPregnantCertificateTypeId(), request.getPregnantCertificateNum(),
request.getVcCardNo(), request.getHospitalId());
boolean flag = false;
- if(dbObj==null){//新增
- flag = fetationService.insertbuildRecord(womanFetationRecord, womanHusband);
- }else{//修改
+ 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);
+ }
+ }else{//修改
flag = fetationService.updatebuildRecord(womanFetationRecord, womanHusband);
}
if(flag){
diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequest.java b/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequest.java
index 6f98306..304789c 100644
--- a/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequest.java
+++ b/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequest.java
@@ -14,14 +14,28 @@ import com.lyms.hospital.util.FormParam;
@Form
public class WomanFetationRequest {
+
+
+ /*
+ * 新字段 since 2017-04-21 10:33:43
+ */
+
+ private String womanHusbandId;// 【新】配偶信息ID
+ private String baseFamilyIncome;//家庭收入
+ private String husbandBirthStr;//【新字段】出生日期
+ private String hospitalCorrectLastMenstruation;//【新字段】纠正末次月经
+ private String hospitalBarcode;//【新字段】条码
+
+ /*
+ * 新字段 since 2017-04-21 10:33:43
+ */
+
// 建档ID
private String id;
// 女性居民ID
@FormParam
private String pid;
- // 【新】配偶信息ID
- private String womanHusbandId;
/*********** 孕妇基本信息 ***********/
@@ -623,5 +637,37 @@ public class WomanFetationRequest {
public void setWomanHusbandId(String womanHusbandId) {
this.womanHusbandId = womanHusbandId;
}
+
+ public String getBaseFamilyIncome() {
+ return baseFamilyIncome;
+ }
+
+ public void setBaseFamilyIncome(String baseFamilyIncome) {
+ this.baseFamilyIncome = baseFamilyIncome;
+ }
+
+ public String getHusbandBirthStr() {
+ return husbandBirthStr;
+ }
+
+ public void setHusbandBirthStr(String husbandBirthStr) {
+ this.husbandBirthStr = husbandBirthStr;
+ }
+
+ public String getHospitalCorrectLastMenstruation() {
+ return hospitalCorrectLastMenstruation;
+ }
+
+ public void setHospitalCorrectLastMenstruation(String hospitalCorrectLastMenstruation) {
+ this.hospitalCorrectLastMenstruation = hospitalCorrectLastMenstruation;
+ }
+
+ public String getHospitalBarcode() {
+ return hospitalBarcode;
+ }
+
+ public void setHospitalBarcode(String hospitalBarcode) {
+ this.hospitalBarcode = hospitalBarcode;
+ }
}
diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequestWrapper.java b/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequestWrapper.java
index baaa222..3f4b5dd 100644
--- a/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequestWrapper.java
+++ b/parent/hospital.web/src/main/java/com/lyms/hospital/request/woman/WomanFetationRequestWrapper.java
@@ -23,7 +23,7 @@ public class WomanFetationRequestWrapper {
womanFetationRecord.setId(req.getId());
womanHusband.setTargetId(req.getId());
/*
- * 孕妇基本信息
+ * 孕妇基本信息(10+1)
*/
womanFetationRecord.setBaseWomanName(req.getPregnantName());//孕妇姓名
womanFetationRecord.setBasePapersType(req.getPregnantCertificateTypeId());//孕妇证件类型
@@ -34,10 +34,10 @@ public class WomanFetationRequestWrapper {
womanFetationRecord.setBaseRegisterType(req.getPregnantCensusTypeId());//孕妇户籍类型
womanFetationRecord.setBaseDwellType(req.getPregnantLiveTypeId());//孕妇居住类别
womanFetationRecord.setBaseOccupationType(req.getPregnantProfessionTypeId());//孕妇职业类别
- womanFetationRecord.setBaseWomanCulture("");//【新】文化程度==========================
- womanFetationRecord.setBaseFamilyIncome("");//【新】家庭收入==========================
+ womanFetationRecord.setBaseWomanCulture(req.getPregnantLevelTypeId());//文化程度
+ womanFetationRecord.setBaseFamilyIncome(req.getBaseFamilyIncome());//【新】家庭收入==========================
/*
- * 孕妇联系方式
+ * 孕妇联系方式(17)
*/
womanFetationRecord.setContactWomanWay(req.getPregnantPhone());//孕妇电话
womanFetationRecord.setContactWorkAddress(req.getPregnantWorkUnit());//孕妇工作单位
@@ -64,11 +64,11 @@ public class WomanFetationRequestWrapper {
*/
womanFetationRecord.setHospitalLastMenstruation(DateUtil.parseYMD(req.getLastMenstrualPeriod()));//末次月经
//【新】纠正末次月经================
- womanFetationRecord.setHospitalCorrectLastMenstruation(null);
+ womanFetationRecord.setHospitalCorrectLastMenstruation(DateUtil.parseYMD(req.getHospitalCorrectLastMenstruation()));
womanFetationRecord.setHospitalExpectedDate(DateUtil.parseYMD(req.getDueDate()));//预产期
womanFetationRecord.setHospitalPatientCard(req.getVcCardNo());//就诊卡号
//【新】条码=====================
- womanFetationRecord.setHospitalBarcode(null);
+ womanFetationRecord.setHospitalBarcode(req.getHospitalBarcode());
womanFetationRecord.setHospitalServiceType(req.getServiceType()+"");//服务类型
womanFetationRecord.setHospitalServiceStatus(req.getServiceStatus()+"");//服务状态
womanFetationRecord.setHospitalRecordNumber(req.getFileCode());//档案编号
@@ -86,7 +86,7 @@ public class WomanFetationRequestWrapper {
//【新】建档来源=====================
womanFetationRecord.setBuildType(null);//建档来源
/*
- * 丈夫信息
+ * 丈夫信息(14+1)
*/
womanHusband.setHusbandName(req.getHusbandName());//丈夫姓名
womanHusband.setHusbandPapersType(req.getHusbandCertificateTypeId());//丈夫证件类型
@@ -94,9 +94,8 @@ public class WomanFetationRequestWrapper {
womanHusband.setHusbandCountry(req.getHusbandCountryId());//丈夫国籍
womanHusband.setHusbandNation(req.getHusbandNationId());//丈夫民族
//【新】丈夫出生日期=====================
- womanHusband.setHusbandBirth(null);
- //【新】丈夫文化程度=====================
- womanHusband.setHusbandCulture(null);
+ womanHusband.setHusbandBirth(DateUtil.parseYMD(req.getHusbandBirthStr()));
+ womanHusband.setHusbandCulture(req.getHusbandLevelTypeId());//丈夫文化程度
womanHusband.setHusbandWay(req.getHusbandPhone());//丈夫联系方式
womanHusband.setHusbandOccupationType(req.getHusbandProfessionTypeId());//丈夫职业类别
womanHusband.setHusbandWorkAddress(req.getHusbandWorkUnit());//丈夫工作单位
@@ -105,6 +104,7 @@ public class WomanFetationRequestWrapper {
womanHusband.setHusbandRegisterArea(req.getHusbandAreaRegisterId());//丈夫居住地区县
womanHusband.setHusbandRegisterStreet(req.getHusbandStreetRegisterId());//丈夫居住地乡镇街道
womanHusband.setHusbandRegisterDetail(req.getHusbandAddressRegister());//丈夫居住地详细地址
+
womanHusband.setTargetType(WomanHusband.TARGET_TYPE_ARCHIVE);//配偶信息来源于孕妇建档
}
}
diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/response/keymap/WomanFetationRecordKeymap.java b/parent/hospital.web/src/main/java/com/lyms/hospital/response/keymap/WomanFetationRecordKeymap.java
new file mode 100644
index 0000000..c67dcd4
--- /dev/null
+++ b/parent/hospital.web/src/main/java/com/lyms/hospital/response/keymap/WomanFetationRecordKeymap.java
@@ -0,0 +1,215 @@
+package com.lyms.hospital.response.keymap;
+
+/**
+ * 孕妇建档-新老系统字段名映射
+ * @author xujiahong
+ *
+ */
+public class WomanFetationRecordKeymap {
+
+ /*
+ 【未映射字段(需要手动get,set)】
+ WomanFetationRecord====================
+
+ "hospitalMember",//会员预约时间???
+ "hospitalMemberDate",//体验到期时间
+
+ "buildDate",//建档时间
+ "buildType",//建档来源
+ "createId",//
+ "createTime",//
+ "enalble",//
+ "id",//
+ "ifdel",//
+ "modifyId",//
+ "modifyTime",//
+ "womanPersonId"//女性居民表ID
+
+ WomanHusband===============================
+ "bloodRelation",//
+ "bloodRelationText",//
+ "createTime",//
+ "id",//
+ "isProvide",//
+ "targetId",//
+ "targetType",//
+
+ WomanFetationResponse=====================
+ "id",//建档Id
+ "pid",
+
+ 【删除字段】
+ "expType",//vip体验类型
+ "expVip",//vip体验
+ "vipEndTime",//vip体验结束日期
+ "dueStatus"//分娩状态 0未终止妊娠 1终止妊娠
+ 【新增字段】
+ "baseFamilyIncome",//【新字段】家庭收入
+ "husbandBirth",//【新字段】出生日期
+ "hospitalCorrectLastMenstruation",//【新字段】纠正末次月经
+ "hospitalBarcode",//【新字段】条码
+ 【】
+
+ */
+
+ public static String[] original = {
+ /*
+ * 孕妇基本信息(10+1)
+ */
+ "baseWomanName",
+ "basePapersType",
+ "basePapersNumber",
+ "baseWomanCountry",
+ "baseWomanNation",
+ "baseWomanBirthStr",
+ "baseRegisterType",//户籍类别
+ "baseDwellType",//居住类别
+ "baseOccupationType",//职业类别
+ "baseWomanCulture",//文化程度
+ "baseFamilyIncome",//【新字段】家庭收入
+ /*
+ * 孕妇联系方式(17=)
+ */
+ "contactWomanWay",
+ "contactWorkAddress",
+ //居住地:省、市、区、乡镇街道、详细地址
+ "contactDwellProvince",
+ "contactDwellCity",
+ "contactDwellArea",
+ "contactDwellStreet",
+ "contactDwellDetail",
+ //户籍地址:省、市、区、乡镇街道、详细地址
+ "contactRegisterProvince",
+ "contactRegisterCity",
+ "contactRegisterArea",
+ "contactRegisterStreet",
+ "contactRegisterDetail",
+ //产后修养地:省、市、区、乡镇街道、详细地址
+ "contactPostpartumProvince",
+ "contactPostpartumCity",
+ "contactPostpartumArea",
+ "contactPostpartumStreet",
+ "contactPostpartumDetail",
+ /*
+ * 丈夫信息(=======14+1)
+ */
+ "husbandName",//
+ "husbandPapersType",//
+ "husbandPapersNumber",//
+ "husbandCountry",//
+ "husbandNation",//
+ "husbandBirthStr",//【新字段】出生日期
+ "husbandOccupationType",//
+ "husbandCulture",//
+ "husbandWay",//
+ "husbandWorkAddress",//
+
+ "husbandRegisterProvince",//
+ "husbandRegisterCity",//
+ "husbandRegisterArea",//
+ "husbandRegisterStreet",//
+ "husbandRegisterDetail",//
+
+
+ /*
+ * 孕妇院内信息(========14+2-4)
+ */
+ "hospitalLastMenstruationStr",//末次月经
+ "hospitalCorrectLastMenstruationStr",//【新字段】纠正末次月经
+ "hospitalExpectedDateStr",//预产期
+ "hospitalPatientCard",//就诊卡
+ "hospitalBarcode",//【新字段】条码
+ "hospitalRecordNumber",//档案编号
+ "hospitalServiceType",//服务类型
+ "hospitalServiceStatus",//服务状态
+
+ "hospitalRecordDoctor",//建档医生
+ "hostpitalId",//建档医院
+ "hospitalRecordDateStr",//建档日期
+ "hospitalRecordRemark",//档案备注
+
+ };
+
+ public static String[] alias = {
+ /*
+ * 孕妇基本信息(10+1)
+ */
+ "pregnantName",
+ "pregnantCertificateTypeId",
+ "pregnantCertificateNum",
+ "pregnantCountryId",
+ "pregnantNationId",
+ "birthday",
+ "pregnantCensusTypeId",//户籍类别
+ "pregnantLiveTypeId",//居住类别
+ "pregnantProfessionTypeId",//职业类别
+ "pregnantLevelTypeId",//文化程度
+ "baseFamilyIncome",//【新字段】家庭收入
+ /*
+ * 孕妇联系方式(17=)
+ */
+ "pregnantPhone",
+ "pregnantWorkUnit",
+ //居住地:省、市、区、乡镇街道、详细地址
+ "pregnantLiveProvinceId",
+ "pregnantLiveCityId",
+ "pregnantLiveAreaId",
+ "pregnantLiveStreetId",
+ "pregnantLiveAddr",
+ //户籍地址:省、市、区、乡镇街道、详细地址
+ "pregnantCensusProvinceId",
+ "pregnantCensusCityId",
+ "pregnantCensusAreaId",
+ "pregnantCensusStreetId",
+ "pregnantCensusAddr",
+ //产后修养地:省、市、区、乡镇街道、详细地址
+ "childbirthProvinceId",
+ "childbirthCityId",
+ "childbirthAreaId",
+ "childbirthStreetId",
+ "childbirthAddr",
+ /*
+ * 丈夫信息(14+1)
+ */
+ "husbandName",
+ "husbandCertificateTypeId",
+ "husbandCertificateNum",
+ "husbandCountryId",
+ "husbandNationId",
+ "husbandBirthStr",//【新字段】出生日期
+ "husbandProfessionTypeId",//职业类别
+ "husbandLevelTypeId",//丈夫文化程度
+ "husbandPhone",
+ "husbandWorkUnit",
+ //地址
+ "husbandProvinceRegisterId",
+ "husbandCityRegisterId",
+ "husbandAreaRegisterId",
+ "husbandStreetRegisterId",
+ "husbandAddressRegister",
+
+ /*
+ * 孕妇院内信息(14+2-4)
+ */
+ "lastMenstrualPeriod",//末次月经
+ "hospitalCorrectLastMenstruation",//【新字段】纠正末次月经
+ "dueDate",//预产期
+ "vcCardNo",//就诊卡号
+ "hospitalBarcode",//【新字段】条码
+ "fileCode",//档案编号
+ "serviceType",//服务类型
+ "serviceStatus",//服务状态
+
+ "bookbuildingDoctor",//建档医生ID
+ "hospitalId",//建档医院ID
+ "bookbuildingDate",//建档日期
+ "mremark",//备注
+
+// "expType",//vip体验类型
+// "expVip",//vip体验
+// "vipEndTime",//vip体验结束日期
+// "dueStatus"//分娩状态 0未终止妊娠 1终止妊娠
+
+ };
+
+}
diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/OldDictionary.java b/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/OldDictionary.java
new file mode 100644
index 0000000..1d99f04
--- /dev/null
+++ b/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/OldDictionary.java
@@ -0,0 +1,65 @@
+package com.lyms.hospital.util.trans;
+
+public class OldDictionary {
+
+ private String id;
+ private String hildConfigs;
+ private String code;
+ private String desc;
+ private Integer enable;
+ private String name;
+ private String parentId;
+
+ public OldDictionary(){}
+
+ public OldDictionary(String id,String name){
+ this.id = id;
+ this.name = name;
+ this.enable = 1;
+ }
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getHildConfigs() {
+ return hildConfigs;
+ }
+ public void setHildConfigs(String hildConfigs) {
+ this.hildConfigs = hildConfigs;
+ }
+ public String getCode() {
+ return code;
+ }
+ public void setCode(String code) {
+ this.code = code;
+ }
+ public String getDesc() {
+ return desc;
+ }
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+ public Integer getEnable() {
+ return enable;
+ }
+ public void setEnable(Integer enable) {
+ this.enable = enable;
+ }
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getParentId() {
+ return parentId;
+ }
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+
+
+}
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
new file mode 100644
index 0000000..c71de01
--- /dev/null
+++ b/parent/hospital.web/src/main/java/com/lyms/hospital/util/trans/XjhMapUtil.java
@@ -0,0 +1,264 @@
+package com.lyms.hospital.util.trans;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import com.lyms.hospital.response.keymap.WomanFetationRecordKeymap;
+import com.lyms.util.DateUtil;
+
+public class XjhMapUtil {
+
+ /**
+ * 简单处理映射字段类型不匹配的情况
+ * @param property 目标字段Bean相关信息
+ * @param value 目标字段值
+ * @param obj 对象
+ * @author xujiahong
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ */
+ private static void invokeIgnoreType(PropertyDescriptor property,Object value,Object obj) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+ Class> keyType = property.getPropertyType();
+ Class> valueType = value.getClass();
+ // 得到property对应的setter方法
+ Method setter = property.getWriteMethod();
+ //简单处理映射字段类型不匹配的情况
+ if (keyType.equals(valueType)) {
+ setter.invoke(obj, value);
+ } else {
+ if(keyType.equals(String.class)){
+ setter.invoke(obj, value.toString());
+ }else if(keyType.equals(Integer.class)){
+ setter.invoke(obj, Integer.parseInt(value.toString()));
+ }else if(keyType.equals(Double.class)){
+ setter.invoke(obj, Double.parseDouble(value.toString()));
+ }else{
+ System.err.println("映射"+obj.getClass().getName()+"对象时发生错误");
+ System.err.println("字段【"+property.getName()+"】没有可匹配的自动转换类型");
+ }
+ }
+ }
+
+ public static Object transMap2Bean(Map map, Object obj) {
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ String key = property.getName();
+ if (map.containsKey(key)) {
+ Object value = map.get(key);
+ invokeIgnoreType(property,value,obj);
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("映射"+obj.getClass().getName()+"对象时发生错误");
+ System.err.println("transMap2Bean Error " + e);
+ }
+ return obj;
+ }
+
+ // 自动处理时间字段和对应的字符串字段(Str结尾)
+ public static Object transMap2FormatBean(Map map, Object obj) {
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ String key = property.getName();
+ Class> keyType = property.getPropertyType();
+ // set当前字段
+ if (map.containsKey(key)) {
+ Object value = map.get(key);
+ invokeIgnoreType(property,value,obj);
+
+ /*
+ * 自动处理时间字段和对应的字符串字段(Str结尾)
+ */
+ if (keyType.equals(String.class) && key.length() > 3
+ && "Str".equals(key.substring(key.length() - 3))) {// key可能是格式化字段
+ String dateKey = key.substring(key.length() - 3);
+ for (PropertyDescriptor dateProperty : propertyDescriptors) {
+ if (dateKey.equals(dateProperty.getName())) {// 找到了对应的日期字段,set之
+ String dateValue = value.toString();
+ if (dateValue.length() == 10) {// yyyy-MM-dd
+ dateProperty.getWriteMethod().invoke(obj, DateUtil.parseYMD(dateValue));
+ } else if (dateValue.length() == 19) {// yyyy-MM-dd
+ // HH:mm:ss
+ dateProperty.getWriteMethod().invoke(obj, DateUtil.parseYMDHMS(dateValue));
+ }
+ }
+ }
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ System.err.println("映射"+obj.getClass().getName()+"对象时发生错误");
+ System.err.println("transMap2FormatBean Error " + e);
+ }
+ return obj;
+ }
+
+ public static Map transBean2Map(Object obj) {
+ Map map = new HashMap<>();
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ String key = property.getName();
+ // 过滤class属性
+ if (!key.equals("class")) {
+ // 得到property对应的getter方法
+ Method getter = property.getReadMethod();
+ Object value = getter.invoke(obj);
+ map.put(key, value);
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("映射"+obj.getClass().getName()+"对象时发生错误");
+ System.err.println("transBean2Map Error " + e);
+ }
+ return map;
+ }
+
+ public static HashMap getKeyMap(String[] original, String[] alias) {
+ int length = original.length;
+ if (length != alias.length) {
+ throw new RuntimeException("映射配置错误");
+ }
+ HashMap map = new HashMap<>();
+ for (int i = 0; i < length; i++) {
+ map.put(original[i], alias[i]);
+ map.put(alias[i], original[i]);
+ }
+ /*
+ * 1--A(正常映射) 4--4(同名映射,允许) 2--C,C--3(错误映射) 错误的keyMap映射的value会有重复
+ */
+ Set keySet = map.keySet();
+ Set valueSet = new HashSet<>();
+ for (String key : keySet) {
+ valueSet.add(map.get(key));
+ }
+ if (keySet.size() != valueSet.size()) {
+ throw new RuntimeException("映射配置错误");
+ }
+ return map;
+ }
+
+ public static Map transBean2AliasMap(Object obj, HashMap keyMap) {
+ Map map = new HashMap<>();
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ String field = property.getName();
+ // 过滤class属性
+ if (!field.equals("class")) {
+ // 得到property对应的getter方法
+ Method getter = property.getReadMethod();
+ Object value = getter.invoke(obj);
+ if (keyMap.get(field) != null) {
+ map.put(keyMap.get(field), value);
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("映射"+obj.getClass().getName()+"对象时发生错误");
+ System.err.println("transBean2AliasMap Error " + e);
+ }
+ return map;
+ }
+
+ public static Map transBean2FormatAliasMap(Object obj, HashMap keyMap) {
+ Map map = new HashMap<>();
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ String field = property.getName();
+ // Class> fieldType = property.getPropertyType();
+ // 过滤class属性
+ if (!field.equals("class")) {
+ // 得到property对应的getter方法
+ Method getter = property.getReadMethod();
+ Object value = getter.invoke(obj);
+ if (value instanceof Date) {// 自动格式化日期对象
+ Date dateValue = (Date) value;
+ String str = DateUtil.getyyyy_MM_dd(dateValue);// getyyyy_MM_dd_hms
+ if (keyMap.get(field + "Str") != null) {
+ map.put(keyMap.get(field + "Str"), str);
+ }
+ } else {// 普通字段,别名存储
+ if (keyMap.get(field) != null) {
+ if (map.get(keyMap.get(field)) == null) {// 如果被以上的格式化代码赋值过,则不再过问
+ map.put(keyMap.get(field), value);
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("映射"+obj.getClass().getName()+"对象时发生错误");
+ System.err.println("transBean2FormatAliasMap Error " + e);
+ }
+ 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);
+ }
+
+ /*
+ * 方便书写映射文件keyMap
+ */
+ public static void printField(Object obj) {
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor property : propertyDescriptors) {
+ String key = property.getName();
+ // 过滤class属性
+ if (!key.equals("class")) {
+ System.out.println("\"" + key + "\",//");// "name",
+ }
+ }
+ } catch (Exception e) {
+ System.err.println("printField Error " + e);
+ }
+ }
+
+ /*
+ * 方便书写 json
+ */
+ public static void printJsonByArray(String[] args) {
+ System.out.println("{");
+ for (int i = 0; i < args.length; i++) {
+ String str = "\"" + args[i] + "\":\"666\"";
+ if (i != args.length - 1) {
+ str += ",";
+ }
+ System.out.println(str);
+ }
+ System.out.println("}");
+ }
+
+ public static void main(String[] args) {
+ // printField(new WomanHusband());
+ printJsonByArray(WomanFetationRecordKeymap.alias);
+ }
+
+}
--
1.8.3.1