Commit c80b825a authored by 谢希宇's avatar 谢希宇

Aidea product update by Strive Date 2020-11-12

parent c799f851
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if> <if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if> <if test="limit>0">limit #{offset},#{limit}</if>
</select> </select>
<select id="consultSheetList" resultType="com.cftech.consultsheet.model.ConsultSheet"> <select id="consultSheetList" resultType="com.cftech.consultsheet.model.ConsultSheet">
SELECT SELECT
<include refid="sqlCol"/> <include refid="sqlCol"/>
...@@ -206,14 +207,14 @@ ...@@ -206,14 +207,14 @@
and open_id = #{openid} and open_id = #{openid}
</if> </if>
<if test="name!=null and name !=''"> <if test="name!=null and name !=''">
and user_name like concat('%',#{name},'%') and CONVERT(AES_DECRYPT(user_name,'aideakey') USING UTF8) like concat('%',#{name},'%')
</if> </if>
<if test="id!=null"> <if test="id!=null">
and id = #{id} and id = #{id}
</if> </if>
ORDER BY create_time DESC ORDER BY create_time DESC
<if test="page!=null and pageSize !='' and pageSize!=null and page !=''"> <if test="page!=null and pageSize !='' and pageSize!=null and page !=''">
limit #{page},#{pageSize} limit #{page}, #{pageSize}
</if> </if>
</select> </select>
......
package com.cftech.consultsheet.service.impl; package com.cftech.consultsheet.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cftech.accounts.model.MpAccountsEntity; import com.cftech.accounts.model.MpAccountsEntity;
import com.cftech.accounts.service.MpAccountsService; import com.cftech.accounts.service.MpAccountsService;
import com.cftech.base.codingrule.utils.CodingruleUtils; import com.cftech.base.codingrule.utils.CodingruleUtils;
import com.cftech.base.org.api.QyMediaUtil;
import com.cftech.base.org.api.QyMsgUtil; import com.cftech.base.org.api.QyMsgUtil;
import com.cftech.base.org.model.Qyuser; import com.cftech.base.org.model.Qyuser;
import com.cftech.base.org.service.QyuserService; import com.cftech.base.org.service.QyuserService;
...@@ -18,11 +20,14 @@ import com.cftech.core.scope.OrderType; ...@@ -18,11 +20,14 @@ import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Conds; import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort; import com.cftech.core.sql.Sort;
import com.cftech.core.util.Constants; import com.cftech.core.util.Constants;
import com.cftech.core.util.MpTokenUtil;
import com.cftech.core.util.StringUtils; import com.cftech.core.util.StringUtils;
import com.cftech.core.util.SystemConfig; import com.cftech.core.util.SystemConfig;
import com.cftech.cos.config.cosconfig.model.Cosconfig;
import com.cftech.member.model.Member; import com.cftech.member.model.Member;
import com.cftech.member.service.MemberService; import com.cftech.member.service.MemberService;
import com.cftech.order.service.OrderService; import com.cftech.order.service.OrderService;
import org.mp.api.wxbase.wxmedia.JwMediaAPI;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
...@@ -61,6 +66,12 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im ...@@ -61,6 +66,12 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im
@Autowired @Autowired
private CodingruleUtils codingruleUtils; private CodingruleUtils codingruleUtils;
@Autowired
private MpTokenUtil mpTokenUtil;
@Autowired
private QyMediaUtil mediaUtil;
@Autowired @Autowired
private QyMsgUtil qyMsgUtil; private QyMsgUtil qyMsgUtil;
...@@ -99,11 +110,22 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im ...@@ -99,11 +110,22 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im
public JSONObject pollingConsultSheet(ConsultSheet consultSheet) { public JSONObject pollingConsultSheet(ConsultSheet consultSheet) {
JSONObject retObj = new JSONObject(); JSONObject retObj = new JSONObject();
try { try {
MpAccountsEntity mpAccountsAppid = mpAccountsService.getMpAccountsAppid(consultSheet.getAppId()); MpAccountsEntity mpAccountsEntity = mpAccountsService.getMpAccountsAppid(consultSheet.getAppId());
consultSheet.setConsultId(codingruleUtils.getNumber(consultSheet.getAccountsId(), ConsultSheet.class.getName())); consultSheet.setConsultId(codingruleUtils.getNumber(consultSheet.getAccountsId(), ConsultSheet.class.getName()));
//处理处方单图片
String fileName = mediaUtil.downloadMpMediaToDisk(mpAccountsEntity.getId(), "consultSheet", consultSheet.getPrescription());
String url = SystemConfig.p.getProperty("QY_DOMAIN") + SystemConfig.p.getProperty("IMAGEURL").replace("{PICFILENAME}", fileName);
consultSheet.setAccountsId(mpAccountsEntity.getId());
consultSheet.setPrescription(url);
if (consultSheetMapper.save(consultSheet) > 0) { if (consultSheetMapper.save(consultSheet) > 0) {
memberProcess(consultSheet.getOpenId(), consultSheet); memberProcess(consultSheet.getOpenId(), consultSheet);
//展示客服二维码
Qyuser serviceCus = qyuserService.fetchById(consultSheet.getServiceId());
retObj.put("errorNo", 0); retObj.put("errorNo", 0);
retObj.put("data", serviceCus.getQrcode());
retObj.put("errorMsg", "咨询单提交成功,请等待药师审核"); retObj.put("errorMsg", "咨询单提交成功,请等待药师审核");
} else { } else {
retObj.put("errorNo", 1); retObj.put("errorNo", 1);
...@@ -292,8 +314,4 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im ...@@ -292,8 +314,4 @@ public class ConsultSheetServiceImpl extends GenericServiceImpl<ConsultSheet> im
agenId, msg, false); agenId, msg, false);
} }
@Scheduled(cron="*/5 * * * * ?")
public void dingshi() {
System.out.println("启动定时任务5秒一次");
}
} }
\ No newline at end of file
...@@ -49,6 +49,5 @@ public class MobileConsultSheetController { ...@@ -49,6 +49,5 @@ public class MobileConsultSheetController {
public void test(Long id) { public void test(Long id) {
ConsultSheet consultSheet = consultSheetService.fetchById(id); ConsultSheet consultSheet = consultSheetService.fetchById(id);
consultSheetService.sendQyWechatMassage(consultSheet); consultSheetService.sendQyWechatMassage(consultSheet);
} }
} }
...@@ -41,7 +41,7 @@ LOG_URL=http://www.michang-tech.com.cn:6989/log/addlog ...@@ -41,7 +41,7 @@ LOG_URL=http://www.michang-tech.com.cn:6989/log/addlog
#\u6821\u9A8C\u5151\u6362\u5BC6\u7801KEY #\u6821\u9A8C\u5151\u6362\u5BC6\u7801KEY
MEMBER_PASSWORD_KEY=DONGCHANGINT9527; MEMBER_PASSWORD_KEY=DONGCHANGINT9527;
list.refreshtoken=true list.refreshtoken=true
jwt.domain=127.0.0.1 jwt.domain=pd.shxrtech.com
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD #\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
jwt.duration=86400000 jwt.duration=86400000
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u03AAtrue #\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u03AAtrue
......
...@@ -5,6 +5,7 @@ import com.cftech.addresst.model.Address; ...@@ -5,6 +5,7 @@ import com.cftech.addresst.model.Address;
import com.cftech.addresst.model.AddressVO; import com.cftech.addresst.model.AddressVO;
import com.cftech.addresst.model.Area; import com.cftech.addresst.model.Area;
import com.cftech.core.generic.GenericDao; import com.cftech.core.generic.GenericDao;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -30,7 +31,7 @@ public interface AddressMapper extends GenericDao<Address> { ...@@ -30,7 +31,7 @@ public interface AddressMapper extends GenericDao<Address> {
* @Param * @Param
* @return * @return
**/ **/
List<AddressVO> addressList(String openId); List<AddressVO> addressList(@Param("openId") String openId, @Param("addressId") Long addressId);
/** /**
* @Description 根据id查询收货地址 * @Description 根据id查询收货地址
* @Date 9:53 2020/10/20 * @Date 9:53 2020/10/20
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
) )
</insert> </insert>
<select id="addressId" resultType="com.cftech.addresst.model.AddressVO"> <select id="addressId" resultType="com.cftech.addresst.model.AddressVO">
select select
t.id, t.id,
t.open_id as openId, t.open_id as openId,
t.address_name as addressName, t.address_name as addressName,
...@@ -151,7 +151,6 @@ select ...@@ -151,7 +151,6 @@ select
LEFT JOIN area c ON t.area_id = c.areaid LEFT JOIN area c ON t.area_id = c.areaid
and t.del_flag=0 and t.del_flag=0
WHERE t.id = #{id} WHERE t.id = #{id}
</select> </select>
<select id="addressList" resultType="com.cftech.addresst.model.AddressVO"> <select id="addressList" resultType="com.cftech.addresst.model.AddressVO">
SELECT SELECT
...@@ -177,7 +176,10 @@ select ...@@ -177,7 +176,10 @@ select
LEFT JOIN area b ON t.city_id = b.areaid LEFT JOIN area b ON t.city_id = b.areaid
LEFT JOIN area c ON t.area_id = c.areaid LEFT JOIN area c ON t.area_id = c.areaid
WHERE t.open_id = #{openId} WHERE t.open_id = #{openId}
and t.del_flag=0 AND t.del_flag=0
<if test="addressId != null and addressId != '' ">
AND t.id = #{addressId}
</if>
</select> </select>
<select id="fetchById" parameterType="java.lang.Long" resultMap="resultMap"> <select id="fetchById" parameterType="java.lang.Long" resultMap="resultMap">
......
...@@ -10,50 +10,55 @@ import java.io.Serializable; ...@@ -10,50 +10,55 @@ import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
* 收货地址管理Service * 收货地址管理Service
* *
* @author Licc * @author Licc
* @date: 2020-09-29 17:17 * @date: 2020-09-29 17:17
*/ */
public interface AddressService extends GenericService<Address> { public interface AddressService extends GenericService<Address> {
List<Area> listArea(); List<Area> listArea();
/** /**
* @return
* @Description 个人收货地址数据回填 * @Description 个人收货地址数据回填
* @Date 9:53 2020/10/20 * @Date 9:53 2020/10/20
* @Param * @Param
* @return
**/ **/
JSONObject addressList(String openId,String appId); JSONObject addressList(String openId, String appId, Long addressId);
/** /**
* @return
* @Description 根据id查询收货地址 * @Description 根据id查询收货地址
* @Date 9:53 2020/10/20 * @Date 9:53 2020/10/20
* @Param * @Param
* @return
**/ **/
JSONObject addressId(Long id,String appId); JSONObject addressId(Long id, String appId);
/** /**
* @return
* @Description 个人收货地址新增 * @Description 个人收货地址新增
* @Date 9:53 2020/10/20 * @Date 9:53 2020/10/20
* @Param * @Param
* @return
**/ **/
JSONObject addressAdd(Address address); JSONObject addressAdd(Address address);
/** /**
* @return
* @Author Licc * @Author Licc
* @Description 个人收货地址修改 * @Description 个人收货地址修改
* @Date 15:23 2020/10/20 * @Date 15:23 2020/10/20
* @Param * @Param
* @return
**/ **/
JSONObject updateAddress(Address address); JSONObject updateAddress(Address address);
/** /**
* @return
* @Author Licc * @Author Licc
* @Description 个人收货地址删除 * @Description 个人收货地址删除
* @Date 15:53 2020/10/20 * @Date 15:53 2020/10/20
* @Param * @Param
* @return
**/ **/
JSONObject deleteAddress(String id,String appId); JSONObject deleteAddress(String id, String appId);
} }
...@@ -51,7 +51,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A ...@@ -51,7 +51,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
} }
@Override @Override
public JSONObject addressList(String openId, String appId) { public JSONObject addressList(String openId, String appId, Long addressId) {
JSONObject rtnJson = new JSONObject(); JSONObject rtnJson = new JSONObject();
try { try {
...@@ -61,7 +61,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A ...@@ -61,7 +61,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
return rtnJson; return rtnJson;
} }
MpAccountsEntity mpAccountsAppid = mpAccountsService.getMpAccountsAppid(appId); MpAccountsEntity mpAccountsAppid = mpAccountsService.getMpAccountsAppid(appId);
List<AddressVO> addressList = addressMapper.addressList(openId); List<AddressVO> addressList = addressMapper.addressList(openId, addressId);
Log.info("参数:" + addressList); Log.info("参数:" + addressList);
if (!addressList.equals("") || addressList != null) { if (!addressList.equals("") || addressList != null) {
rtnJson.put("errorNo", "0"); rtnJson.put("errorNo", "0");
...@@ -79,7 +79,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A ...@@ -79,7 +79,7 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
public JSONObject addressId(Long id,String appId) { public JSONObject addressId(Long id,String appId) {
JSONObject rtnJson = new JSONObject(); JSONObject rtnJson = new JSONObject();
try { try {
if (id.equals("")) { if (id == null) {
rtnJson.put("errorNo", "1"); rtnJson.put("errorNo", "1");
rtnJson.put("errorMsg", "id不能为空"); rtnJson.put("errorMsg", "id不能为空");
return rtnJson; return rtnJson;
...@@ -89,11 +89,11 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A ...@@ -89,11 +89,11 @@ public class AddressServiceImpl extends GenericServiceImpl<Address> implements A
if (addressVOS!=null){ if (addressVOS!=null){
Log.info("参数:"+addressVOS); Log.info("参数:"+addressVOS);
rtnJson.put("errorNo","0"); rtnJson.put("errorNo","0");
rtnJson.put("errorMsg",addressVOS); rtnJson.put("data",addressVOS);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
rtnJson.put("errorNO", "1"); rtnJson.put("errorNo", "1");
} }
return rtnJson; return rtnJson;
} }
......
...@@ -37,8 +37,8 @@ public class MobileAddressController { ...@@ -37,8 +37,8 @@ public class MobileAddressController {
* @Param * @Param
**/ **/
@RequestMapping(value = "/addressList", method = {RequestMethod.GET, RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/addressList", method = {RequestMethod.GET, RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JSONObject addressList(String openId, String appId) { public JSONObject addressList(String openId, String appId, Long addressId) {
return addressService.addressList(openId,appId); return addressService.addressList(openId, appId, addressId);
} }
/** /**
......
...@@ -191,7 +191,7 @@ public class MobileQybaseController { ...@@ -191,7 +191,7 @@ public class MobileQybaseController {
} }
} }
String filePath = USER_IMAGES_DIR + ""; String filePath = USER_IMAGES_DIR;
String picPath = filePath + File.separator + picFileName; String picPath = filePath + File.separator + picFileName;
//取后缀 //取后缀
......
package com.cftech.base.org.api; package com.cftech.base.org.api;
import com.cftech.accounts.model.MpAccountsEntity; import com.cftech.accounts.model.MpAccountsEntity;
import com.cftech.core.constants.MpApiConstants;
import com.cftech.core.constants.WxApiConstants; import com.cftech.core.constants.WxApiConstants;
import com.cftech.core.util.MpTokenUtil;
import com.cftech.core.util.QyTokenUtil; import com.cftech.core.util.QyTokenUtil;
import com.cftech.core.util.SystemConfig; import com.cftech.core.util.SystemConfig;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -25,6 +27,9 @@ public class QyMediaUtil { ...@@ -25,6 +27,9 @@ public class QyMediaUtil {
private final QyTokenUtil qyTokenUtil; private final QyTokenUtil qyTokenUtil;
@Autowired
private MpTokenUtil mpTokenUtil;
// 图片目录 // 图片目录
public static final String USER_IMAGES_DIR = SystemConfig.p.getProperty("userfiles.imgdir"); public static final String USER_IMAGES_DIR = SystemConfig.p.getProperty("userfiles.imgdir");
...@@ -53,6 +58,79 @@ public class QyMediaUtil { ...@@ -53,6 +58,79 @@ public class QyMediaUtil {
return res; return res;
} }
/**
* 下载媒体文件至磁盘(服务号)
*
* @param accountsId 微信账号
* @param moduleName 模块名称,可不填
* @param mediaId 媒体的Id
* @return 形成的文件名称
*/
public String downloadMpMediaToDisk(Long accountsId, String moduleName, String mediaId) {
String finalFileName = "";
MpAccountsEntity accountsEntity = mpTokenUtil.searchAccountsById(accountsId);
BufferedInputStream bis = null;
FileOutputStream fos = null;
HttpURLConnection conn = null;
String requestUrl = MpApiConstants.MEDIA_GET.replace("ACCESS_TOKEN", mpTokenUtil.getToken(accountsEntity))
.replace("MEDIA_ID", mediaId);
try {
URL url = new URL(requestUrl);
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setRequestMethod("GET");
//String fileExt = getFileEndWitsh(conn.getHeaderField("Content-Type"));
String fileExt = ".jpg";
String fileName = getRundomName(moduleName);
finalFileName = fileName + fileExt;
String dir = USER_IMAGES_DIR;
File ff = new File(dir);
if (!ff.exists()) {
ff.mkdir();
}
String realPath = dir + File.separator + finalFileName;
bis = new BufferedInputStream(conn.getInputStream());
fos = new FileOutputStream(new File(realPath));
byte[] buf = new byte[8096];
int size = 0;
while ((size = bis.read(buf)) != -1) {
fos.write(buf, 0, size);
}
fos.close();
bis.close();
conn.disconnect();
} catch (IOException e) {
log.error("下载媒体文件失败:{}", e.getMessage());
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
log.error("下载媒体文件失败 IOException:{}", e.getMessage());
}
}
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
log.error("下载媒体文件失败 IOException:{}", e.getMessage());
}
}
if (conn != null) {
conn.disconnect();
}
}
return finalFileName;
}
/** /**
* 下载媒体文件至磁盘 * 下载媒体文件至磁盘
* *
......
...@@ -10,5 +10,7 @@ public class MpApiConstants { ...@@ -10,5 +10,7 @@ public class MpApiConstants {
/* JSAPI_TICKET */ /* JSAPI_TICKET */
public static final String JSAPI_TICKET_GET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi"; public static final String JSAPI_TICKET_GET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi";
public static final String MEDIA_GET = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID";
} }
...@@ -127,6 +127,7 @@ public class QyTokenUtil { ...@@ -127,6 +127,7 @@ public class QyTokenUtil {
return token; return token;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
log.error("获取token失败" + e.getMessage());
} }
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment