Commit 51c47dd2d2945b4924bdc678effe0cee5402a8a7
1 parent
bf04549186
Exists in
master
and in
6 other branches
自定义配置管理
Showing 5 changed files with 304 additions and 0 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/SequenceConstant.java
- platform-dal/src/main/java/com/lyms/platform/pojo/PlantformConfigModel.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PlantformConfigController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PlantformConfigService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PlantformConfigServiceImpl.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/SequenceConstant.java
View file @
51c47dd
| ... | ... | @@ -11,5 +11,8 @@ |
| 11 | 11 | public static final String HOSPITAL_COUPON_CODE = "HOSPITAL_COUPON_CODE"; |
| 12 | 12 | public static final String HOSPITAL_COUPON_CODE_REMARK = "医院优惠券打印的时候显示编码"; |
| 13 | 13 | |
| 14 | + public static final String CUSTOM_TYPE = "CUSTOM_TYPE"; | |
| 15 | + public static final String CUSTOM_CONTENT= "CUSTOM_CONTENT"; | |
| 16 | + | |
| 14 | 17 | } |
platform-dal/src/main/java/com/lyms/platform/pojo/PlantformConfigModel.java
View file @
51c47dd
| ... | ... | @@ -36,6 +36,10 @@ |
| 36 | 36 | * key的类型 |
| 37 | 37 | */ |
| 38 | 38 | private String type; |
| 39 | + | |
| 40 | + private String serchKey; | |
| 41 | + | |
| 42 | + private String parentId; | |
| 39 | 43 | |
| 40 | 44 | /** |
| 41 | 45 | * 创建时间 |
| ... | ... | @@ -52,6 +56,26 @@ |
| 52 | 56 | * 用于记录每次自增之后的值 |
| 53 | 57 | */ |
| 54 | 58 | private Long incrementValue; |
| 59 | + | |
| 60 | + public static long getSerialVersionUID() { | |
| 61 | + return serialVersionUID; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getSerchKey() { | |
| 65 | + return serchKey; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setSerchKey(String serchKey) { | |
| 69 | + this.serchKey = serchKey; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public String getParentId() { | |
| 73 | + return parentId; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setParentId(String parentId) { | |
| 77 | + this.parentId = parentId; | |
| 78 | + } | |
| 55 | 79 | |
| 56 | 80 | public ObjectId getId() { |
| 57 | 81 | return id; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PlantformConfigController.java
View file @
51c47dd
| 1 | +package com.lyms.platform.operate.web.controller; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.annotation.TokenRequired; | |
| 4 | +import com.lyms.platform.common.base.BaseController; | |
| 5 | +import com.lyms.platform.common.result.BaseResponse; | |
| 6 | +import com.lyms.platform.operate.web.service.PlantformConfigService; | |
| 7 | +import com.lyms.platform.pojo.PlantformConfigModel; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.stereotype.Controller; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 12 | +import org.springframework.web.bind.annotation.ResponseBody; | |
| 13 | + | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | +import java.util.Date; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * Created by lt on 2017/8/16 0016 | |
| 19 | + */ | |
| 20 | +@Controller | |
| 21 | +@RequestMapping("/config") | |
| 22 | +public class PlantformConfigController extends BaseController { | |
| 23 | + | |
| 24 | + @Autowired | |
| 25 | + private PlantformConfigService plantformConfigService; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 自定义类型列表 | |
| 29 | + */ | |
| 30 | + @TokenRequired | |
| 31 | + @ResponseBody | |
| 32 | + @RequestMapping(value = "/custom/type", method = RequestMethod.GET) | |
| 33 | + public BaseResponse customType(String key, Integer page, Integer limit, HttpServletRequest request) { | |
| 34 | + return plantformConfigService.listCustomType(key, page, limit, getUserId(request)); | |
| 35 | + } | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 自定义类型列表初始化 用于内容的下拉列表 | |
| 39 | + */ | |
| 40 | + @TokenRequired | |
| 41 | + @ResponseBody | |
| 42 | + @RequestMapping(value = "/custom/type/init", method = RequestMethod.GET) | |
| 43 | + public BaseResponse customTypeInit(HttpServletRequest request) { | |
| 44 | + return plantformConfigService.customTypeInit(getUserId(request)); | |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 添加/修改自定义类型 | |
| 49 | + * @param name | |
| 50 | + * @return | |
| 51 | + */ | |
| 52 | + @TokenRequired | |
| 53 | + @ResponseBody | |
| 54 | + @RequestMapping(value = "/custom/type", method = RequestMethod.PUT) | |
| 55 | + public BaseResponse customType(String name, String id, HttpServletRequest request) { | |
| 56 | + return plantformConfigService.addCustomType(name, id, getUserId(request)); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @TokenRequired | |
| 60 | + @ResponseBody | |
| 61 | + @RequestMapping(value = "/custom/type", method = RequestMethod.DELETE) | |
| 62 | + public BaseResponse delCustomType(String id, HttpServletRequest request) { | |
| 63 | + return plantformConfigService.delCustomType(id, getUserId(request)); | |
| 64 | + } | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * 自定义内容 | |
| 70 | + */ | |
| 71 | + @TokenRequired | |
| 72 | + @ResponseBody | |
| 73 | + @RequestMapping(value = "/custom/content", method = RequestMethod.GET) | |
| 74 | + public BaseResponse customContent(String parentId, Date startDate, Date endDate, Integer page, Integer limit, HttpServletRequest request) { | |
| 75 | + return plantformConfigService.customContentList(parentId, startDate, endDate, page, limit, getUserId(request)); | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * 添加/修改自定义内容 | |
| 80 | + * @param key | |
| 81 | + * @param content | |
| 82 | + * @return | |
| 83 | + */ | |
| 84 | + @TokenRequired | |
| 85 | + @ResponseBody | |
| 86 | + @RequestMapping(value = "/custom/content", method = RequestMethod.PUT) | |
| 87 | + public BaseResponse customContent(String parentId, String id, String content, String key, HttpServletRequest request) { | |
| 88 | + return plantformConfigService.addCustomContent(parentId, id, content, key, getUserId(request)); | |
| 89 | + } | |
| 90 | + | |
| 91 | + @TokenRequired | |
| 92 | + @ResponseBody | |
| 93 | + @RequestMapping(value = "/custom/content", method = RequestMethod.DELETE) | |
| 94 | + public BaseResponse delCustomContent(String id, HttpServletRequest request) { | |
| 95 | + return plantformConfigService.delCustomContent(id, getUserId(request)); | |
| 96 | + } | |
| 97 | + | |
| 98 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PlantformConfigService.java
View file @
51c47dd
| 1 | +package com.lyms.platform.operate.web.service; | |
| 2 | + | |
| 3 | +import com.lyms.platform.common.result.BaseResponse; | |
| 4 | + | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Created by lt on 2017/8/16 0016 | |
| 9 | + */ | |
| 10 | +public interface PlantformConfigService extends IBaseService { | |
| 11 | + BaseResponse addCustomType(String name, String id, Integer userId); | |
| 12 | + | |
| 13 | + BaseResponse listCustomType(String key, Integer page, Integer limit, Integer userId); | |
| 14 | + | |
| 15 | + BaseResponse delCustomType(String id, Integer userId); | |
| 16 | + | |
| 17 | + BaseResponse customTypeInit(Integer userId); | |
| 18 | + | |
| 19 | + BaseResponse customContentList(String parentId, Date startDate, Date endDate, Integer page, Integer limit, Integer userId); | |
| 20 | + | |
| 21 | + BaseResponse addCustomContent(String parentId, String id, String content, String key, Integer userId); | |
| 22 | + | |
| 23 | + BaseResponse delCustomContent(String id, Integer userId); | |
| 24 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PlantformConfigServiceImpl.java
View file @
51c47dd
| 1 | +package com.lyms.platform.operate.web.service.impl; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.SequenceConstant; | |
| 4 | +import com.lyms.platform.common.result.BaseResponse; | |
| 5 | +import com.lyms.platform.common.result.PageResult; | |
| 6 | +import com.lyms.platform.common.result.RespBuilder; | |
| 7 | +import com.lyms.platform.common.utils.DateUtil; | |
| 8 | +import com.lyms.platform.common.utils.MongoConvertHelper; | |
| 9 | +import com.lyms.platform.common.utils.ReflectionUtils; | |
| 10 | +import com.lyms.platform.common.utils.StringUtils; | |
| 11 | +import com.lyms.platform.operate.web.facade.AutoMatchFacade; | |
| 12 | +import com.lyms.platform.operate.web.service.PlantformConfigService; | |
| 13 | +import com.lyms.platform.operate.web.utils.MongoUtil; | |
| 14 | +import com.lyms.platform.pojo.NewbornVisit; | |
| 15 | +import com.lyms.platform.pojo.PlantformConfigModel; | |
| 16 | +import org.bson.types.ObjectId; | |
| 17 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 18 | +import org.springframework.data.domain.Sort; | |
| 19 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 20 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 21 | +import org.springframework.data.mongodb.core.query.Query; | |
| 22 | +import org.springframework.data.mongodb.core.query.Update; | |
| 23 | +import org.springframework.stereotype.Service; | |
| 24 | + | |
| 25 | +import java.util.*; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * Created by lt on 2017/8/16 0016 | |
| 29 | + */ | |
| 30 | +@Service | |
| 31 | +public class PlantformConfigServiceImpl extends BaseServiceImpl implements PlantformConfigService { | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + private AutoMatchFacade autoMatchFacade; | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + private MongoTemplate mongoTemplate; | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public BaseResponse listCustomType(String key, Integer page, Integer limit, Integer userId) { | |
| 41 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 42 | + Query query = new Query(); | |
| 43 | + if(StringUtils.isNotEmpty(key)) { | |
| 44 | + query.addCriteria(Criteria.where("value").regex(key)); | |
| 45 | + } | |
| 46 | + query.addCriteria(Criteria.where("key").is(hospitalId)).with(new Sort(Sort.Direction.DESC,"createDate")); | |
| 47 | + PageResult pageResult = findMongoPage(PlantformConfigModel.class, query, page, limit); | |
| 48 | + | |
| 49 | + List<PlantformConfigModel> configModels = (List<PlantformConfigModel>) pageResult.getGrid(); | |
| 50 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 51 | + for (PlantformConfigModel configModel : configModels) { | |
| 52 | + Map<String, Object> tempMap = new HashMap<>(); | |
| 53 | + tempMap.put("id", configModel.getId()); | |
| 54 | + tempMap.put("name", configModel.getValue()); | |
| 55 | + tempMap.put("date", DateUtil.getyyyy_MM_dd_hms(configModel.getCreateDate())); | |
| 56 | + restList.add(tempMap); | |
| 57 | + } | |
| 58 | + pageResult.setGrid(restList); | |
| 59 | + | |
| 60 | + return RespBuilder.buildSuccess(pageResult); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public BaseResponse delCustomType(String id, Integer userId) { | |
| 65 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 66 | + mongoTemplate.remove(Query.query(Criteria.where("key").is(hospitalId).and("type").is(SequenceConstant.CUSTOM_TYPE)), PlantformConfigModel.class); | |
| 67 | + mongoTemplate.remove(Query.query(Criteria.where("parentId").is(hospitalId).and("type").is(SequenceConstant.CUSTOM_CONTENT)), PlantformConfigModel.class); | |
| 68 | + return RespBuilder.buildSuccess(); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public BaseResponse customTypeInit(Integer userId) { | |
| 73 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 74 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 75 | + List<PlantformConfigModel> plantformConfigModels = mongoTemplate.find(Query.query(Criteria.where("key").is(hospitalId).and("type").is(SequenceConstant.CUSTOM_TYPE)), PlantformConfigModel.class); | |
| 76 | + for (PlantformConfigModel plantformConfigModel : plantformConfigModels) { | |
| 77 | + Map<String, Object> temp = new HashMap<>(); | |
| 78 | + temp.put("id", plantformConfigModel.getId()); | |
| 79 | + temp.put("name", plantformConfigModel.getValue()); | |
| 80 | + } | |
| 81 | + return RespBuilder.buildSuccess(restList); | |
| 82 | + } | |
| 83 | + @Override | |
| 84 | + public BaseResponse addCustomType(String name, String id, Integer userId) { | |
| 85 | + if(StringUtils.isEmpty(id)) { | |
| 86 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 87 | + PlantformConfigModel plantformConfigModel = new PlantformConfigModel(); | |
| 88 | + plantformConfigModel.setCreateDate(new Date()); | |
| 89 | + plantformConfigModel.setKey(hospitalId); | |
| 90 | + plantformConfigModel.setValue(name); | |
| 91 | + plantformConfigModel.setType(SequenceConstant.CUSTOM_TYPE); | |
| 92 | + plantformConfigModel.setRemark("产检处理意见自定义类型"); | |
| 93 | + mongoTemplate.save(plantformConfigModel); | |
| 94 | + } else { | |
| 95 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(id)), Update.update("value", name).set("createDate", new Date()) , PlantformConfigModel.class); | |
| 96 | + } | |
| 97 | + return RespBuilder.buildSuccess(); | |
| 98 | + } | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + @Override | |
| 103 | + public BaseResponse customContentList(String parentId, Date startDate, Date endDate, Integer page, Integer limit, Integer userId) { | |
| 104 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 105 | + Query query = new Query(); | |
| 106 | + if(StringUtils.isNotEmpty(parentId)) { | |
| 107 | + query.addCriteria(Criteria.where("parentId").is(parentId)); | |
| 108 | + } | |
| 109 | + query.addCriteria(Criteria.where("key").is(hospitalId)).with(new Sort(Sort.Direction.DESC,"createDate")); | |
| 110 | + PageResult pageResult = findMongoPage(PlantformConfigModel.class, query, page, limit); | |
| 111 | + | |
| 112 | + List<PlantformConfigModel> configModels = (List<PlantformConfigModel>) pageResult.getGrid(); | |
| 113 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
| 114 | + for (PlantformConfigModel configModel : configModels) { | |
| 115 | + Map<String, Object> map = ReflectionUtils.beanToMap(configModel); | |
| 116 | + map.put("date", DateUtil.getyyyy_MM_dd_hms(configModel.getCreateDate())); | |
| 117 | + restList.add(map); | |
| 118 | + } | |
| 119 | + pageResult.setGrid(restList); | |
| 120 | + | |
| 121 | + return RespBuilder.buildSuccess(pageResult); | |
| 122 | + } | |
| 123 | + | |
| 124 | + | |
| 125 | + @Override | |
| 126 | + public BaseResponse addCustomContent(String parentId, String id, String content, String key, Integer userId) { | |
| 127 | + PlantformConfigModel plantformConfigModel = new PlantformConfigModel(); | |
| 128 | + if(StringUtils.isEmpty(id)) { | |
| 129 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 130 | + plantformConfigModel.setCreateDate(new Date()); | |
| 131 | + plantformConfigModel.setParentId(parentId); | |
| 132 | + plantformConfigModel.setKey(hospitalId); | |
| 133 | + plantformConfigModel.setValue(content); | |
| 134 | + plantformConfigModel.setSerchKey(key); | |
| 135 | + plantformConfigModel.setType(SequenceConstant.CUSTOM_CONTENT); | |
| 136 | + plantformConfigModel.setRemark("产检处理意见自定义内容"); | |
| 137 | + mongoTemplate.save(plantformConfigModel); | |
| 138 | + } else { | |
| 139 | + plantformConfigModel.setCreateDate(new Date()); | |
| 140 | + plantformConfigModel.setSerchKey(key); | |
| 141 | + plantformConfigModel.setId(new ObjectId(id)); | |
| 142 | + plantformConfigModel.setParentId(parentId); | |
| 143 | + | |
| 144 | + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(plantformConfigModel)); | |
| 145 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(id)), update, PlantformConfigModel.class); | |
| 146 | + } | |
| 147 | + return RespBuilder.buildSuccess(); | |
| 148 | + } | |
| 149 | + | |
| 150 | + @Override | |
| 151 | + public BaseResponse delCustomContent(String id, Integer userId) { | |
| 152 | + mongoTemplate.remove(Query.query(Criteria.where("id").is(id)), PlantformConfigModel.class); | |
| 153 | + return RespBuilder.buildSuccess(); | |
| 154 | + } | |
| 155 | +} |