123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- package com.yihu.wlyy.service.app.label;
- import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
- import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelLog;
- import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
- import com.yihu.wlyy.repository.doctor.SignPatientLabelLogDao;
- import com.yihu.wlyy.service.BaseService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- /**
- * 标签服务类
- * <p>
- * Created by lyr on 2016/10/9.
- */
- @Service
- @Transactional
- public class SignPatientLabelService extends BaseService {
- @Autowired
- SignPatientLabelDao labelDao;
- @Autowired
- SignPatientLabelLogDao labelLogDao;
- /**
- * 新增自定义标签
- *
- * @param lableName 标签名称
- * @param creator 创建人
- * @param teamCode 所属团队
- * @return
- */
- public SignPatientLabel addLabel(String lableName, String creator, long teamCode) {
- SignPatientLabel label = new SignPatientLabel();
- label.setLabelCode(getCode());
- label.setLabelName(lableName);
- label.setLabelType("4");
- label.setIsSystem(1);
- label.setCreator(creator);
- label.setTeamCode(teamCode);
- label.setStatus(1);
- label.setCzrq(new Date());
- return labelDao.save(label);
- }
- /**
- * 修改某个自定义标签
- *
- * @param labelCode 标签code
- * @param newName 新名称
- * @return
- */
- public int modifyLabel(String labelCode, String newName, String modifyBy) {
- SignPatientLabel label = labelDao.findByLabelCodeAndLabelTypeAndStatus(labelCode, "4", 1);
- if (label == null) {
- // 标签不存在
- return -1;
- }
- if (label.getIsSystem() == 1) {
- // 系统标签不能修改
- return -2;
- }
- SignPatientLabelLog log = new SignPatientLabelLog();
- log.setLabelCode(labelCode);
- log.setOldName(label.getLabelName());
- log.setNewName(newName);
- log.setModifyType(1);
- log.setModifyBy(modifyBy);
- log.setCzrq(new Date());
- label.setLabelName(newName);
- label.setCzrq(new Date());
- labelLogDao.save(log);
- return 1;
- }
- /**
- * 删除某个自定义标签
- *
- * @param labelCode 标签code
- * @return
- */
- public int deleteLabel(String labelCode, String modifyBy) {
- SignPatientLabel label = labelDao.findByLabelCodeAndLabelTypeAndStatus(labelCode, "4", 1);
- if (label == null) {
- // 标签不存在
- return -1;
- }
- if (label.getIsSystem() == 1) {
- // 系统标签不能删除
- return -2;
- }
- SignPatientLabelLog log = new SignPatientLabelLog();
- log.setLabelCode(labelCode);
- log.setModifyType(2);
- log.setModifyBy(modifyBy);
- log.setCzrq(new Date());
- label.setStatus(0);
- label.setCzrq(new Date());
- labelLogDao.save(log);
- return 1;
- }
- /**
- * 查询某个团队的标签
- *
- * @param teamCode 团队code
- * @return
- */
- public List<SignPatientLabel> getTeamAllLabels(long teamCode) {
- List<SignPatientLabel> labels = new ArrayList<>();
- // 非自定义系统标签
- List<SignPatientLabel> systemLabels = labelDao.findSystemLabels();
- if (systemLabels.size() > 0) {
- labels.addAll(systemLabels);
- }
- // 自定义标签
- List<SignPatientLabel> customLabels = labelDao.findCustomLabels(teamCode);
- if (customLabels.size() > 0) {
- labels.addAll(customLabels);
- }
- return labels;
- }
- /**
- * 查询某个团队的自定义标签
- *
- * @param teamCode 团队code
- * @return
- */
- public List<SignPatientLabel> getLabelsByTypeAndTeam(String labelType, long teamCode) {
- List<SignPatientLabel> labels = new ArrayList<>();
- if (labelType.equals("4")) {
- // 自定义标签
- labels = labelDao.findCustomLabels(teamCode);
- } else {
- labels = labelDao.findByLabelTypeAndStatus(labelType, 1);
- }
- return labels;
- }
- /**
- * 查询某个标签
- *
- * @param labelCode 标签code
- * @param labelType 标签类型
- * @return
- */
- public SignPatientLabel getLabelByCodeAndType(String labelCode, String labelType) {
- return labelDao.findByLabelCodeAndLabelTypeAndStatus(labelCode,labelType,1);
- }
- }
|