5 changed files with 130 additions and 423 deletions
@ -1,387 +0,0 @@ |
|||||
package com.dreamchaser.depository_manage; |
|
||||
|
|
||||
import com.alibaba.fastjson.JSONObject; |
|
||||
import com.dreamchaser.depository_manage.config.PublicConfig; |
|
||||
import com.dreamchaser.depository_manage.config.QyWxConfig; |
|
||||
import com.dreamchaser.depository_manage.entity.Depository; |
|
||||
import com.dreamchaser.depository_manage.entity.MaterialType; |
|
||||
import com.dreamchaser.depository_manage.entity.UserByPort; |
|
||||
import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP; |
|
||||
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details; |
|
||||
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver; |
|
||||
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_SpRecord; |
|
||||
import com.dreamchaser.depository_manage.pojo.callBackXml.callBackXml_button_templatecard.TemplateCard; |
|
||||
import com.dreamchaser.depository_manage.security.pool.HandlesOtherFunctionalThreadPool; |
|
||||
import com.dreamchaser.depository_manage.security.pool.RedisPool; |
|
||||
import com.dreamchaser.depository_manage.mapper.DepositoryMapper; |
|
||||
import com.dreamchaser.depository_manage.service.*; |
|
||||
import com.dreamchaser.depository_manage.service.impl.QyWxOperationService; |
|
||||
import com.dreamchaser.depository_manage.utils.*; |
|
||||
import javafx.scene.control.TableRow; |
|
||||
import org.apache.commons.collections4.CollectionUtils; |
|
||||
import org.apache.poi.ss.formula.functions.T; |
|
||||
import org.junit.Test; |
|
||||
import org.junit.runner.RunWith; |
|
||||
import org.redisson.api.RLock; |
|
||||
import org.redisson.api.RedissonClient; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.boot.test.context.SpringBootTest; |
|
||||
import org.springframework.cglib.beans.BeanMap; |
|
||||
import org.springframework.test.context.junit4.SpringRunner; |
|
||||
|
|
||||
import java.lang.reflect.Field; |
|
||||
import java.util.*; |
|
||||
import java.util.concurrent.ExecutorService; |
|
||||
import java.util.concurrent.LinkedBlockingQueue; |
|
||||
import java.util.concurrent.ThreadPoolExecutor; |
|
||||
import java.util.concurrent.TimeUnit; |
|
||||
import java.util.stream.Collectors; |
|
||||
|
|
||||
@SpringBootTest |
|
||||
@RunWith(SpringRunner.class) |
|
||||
public class OtherTest { |
|
||||
|
|
||||
@Autowired |
|
||||
DepositoryRecordService depositoryRecordService; |
|
||||
|
|
||||
@Autowired |
|
||||
StockTakingService stockTakingService; |
|
||||
|
|
||||
@Autowired |
|
||||
DepositoryMapper depositoryMapper; |
|
||||
|
|
||||
@Autowired |
|
||||
DepositoryService depositoryService; |
|
||||
|
|
||||
@Autowired |
|
||||
QyWxOperationService qyWxOperationService; |
|
||||
|
|
||||
@Autowired |
|
||||
MaterialTypeService materialTypeService; |
|
||||
|
|
||||
@Autowired |
|
||||
RedisPool redisPool; |
|
||||
|
|
||||
public static Map<String, String> objectToMap(Object object) { |
|
||||
Map<String, String> dataMap = new HashMap<>(); |
|
||||
Class<?> clazz = object.getClass(); |
|
||||
for (Field field : clazz.getDeclaredFields()) { |
|
||||
try { |
|
||||
field.setAccessible(true); |
|
||||
Object o = field.get(object); |
|
||||
if (o != null) { |
|
||||
|
|
||||
dataMap.put(field.getName(), o.toString()); |
|
||||
} else { |
|
||||
dataMap.put(field.getName(), ""); |
|
||||
|
|
||||
} |
|
||||
} catch (IllegalAccessException e) { |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
} |
|
||||
return dataMap; |
|
||||
} |
|
||||
|
|
||||
public UserByPort getLoginUserInformation(String userKey) { |
|
||||
// 拼接存储key
|
|
||||
String userLoginkey = PublicConfig.LoginRedisPrefix + userKey; |
|
||||
// 获取当前登录用户的工号
|
|
||||
String usernumber = (String) redisPool.getRedisTemplateByDb(5).opsForHash().get(userLoginkey, "usernumber"); |
|
||||
String userInfoKey = PublicConfig.userInfoRedisPrefix + usernumber; |
|
||||
// 获取当前存储的所有key值
|
|
||||
Iterator<Object> iterator = redisPool.getRedisTemplateByDb(5).opsForHash().keys(userInfoKey).iterator(); |
|
||||
// 定义map
|
|
||||
Map<String, Object> map = new HashMap<>(); |
|
||||
// 遍历获取存储的redis中的值
|
|
||||
while (iterator.hasNext()) { |
|
||||
Object next = iterator.next(); |
|
||||
Object o = redisPool.getRedisTemplateByDb(5).opsForHash().get(userInfoKey, next); |
|
||||
map.put((String) next, o); |
|
||||
} |
|
||||
return JSONObject.parseObject(JSONObject.toJSONString(map), UserByPort.class); |
|
||||
} |
|
||||
|
|
||||
Depository findParentDepository(Depository depository, List<Depository> depositoryList) { |
|
||||
for (Depository d : depositoryList |
|
||||
) { |
|
||||
if (Integer.compare(depository.getParentId(), d.getId()) == 0) { |
|
||||
if (Integer.compare(0, d.getParentId()) == 0) { |
|
||||
return d; |
|
||||
} else { |
|
||||
return findParentDepository(d, depositoryList); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
@Test |
|
||||
public void someTest(){ |
|
||||
Map<String,Object> map = new HashMap<>(); |
|
||||
map.put("a",""); |
|
||||
Object a = map.get("a"); |
|
||||
if(a == null || "".equals(a)){ |
|
||||
System.out.println("a1"); |
|
||||
}else{ |
|
||||
System.out.println(ObjectFormatUtil.toInteger(a)); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
public void main() { |
|
||||
ExecutorService exs = new ThreadPoolExecutor(10, 100, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(10),new ThreadPoolExecutor.DiscardPolicy()); |
|
||||
for (int i = 0; i < 20; i++) { |
|
||||
int finalI = i; |
|
||||
exs.submit(()->{ |
|
||||
Random random = new Random(); |
|
||||
int threadSize = random.nextInt(9999); |
|
||||
try { |
|
||||
Thread.sleep(threadSize); |
|
||||
} catch (InterruptedException e) { |
|
||||
e.printStackTrace(); |
|
||||
} |
|
||||
System.out.println("开始执行第"+ finalI +"个任务"); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
for (int i = 0; i < 1000; i++) { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
ThreadPoolExecutor threadPool = (ThreadPoolExecutor) exs; |
|
||||
|
|
||||
exs.shutdown(); // 禁止提交新任务
|
|
||||
// 设定最大重试次数
|
|
||||
try { |
|
||||
// 等待 60 s
|
|
||||
if (!exs.awaitTermination(60, TimeUnit.SECONDS)) { |
|
||||
// 调用 shutdownNow 取消正在执行的任务
|
|
||||
exs.shutdownNow(); |
|
||||
// 再次等待 60 s,如果还未结束,可以再次尝试,或者直接放弃
|
|
||||
if (!exs.awaitTermination(60, TimeUnit.SECONDS)) |
|
||||
System.err.println("线程池任务未正常执行结束"); |
|
||||
} |
|
||||
} catch (InterruptedException ie) { |
|
||||
// 重新调用 shutdownNow
|
|
||||
exs.shutdownNow(); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
exs.submit(()->{ |
|
||||
System.out.println("全部结束后提交新任务"); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
@Test |
|
||||
public void StockTakingTest() { |
|
||||
ApprovalInfo_Details approvalInfo_details = new ApprovalInfo_Details(); |
|
||||
ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver(); |
|
||||
approver.setUserId("PangFuZhen"); |
|
||||
approvalInfo_details.setApprover(approver); |
|
||||
|
|
||||
|
|
||||
// 用于处理盘点记录
|
|
||||
TemplateCard templateCard = new TemplateCard(); |
|
||||
templateCard.setFromUserName("PangFuZhen"); |
|
||||
templateCard.setEventKey("wms_completepass_StockTakingId4"); |
|
||||
stockTakingService.completeStockTakingByQyWx(templateCard, "e3bfa398fe9d0e1ab78a00ff59eff788"); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
@Test |
|
||||
public void ApplicationInTest() { |
|
||||
ApprovalInfo_Details approvalInfo_details = new ApprovalInfo_Details(); |
|
||||
ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver(); |
|
||||
approver.setUserId("PangFuZhen"); |
|
||||
approvalInfo_details.setApprover(approver); |
|
||||
depositoryRecordService.reviewByQyWxApprovalIn("[142, 143]", approvalInfo_details, "d35f243c9791341c148f7826994829ec", "2", "202305050015"); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
@Test |
|
||||
public void ApplicationOutTest() { |
|
||||
ApprovalInfo_Details approvalInfo_details = new ApprovalInfo_Details(); |
|
||||
ApprovalInfo_Details_Approver approver = new ApprovalInfo_Details_Approver(); |
|
||||
approver.setUserId("PangFuZhen"); |
|
||||
approvalInfo_details.setApprover(approver); |
|
||||
depositoryRecordService.reviewByQyWxApprovalOut("107", approvalInfo_details, "d35f243c9791341c148f7826994829ec", "2", "", true, 2); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
@Test |
|
||||
public void Test(){ |
|
||||
// 定义当前流程审批时间
|
|
||||
String as_SpTime = ""; |
|
||||
// 定义当前审批流程是是否要通过仓储中心
|
|
||||
boolean flagForFirst = true; // 默认通过
|
|
||||
|
|
||||
// 设置当前审批是否为仓库管理员(1为部门负责人,2为仓储中心,3为仓库管理员)
|
|
||||
int flagForDepository = 1; // 默认为部门负责人
|
|
||||
|
|
||||
// 定义已完成审批的节点数
|
|
||||
int approval_count = 0; |
|
||||
|
|
||||
// 获取审批流程信息
|
|
||||
ApprovalInfo_SpRecord as = null; |
|
||||
// 获取审批节点详情
|
|
||||
ApprovalInfo_Details approvalInfo_details = null; |
|
||||
|
|
||||
// 获取审批申请状态变化类型:1-提单;2-同意;3-驳回;4-转审;5-催办;6-撤销;8-通过后撤销;10-添加备注
|
|
||||
String spStatus = "2"; |
|
||||
List<ApprovalInfo_SpRecord> spRecord_list = new ArrayList<>(); |
|
||||
ApprovalInfo_SpRecord approvalInfo_spRecordd = new ApprovalInfo_SpRecord(); |
|
||||
List<ApprovalInfo_Details> detailsList = new ArrayList<>(); |
|
||||
ApprovalInfo_Details ads = new ApprovalInfo_Details(); |
|
||||
ads.setSpTime("1685318533000"); |
|
||||
ads.setSpStatus("2"); |
|
||||
detailsList.add(ads); |
|
||||
approvalInfo_spRecordd.setDetails(detailsList); |
|
||||
spRecord_list.add(approvalInfo_spRecordd); |
|
||||
spRecord_list.add(approvalInfo_spRecordd); |
|
||||
|
|
||||
for (ApprovalInfo_SpRecord approvalInfo_SpRecord : spRecord_list) { |
|
||||
|
|
||||
// 获取当前审批节点详情。当节点为标签或上级时,一个节点可能有多个分支
|
|
||||
List<ApprovalInfo_Details> details = approvalInfo_SpRecord.getDetails(); |
|
||||
|
|
||||
// 定义审批操作时间
|
|
||||
String spTime = ""; |
|
||||
// 定义审批操作状态
|
|
||||
String ad_SpStatus = ""; |
|
||||
// 定义审批详情
|
|
||||
ApprovalInfo_Details ap_detail = null; |
|
||||
|
|
||||
for (ApprovalInfo_Details ad : details) { |
|
||||
|
|
||||
// 获取节点分支审批人审批操作时间,0为尚未操作
|
|
||||
spTime = ad.getSpTime(); |
|
||||
|
|
||||
// 如果当前审批节点已经处理
|
|
||||
if (!("0".equals(spTime))) { |
|
||||
|
|
||||
// 设置当前处理的详情
|
|
||||
ap_detail = ad; |
|
||||
// 设置当前审批的状态
|
|
||||
ad_SpStatus = ad.getSpStatus(); |
|
||||
// 已审批节点数+1
|
|
||||
approval_count++; |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
if (!"0".equals(spTime)) { |
|
||||
// 如果已经操作
|
|
||||
|
|
||||
// 盘点当前审批状态是否为回调时操作状态
|
|
||||
if (ad_SpStatus.equals(spStatus)) { |
|
||||
// 将当前审批进行暂存
|
|
||||
if (as == null) { |
|
||||
// 如果是当前并没有获取到审批节点
|
|
||||
as = approvalInfo_SpRecord; |
|
||||
as_SpTime = spTime; |
|
||||
approvalInfo_details = ap_detail; |
|
||||
} else { |
|
||||
// 如果已经获取到审批节点
|
|
||||
|
|
||||
// 获取当前审批节点处理时间
|
|
||||
long aLong = Long.parseLong(spTime); |
|
||||
|
|
||||
// 获取之前节点的审批时间
|
|
||||
long aLong1 = Long.parseLong(as_SpTime); |
|
||||
|
|
||||
if (aLong >= aLong1) { |
|
||||
// 如果当前审批节点是最近处理
|
|
||||
|
|
||||
// 更新当前审批节点
|
|
||||
as = approvalInfo_SpRecord; |
|
||||
as_SpTime = spTime; |
|
||||
approvalInfo_details = ap_detail; |
|
||||
flagForFirst = false; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if("2".equals(spStatus)){ |
|
||||
ApprovalInfo_SpRecord approvalInfo_spRecord = null; |
|
||||
if(spRecord_list.size() > 1){ |
|
||||
approvalInfo_spRecord = spRecord_list.get(1); |
|
||||
} |
|
||||
if (approvalInfo_spRecord != null) { |
|
||||
// 获取第二个节点中审批人信息
|
|
||||
List<ApprovalInfo_Details> details = approvalInfo_spRecord.getDetails(); |
|
||||
// 获取仓储中心负责人标签下的成员
|
|
||||
List<String> qyWxLabelUserList = QyWxConfig.getQyWxLabelUserList("01ef3eace6cd7d384581bb058c60f48b"); |
|
||||
// 定义当前是否为标签
|
|
||||
boolean flagForLabel = true; // 默认为标签
|
|
||||
|
|
||||
if (details.size() != qyWxLabelUserList.size()) { |
|
||||
// 如果节点数目不等于标签人员数
|
|
||||
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(107); |
|
||||
|
|
||||
if (Integer.compare(applicationOutRecordPById.getFlagForOpenDepository(), 2) == 0) { |
|
||||
// 如果是申请的开放仓库
|
|
||||
|
|
||||
// 获取当时发送审批时其他部门负责人Id
|
|
||||
String otherDepartmentIdList = (String) redisPool.getRedisTemplateByDb(14).opsForHash().get("wms_QyWxMessage_" + "spNo", "otherDepartmentIdList"); |
|
||||
if (otherDepartmentIdList != null) { |
|
||||
for (ApprovalInfo_Details ad : details |
|
||||
) { |
|
||||
// 获取当前节点审批人userId
|
|
||||
String approver = ad.getApprover().getUserId(); |
|
||||
flagForLabel = flagForLabel && otherDepartmentIdList.contains(approver); |
|
||||
} |
|
||||
} |
|
||||
} else { |
|
||||
flagForLabel = false; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
else { |
|
||||
for (ApprovalInfo_Details ad : details |
|
||||
) { |
|
||||
// 获取当前节点审批人userId
|
|
||||
String approver = ad.getApprover().getUserId(); |
|
||||
flagForLabel = flagForLabel && qyWxLabelUserList.contains(approver); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (!flagForLabel) { |
|
||||
// 如果第二个节点不是标签节点
|
|
||||
if (approval_count > 1) { |
|
||||
// 如果完成审批的节点数大于1
|
|
||||
flagForDepository = 3; |
|
||||
|
|
||||
// 如果已经完成该审批记录,则进行删除
|
|
||||
redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + "spNo"); |
|
||||
} else { |
|
||||
// 如果当前是第一个节点
|
|
||||
flagForFirst = false; |
|
||||
} |
|
||||
|
|
||||
} else { |
|
||||
// 如果第二个节点是标签节点
|
|
||||
if (approval_count > 2) { |
|
||||
// 如果完成审批的节点数大于2
|
|
||||
flagForDepository = 3; |
|
||||
// 如果已经完成该审批记录,则进行删除
|
|
||||
redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + "spNo"); |
|
||||
} else { |
|
||||
// 如果当前并不是标签节点后
|
|
||||
flagForDepository = 2; |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
System.out.println(flagForFirst); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,102 @@ |
|||||
|
package com.dreamchaser.depository_manage; |
||||
|
|
||||
|
import com.dreamchaser.depository_manage.config.QyWxConfig; |
||||
|
import com.dreamchaser.depository_manage.pojo.ApplicationOutRecordP; |
||||
|
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details; |
||||
|
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_Details_Approver; |
||||
|
import com.dreamchaser.depository_manage.pojo.callBackXml.approvalCallBackXml.ApprovalInfo_SpRecord; |
||||
|
import com.dreamchaser.depository_manage.security.pool.RedisPool; |
||||
|
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
||||
|
import org.junit.Test; |
||||
|
import org.junit.runner.RunWith; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) |
||||
|
@RunWith(SpringRunner.class) |
||||
|
public class SomeTest { |
||||
|
|
||||
|
@Autowired |
||||
|
DepositoryRecordService depositoryRecordService; |
||||
|
|
||||
|
@Autowired |
||||
|
RedisPool redisPool; |
||||
|
|
||||
|
@Test |
||||
|
public void someTest() { |
||||
|
ApprovalInfo_SpRecord approvalInfo_spRecord = new ApprovalInfo_SpRecord(); |
||||
|
List<ApprovalInfo_Details> details1 = new ArrayList<>(); |
||||
|
ApprovalInfo_Details ad1 = new ApprovalInfo_Details(); |
||||
|
ad1.setSpStatus("2"); |
||||
|
ApprovalInfo_Details_Approver approver1 = new ApprovalInfo_Details_Approver(); |
||||
|
approver1.setUserId("XinPing"); |
||||
|
ad1.setApprover(approver1); |
||||
|
String spNo = "202305310014"; |
||||
|
int approval_count = 2; |
||||
|
int flagForDepository = 1; |
||||
|
boolean flagForFirst = true; |
||||
|
details1.add(ad1); |
||||
|
approvalInfo_spRecord.setDetails(details1); |
||||
|
if (approvalInfo_spRecord != null) { |
||||
|
// 获取第二个节点中审批人信息
|
||||
|
List<ApprovalInfo_Details> details = approvalInfo_spRecord.getDetails(); |
||||
|
// 定义当前是否为标签
|
||||
|
boolean flagForLabel = true; // 默认为标签
|
||||
|
|
||||
|
|
||||
|
// 如果节点数目不等于标签人员数
|
||||
|
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(5); |
||||
|
|
||||
|
if (Integer.compare(applicationOutRecordPById.getFlagForOpenDepository(), 2) == 0) { |
||||
|
// 如果是申请的开放仓库
|
||||
|
|
||||
|
// 获取当时发送审批时其他部门负责人Id
|
||||
|
String otherDepartmentIdList = (String) redisPool.getRedisTemplateByDb(14).opsForHash().get("wms_QyWxMessage_" + spNo, "otherDepartmentIdList"); |
||||
|
if (otherDepartmentIdList != null) { |
||||
|
for (ApprovalInfo_Details ad : details |
||||
|
) { |
||||
|
// 获取当前节点审批人userId
|
||||
|
String approver = ad.getApprover().getUserId(); |
||||
|
flagForLabel = flagForLabel && otherDepartmentIdList.contains(approver); |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
flagForLabel = false; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
if (!flagForLabel) { |
||||
|
// 如果第二个节点不是标签节点
|
||||
|
if (approval_count > 1) { |
||||
|
// 如果完成审批的节点数大于1
|
||||
|
flagForDepository = 3; |
||||
|
|
||||
|
// 如果已经完成该审批记录,则进行删除
|
||||
|
// redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + spNo);
|
||||
|
} else { |
||||
|
// 如果当前是第一个节点
|
||||
|
flagForFirst = false; |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
// 如果第二个节点是标签节点
|
||||
|
if (approval_count > 2) { |
||||
|
// 如果完成审批的节点数大于2
|
||||
|
flagForDepository = 3; |
||||
|
// 如果已经完成该审批记录,则进行删除
|
||||
|
// redisPool.getRedisTemplateByDb(14).delete("wms_QyWxMessage_" + spNo);
|
||||
|
} else { |
||||
|
// 如果当前并不是标签节点后
|
||||
|
flagForDepository = 2; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
System.out.println(flagForDepository); |
||||
|
System.out.println(flagForFirst); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue