Browse Source

Merge branch 'dev' of wujunjie/patient-co-management into dev

huangwenjie 7 years ago
parent
commit
f93b2d85e0

+ 5 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/survey/QuestionnaireController.java

@ -2,6 +2,8 @@ package com.yihu.wlyy.controller.manager.survey;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.WlyyUserRole;
import com.yihu.wlyy.entity.survey.QuestionnairePrize;
import com.yihu.wlyy.entity.survey.QuestionnaireWinning;
import com.yihu.wlyy.service.manager.survey.QuestionnaireService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import com.yihu.wlyy.vo.UserPrizeVO;
@ -40,13 +42,14 @@ public class QuestionnaireController extends BaseController {
    @RequestMapping(value = "list")
    @ResponseBody
    public String searchList(
            @RequestParam(value = "type",defaultValue = "1")Integer type,
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "idCard",required = false)String idCard,
            @RequestParam(value = "page",required = false)Integer page,
            @RequestParam(value = "rows",required = false)Integer pageSize){
        try{
            List<UserPrizeVO> userprizes = questionnaireService.searchList(name,idCard,page, pageSize);
            List<UserPrizeVO> total = questionnaireService.searchListCount(name,idCard);
            List<QuestionnaireWinning> userprizes = questionnaireService.searchList(type ,name,idCard,page, pageSize);
            List<QuestionnaireWinning> total = questionnaireService.searchListCount(type,name,idCard);
            return write(200,"操作成功",page,pageSize,total.size(),userprizes);
        }catch (Exception ex){
            error(ex);

+ 33 - 15
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/survey/QuestionnaireService.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.service.manager.survey;
import com.yihu.wlyy.entity.HospitalDept;
import com.yihu.wlyy.entity.survey.QuestionnairePrize;
import com.yihu.wlyy.entity.survey.QuestionnaireWinning;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.repository.survey.QuestionnairePrizeDao;
import com.yihu.wlyy.service.common.excel.ExcelData;
@ -27,6 +28,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -44,15 +46,15 @@ public class QuestionnaireService extends BaseJpaService {
    @Value("${Riva.RIVAED_KEY2}")
    private String key2;//key2值
    public List<UserPrizeVO> searchList(String name,String idCard,Integer page,Integer pageSize) throws Exception{
    public List<QuestionnaireWinning> searchList(Integer type,String name,String idCard,Integer page,Integer pageSize) throws Exception{
        if(page <= 0){
            page = 1;
        }
        if(pageSize <= 0){
            pageSize = 15;
        }
    String sql = "SELECT w.user_name, w.user_idcard, w.user_openid, w.prize_type, w.prize_code, p.validity, p.address FROM wlyy_questionnaire_winning w, wlyy_questionnaire_prize p WHERE w.prize_code = p.`code` and w.winning = 1 and w.del = 0 and p.used = 1 and p.del = 0  " +
            "and type = 2";
    String sql = "SELECT w.* FROM wlyy_questionnaire_winning w WHERE w.winning = 1 and w.del = 0  " +
            "and w.prize_type = " + type;
        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idCard)){
            sql += " w.user_name = " + name + " w.user_idcard = " + idCard;
        }else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idCard)){
@ -61,14 +63,14 @@ public class QuestionnaireService extends BaseJpaService {
            sql += " w.user_name = " + name;
        }
        sql += " order by w.update_time desc limit " + (page-1) +"," +pageSize;
        List<UserPrizeVO> userPrizeVOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(UserPrizeVO.class));
        List<QuestionnaireWinning> userPrizeVOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(QuestionnaireWinning.class));
        return userPrizeVOList;
    }
    public List<UserPrizeVO> searchListCount(String name,String idCard) throws Exception{
    public List<QuestionnaireWinning> searchListCount(Integer type, String name, String idCard) throws Exception{
    String sql = "SELECT w.user_name, w.user_idcard, w.user_openid, w.prize_type, w.prize_code, p.validity, p.address FROM wlyy_questionnaire_winning w, wlyy_questionnaire_prize p WHERE w.prize_code = p.`code` and w.winning = 1 and w.del = 0 and p.used = 1 and p.del = 0  " +
            "and type = 2";
        String sql = "SELECT w.* FROM wlyy_questionnaire_winning w WHERE w.winning = 1 and w.del = 0  " +
                "and w.prize_type = " + type;
        if (StringUtils.isNotEmpty(name) && StringUtils.isNotEmpty(idCard)){
            sql += " w.user_name = " + name + " w.user_idcard = " + idCard;
        }else if (StringUtils.isEmpty(name) && StringUtils.isNotEmpty(idCard)){
@ -76,8 +78,8 @@ public class QuestionnaireService extends BaseJpaService {
        }else if (StringUtils.isNotEmpty(name) && StringUtils.isEmpty(idCard)){
            sql += " w.user_name = " + name;
        }
        sql += " order by w.idCard desc ";
        List<UserPrizeVO> userPrizeVOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<UserPrizeVO>());
        sql += " order by w.update_time desc ";
        List<QuestionnaireWinning> userPrizeVOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(QuestionnaireWinning.class));
        return userPrizeVOList;
    }
