213 lines
8.0 KiB
Plaintext
213 lines
8.0 KiB
Plaintext
|
|
package com.nationalelectric.greenH5;
|
|||
|
|
|
|||
|
|
import java.util.Date;
|
|||
|
|
import java.util.List;
|
|||
|
|
|
|||
|
|
import javax.annotation.Resource;
|
|||
|
|
|
|||
|
|
import org.apache.commons.lang.StringUtils;
|
|||
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|||
|
|
import org.codehaus.jackson.type.TypeReference;
|
|||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|||
|
|
import org.springframework.stereotype.Controller;
|
|||
|
|
import org.springframework.transaction.annotation.Transactional;
|
|||
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|||
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|||
|
|
|
|||
|
|
import com.nationalelectirc.Constant.Constant;
|
|||
|
|
import com.nationalelectirc.utils.RestResult;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenApplyListBizc;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenHaircutCommentBizc;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenHaircutInfoBizc;
|
|||
|
|
import com.nationalelectric.greenH5.bizc.IGreenOperateLogBizc;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenApply;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenApplyList;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenHaircutComment;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenHaircutInfo;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenUserInfo;
|
|||
|
|
import com.nationalelectric.greenH5.po.GreenWashCarInfo;
|
|||
|
|
import com.sgcc.uap.persistence.IHibernateDao;
|
|||
|
|
import com.sgcc.uap.service.validator.ServiceValidatorUtil;
|
|||
|
|
import com.sun.org.apache.xpath.internal.operations.And;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* <b>概述</b>:<br>
|
|||
|
|
* <p>
|
|||
|
|
* <b>功能</b>:<br>
|
|||
|
|
*
|
|||
|
|
* @author dell
|
|||
|
|
*/
|
|||
|
|
@Controller
|
|||
|
|
@RequestMapping("/greenHaircutComment")
|
|||
|
|
public class GreenHaircutCommentController extends GreenBaseController {
|
|||
|
|
/**
|
|||
|
|
* 理发预约评论service
|
|||
|
|
*/
|
|||
|
|
@Resource
|
|||
|
|
private IGreenHaircutCommentBizc greenhaircutcommentBizc;
|
|||
|
|
/**
|
|||
|
|
* HibernateDao逻辑构件
|
|||
|
|
*/
|
|||
|
|
@Autowired
|
|||
|
|
IHibernateDao hibernateDao;
|
|||
|
|
/**
|
|||
|
|
* 理发预约service
|
|||
|
|
*/
|
|||
|
|
@Resource
|
|||
|
|
private IGreenHaircutInfoBizc greenhaircutinfoBizc;
|
|||
|
|
/**
|
|||
|
|
* 我的申请service
|
|||
|
|
*/
|
|||
|
|
@Resource
|
|||
|
|
private IGreenApplyListBizc greenapplylistBizc;
|
|||
|
|
@Resource
|
|||
|
|
private IGreenOperateLogBizc greenOperateLogBizc;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 保存理发评论信息
|
|||
|
|
*
|
|||
|
|
* @param greenHaircutComment
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@SuppressWarnings("unchecked")
|
|||
|
|
@Transactional(rollbackFor = Exception.class)
|
|||
|
|
@RequestMapping(value = "/saveHaircutComment", method = RequestMethod.POST)
|
|||
|
|
public @ResponseBody RestResult saveHaircutComment(@RequestBody Object requestBody) {
|
|||
|
|
GreenHaircutComment greenHaircutComment = new ObjectMapper().convertValue(requestBody,
|
|||
|
|
new TypeReference<GreenHaircutComment>() {
|
|||
|
|
});
|
|||
|
|
try {
|
|||
|
|
String userId = greenHaircutComment.getUserId();
|
|||
|
|
GreenUserInfo info = getUserInfo(userId);
|
|||
|
|
if (info == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
// 校验
|
|||
|
|
//ServiceValidatorUtil.validatorJavaBean(greenHaircutComment);
|
|||
|
|
// 根据id查询理发详情
|
|||
|
|
if ("1".equals(greenHaircutComment.getType())) {
|
|||
|
|
GreenHaircutInfo greenHaircutInfo = greenhaircutinfoBizc.get(greenHaircutComment.getDetailId());
|
|||
|
|
if (greenHaircutInfo == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "无此记录");
|
|||
|
|
}
|
|||
|
|
// 预约人姓名
|
|||
|
|
greenHaircutComment.setApplicantName(greenHaircutInfo.getApplyPersonName());
|
|||
|
|
greenHaircutComment.setCreator(greenHaircutComment.getUserId());
|
|||
|
|
greenHaircutComment.setModifier(greenHaircutComment.getUserId());
|
|||
|
|
} else if ("2".equals(greenHaircutComment.getType())) {
|
|||
|
|
GreenWashCarInfo greenWashCarInfo = hibernateDao.getObject(GreenWashCarInfo.class,
|
|||
|
|
greenHaircutComment.getDetailId());
|
|||
|
|
if (greenWashCarInfo == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "无此记录");
|
|||
|
|
}
|
|||
|
|
// 预约人姓名
|
|||
|
|
greenHaircutComment.setApplicantName(greenWashCarInfo.getUserName());
|
|||
|
|
greenHaircutComment.setCreator(greenHaircutComment.getUserId());
|
|||
|
|
greenHaircutComment.setModifier(greenHaircutComment.getUserId());
|
|||
|
|
}else{
|
|||
|
|
greenHaircutComment.setApplicantName(greenHaircutComment.getApplicantName()==null?"":greenHaircutComment.getApplicantName());
|
|||
|
|
greenHaircutComment.setCreator(userId);
|
|||
|
|
greenHaircutComment.setModifier(userId);
|
|||
|
|
}
|
|||
|
|
greenHaircutComment.setGmtCreated(new Date());
|
|||
|
|
greenHaircutComment.setGmtModified(new Date());
|
|||
|
|
greenHaircutComment.setIsDeleted("N");
|
|||
|
|
// 执行保存操作
|
|||
|
|
greenhaircutcommentBizc.add(greenHaircutComment);
|
|||
|
|
if("5".equals(greenHaircutComment.getType())){
|
|||
|
|
Long detailId = greenHaircutComment.getDetailId();
|
|||
|
|
String sql = "update green_usecar_apply set isEvaluate=1 where id = ?";
|
|||
|
|
hibernateDao.updateWithSql(sql,new Object[] { detailId });
|
|||
|
|
}else if("6".equals(greenHaircutComment.getType())||"9".equals(greenHaircutComment.getType())){
|
|||
|
|
Long detailId = greenHaircutComment.getDetailId();
|
|||
|
|
String sql = "update green_fault_repair_info set is_Evaluate=1 where id = ?";
|
|||
|
|
hibernateDao.updateWithSql(sql,new Object[] { detailId });
|
|||
|
|
}
|
|||
|
|
else if("7".equals(greenHaircutComment.getType())||"8".equals(greenHaircutComment.getType())){
|
|||
|
|
Long detailId = greenHaircutComment.getDetailId();
|
|||
|
|
String sql = "update green_report set is_Evaluate=1 where id = ?";
|
|||
|
|
hibernateDao.updateWithSql(sql,new Object[] { detailId });
|
|||
|
|
}
|
|||
|
|
else if("10".equals(greenHaircutComment.getType())){
|
|||
|
|
Long detailId = greenHaircutComment.getDetailId();
|
|||
|
|
String sql = "update green_seekmedical_record set comment_status=comment_status+1 where id = ?";
|
|||
|
|
hibernateDao.updateWithSql(sql,new Object[] { detailId });
|
|||
|
|
}
|
|||
|
|
else{
|
|||
|
|
String sql = "select * from green_apply ga where ga.apply_type = '06' and ga.del_flag = 0 and ga.detail_id = ?";
|
|||
|
|
if ("2".equals(greenHaircutComment.getType())) { // 洗车预约评论
|
|||
|
|
sql = "select * from green_apply ga where ga.apply_type = '09' and ga.del_flag = 0 and ga.detail_id = ?";
|
|||
|
|
}
|
|||
|
|
List<GreenApply> queryList = hibernateDao.queryForListWithSql(sql,
|
|||
|
|
new Object[] { greenHaircutComment.getDetailId() },
|
|||
|
|
new BeanPropertyRowMapper<GreenApply>(GreenApply.class));
|
|||
|
|
if (queryList.size() <= 0) {
|
|||
|
|
throw new Exception("评论失败,请重试");
|
|||
|
|
}
|
|||
|
|
// 获取请预约list表信息
|
|||
|
|
GreenApply apply = queryList.get(0);
|
|||
|
|
if (apply.getCommentStatus().equals("1")) {
|
|||
|
|
return new RestResult(Constant.FAILED, "请勿重复评论");
|
|||
|
|
}
|
|||
|
|
apply.setCommentStatus("1"); // 已评价
|
|||
|
|
apply.setUpdTime(new Date());
|
|||
|
|
hibernateDao.updateObject(apply, apply.getId());
|
|||
|
|
}
|
|||
|
|
return new RestResult(Constant.SUCCESS, "评论成功");
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
// 设置手动回滚
|
|||
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|||
|
|
return new RestResult(Constant.FAILED, "评论失败,请重试");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 根据id查询理发评论
|
|||
|
|
*
|
|||
|
|
* @param greenHaircutComment
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
@RequestMapping(value = "/getHaircutComment", method = RequestMethod.POST)
|
|||
|
|
public @ResponseBody RestResult getHaircutComment(@RequestBody Object requestBody) {
|
|||
|
|
GreenHaircutComment greenHaircutComment = new ObjectMapper().convertValue(requestBody,
|
|||
|
|
new TypeReference<GreenHaircutComment>() {
|
|||
|
|
});
|
|||
|
|
try {
|
|||
|
|
String userId = greenHaircutComment.getUserId();
|
|||
|
|
GreenUserInfo info = getUserInfo(userId);
|
|||
|
|
if (info == null) {
|
|||
|
|
return new RestResult(Constant.FAILED, "非法用户");
|
|||
|
|
}
|
|||
|
|
// 根据id查询理发评论
|
|||
|
|
GreenHaircutComment queryBean = greenhaircutcommentBizc.get(greenHaircutComment.getId());
|
|||
|
|
return new RestResult(Constant.SUCCESS, "查询成功", queryBean);
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
return new RestResult(Constant.FAILED, "查询失败");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 将字符串从第二位开始后边全部替换成*
|
|||
|
|
*
|
|||
|
|
* @param str
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
public String repalceStr(String str) {
|
|||
|
|
if (str.length() > 1) {
|
|||
|
|
String[] arr = str.split("");
|
|||
|
|
for (int i = 1; i < arr.length; i++) {
|
|||
|
|
arr[i] = "*";
|
|||
|
|
}
|
|||
|
|
return StringUtils.join(arr);
|
|||
|
|
} else {
|
|||
|
|
return str;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|