瀏覽代碼

提交修改bug,增加提交,撤回等

qingyang_zhang 5 月之前
父節點
當前提交
00849bdaba

二進制
app/workSheetSystem/lib/shr_sso_client.jar


+ 19 - 0
app/workSheetSystem/pom.xml

@@ -16,6 +16,7 @@
     <description>workSheetSystem</description>
     <properties>
         <java.version>1.8</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>
     <dependencies>
 
@@ -192,6 +193,24 @@
             <!--jar包路径 注意:这里用的是  {pom.basedir}-->
             <systemPath>${pom.basedir}/lib/ksql.jar</systemPath>
         </dependency>
+        <dependency>
+            <groupId>com.kingdee.sso</groupId>   <!--自定义-->
+            <artifactId>sso-sdk</artifactId>  <!--自定义-->
+            <version>0.0.1-SNAPSHOT</version>  <!--自定义-->
+            <scope>system</scope>
+            <!--jar包路径 注意:这里用的是  {pom.basedir}-->
+            <systemPath>${pom.basedir}/lib/shr_sso_client.jar</systemPath>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>2.9.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.13</version> <!-- 请使用最新的版本号 -->
+        </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>javax.servlet-api</artifactId>

+ 22 - 2
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/controller/PersonWorkController.java

@@ -246,14 +246,34 @@ public class PersonWorkController {
             @ApiImplicitParam(name = "id", value = "报工id", required = true, paramType = "query", dataType = "String"),
     })
     public MessageResult submitWork(@RequestHeader("token") String token, String id) {
+        MessageResult result = MessageResult.success();
         String number = JWTUtil.getCacheNumber(token);
         if (StringUtils.isEmpty(number)) {
             return MessageResult.error("token异常");
         }
         int i = personWorkService.submitWork(number,id);
-        MessageResultV2 result=MessageResultV2.success();
+        if(i<1) {
+            result = MessageResult.fail("提交失败");
+        }
+        return result;
+    }
+    @ApiOperation(value = "撤销工作流", notes = "撤销工作流")
+    @RequestMapping(value = "/revocaWork", method = RequestMethod.GET)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
+            @ApiImplicitParam(name = "id", value = "报工id", required = true, paramType = "query", dataType = "String"),
+    })
+    public MessageResult revocaWork(@RequestHeader("token") String token, String id) {
+        MessageResult result = MessageResult.success();
+        String number = JWTUtil.getCacheNumber(token);
+        if (StringUtils.isEmpty(number)) {
+            return MessageResult.error("token异常");
+        }
+        int i = personWorkService.revocaWork(number,id);
+        if(i<1) {
+            result = MessageResult.fail("撤回失败");
+        }
         // result.setData(list);
         return result;
     }
-
 }

+ 34 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/controller/YunzhijiaController.java

@@ -1,5 +1,6 @@
 package com.qy.worksheetsystem.controller;
 
+import cn.hutool.core.util.StrUtil;
 import com.qy.worksheetsystem.model.MessageResult;
 import com.qy.worksheetsystem.model.MessageResultV2;
 import com.qy.worksheetsystem.service.YunzhijiaService;
@@ -9,6 +10,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
@@ -28,7 +30,39 @@ public class YunzhijiaController {
 
     @Autowired
     private YunzhijiaService yunzhijiaService;
+    @Value("${HR.ais.effective}")
+    private String effective;
+    @Value("${HR.ais.password}")
+    private String password;
+    @ApiOperation(value = "获取用户信息by密码", notes = "获取用户信息by密码")
+    @RequestMapping(value ="/getUserInfoByEncryptId",method = RequestMethod.GET)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "encryptId", value = "人员id", required = true, paramType = "header", dataType = "String"),
+    })
+    public MessageResult getUserInfoByEncryptId(@RequestHeader("encryptId") String encryptId) throws Exception {
+        String str = JWTUtil.decrypt(encryptId,password);
+        MessageResult messageResult = null;
+        if(StrUtil.isNotBlank(str)) {
+            String[] strs = str.split(",");
+            String id = strs[0];
+            String time = strs[1];
+
+            long nowTime = System.currentTimeMillis();
 
+            if ((nowTime - new Long(time)) > new Long(effective)) {
+                messageResult = MessageResult.fail("认证失败!");
+                return messageResult;
+            }
+            Map<String, Object> map = yunzhijiaService.getUserInfoById(id);
+            if (map.isEmpty()) {
+                messageResult = MessageResult.fail("认证失败!");
+            } else {
+                messageResult = MessageResult.success();
+                messageResult.setData(map);
+            }
+        }
+        return messageResult;
+    }
 
     @ApiOperation(value = "获取用户信息", notes = "获取用户信息")
     @RequestMapping(value ="/getUserInfoById",method = RequestMethod.GET)

+ 1 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/filter/CORSFilter.java