@ -105,11 +107,10 @@ public class QuestionnaireService extends BaseJpaService {
            });
            //判断导入的奖品资源是否存在,不存在则保存
            QuestionnairePrize existPrize = prizeDao.findByPrizeType(1,prize.getPrizeCode());
            QuestionnairePrize existPrize = prizeDao.findByPrizeType(prize.getType(),prize.getPrizeCode());
            if(existPrize == null){
                //                需要从表格取值
                prize.setCode(getCode());
                prize.setType(1);
                prize.setUsed(0);
                prize.setDel(0);
                prize.setCreateTime(new Date());
@ -128,8 +129,19 @@ public class QuestionnaireService extends BaseJpaService {
     */
    private Map<Integer, ExcelData> mappingQuestionnairePrize(QuestionnairePrize prize) {
        Map<Integer, ExcelData> dataMap = new HashMap<>();
        //兑奖码
        //奖品类型
        dataMap.put(0, new ExcelData() {
            @Override
            public void transform(String data) {
                //加密
                Integer type = Integer.valueOf(data);
                prize.setType(type);
            }
        });
        //兑奖码
        dataMap.put(1, new ExcelData() {
            @Override
            public void transform(String data) {
                //加密
@ -140,15 +152,21 @@ public class QuestionnaireService extends BaseJpaService {
        });
        //有效期
        dataMap.put(1, new ExcelData() {
        dataMap.put(2, new ExcelData() {
            @Override
            public void transform(String data) {
                prize.setValidity(new Date());
                try {
                    SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm");
                    Date validity = format.parse(data);
                    prize.setValidity(validity);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        });
        //领取地址
        dataMap.put(2, new ExcelData() {
        dataMap.put(3, new ExcelData() {
            @Override
            public void transform(String data) {
                prize.setAddress(data);

+ 7 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -91,7 +91,7 @@ public class DoctorGuidanceTempService extends BaseService {
     * @param content 指导内容
     * @return
     */
    public DoctorGuidanceTemp add(String doctor, String content, String modelName, String imagesUrl) {
    public DoctorGuidanceTemp add(String doctor, String content, String modelName, String imagesUrl) throws Exception{
        DoctorGuidanceTemp guidanceTemp = new DoctorGuidanceTemp();
        String imageUrls = "";
        String imageRow = "";
@ -104,7 +104,11 @@ public class DoctorGuidanceTempService extends BaseService {
        guidanceTemp.setModelName(modelName);
        if (imagesUrl == null || "".equals(imagesUrl)) {
        if (StringUtils.isNotEmpty(imagesUrl)) {
            imagesUrl = CommonUtil.validateImages(imagesUrl);
        }
        /*if (imagesUrl == null || "".equals(imagesUrl)) {
            imagesUrl = null;
        } else {
            String[] images = imagesUrl.split(",");
@ -122,7 +126,7 @@ public class DoctorGuidanceTempService extends BaseService {
            imagesUrl = imageUrls + imageRow;
            imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
        }
        }*/
        guidanceTemp.setImagesUrl(imagesUrl);

+ 27 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -257,6 +257,33 @@ public class CommonUtil {
        }
    }
    /**
     * 校验图片本地路径掺杂网络路径,统一返回网路路径
     *
     * @param images
     * @throws Exception
     */
    public  String validateImages(String images) throws Exception {
        String imagePath = "";
        String imageUrls = "";
        String imageRow = "";
        String[] imgs = images.split(",");
        for (String image : imgs) {
            if (image.contains("group1")) {
                imageUrls += image + ",";
            } else {
                try {
                    imageRow += copyTempImage(image) + ",";
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        imagePath += imageUrls + imageRow;
        imagePath = imagePath.substring(0, imagePath.length() - 1);
        return imagePath;
    }
    public void changeToMp3(String sourcePath, String targetPath) {
        File source = new File(sourcePath);

+ 9 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthGuidanceController.java

@ -13,12 +13,15 @@ import com.yihu.wlyy.service.template.DoctorGuidanceTempService;
import com.yihu.wlyy.service.template.DoctorTeamGuidanceService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.web.third.ylzpay.ThirdOnepayController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -37,6 +40,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Api(description = "健康指导")
public class DoctorHealthGuidanceController extends WeixinBaseController {
    private static final Logger logger = LoggerFactory.getLogger(DoctorHealthGuidanceController.class);
    @Autowired
    private PatientHealthGuidanceService patientHealthGuidanceService;
@ -176,8 +181,9 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
					images = CommonUtil.copyTempImage(images);
				}*/
                if (StringUtils.isNotEmpty(images)) {
                    images = doctorTeamGuidanceService.validateImages(images);
                    images = CommonUtil.validateImages(images);
                }
                logger.info("========================================> "+images);
                guidance.setImages(images);
                // 保存到居民端健康指导
@ -202,7 +208,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
                guidance.setPatient(patient);
                Doctor doctor = doctorService.findDoctorByCode(getUID());
                if (StringUtils.isNotEmpty(images)) {
                    images = doctorTeamGuidanceService.validateImages(images);
                    images = CommonUtil.validateImages(images);
                }
                /*if (images == null || "".equals(images)) {
                    images = null;
@ -224,6 +230,7 @@ public class DoctorHealthGuidanceController extends WeixinBaseController {
//                    images = imageUrls + imageRow;
//                    images = images.substring(0, images.length() - 1);
//                }
                logger.info("========================================> "+images);
                guidance.setImages(images);
                // 保存