Commit 6a2b08fd authored by 竹天卫's avatar 竹天卫

11111

parents c5a1308b 6a4acfae
...@@ -59,11 +59,11 @@ public class NonStandardApplyController { ...@@ -59,11 +59,11 @@ public class NonStandardApplyController {
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
@ApiOperation(value = "获取所有非标产值申请") @ApiOperation(value = "获取当前用户所有的非标产值申请")
@GetMapping("/getList") @GetMapping("/getList")
public BaseResponse getList() { public BaseResponse getList(Integer userId) {
try { try {
return iNonStandardApplyService.getList(); return iNonStandardApplyService.getList(userId);
} catch (Exception e) { } catch (Exception e) {
log.debug("获取所有的非标产值申请{}", e); log.debug("获取所有的非标产值申请{}", e);
} }
......
...@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.PutMapping; ...@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -225,16 +226,16 @@ public class NormProductionController { ...@@ -225,16 +226,16 @@ public class NormProductionController {
@GetMapping("/workload/statistics") @GetMapping("/workload/statistics")
@ApiOperation("工作量统计") @ApiOperation("工作量统计")
public BaseResponse<List<WorkloadStatisticsVo>> workloadStatistics(String start, String end) { public BaseResponse<List<WorkloadStatisticsVo>> workloadStatistics(String start, String end, Integer userId) {
Date startTime = null; Date startTime = null;
Date endTime = DateUtil.date(); Date endTime = DateUtil.date();
if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)){ if (StrUtil.isNotBlank(start) && StrUtil.isNotBlank(end)) {
startTime = DateUtil.parseDate(start); startTime = DateUtil.parseDate(start);
endTime = DateUtil.parseDate(end); endTime = DateUtil.parseDate(end);
} }
return BaseResponse.okData(iNormProductionService.workloadStatistics(startTime,endTime)); return BaseResponse.okData(iNormProductionService.workloadStatistics(startTime, endTime, userId));
} }
} }
......
...@@ -107,6 +107,7 @@ public class ReportController { ...@@ -107,6 +107,7 @@ public class ReportController {
//六元素导出 //六元素导出
List<SixElementReport> list = iEntrustService.getSampleSixElementCheck(entrustId); List<SixElementReport> list = iEntrustService.getSampleSixElementCheck(entrustId);
list.forEach(this::initMapStr2AlongPro); list.forEach(this::initMapStr2AlongPro);
List<SixElementReport> al2o3AndTio2List = list.stream() List<SixElementReport> al2o3AndTio2List = list.stream()
.filter(arg -> !"-".equals(arg.getAl2o3AndTio2())) .filter(arg -> !"-".equals(arg.getAl2o3AndTio2()))
...@@ -135,7 +136,7 @@ public class ReportController { ...@@ -135,7 +136,7 @@ public class ReportController {
*/ */
private void initMapStr2AlongPro(SixElementReport sixElement) { private void initMapStr2AlongPro(SixElementReport sixElement) {
String countResult = sixElement.getCountResult(); String countResult = sixElement.getCountResults();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class); HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
sixElement.setAl2o3("-"); sixElement.setAl2o3("-");
...@@ -159,7 +160,7 @@ public class ReportController { ...@@ -159,7 +160,7 @@ public class ReportController {
} }
private void initMapStr2AlongPro(IndustrialReport industrialReport){ private void initMapStr2AlongPro(IndustrialReport industrialReport){
String countResult = industrialReport.getCountResult(); String countResult = industrialReport.getCountResults();
HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class); HashMap<String, String> countResultMap = JSON.parseObject(countResult, HashMap.class);
industrialReport.setAad(countResultMap.getOrDefault(IndustrialElementKey.Aad.getKey(),"0")); industrialReport.setAad(countResultMap.getOrDefault(IndustrialElementKey.Aad.getKey(),"0"));
......
package cn.wise.sc.cement.business.controller; package cn.wise.sc.cement.business.controller;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.service.impl.WeiXinService; import cn.wise.sc.cement.business.service.impl.WeiXinService;
import cn.wise.sc.cement.business.wrapper.WrapMapper;
import cn.wise.sc.cement.business.wrapper.Wrapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -13,76 +13,116 @@ import org.springframework.web.bind.annotation.GetMapping; ...@@ -13,76 +13,116 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "微信接口") @Api(tags = "微信接口")
@RestController @RestController
@RequestMapping("/tcdri/weixin") @RequestMapping("/tcdri/weixin")
public class WeiXinController { public class WeiXinController {
private static final Logger log = LoggerFactory.getLogger("WeiXinController"); private static final Logger log = LoggerFactory.getLogger("WeiXinController");
@Autowired
private WeiXinService weiXinService;
@ApiOperation(value = "获取登录token-小程序端")
@GetMapping("/getToken")
public BaseResponse getToken(String code){
try {
return weiXinService.getToken(code,"APP");
}catch (Exception e){
log.debug("获取登录token{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取登录token-管理端")
@GetMapping("/getPCToken")
public BaseResponse getPCToken(String code){
try {
return weiXinService.getToken(code, "PC");
}catch (Exception e){
log.debug("获取登录token{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取accessToken信息-小程序端")
@GetMapping("/getAccessToken")
public BaseResponse getAccessToken(){
try {
String accessToken = weiXinService.getAccessToken();
return BaseResponse.okData(accessToken);
}catch (Exception e){
log.debug("获取accessToken信息-小程序端{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取accessToken信息-管理端")
@GetMapping("/getPCAccessToken")
public BaseResponse getPCAccessToken(){
try {
String accessToken = weiXinService.getPCAccessToken();
return BaseResponse.okData(accessToken);
}catch (Exception e){
log.debug("获取accessToken信息-管理端{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "当前登录用户")
@GetMapping("/getLoginUser")
public BaseResponse getLoginUser(){
try {
return weiXinService.getLoginUser();
}catch (Exception e){
log.debug("当前登录用户{}",e);
}
return BaseResponse.errorMsg("失败!");
}
@Autowired
private WeiXinService weiXinService;
@ApiOperation(value = "获取登录token-小程序端")
@GetMapping("/getToken")
public BaseResponse getToken(String code) {
log.debug("============================================");
log.debug("code: {}", code);
log.debug("=============================================");
try {
return weiXinService.getToken(code, "APP");
} catch (Exception e) {
log.debug("获取登录token{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "获取登录token-管理端")
@GetMapping("/getPCToken")
public BaseResponse getPCToken(String code) {
try {
return weiXinService.getToken(code, "PC");
} catch (Exception e) {
log.debug("获取登录token{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "当前登录用户")
@GetMapping("/getLoginUser")
public BaseResponse getLoginUser() {
try {
return weiXinService.getLoginUser();
} catch (Exception e) {
log.debug("当前登录用户{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@GetMapping("/jsapiTicket")
@ApiOperation("获取jsapi_ticket")
public BaseResponse<Map> getAccessToken() {
String accessToken = weiXinService.getJsapiTicket();
Map<String, String> rts = new HashMap<>(5);
rts.put("jsapi_ticket", accessToken);
rts.put("timestamp", (new Date()).getTime() / 1000 + "");
rts.put("noncestr", "Wm3WZYTPz0wzccnW");
rts.put("app_id", "ww348f91b2573c1867");
rts.put("jsApiList","['scanQRCode']");
return BaseResponse.okData(rts);
}
@GetMapping("/signature")
@ApiOperation("获取accessToken")
public BaseResponse<String> signature(String param) {
MessageDigest md;
String tmpStr = null;
try {
md = MessageDigest.getInstance("SHA-1");
byte[] digest = md.digest(param.getBytes());
tmpStr = byteToStr(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return BaseResponse.okData(StrUtil.swapCase(tmpStr));
}
/**
* 将字节数组转换为十六进制字符串
*
* @param byteArray
* @return
*/
private static String byteToStr(byte[] byteArray) {
String strDigest = "";
for (int i = 0; i < byteArray.length; i++) {
strDigest += byteToHexStr(byteArray[i]);
}
return strDigest;
}
/**
* 将字节转换为十六进制字符串
*
* @param mByte
* @return
*/
private static String byteToHexStr(byte mByte) {
char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
char[] tempArr = new char[2];
tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
tempArr[1] = Digit[mByte & 0X0F];
String s = new String(tempArr);
return s;
}
} }
...@@ -24,7 +24,7 @@ public interface NonStandardApplyMapper extends BaseMapper<NonStandardApply> { ...@@ -24,7 +24,7 @@ public interface NonStandardApplyMapper extends BaseMapper<NonStandardApply> {
List<NonStandardApplyVo> getById(@Param("params") Map<String, Object> params); List<NonStandardApplyVo> getById(@Param("params") Map<String, Object> params);
List<NonStandardApplyVo> getList(QueryWrapper<NonStandardApply> qw); List<NonStandardApplyVo> getList(@Param("params") Map<String, Object> params);
List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params); List<Map<String, Object>> exportList(@Param("params") Map<String, Object> params);
} }
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
select na.*,su.name as name,su.username as account select na.*,su.name as name,su.username as account
from nonstandard_apply na from nonstandard_apply na
LEFT JOIN sys_user su ON su.id = na.user_id LEFT JOIN sys_user su ON su.id = na.user_id
<include refid="where"/>
order by na.id asc order by na.id asc
</select> </select>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<select id="getSampleSixElementCheck" resultType="cn.wise.sc.cement.business.model.SixElementReport"> <select id="getSampleSixElementCheck" resultType="cn.wise.sc.cement.business.model.SixElementReport">
SELECT * FROM (SELECT count_result,entrust_id,team_group_name,sct.sample_id FROM sample_check sc SELECT * FROM (SELECT count_results,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
LEFT JOIN LEFT JOIN
(SELECT check_id,sample_id FROM sample_check_team) sct (SELECT check_id,sample_id FROM sample_check_team) sct
ON sct.check_id = sc.id ON sct.check_id = sc.id
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
(SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id (SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id
FROM sample) s FROM sample) s
ON s.id = sscct.sample_id AND entrust_id = #{entrustId} ON s.id = sscct.sample_id AND entrust_id = #{entrustId}
WHERE count_result IS NOT NULL; WHERE count_results IS NOT NULL;
</select> </select>
<select id="getSampleIndustrialCheck" resultType="cn.wise.sc.cement.business.model.IndustrialReport"> <select id="getSampleIndustrialCheck" resultType="cn.wise.sc.cement.business.model.IndustrialReport">
SELECT * FROM (SELECT count_result,entrust_id,team_group_name,sct.sample_id FROM sample_check sc SELECT * FROM (SELECT count_results,entrust_id,team_group_name,sct.sample_id FROM sample_check sc
LEFT JOIN LEFT JOIN
(SELECT check_id,sample_id FROM sample_check_team) sct (SELECT check_id,sample_id FROM sample_check_team) sct
ON sct.check_id = sc.id ON sct.check_id = sc.id
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
(SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id (SELECT cement_code,sample_code,sample_form,`name` as sample_name,weight,id
FROM sample) s FROM sample) s
ON s.id = sscct.sample_id AND entrust_id = #{entrustId} ON s.id = sscct.sample_id AND entrust_id = #{entrustId}
WHERE count_result IS NOT NULL; WHERE count_results IS NOT NULL;
</select> </select>
</mapper> </mapper>
...@@ -41,7 +41,7 @@ public class IndustrialReport implements Serializable { ...@@ -41,7 +41,7 @@ public class IndustrialReport implements Serializable {
/** /**
* 校核数据 * 校核数据
*/ */
private String countResult; private String countResults;
//下面是工业特性得检测项 //下面是工业特性得检测项
......
...@@ -42,7 +42,7 @@ public class SixElementReport implements Serializable { ...@@ -42,7 +42,7 @@ public class SixElementReport implements Serializable {
/** /**
* 校核数据 * 校核数据
*/ */
private String countResult; private String countResults;
//下面为六元素 //下面为六元素
......
...@@ -34,7 +34,7 @@ public interface INonStandardApplyService extends IService<NonStandardApply> { ...@@ -34,7 +34,7 @@ public interface INonStandardApplyService extends IService<NonStandardApply> {
* *
* @return List * @return List
*/ */
BaseResponse<List<NonStandardApplyVo>> getList(); BaseResponse<List<NonStandardApplyVo>> getList(Integer userId);
/** /**
* 通过id查询非标产值申请信息 * 通过id查询非标产值申请信息
......
...@@ -121,5 +121,5 @@ public interface INormProductionService extends IService<NormProduction> { ...@@ -121,5 +121,5 @@ public interface INormProductionService extends IService<NormProduction> {
* @param endTime 结束时间 * @param endTime 结束时间
* @return 统计对象 * @return 统计对象
*/ */
List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime); List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime,Integer userId);
} }
...@@ -476,7 +476,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -476,7 +476,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
String[] teamIdS = teamIds.split("、"); String[] teamIdS = teamIds.split("、");
for (String teamId : teamIdS) { for (String teamId : teamIdS) {
Team team = teamMapper.selectById(Integer.valueOf(teamId)); Team team = teamMapper.selectById(Integer.valueOf(teamId));
if (team != null && "1".equals(team.getQualifications())) { if (team != null && 1 == team.getQualifications()) {
team.getName(); team.getName();
teamName = teamName.equals("") ? team.getName() : (teamName + "、" + team.getName()); teamName = teamName.equals("") ? team.getName() : (teamName + "、" + team.getName());
} }
...@@ -2277,7 +2277,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl ...@@ -2277,7 +2277,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
for (String idStr : teamSplit) { for (String idStr : teamSplit) {
int id = Integer.parseInt(idStr); int id = Integer.parseInt(idStr);
teams.forEach(opt -> { teams.forEach(opt -> {
if (opt.getId() == id && "1".equals(opt.getQualifications())) { if (opt.getId() == id && 1 == opt.getQualifications()) {
if (StrUtil.isBlank(arg.getTeamName())) { if (StrUtil.isBlank(arg.getTeamName())) {
arg.setTeamName(opt.getName()); arg.setTeamName(opt.getName());
} else { } else {
......
...@@ -52,10 +52,10 @@ public class NonStandardApplyServiceImpl extends ServiceImpl<NonStandardApplyMap ...@@ -52,10 +52,10 @@ public class NonStandardApplyServiceImpl extends ServiceImpl<NonStandardApplyMap
} }
@Override @Override
public BaseResponse<List<NonStandardApplyVo>> getList() { public BaseResponse<List<NonStandardApplyVo>> getList(Integer userId) {
QueryWrapper<NonStandardApply> qw = new QueryWrapper<>(); Map<String, Object> params = new HashMap<>();
qw.ge("status",0); params.put("userId",userId);
List<NonStandardApplyVo> list = nonStandardApplyMapper.getList(qw); List<NonStandardApplyVo> list = nonStandardApplyMapper.getList(params);
return BaseResponse.okData(list); return BaseResponse.okData(list);
} }
......
...@@ -592,7 +592,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, ...@@ -592,7 +592,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
} }
@Override @Override
public List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime) { public List<WorkloadStatisticsVo> workloadStatistics(Date startTime, Date endTime, Integer userId) {
long start = getDefaultStart(startTime == null ? 0 : startTime.getTime()); long start = getDefaultStart(startTime == null ? 0 : startTime.getTime());
long end = getDefaultEnd(endTime.getTime()); long end = getDefaultEnd(endTime.getTime());
...@@ -601,18 +601,23 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper, ...@@ -601,18 +601,23 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
QueryWrapper<SampleDistribution> qw = new QueryWrapper<>(); QueryWrapper<SampleDistribution> qw = new QueryWrapper<>();
if (startTime != null) { if (startTime != null) {
qw.ge("finish_time", DateUtil.format(DateUtil.date(start),"yyyy-MM-dd")); qw.ge("finish_time", DateUtil.format(DateUtil.date(start), "yyyy-MM-dd"));
} }
qw.le("finish_time", DateUtil.format(DateUtil.date(end),"yyyy-MM-dd")); if (userId != null && userId != 0) {
qw.eq("user_id", userId);
}
qw.le("finish_time", DateUtil.format(DateUtil.date(end), "yyyy-MM-dd"));
qw.eq("status", 2); qw.eq("status", 2);
List<SampleDistribution> sampleDistributions = iSampleDistributionService.list(qw); List<SampleDistribution> sampleDistributions = iSampleDistributionService.list(qw);
//脾气比能力大 蠢货
QueryWrapper<NonStandardApply> qwA = new QueryWrapper<>(); QueryWrapper<NonStandardApply> qwA = new QueryWrapper<>();
if (startTime != null) { if (startTime != null) {
qwA.ge("start_time", DateUtil.format(DateUtil.date(start),"yyyy-MM-dd")); qwA.ge("start_time", DateUtil.format(DateUtil.date(start), "yyyy-MM-dd"));
}
if (userId != null && userId != 0) {
qwA.eq("user_id", userId);
} }
qwA.le("start_time", DateUtil.format(DateUtil.date(end),"yyyy-MM-dd")); qwA.le("start_time", DateUtil.format(DateUtil.date(end), "yyyy-MM-dd"));
qwA.eq("status", 2); qwA.eq("status", 2);
List<NonStandardApply> nonStandardApplies = iNonStandardApplyService.list(qwA); List<NonStandardApply> nonStandardApplies = iNonStandardApplyService.list(qwA);
......
...@@ -77,7 +77,6 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua ...@@ -77,7 +77,6 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
List<QualityApply> list = this.list(qw); List<QualityApply> list = this.list(qw);
//找到所有项目id归类 //找到所有项目id归类
Set<Integer> projectIds = list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet()); Set<Integer> projectIds = list.stream().map(QualityApply::getProjectId).collect(Collectors.toSet());
String[] headers = null;
List<Object[]> datas = new ArrayList<>(); List<Object[]> datas = new ArrayList<>();
//关联部门名字 //关联部门名字
Set<Integer> userIds = list.stream() Set<Integer> userIds = list.stream()
...@@ -124,8 +123,8 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua ...@@ -124,8 +123,8 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
&& arg.getProjectId().intValue() == projectId) && arg.getProjectId().intValue() == projectId)
.collect(Collectors.toList()); .collect(Collectors.toList());
//以样品归类 //以样品归类
Set<Integer> sampleIds = samples.stream().map(QualityApply::getTeamGroupId) // Set<Integer> sampleIds = samples.stream().map(QualityApply::getTeamGroupId)
.collect(Collectors.toSet()); // .collect(Collectors.toSet());
//写每个样品的表头 //写每个样品的表头
list.stream() list.stream()
...@@ -181,7 +180,7 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua ...@@ -181,7 +180,7 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
} }
} }
ExcelUtil.excelExport("qualityApply", headers, datas, response); ExcelUtil.excelExport("qualityApply", null, datas, response);
} }
} }
...@@ -25,30 +25,34 @@ import java.util.Map; ...@@ -25,30 +25,34 @@ import java.util.Map;
@Service @Service
public class WeiXinService { public class WeiXinService {
@Value("${weixin.corpid}") @Value("${weixin.corpid}")
private String corpid; private String corpid;
@Value("${weixin.corpsecret}") @Value("${weixin.corpsecret}")
private String corpsecret; private String corpsecret;
@Value("${weixin.corpsecretPC}") @Value("${weixin.corpsecretPC}")
private String corpsecretPC; private String corpsecretPC;
@Autowired @Autowired
private ISysUserService userService; private ISysUserService userService;
@Autowired @Autowired
RedisUtil redisUtil; RedisUtil redisUtil;
/** final static String ACCESS_TOKEN = "ACCESS_TOKEN";
* 获取登录token final static String JSAPITICKET = "JSAPITICKET";
* @param code
* @param type PC管理端 APP小程序端 /**
* @return * 获取登录token
*/ *
public BaseResponse<String> getToken(String code,String type) { * @param code
if (StrUtil.isEmpty(code)) { * @param type PC管理端 APP小程序端
return BaseResponse.errorMsg("code为必填项!"); * @return
} */
System.out.println("==================code==================="); public BaseResponse<String> getToken(String code, String type) {
System.out.println(code); if (StrUtil.isEmpty(code)) {
try { return BaseResponse.errorMsg("code为必填项!");
}
System.out.println("==================code===================");
System.out.println(code);
try {
/*String accessToken = null; /*String accessToken = null;
if(type.equals("PC")){ if(type.equals("PC")){
accessToken = getAccessToken(); accessToken = getAccessToken();
...@@ -67,114 +71,114 @@ public class WeiXinService { ...@@ -67,114 +71,114 @@ public class WeiXinService {
System.out.println("==================UserId==================="); System.out.println("==================UserId===================");
System.out.println(UserId); System.out.println(UserId);
JSONObject userJson = getUser(accessToken, UserId);*/ JSONObject userJson = getUser(accessToken, UserId);*/
QueryWrapper<SysUser> wrapper = new QueryWrapper<>(); QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
// wrapper.eq("phone", userJson.get("mobile")); // wrapper.eq("phone", userJson.get("mobile"));
wrapper.eq("phone", code); //暂时用手机号代替code wrapper.eq("phone", code); //暂时用手机号代替code
SysUser sysUser = userService.getOne(wrapper); SysUser sysUser = userService.getOne(wrapper);
if(sysUser == null){ if (sysUser == null) {
return BaseResponse.errorMsg("非系统用户不允许登录!"); return BaseResponse.errorMsg("非系统用户不允许登录!");
} }
if(sysUser.getStatus()==0){ if (sysUser.getStatus() == 0) {
return BaseResponse.errorMsg("用户被禁用!"); return BaseResponse.errorMsg("用户被禁用!");
} }
if(sysUser.getIsDelete()==0){ if (sysUser.getIsDelete() == 0) {
return BaseResponse.errorMsg("用户被删除!"); return BaseResponse.errorMsg("用户被删除!");
} }
//生成token,存入redis //生成token,存入redis
String token = JwtUtil.createToken(sysUser.getId(), sysUser.getUsername(), String token = JwtUtil.createToken(sysUser.getId(), sysUser.getUsername(),
sysUser.getName(), sysUser.getPhone()); sysUser.getName(), sysUser.getPhone());
System.out.println(token); System.out.println(token);
redisUtil.setString(sysUser.getId().toString(),token,3600); redisUtil.setString(sysUser.getId().toString(), token, 3600);
return BaseResponse.okData(token); return BaseResponse.okData(token);
} catch (Exception e) { } catch (Exception e) {
return BaseResponse.errorMsg(e.getMessage()); return BaseResponse.errorMsg(e.getMessage());
} }
} }
//获取accessToken信息 //获取accessToken信息
public String getAccessToken() { public String getAccessToken() {
try { try {
String param = "corpid=%s&corpsecret=%s"; String param = "corpid=%s&corpsecret=%s";
param = String.format(param, corpid, corpsecret); param = String.format(param, corpid, corpsecret);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param); JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
String accessToken = jsonObject.getString("access_token"); String accessToken = jsonObject.getString("access_token");
System.out.println("==================accessToken==================="); System.out.println("==================accessToken===================");
System.out.println(accessToken); System.out.println(accessToken);
return accessToken; return accessToken;
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
} }
public String getPCAccessToken() { //获取accessToken信息
try { public String getJsapiTicket() {
String param = "corpid=%s&corpsecret=%s"; try {
param = String.format(param, corpid, corpsecretPC); String accessToken;
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param); String jsapiTicket;
String accessToken = jsonObject.getString("access_token"); if (!redisUtil.existsKey(ACCESS_TOKEN)) {
System.out.println("==================accessToken==================="); String param = "corpid=%s&corpsecret=%s";
System.out.println(accessToken); param = String.format(param, corpid, corpsecret);
return accessToken; JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
} catch (Exception e) { accessToken = jsonObject.getString("access_token");
return null; redisUtil.setString(ACCESS_TOKEN, accessToken, 7200);
} }
} accessToken = redisUtil.getString(ACCESS_TOKEN) + "";
System.out.println("==================accessToken===================");
System.out.println(accessToken);
//获取用户信息 if (!redisUtil.existsKey(JSAPITICKET)) {
public JSONObject getUser(String accessToken, String userId) { String param3 = "access_token=%s&type=agent_config";
try { param3 = String.format(param3, accessToken);
String param = "access_token=%s&userid=%s"; JSONObject ticketJsonObject = WeixinInterfaceUtil.doGet(Global.userTicket, param3);
param = String.format(param, accessToken, userId); jsapiTicket = ticketJsonObject.getString("ticket");
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERURL, param); redisUtil.setString(JSAPITICKET, jsapiTicket, 7200);
System.out.println("==================jsonObject==================="); }
System.out.println(jsonObject);
return jsonObject; jsapiTicket = redisUtil.getString(JSAPITICKET) + "";
} catch (Exception e) { return jsapiTicket;
return null; } catch (Exception e) {
} return null;
} }
}
/**
* 当前登录用户 public String getPCAccessToken() {
* @return try {
*/ String param = "corpid=%s&corpsecret=%s";
public BaseResponse<LoginUser> getLoginUser() { param = String.format(param, corpid, corpsecretPC);
LoginUser loginUser = userService.getLoginUser(); JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.ACCESSTOKENURL, param);
return BaseResponse.okData(loginUser); String accessToken = jsonObject.getString("access_token");
} System.out.println("==================accessToken===================");
System.out.println(accessToken);
/** return accessToken;
* 消息发送 } catch (Exception e) {
*/ return null;
public void sendMessage(){ }
WeixinInterfaceUtil.sendPostRequest(null, null); }
}
//获取用户信息
public JSONObject getUser(String accessToken, String userId) {
try {
String param = "access_token=%s&userid=%s";
param = String.format(param, accessToken, userId);
JSONObject jsonObject = WeixinInterfaceUtil.doGet(Global.USERURL, param);
System.out.println("==================jsonObject===================");
System.out.println(jsonObject);
return jsonObject;
} catch (Exception e) {
return null;
}
}
/**
* 当前登录用户
*
* @return
*/
public BaseResponse<LoginUser> getLoginUser() {
LoginUser loginUser = userService.getLoginUser();
return BaseResponse.okData(loginUser);
}
} }
package cn.wise.sc.cement.business.util.dfs; package cn.wise.sc.cement.business.util.dfs;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.csource.common.MyException; import org.csource.common.MyException;
import org.csource.common.NameValuePair; import org.csource.common.NameValuePair;
import org.csource.fastdfs.*; import org.csource.fastdfs.*;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
......
...@@ -30,6 +30,7 @@ public interface Global { ...@@ -30,6 +30,7 @@ public interface Global {
*/ */
public static final String USERURL = "https://qyapi.weixin.qq.com/cgi-bin/user/get"; public static final String USERURL = "https://qyapi.weixin.qq.com/cgi-bin/user/get";
public static final String ticket = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket";
/** /**
* 微信公众平台,发送应用消息的接口地址,Https请求方式:GET * 微信公众平台,发送应用消息的接口地址,Https请求方式:GET
* 接口地址示例:https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN * 接口地址示例:https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN
...@@ -37,6 +38,7 @@ public interface Global { ...@@ -37,6 +38,7 @@ public interface Global {
public static final String SENDMESSAGE = "https://qyapi.weixin.qq.com/cgi-bin/message/send"; public static final String SENDMESSAGE = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
public static final String userTicket = "https://qyapi.weixin.qq.com/cgi-bin/ticket/get";
} }
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