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; /** * 标签服务类 *
* 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