|  | @ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.fasterxml.jackson.databind.ObjectMapper;
 | 
	
		
			
				|  |  | import com.sun.tools.corba.se.idl.ExceptionEntry;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.dict.DictJobTitleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.dao.doctor.BaseDoctorIncentiveDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.dict.DictDoctorDutyService;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.doctor.excelImport.BaseDoctorExcelDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.base.service.org.OrgTree;
 | 
	
	
		
			
				|  | @ -16,15 +17,18 @@ import com.yihu.jw.dict.dao.DictHospitalDeptDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.BaseIncentiveDictDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictHospitalDeptDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.dict.DictJobTitleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorIncentiveDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.org.BaseOrgDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.exception.business.ManageException;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.dict.BaseIncentiveDictDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
 | 
	
	
		
			
				|  | @ -33,9 +37,12 @@ import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.org.dao.BaseOrgDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.Envelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.web.MixEnvelop;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.security.MD5;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @ -49,6 +56,7 @@ import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | import org.springframework.util.CollectionUtils;
 | 
	
		
			
				|  |  | import org.springframework.util.StringUtils;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.sound.sampled.Mixer;
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | import java.util.logging.Logger;
 | 
	
	
		
			
				|  | @ -112,6 +120,10 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     private YkyyEntranceService ykyyEntranceService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorMappingDao doctorMappingDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorIncentiveDao baseDoctorIncentiveDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseIncentiveDictDao baseIncentiveDictDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Value("${wechat.flag}")
 | 
	
		
			
				|  |  |     private boolean flag;
 | 
	
	
		
			
				|  | @ -122,6 +134,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |     private HttpClientUtil httpClientUtil;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorRoleDao baseDoctorRoleDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HibenateUtils hibenateUtils;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -405,6 +419,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         JSONObject doctor = jsonObject.getJSONObject("doctor");
 | 
	
		
			
				|  |  |         JSONArray role = jsonObject.getJSONArray("role");
 | 
	
		
			
				|  |  |         JSONArray hospital = jsonObject.getJSONArray("hospital");
 | 
	
		
			
				|  |  |         String doctorMappingCode = jsonObject.getString("doctorMappingCode");
 | 
	
		
			
				|  |  |         if (null == doctor) {
 | 
	
		
			
				|  |  |             result.put("msg", "医生信息不可为空!");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
	
		
			
				|  | @ -413,6 +428,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         //组装医生信息
 | 
	
		
			
				|  |  |         BaseDoctorDO baseDoctorDO = null;
 | 
	
		
			
				|  |  |         BaseDoctorDO baseDoctorvo = null;
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = null;
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             baseDoctorvo = objectMapper.readValue(doctor.toJSONString(), BaseDoctorDO.class);
 | 
	
		
			
				|  |  |             baseDoctorDO =  baseDoctorDao.findByIdcardAndDel(baseDoctorvo.getIdcard());
 | 
	
	
		
			
				|  | @ -441,18 +457,31 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     DoctorMappingDO doctorMappingDO =doctorMappingDao.findByDoctor(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                     doctorMappingDO = doctorMappingDao.findByDoctor(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                     if (null==doctorMappingDO){
 | 
	
		
			
				|  |  |                         doctorMappingDO = new DoctorMappingDO();
 | 
	
		
			
				|  |  |                         doctorMappingDO.setMappingCode(mappingCode);
 | 
	
		
			
				|  |  |                         doctorMappingDO.setDoctor(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                         doctorMappingDO.setDoctorName(baseDoctorDO.getName());
 | 
	
		
			
				|  |  |                         doctorMappingDO.setIdcard(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                         doctorMappingDO.setOrgCode("350211A5010");
 | 
	
		
			
				|  |  |                         doctorMappingDO.setOrgName("厦门大学附属心血管病医院");
 | 
	
		
			
				|  |  |                         doctorMappingDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                         doctorMappingDao.save(doctorMappingDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (!StringUtils.isEmpty(doctorMappingCode)){
 | 
	
		
			
				|  |  |                     doctorMappingDO = doctorMappingDao.findByIdcard(baseDoctorvo.getIdcard());
 | 
	
		
			
				|  |  |                     if (doctorMappingDO==null){
 | 
	
		
			
				|  |  |                         doctorMappingDO = new DoctorMappingDO();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     doctorMappingDO.setMappingCode(doctorMappingCode);
 | 
	
		
			
				|  |  |                     doctorMappingDO.setDoctor(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                     doctorMappingDO.setDoctorName(baseDoctorDO.getName());
 | 
	
		
			
				|  |  |                     doctorMappingDO.setIdcard(baseDoctorDO.getId());
 | 
	
		
			
				|  |  |                     doctorMappingDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                     doctorMappingDO= doctorMappingDao.save(doctorMappingDO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (IOException e) {
 | 
	
		
			
				|  |  |             result.put("msg", "convert doctor jsonObject to BaseDoctorDO failed," + e.getCause());
 | 
	
	
		
			
				|  | @ -493,6 +522,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         if (!CollectionUtils.isEmpty(hospital)) {
 | 
	
		
			
				|  |  |             BaseDoctorHospitalDO baseDoctorHospitalDO = null;
 | 
	
		
			
				|  |  |             List<BaseDoctorHospitalDO> hospitalDOList = new ArrayList<>();
 | 
	
		
			
				|  |  |             String orgCode = "";
 | 
	
		
			
				|  |  |             String orgName = "";
 | 
	
		
			
				|  |  |             try {
 | 
	
		
			
				|  |  |                 for (Object object : hospital) {
 | 
	
		
			
				|  |  |                     baseDoctorHospitalDO = objectMapper.readValue(object.toString(), BaseDoctorHospitalDO.class);
 | 
	
	
		
			
				|  | @ -505,6 +536,8 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |                         if (null!=dictHospitalDeptDO){
 | 
	
		
			
				|  |  |                             baseDoctorHospitalDO.setDeptName(dictHospitalDeptDO.getName());
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         orgCode = baseDoctorHospitalDO.getOrgCode();
 | 
	
		
			
				|  |  |                         orgName = baseDoctorHospitalDO.getOrgName();
 | 
	
		
			
				|  |  |                         baseDoctorHospitalDao.save(baseDoctorHospitalDO);
 | 
	
		
			
				|  |  |                     }else {
 | 
	
		
			
				|  |  |                         try {
 | 
	
	
		
			
				|  | @ -516,6 +549,9 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 doctorMappingDO.setOrgCode(orgCode);
 | 
	
		
			
				|  |  |                 doctorMappingDO.setOrgName(orgName);
 | 
	
		
			
				|  |  |                 doctorMappingDao.save(doctorMappingDO);
 | 
	
		
			
				|  |  |             } catch (IOException e) {
 | 
	
		
			
				|  |  |                 result.put("msg", "convert hospital jsonObject to baseDoctorHospitalDO failed," + e.getCause());
 | 
	
		
			
				|  |  |                 result.put("response", ConstantUtils.FAIL);
 | 
	
	
		
			
				|  | @ -933,5 +969,179 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
 | 
	
		
			
				|  |  |         result.put("correctCount", doctors.size());
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public Map saveIncentive(String doctor,String incentiveIds){
 | 
	
		
			
				|  |  |         List<BaseDoctorIncentiveDO> list = baseDoctorIncentiveDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |         Map map = new HashMap();
 | 
	
		
			
				|  |  |         String name = "";
 | 
	
		
			
				|  |  |         BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |         if (baseDoctorDO!=null){
 | 
	
		
			
				|  |  |             name = baseDoctorDO.getName();
 | 
	
		
			
				|  |  |             map.put("status",-1);
 | 
	
		
			
				|  |  |             map.put("msg","获取医生信息失败");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (incentiveIds.contains(",")){
 | 
	
		
			
				|  |  |             String[] incentiveId = incentiveIds.split(",");
 | 
	
		
			
				|  |  |             for (int i= 0;i<incentiveId.length;i++){
 | 
	
		
			
				|  |  |                 BaseIncentiveDictDO baseIncentiveDictDO = baseIncentiveDictDao.findoneById(incentiveId[i]);
 | 
	
		
			
				|  |  |                 if (list!=null&&list.size()>0){
 | 
	
		
			
				|  |  |                     for (int j= 0;j<list.size();j++){
 | 
	
		
			
				|  |  |                         if (list.get(j).getIncentiveId().equalsIgnoreCase(incentiveId[i])){
 | 
	
		
			
				|  |  |                             list.get(j).setIsDel("1");
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDao.save(list.get(j));
 | 
	
		
			
				|  |  |                             list.remove(j);
 | 
	
		
			
				|  |  |                         }else {
 | 
	
		
			
				|  |  |                             BaseDoctorIncentiveDO baseDoctorIncentiveDO = new BaseDoctorIncentiveDO();
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIsDel("1");
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setDoctorCode(doctor);
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setDoctorName(name);
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIncentiveId(baseIncentiveDictDO.getId());
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIncentiveName(baseIncentiveDictDO.getIncentiveName());
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIncentiveImg(baseIncentiveDictDO.getIncentiveImg());
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDao.save(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     for (BaseDoctorIncentiveDO baseDoctorIncentiveDO:list){
 | 
	
		
			
				|  |  |                         baseDoctorIncentiveDO.setIsDel("0");
 | 
	
		
			
				|  |  |                         baseDoctorIncentiveDao.save(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     BaseDoctorIncentiveDO baseDoctorIncentiveDO = new BaseDoctorIncentiveDO();
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIsDel("1");
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setDoctorCode(doctor);
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setDoctorName(name);
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIncentiveId(baseIncentiveDictDO.getId());
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIncentiveName(baseIncentiveDictDO.getIncentiveName());
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIncentiveImg(baseIncentiveDictDO.getIncentiveImg());
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDao.save(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put("status",200);
 | 
	
		
			
				|  |  |             map.put("msg","操作成功");
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             BaseIncentiveDictDO baseIncentiveDictDO = baseIncentiveDictDao.findoneById(incentiveIds);
 | 
	
		
			
				|  |  |             if (baseIncentiveDictDO!=null){
 | 
	
		
			
				|  |  |                 BaseDoctorIncentiveDO baseDoctorIncentiveDO = new BaseDoctorIncentiveDO();
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIsDel("1");
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setDoctorCode(doctor);
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setDoctorName(name);
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIncentiveId(baseIncentiveDictDO.getId());
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIncentiveName(baseIncentiveDictDO.getIncentiveName());
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIncentiveImg(baseIncentiveDictDO.getIncentiveImg());
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDao.save(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put("status",200);
 | 
	
		
			
				|  |  |             map.put("msg","操作成功");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public Map saveDoctorIncentive(String doctor,String incentiveIds) throws Exception{
 | 
	
		
			
				|  |  |         List<BaseDoctorIncentiveDO> list = baseDoctorIncentiveDao.findByDoctorCode(doctor);
 | 
	
		
			
				|  |  |         List<BaseDoctorIncentiveDO> saveList = new ArrayList<>();
 | 
	
		
			
				|  |  |         Map map = new HashMap();
 | 
	
		
			
				|  |  |         String name = "";
 | 
	
		
			
				|  |  |         BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doctor);
 | 
	
		
			
				|  |  |         if (baseDoctorDO!=null){
 | 
	
		
			
				|  |  |             name = baseDoctorDO.getName();
 | 
	
		
			
				|  |  |             map.put("status",-1);
 | 
	
		
			
				|  |  |             map.put("msg","获取医生信息失败");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (incentiveIds.contains(",")){
 | 
	
		
			
				|  |  |             String[] incentiveId = incentiveIds.split(",");
 | 
	
		
			
				|  |  |             for (int i= 0;i<incentiveId.length;i++){
 | 
	
		
			
				|  |  |                 BaseIncentiveDictDO baseIncentiveDictDO = baseIncentiveDictDao.findoneById(incentiveId[i]);
 | 
	
		
			
				|  |  |                 if (list!=null&&list.size()>0){
 | 
	
		
			
				|  |  |                     for (int j= 0;j<list.size();j++){
 | 
	
		
			
				|  |  |                         if (list.get(j).getIncentiveId().equalsIgnoreCase(incentiveId[i])&&"1".equalsIgnoreCase(list.get(j).getIsDel())){
 | 
	
		
			
				|  |  |                             throw new Exception("该激励已经保存过");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         }else if (list.get(j).getIncentiveId().equalsIgnoreCase(incentiveId[i])&&"0".equalsIgnoreCase(list.get(j).getIsDel())){
 | 
	
		
			
				|  |  |                             list.get(j).setIsDel("1");
 | 
	
		
			
				|  |  |                             saveList.add(list.get(j));
 | 
	
		
			
				|  |  |                         }else {
 | 
	
		
			
				|  |  |                             BaseDoctorIncentiveDO baseDoctorIncentiveDO = new BaseDoctorIncentiveDO();
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIsDel("1");
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setDoctorCode(doctor);
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setDoctorName(name);
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIncentiveId(baseIncentiveDictDO.getId());
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIncentiveName(baseIncentiveDictDO.getIncentiveName());
 | 
	
		
			
				|  |  |                             baseDoctorIncentiveDO.setIncentiveImg(baseIncentiveDictDO.getIncentiveImg());
 | 
	
		
			
				|  |  |                             saveList.add(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     BaseDoctorIncentiveDO baseDoctorIncentiveDO = new BaseDoctorIncentiveDO();
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIsDel("1");
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setDoctorCode(doctor);
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setDoctorName(name);
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIncentiveId(baseIncentiveDictDO.getId());
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIncentiveName(baseIncentiveDictDO.getIncentiveName());
 | 
	
		
			
				|  |  |                     baseDoctorIncentiveDO.setIncentiveImg(baseIncentiveDictDO.getIncentiveImg());
 | 
	
		
			
				|  |  |                     saveList.add(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             baseDoctorIncentiveDao.save(saveList);
 | 
	
		
			
				|  |  |             map.put("status",200);
 | 
	
		
			
				|  |  |             map.put("msg","操作成功");
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             BaseIncentiveDictDO baseIncentiveDictDO = baseIncentiveDictDao.findoneById(incentiveIds);
 | 
	
		
			
				|  |  |             if (baseIncentiveDictDO!=null){
 | 
	
		
			
				|  |  |                 BaseDoctorIncentiveDO baseDoctorIncentiveDO = new BaseDoctorIncentiveDO();
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIsDel("1");
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setDoctorCode(doctor);
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setDoctorName(name);
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIncentiveId(baseIncentiveDictDO.getId());
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIncentiveName(baseIncentiveDictDO.getIncentiveName());
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDO.setIncentiveImg(baseIncentiveDictDO.getIncentiveImg());
 | 
	
		
			
				|  |  |                 baseDoctorIncentiveDao.save(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             map.put("status",200);
 | 
	
		
			
				|  |  |             map.put("msg","操作成功");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public Envelop removeDoctorIncentive(String doctor, String incentiveId){
 | 
	
		
			
				|  |  |         Envelop envelop = new Envelop();
 | 
	
		
			
				|  |  |         BaseDoctorIncentiveDO baseDoctorIncentiveDO = baseDoctorIncentiveDao.findByDoctorCodeAndIncentiveIdAndIsDel(doctor,incentiveId,"1");
 | 
	
		
			
				|  |  |         if (baseDoctorIncentiveDO!=null){
 | 
	
		
			
				|  |  |             baseDoctorIncentiveDO.setIsDel("0");
 | 
	
		
			
				|  |  |             baseDoctorIncentiveDao.save(baseDoctorIncentiveDO);
 | 
	
		
			
				|  |  |             envelop.setStatus(200);
 | 
	
		
			
				|  |  |             envelop.setMessage("删除成功");
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             envelop.setStatus(-1);
 | 
	
		
			
				|  |  |             envelop.setMessage("删除失败");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return envelop;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public MixEnvelop findIncentiveByDoctor(String doctorId, Integer page, Integer pageSize) {
 | 
	
		
			
				|  |  |         MixEnvelop mixEnvelop = new MixEnvelop();
 | 
	
		
			
				|  |  |         List<BaseDoctorIncentiveDO> list = baseDoctorIncentiveDao.findByDoctorCodeList(doctorId,creatPage(page,pageSize,""));
 | 
	
		
			
				|  |  |         List<BaseDoctorIncentiveDO> listCount = baseDoctorIncentiveDao.findByDoctorCodeListCount(doctorId);
 | 
	
		
			
				|  |  |         mixEnvelop.setPageSize(pageSize);
 | 
	
		
			
				|  |  |         mixEnvelop.setCurrPage(page);
 | 
	
		
			
				|  |  |         mixEnvelop.setTotalCount(listCount==null?0:listCount.size());
 | 
	
		
			
				|  |  |         mixEnvelop.setDetailModelList(list);
 | 
	
		
			
				|  |  |         return mixEnvelop;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> findIncentiveDict(String doctorCode){
 | 
	
		
			
				|  |  |         String sql = "select b.id as \"id\"," +
 | 
	
		
			
				|  |  |                 "b.incentive_name as \"incentiveName\"," +
 | 
	
		
			
				|  |  |                 "b.incentive_img as \"incentiveImg\"," +
 | 
	
		
			
				|  |  |                 "b.incentive_status as \"incentiveStatus\"," +
 | 
	
		
			
				|  |  |                 "b.is_del as \"isDel\"," +
 | 
	
		
			
				|  |  |                 "b.incentive_code as \"incentiveCode\"," +
 | 
	
		
			
				|  |  |                 "b.create_time as \"createTime\"" +
 | 
	
		
			
				|  |  |                 "from base_incentive_dict b left join base_doctor_incentive d" +
 | 
	
		
			
				|  |  |                 " on b.id = d.incentive_id where is_del = '1'";
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(doctorCode)){
 | 
	
		
			
				|  |  |             sql+=" and d.doctor_code!='"+doctorCode+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql+=" group by  b.id,b.incentive_img,b.incentive_name" +
 | 
	
		
			
				|  |  |                 "b.incentive_status ,b.is_del, b.incentive_code,b.create_time";
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |