|  | @ -0,0 +1,101 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.door.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.dao.WlyyDoorCommentDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.dao.WlyyDoorCommentDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.dao.WlyyDoorDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.door.dao.WlyyDoorServiceOrderDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.door.WlyyDoorCommentDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.door.WlyyDoorCommentDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.door.WlyyDoorDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.math.BigDecimal;
 | 
	
		
			
				|  |  | import java.util.Date;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by wangpeiqiang on 2019/3/16.
 | 
	
		
			
				|  |  |  * 居民端-评分
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | public class DoorCommentService extends BaseJpaService<WlyyDoorCommentDO, WlyyDoorCommentDao> {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     BasePatientDao patientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     WlyyDoorCommentDao doorCommentDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     WlyyDoorCommentDoctorDao doorCommentDoctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     WlyyDoorServiceOrderDao wlyyDoorServiceOrderDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     WlyyDoorDoctorDao wlyyDoorDoctorDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String add(String patientCode,String orderId, Integer professionalSkill,Integer serveAttitude,Integer serveEfficiency,String description,Integer isAnonymous){
 | 
	
		
			
				|  |  |         BasePatientDO patient =patientDao.findById(patientCode);
 | 
	
		
			
				|  |  |         WlyyDoorCommentDO doorComment = new WlyyDoorCommentDO();
 | 
	
		
			
				|  |  |         BigDecimal evaluateSplit = BigDecimal.ZERO;
 | 
	
		
			
				|  |  |         BigDecimal num = new BigDecimal("3");
 | 
	
		
			
				|  |  |         //计算三项评分平均分
 | 
	
		
			
				|  |  |         evaluateSplit = evaluateSplit.add(
 | 
	
		
			
				|  |  |                 (new BigDecimal(professionalSkill).add(new BigDecimal(serveAttitude)).add(new BigDecimal(serveEfficiency))).divide(num,2,BigDecimal.ROUND_HALF_UP)
 | 
	
		
			
				|  |  |         );
 | 
	
		
			
				|  |  |         doorComment.setOrderId(orderId);
 | 
	
		
			
				|  |  |         doorComment.setCode(getCode());
 | 
	
		
			
				|  |  |         doorComment.setProfessionalSkill(professionalSkill);
 | 
	
		
			
				|  |  |         doorComment.setServeAttitude(serveAttitude);
 | 
	
		
			
				|  |  |         doorComment.setServeEfficiency(serveEfficiency);
 | 
	
		
			
				|  |  |         doorComment.setEvaluateSplit(evaluateSplit);
 | 
	
		
			
				|  |  |         doorComment.setIsAnonymous(isAnonymous);
 | 
	
		
			
				|  |  |         doorComment.setDescription(description);
 | 
	
		
			
				|  |  |         doorComment.setPatient(patientCode);
 | 
	
		
			
				|  |  |         doorComment.setCreateUser(patientCode);
 | 
	
		
			
				|  |  |         doorComment.setCreateUserName(patient.getName());
 | 
	
		
			
				|  |  |         doorComment.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         doorCommentDao.save(doorComment);
 | 
	
		
			
				|  |  |         //更新工单状态
 | 
	
		
			
				|  |  |         WlyyDoorServiceOrderDO wlyyDoorServiceOrderDO =wlyyDoorServiceOrderDao.findOne(orderId);
 | 
	
		
			
				|  |  |         wlyyDoorServiceOrderDO.setStatus(6);
 | 
	
		
			
				|  |  |         wlyyDoorServiceOrderDO.setCompleteTime(new Date());
 | 
	
		
			
				|  |  |         wlyyDoorServiceOrderDO.setUpdateUser(patientCode);
 | 
	
		
			
				|  |  |         wlyyDoorServiceOrderDO.setUpdateUserName(patient.getName());
 | 
	
		
			
				|  |  |         wlyyDoorServiceOrderDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |         wlyyDoorServiceOrderDao.save(wlyyDoorServiceOrderDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<WlyyDoorDoctorDO> wlyyDoorDoctorDOList =this.wlyyDoorDoctorDao.findByOrderId(orderId);
 | 
	
		
			
				|  |  |         for(WlyyDoorDoctorDO wlyyDoorDoctorDO:wlyyDoorDoctorDOList) {
 | 
	
		
			
				|  |  |             WlyyDoorCommentDoctorDO doorCommentDoctor = new WlyyDoorCommentDoctorDO();
 | 
	
		
			
				|  |  |             doorCommentDoctor.setOrderId(orderId);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setCode(getCode());
 | 
	
		
			
				|  |  |             doorCommentDoctor.setDoctorCode(wlyyDoorDoctorDO.getDoctor());
 | 
	
		
			
				|  |  |             doorCommentDoctor.setProfessionalSkill(professionalSkill);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setServeAttitude(serveAttitude);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setServeEfficiency(serveEfficiency);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setEvaluateSplit(evaluateSplit);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setIsAnonymous(isAnonymous);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setDescription(description);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setPatient(patientCode);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setCreateUser(patientCode);
 | 
	
		
			
				|  |  |             doorCommentDoctor.setCreateUserName(patient.getName());
 | 
	
		
			
				|  |  |             doorCommentDoctor.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             doorCommentDoctorDao.save(doorCommentDoctor);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return"1";
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public JSONObject commentDetail(String patient,String orderId)throws Exception{
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         WlyyDoorCommentDO commentDetail = doorCommentDao.selectCommentDoctor(patient,orderId);
 | 
	
		
			
				|  |  |         result.put("commentDetail",commentDetail);
 | 
	
		
			
				|  |  |         return result;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |