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

11111

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