浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

huangwenjie 7 年之前
父节点
当前提交
31c31339d0

+ 23 - 14
edu-article/JkEdu/src/com/yihu/jk/api/ArticleApi.java

@ -1,27 +1,25 @@
package com.yihu.jk.api;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
import com.common.json.JSONException;
import com.coreframework.db.DB;
import com.coreframework.remoting.standard.DateOper;
import com.coreframework.util.AppConfig;
import com.yihu.jk.dao.ArticleDao;
import com.yihu.jk.dao.ArticlePcDao;
import com.yihu.jk.utils.ApiUtil;
import com.yihu.jk.utils.StringUtil;
import com.yihu.jk.vo.Article;
import com.yihu.jk.vo.ArticleStatistic;
import com.yihu.jk.vo.OrgArticleVo;
import com.yihu.wsgw.api.InterfaceMessage;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import com.common.json.JSONException;
import com.coreframework.db.DB;
import com.coreframework.util.AppConfig;
import com.yihu.jk.dao.ArticleDao;
import com.yihu.jk.utils.ApiUtil;
import com.yihu.jk.utils.StringUtil;
import com.yihu.jk.vo.ArticleStatistic;
import com.yihu.wsgw.api.InterfaceMessage;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.List;
public class ArticleApi {
	private static ArticleDao dao = new ArticleDao();
@ -552,11 +550,22 @@ public class ArticleApi {
			orgArticleVo.setAuthentication(authentication);
			orgArticleVo.setAuthenticationId(authenticationId);
			orgArticleVo.setRoleType(roleType);
			if ("".equals(orgName) && orgName == null) {
			if ("".equals(orgName) || orgName == null) {
				orgName = "无";
			}
			orgArticleVo.setOrgName(orgName);
			orgArticleVo.setArticleSource(orgName);
			//新增文章时 保存分享数,阅读数等数据
//			ArticleStatistic statistic = new ArticleStatistic();
//			statistic.setBrowseNumber(0);
//			statistic.setPointNumber(0);
//			statistic.setCommentNumber(0);
//			statistic.setShareNumber(0);
//			statistic.setCollectionNumber(0);
//			statistic.setArticleId(articleId);
//			dao.insertArticleInitStatistic(statistic);
			dao.insertArticleStatistic(articleId);
			return dao.saveArticle(orgArticleVo).toString();
		}else{
			orgArticleVo.setArticleId(articleId);

+ 10 - 7
edu-article/JkEdu/src/com/yihu/jk/api/ArticleApiTest.java

@ -68,20 +68,23 @@ public class ArticleApiTest {
//		obj.put("articlelevel","1");
//		obj.put("articleTitle","1");
//		obj.put("userCode","0de7295862dd11e69faffa163e8aee56");
		obj.put("roleType",1);
		obj.put("currentUserRole","3502030700");
		obj.put("currentUserRoleLevel",4);//
//		obj.put("currentUserRole","3502110400");
		obj.put("userCode","0de7295862dd11e69faffa163e8aee56");//ylp201703150222
		//obj.put("roleType",1);
		obj.put("currentUserRole","3502110400");
		//obj.put("userCode","0de7295862dd11e69faffa163e8aee56");//ylp201703150222
		obj.put("isMyArticle",true);
		obj.put("page","0");
		obj.put("pageSize","10");
		obj.put("pageSize","9");
		obj.put("currentUserRoleLevel",4);//
		obj.put("sEcho","1");
//		obj.put("articleTitle","我口试");
		im.setParam(obj.toString());
		initDB();
		try{
//			api.authenticationArticle(im);
			System.out.println(api.queryArticleAPPList(im));
//			System.out.println(api.authenArticlePCList(im));//initArticleStatistic
			api.initArticleStatistic();
		}catch(Exception e){
			e.printStackTrace();
		}

+ 6 - 4
edu-article/JkEdu/src/com/yihu/jk/dao/ArticleDao.java

@ -297,8 +297,8 @@ public class ArticleDao {
	public void insertArticleStatistic(String articleId) throws SQLException {
		Sql sql = DB.me().createSql(ArticleSqlNameEnum.insertArticleStatistic);
		sql.addParamValue(articleId);
		sql.addParamValue(articleId);
		System.out.println(sql.toString());
//		sql.addParamValue(articleId);
//		System.out.println(sql.toString());
		DB.me().insert(MyDatabaseEnum.JkEduDB, sql);
	}
@ -684,9 +684,9 @@ public class ArticleDao {
		}else if("4".equals(vo.getOperatorRoleLevel())){//社区、机构
			param.append(" and OperatorRoleCode = '"+vo.getOperatorRoleCode()+"' ");
		}
		param.append(" and UserScope <= ? ");
		if(StringUtil.isNotEmpty(vo.getOperatorRoleLevel())){
		if(StringUtil.isNotEmpty(vo.getOperatorRoleLevel())){
			param.append(" and UserScope <= ? ");
			sql.addParamValue(Integer.valueOf(vo.getOperatorRoleLevel())-1);
		}else{
			sql.addParamValue(3);
@ -778,6 +778,7 @@ public class ArticleDao {
        Sql sql = DB.me().createSql(ArticleSqlNameEnum.getArticlePcList);
        StringBuffer param = new StringBuffer();
		StringBuffer param2 = new StringBuffer();
        StringBuffer pageParam = new StringBuffer();
        if (StringUtil.isNotEmpty(vo.getFirstLevelCategoryId())) {
            param.append(" and FirstLevelCategoryId = ? ");
@ -811,6 +812,7 @@ public class ArticleDao {
        }
        sql.addVar("@Condition", param.toString());
        sql.addVar("@PageParam", pageParam.toString());
		sql.addVar("@Condition2", param2.toString());
        return DB.me().queryForJson(MyDatabaseEnum.JkEduDB, sql, start, pageSize);
    }

+ 30 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jkEduArticle/ThirdJkEduArticleService.java

@ -28,6 +28,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import springfox.documentation.spring.web.json.Json;
import java.util.*;
@ -103,6 +104,7 @@ public class ThirdJkEduArticleService extends BaseService {
    private String updateArticleQRCode = "JkEdu.ArticleQR.updateArticleQRCode";//更新认证标识
    private String saveArticleQRCode = "JkEdu.ArticleQR.saveArticleQRCode";//添加认证标识
    private String getArticleQRCodeById = "JkEdu.ArticleQR.getArticleQRCodeById";//根据id获取认证标识
    private String saveBehavior = "JkEdu.Behavior.saveBehavior";//根据id获取认证标识
    /**
     * 封装入参
     *
@ -731,7 +733,7 @@ public class ThirdJkEduArticleService extends BaseService {
     * @return
     * @throws Exception
     */
    public void checkCategory(String categoryName,Integer categoryLevel) throws Exception {
    public boolean checkCategory(String categoryName,Integer categoryLevel) throws Exception {
        JSONObject json = null;
        try {
            JSONObject param = new JSONObject();
@ -739,12 +741,15 @@ public class ThirdJkEduArticleService extends BaseService {
            param.put("categoryLevel", categoryLevel);
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(checkCategory, param.toString(), "1"));
            json = JSON.parseObject(response);
            JSONArray j = (JSONArray) json.get("result");
            if(j!=null&&j.size()>0){
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!"10000".equals(json.getString("Code"))) {
            new Exception(json.getString("Message"));
        }
        return false;
    }
    /**
@ -916,6 +921,27 @@ public class ThirdJkEduArticleService extends BaseService {
        }
    }
    /**************************************************** behaver *******************************************************/
    public void saveBehavior(String articleId,String cName,String userId) throws Exception {
        JSONObject json = null;
        try{
            JSONObject param = new JSONObject();
            param.put("articleId",articleId);// 文章ID
            param.put("cName",cName);//用户名称
            param.put("userId",userId);//用户ID
            String response = httpClientUtil.httpPost(articleBaseUrl+"/WsPlatform/rest", getParamsMap(saveBehavior, param.toString(), "1"));
            json = JSON.parseObject(response);
        }catch (Exception e) {
            e.printStackTrace();
        }
        if (!"10000".equals(json.getString("Code"))) {
            throw new Exception(json.getString("Message"));
        }
    }
    /**************************************************** other *******************************************************/
    /**

+ 61 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java

@ -1,7 +1,10 @@
package com.yihu.wlyy.web.common.sms;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
@ -25,6 +28,8 @@ import java.util.List;
@Api(description = "短信")
public class SMSController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(PrescriptionInfoService.class);
	@Autowired
	public SMSService smsService;
	@Autowired
@ -94,6 +99,62 @@ public class SMSController extends BaseController {
		}
	}
	@RequestMapping(value = "checkCaptcha", method = RequestMethod.POST)
	@ResponseBody
	public String send2(String mobile, int type, @RequestParam(required = false) String captchaToken) {
		try {
			logger.info("in checkCaptcha");
			if (type > 10 || type < 1) {
				return error(-1, "无效的请求!");
			}
			if (StringUtils.isEmpty(mobile)) {
				return error(-1, "手机号码不允许为空!");
			}
//			if (type == 4) {
//				// 登录时校验用户是否存在
//				List<Patient> patients = patientDao.findByMobile(mobile);
//				if (patients == null||patients.size()==0) {
//					return error(-1, "该手机号未注册!");
//				}
//			} else if (type == 5) {
//				// 登录时校验用户是否存在
//				Doctor doctor = doctorDao.findByMobile(mobile);
//				if (doctor == null) {
//					return error(-1, "该手机号未注册!");
//				}
//			}
			if (StringUtils.isNotEmpty(captchaToken)) {
				String ct = request.getSession().getAttribute("captchaToken").toString();
				if (!StringUtils.equalsIgnoreCase(captchaToken, ct)) {
					return error(-1, "图形验证码错误!");
				}
			}
			// 获取ip地址
			String ip = NetworkUtil.getIpAddress(request);
			if (StringUtils.isEmpty(ip)) {
				return error(-1, "无效的ip请求!");
			}
//			String res = smsService.send(mobile, ip, type, getUID());
			String res = null;
			//内网发送 通过redis的队列
			if("local".equals(springProfiles)){
				logger.info("sendToNeiWang");
				res = smsService.sendToNeiWang(mobile, ip, type);
			}else {
				logger.info("smsService.send");
				res = smsService.send(mobile, ip, type, getRepUID());
			}
			if (StringUtils.equals(res, "ok")) {
				return write(200, "验证码短信已发送!");
			} else {
				return error(-1, res);
			}
		} catch (Exception e) {
			error(e);
			return error(-1, "短信发送失败!");
		}
	}
	/**
	 * 验证手机验证码
	 * @param type 消息类型:1微信端注册,2微信端找回密码,3医生端找回密码

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/jimeiJkEdu/PatientJMJkEduArticleController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.patient.jimeiJkEdu;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.jimeiJkEdu.JMJkEduArticleService;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -28,6 +29,8 @@ public class PatientJMJkEduArticleController extends BaseController {
    @Autowired
    private JMJkEduArticleService jmJkEduArticleService;
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    @RequestMapping(value = "fetchArticlePushedList", method = RequestMethod.GET)
    @ApiOperation("居民获取被推送文章列表 ")
@ -183,4 +186,20 @@ public class PatientJMJkEduArticleController extends BaseController {
            return error(-1,"查询失败!");
        }
    }
    @RequestMapping(value = "saveBehavior", method = RequestMethod.POST)
    @ApiOperation("添加 浏览、转发、分享、点赞 ")
    public String saveBehavior(
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "cName", value = "用户名称", required = true) @RequestParam(value = "cName", required = true) String cName,
            @ApiParam(name = "userId", value = "用户ID", required = true) @RequestParam(value = "userId", required = false) String  userId){
        try {
            thirdJkEduArticleService.saveBehavior(articleId,cName,userId);
//            Long count = healthEducationArticleService.pushArticleLogsCount("ece5c665b16542b0847e52b4a9fee44a");
            return write(200,"保存成功!");
        }catch (Exception e) {
            e.printStackTrace();
            return error(-1,"保存失败!");
        }
    }
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/jkEduArticle/ThirdJkEduArticleController.java

@ -249,6 +249,10 @@ public class ThirdJkEduArticleController extends BaseController {
    ){
        try {
            boolean flag = thirdJkEduArticleService.checkCategory(categoryName,categoryLevel);
            if(flag){
                return error(-2,"文章分类名称重复!");
            }
            thirdJkEduArticleService.addCategory(categoryName,categoryLevel,firstlevelId,secondLevelId,getUID(),getCurrentRoleCode());
            return success("添加成功!");
        }catch (Exception e){