@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 //@Order(1)
+//cmd.exe /c "e: & cd /d E:\kdshr90\eas\openjdk\bin & java -jar e:\workSheet.jar"
 //重点
 //@WebFilter(filterName = "corsFilter", urlPatterns = {"/**"})
 public class CORSFilter implements Filter{

+ 3 - 0
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/service/PersonWorkService.java

@@ -27,4 +27,7 @@ public interface PersonWorkService {
 
     @Transactional
     int submitWork(String number, String id);
+
+    @Transactional
+    int revocaWork(String number, String id);
 }

+ 39 - 3
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/service/impl/PersonWorkServiceImpl.java

@@ -1,8 +1,12 @@
 package com.qy.worksheetsystem.service.impl;
 
 
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.kingdee.shr.api.OSFWSClient;
 import com.qy.worksheetsystem.model.entity.JobBooking;
 import com.qy.worksheetsystem.model.mapper.PersonWorkMapper;
 
@@ -13,6 +17,7 @@ import com.qy.worksheetsystem.util.SnowflakeUtils;
 import com.qy.worksheetsystem.vo.WorkHoursReport;
 import com.qy.worksheetsystem.vo.WorkHoursReportEntry;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -41,10 +46,14 @@ public class PersonWorkServiceImpl implements PersonWorkService {
     private PersonWorkMapper personWorkMapper;
     @Resource
     private PersonService personService;
-
     @Resource
     private ProjectMapper projectMapper;
 
+    @Value("${HR.ais.url}")
+    private String url;
+    @Value("${HR.ais.serviceName}")
+    private String serviceName;
+
     @Override
     @Transactional
     public Map<String,Object> insertWork(Map<String,Object> param){
@@ -167,8 +176,35 @@ public class PersonWorkServiceImpl implements PersonWorkService {
     @Override
     @Transactional
     public int submitWork(String number, String id){
-
+        OSFWSClient client = new OSFWSClient();
+        Map<String,Object> map = Maps.newHashMap();
+        map.put("billId",id);//  单据id
+        map.put("status","1");//  单据id
+        String str = client.proceedOSF(url,serviceName,map);
+        if(StrUtil.isNotBlank(str)){
+            JSONObject j = JSONUtil.parseObj(str);
+            String code = j.getStr("code");
+            if("200".equals(code)){
+                return 1;
+            }
+        }
+        return 0;
+    }
+    @Override
+    @Transactional
+    public int revocaWork(String number, String id){
+        OSFWSClient client = new OSFWSClient();
+        Map<String,Object> map = Maps.newHashMap();
+        map.put("billId",id);//  单据id
+        map.put("status","2");//  单据id
+        String str = client.proceedOSF(url,serviceName,map);
+        if(StrUtil.isNotBlank(str)){
+            JSONObject j = JSONUtil.parseObj(str);
+            String code = j.getStr("code");
+            if("200".equals(code)){
+                return 1;
+            }
+        }
         return 0;
     }
-
 }

+ 29 - 1
app/workSheetSystem/src/main/java/com/qy/worksheetsystem/util/JWTUtil.java

@@ -5,11 +5,17 @@ import com.auth0.jwt.JWTVerifier;
 import com.auth0.jwt.algorithms.Algorithm;
 import com.auth0.jwt.exceptions.JWTDecodeException;
 import com.auth0.jwt.interfaces.DecodedJWT;
+import org.springframework.beans.factory.annotation.Value;
 
 
-
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
 import java.io.UnsupportedEncodingException;
 
+import java.security.SecureRandom;
+import java.util.Base64;
 import java.util.Date;
 
 
@@ -19,12 +25,34 @@ import java.util.Date;
  * @description  JWT工具类
  */
 public class JWTUtil {
+
+    private static final String ALGORITHM = "AES";
+    private static final int KEY_SIZE = 128;
     // 过期时间 24 小时
     public static final long EXPIRE_TIME = 60 * 24 * 60 * 1000;
     private static final int EXPIRE_TIME_S = 60 * 24 * 60;
     // 密钥
     private static final String SECRET = "hty_202401203";
+    public static String encrypt(String data, String password) throws Exception {
+        SecretKey key = generateKey(password);
+        Cipher cipher = Cipher.getInstance(ALGORITHM);
+        cipher.init(Cipher.ENCRYPT_MODE, key);
+        byte[] encryptedData = cipher.doFinal(data.getBytes());
+        return Base64.getEncoder().encodeToString(encryptedData);
+    }
 
+    public static String decrypt(String encryptedData,String password) throws Exception {
+        SecretKey key = generateKey(password);
+        Cipher cipher = Cipher.getInstance(ALGORITHM);
+        cipher.init(Cipher.DECRYPT_MODE, key);
+        byte[] decryptedData = cipher.doFinal(Base64.getDecoder().decode(encryptedData));
+        return new String(decryptedData);
+    }
+    private static SecretKey generateKey(String password) throws Exception {
+        KeyGenerator keyGenerator = KeyGenerator.getInstance(ALGORITHM);
+        keyGenerator.init(KEY_SIZE, new SecureRandom(password.getBytes()));
+        return new SecretKeySpec(keyGenerator.generateKey().getEncoded(), ALGORITHM);
+    }
     /**
      * 生成 token
      */

+ 11 - 0
app/workSheetSystem/src/main/resources/application.yml

@@ -1,4 +1,9 @@
 spring:
+  http:
+    encoding:
+      charset: UTF-8
+      enabled: true
+      force: true
   #profiles:
   #    active: text
 
@@ -82,6 +87,12 @@ HR:
   AttendanceType: eBUAADAXEjxyrXZI
   #出差
   tripType: eBUAADAXEjtyrXZI
+  #密钥
+  ais:
+    password: htyshrtest
+    effective: 10000
+    url: https://10.3.119.205:80/shr
+    serviceName: workHoursReportService
 #企业微信
 weixin:
   corpsecret: