diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/SequenceConstant.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/SequenceConstant.java index ac96bd4..f5ea7b4 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/SequenceConstant.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/SequenceConstant.java @@ -11,4 +11,7 @@ public class SequenceConstant { public static final String HOSPITAL_COUPON_CODE = "HOSPITAL_COUPON_CODE"; public static final String HOSPITAL_COUPON_CODE_REMARK = "医院优惠券打印的时候显示编码"; + public static final String CUSTOM_TYPE = "CUSTOM_TYPE"; + public static final String CUSTOM_CONTENT= "CUSTOM_CONTENT"; + } diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/PlantformConfigModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/PlantformConfigModel.java index d32c644..10f5f90 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/PlantformConfigModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/PlantformConfigModel.java @@ -36,6 +36,10 @@ public class PlantformConfigModel extends BaseModel { * key的类型 */ private String type; + + private String serchKey; + + private String parentId; /** * 创建时间 @@ -53,6 +57,26 @@ public class PlantformConfigModel extends BaseModel { */ private Long incrementValue; + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getSerchKey() { + return serchKey; + } + + public void setSerchKey(String serchKey) { + this.serchKey = serchKey; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + public ObjectId getId() { return id; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PlantformConfigController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PlantformConfigController.java new file mode 100644 index 0000000..dd1ef8a --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PlantformConfigController.java @@ -0,0 +1,98 @@ +package com.lyms.platform.operate.web.controller; + +import com.lyms.platform.common.annotation.TokenRequired; +import com.lyms.platform.common.base.BaseController; +import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.operate.web.service.PlantformConfigService; +import com.lyms.platform.pojo.PlantformConfigModel; +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 javax.servlet.http.HttpServletRequest; +import java.util.Date; + +/** + * Created by lt on 2017/8/16 0016 + */ +@Controller +@RequestMapping("/config") +public class PlantformConfigController extends BaseController { + + @Autowired + private PlantformConfigService plantformConfigService; + + /** + * 自定义类型列表 + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/type", method = RequestMethod.GET) + public BaseResponse customType(String key, Integer page, Integer limit, HttpServletRequest request) { + return plantformConfigService.listCustomType(key, page, limit, getUserId(request)); + } + + /** + * 自定义类型列表初始化 用于内容的下拉列表 + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/type/init", method = RequestMethod.GET) + public BaseResponse customTypeInit(HttpServletRequest request) { + return plantformConfigService.customTypeInit(getUserId(request)); + } + + /** + * 添加/修改自定义类型 + * @param name + * @return + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/type", method = RequestMethod.PUT) + public BaseResponse customType(String name, String id, HttpServletRequest request) { + return plantformConfigService.addCustomType(name, id, getUserId(request)); + } + + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/type", method = RequestMethod.DELETE) + public BaseResponse delCustomType(String id, HttpServletRequest request) { + return plantformConfigService.delCustomType(id, getUserId(request)); + } + + + + /** + * 自定义内容 + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/content", method = RequestMethod.GET) + public BaseResponse customContent(String parentId, Date startDate, Date endDate, Integer page, Integer limit, HttpServletRequest request) { + return plantformConfigService.customContentList(parentId, startDate, endDate, page, limit, getUserId(request)); + } + + /** + * 添加/修改自定义内容 + * @param key + * @param content + * @return + */ + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/content", method = RequestMethod.PUT) + public BaseResponse customContent(String parentId, String id, String content, String key, HttpServletRequest request) { + return plantformConfigService.addCustomContent(parentId, id, content, key, getUserId(request)); + } + + @TokenRequired + @ResponseBody + @RequestMapping(value = "/custom/content", method = RequestMethod.DELETE) + public BaseResponse delCustomContent(String id, HttpServletRequest request) { + return plantformConfigService.delCustomContent(id, getUserId(request)); + } + +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PlantformConfigService.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PlantformConfigService.java new file mode 100644 index 0000000..14e6bd2 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PlantformConfigService.java @@ -0,0 +1,24 @@ +package com.lyms.platform.operate.web.service; + +import com.lyms.platform.common.result.BaseResponse; + +import java.util.Date; + +/** + * Created by lt on 2017/8/16 0016 + */ +public interface PlantformConfigService extends IBaseService { + BaseResponse addCustomType(String name, String id, Integer userId); + + BaseResponse listCustomType(String key, Integer page, Integer limit, Integer userId); + + BaseResponse delCustomType(String id, Integer userId); + + BaseResponse customTypeInit(Integer userId); + + BaseResponse customContentList(String parentId, Date startDate, Date endDate, Integer page, Integer limit, Integer userId); + + BaseResponse addCustomContent(String parentId, String id, String content, String key, Integer userId); + + BaseResponse delCustomContent(String id, Integer userId); +} diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PlantformConfigServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PlantformConfigServiceImpl.java new file mode 100644 index 0000000..3a865a0 --- /dev/null +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PlantformConfigServiceImpl.java @@ -0,0 +1,155 @@ +package com.lyms.platform.operate.web.service.impl; + +import com.lyms.platform.biz.SequenceConstant; +import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.common.result.PageResult; +import com.lyms.platform.common.result.RespBuilder; +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.service.PlantformConfigService; +import com.lyms.platform.operate.web.utils.MongoUtil; +import com.lyms.platform.pojo.NewbornVisit; +import com.lyms.platform.pojo.PlantformConfigModel; +import org.bson.types.ObjectId; +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.*; + +/** + * Created by lt on 2017/8/16 0016 + */ +@Service +public class PlantformConfigServiceImpl extends BaseServiceImpl implements PlantformConfigService { + + @Autowired + private AutoMatchFacade autoMatchFacade; + + @Autowired + private MongoTemplate mongoTemplate; + + @Override + public BaseResponse listCustomType(String key, Integer page, Integer limit, Integer userId) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + Query query = new Query(); + if(StringUtils.isNotEmpty(key)) { + query.addCriteria(Criteria.where("value").regex(key)); + } + query.addCriteria(Criteria.where("key").is(hospitalId)).with(new Sort(Sort.Direction.DESC,"createDate")); + PageResult pageResult = findMongoPage(PlantformConfigModel.class, query, page, limit); + + List configModels = (List) pageResult.getGrid(); + List> restList = new ArrayList<>(); + for (PlantformConfigModel configModel : configModels) { + Map tempMap = new HashMap<>(); + tempMap.put("id", configModel.getId()); + tempMap.put("name", configModel.getValue()); + tempMap.put("date", DateUtil.getyyyy_MM_dd_hms(configModel.getCreateDate())); + restList.add(tempMap); + } + pageResult.setGrid(restList); + + return RespBuilder.buildSuccess(pageResult); + } + + @Override + public BaseResponse delCustomType(String id, Integer userId) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + mongoTemplate.remove(Query.query(Criteria.where("key").is(hospitalId).and("type").is(SequenceConstant.CUSTOM_TYPE)), PlantformConfigModel.class); + mongoTemplate.remove(Query.query(Criteria.where("parentId").is(hospitalId).and("type").is(SequenceConstant.CUSTOM_CONTENT)), PlantformConfigModel.class); + return RespBuilder.buildSuccess(); + } + + @Override + public BaseResponse customTypeInit(Integer userId) { + List> restList = new ArrayList<>(); + String hospitalId = autoMatchFacade.getHospitalId(userId); + List plantformConfigModels = mongoTemplate.find(Query.query(Criteria.where("key").is(hospitalId).and("type").is(SequenceConstant.CUSTOM_TYPE)), PlantformConfigModel.class); + for (PlantformConfigModel plantformConfigModel : plantformConfigModels) { + Map temp = new HashMap<>(); + temp.put("id", plantformConfigModel.getId()); + temp.put("name", plantformConfigModel.getValue()); + } + return RespBuilder.buildSuccess(restList); + } + @Override + public BaseResponse addCustomType(String name, String id, Integer userId) { + if(StringUtils.isEmpty(id)) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + PlantformConfigModel plantformConfigModel = new PlantformConfigModel(); + plantformConfigModel.setCreateDate(new Date()); + plantformConfigModel.setKey(hospitalId); + plantformConfigModel.setValue(name); + plantformConfigModel.setType(SequenceConstant.CUSTOM_TYPE); + plantformConfigModel.setRemark("产检处理意见自定义类型"); + mongoTemplate.save(plantformConfigModel); + } else { + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(id)), Update.update("value", name).set("createDate", new Date()) , PlantformConfigModel.class); + } + return RespBuilder.buildSuccess(); + } + + + + @Override + public BaseResponse customContentList(String parentId, Date startDate, Date endDate, Integer page, Integer limit, Integer userId) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + Query query = new Query(); + if(StringUtils.isNotEmpty(parentId)) { + query.addCriteria(Criteria.where("parentId").is(parentId)); + } + query.addCriteria(Criteria.where("key").is(hospitalId)).with(new Sort(Sort.Direction.DESC,"createDate")); + PageResult pageResult = findMongoPage(PlantformConfigModel.class, query, page, limit); + + List configModels = (List) pageResult.getGrid(); + List> restList = new ArrayList<>(); + for (PlantformConfigModel configModel : configModels) { + Map map = ReflectionUtils.beanToMap(configModel); + map.put("date", DateUtil.getyyyy_MM_dd_hms(configModel.getCreateDate())); + restList.add(map); + } + pageResult.setGrid(restList); + + return RespBuilder.buildSuccess(pageResult); + } + + + @Override + public BaseResponse addCustomContent(String parentId, String id, String content, String key, Integer userId) { + PlantformConfigModel plantformConfigModel = new PlantformConfigModel(); + if(StringUtils.isEmpty(id)) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + plantformConfigModel.setCreateDate(new Date()); + plantformConfigModel.setParentId(parentId); + plantformConfigModel.setKey(hospitalId); + plantformConfigModel.setValue(content); + plantformConfigModel.setSerchKey(key); + plantformConfigModel.setType(SequenceConstant.CUSTOM_CONTENT); + plantformConfigModel.setRemark("产检处理意见自定义内容"); + mongoTemplate.save(plantformConfigModel); + } else { + plantformConfigModel.setCreateDate(new Date()); + plantformConfigModel.setSerchKey(key); + plantformConfigModel.setId(new ObjectId(id)); + plantformConfigModel.setParentId(parentId); + + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(plantformConfigModel)); + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(id)), update, PlantformConfigModel.class); + } + return RespBuilder.buildSuccess(); + } + + @Override + public BaseResponse delCustomContent(String id, Integer userId) { + mongoTemplate.remove(Query.query(Criteria.where("id").is(id)), PlantformConfigModel.class); + return RespBuilder.buildSuccess(); + } +}