Commit fbfd9c56 authored by liangyb's avatar liangyb

#20240719 1.专家评审-查看对比表-当页面无数据时什么都不显示

          2.开标工具-解密过程错误弹窗,未设置招标代表
          3.评标工具-项目解析结构化数据保存数据失败
parent 586d5fca
package com.gx.obe.evaluation.step.composite;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.CallBack;
......@@ -26,9 +33,6 @@ import com.gx.obe.common.icons.IconsActivator;
import com.gx.obe.components.core.enumeration.CommonEnum;
import com.gx.obe.config.utils.PropertiesUtils;
import com.gx.obe.evaluation.step.shell.ShowAiProcessShell;
import com.gx.obe.evaluation.step.widgets.EvalLeftGroupButton;
import com.gx.obe.evaluation.step.widgets.LeftMenuMouseAdapter;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.ObjectUtils;
import com.gx.obe.util.utils.RuntimeUtils;
import com.gx.obe.util.utils.StringUtils;
......@@ -44,6 +48,11 @@ public class AiEvalLeftButton extends ImageButton{
private ShowAiProcessShell showAiProcessShell;
private File downLoadPath;
public static Color BG = ColorConstants.SKIN_BG;
private static final String title = "标书正在下载中... 请勿离开该页面";
private static final String todo = " 已耗时:";
private static final ReentrantLock lock = new ReentrantLock();
private static volatile Future<Boolean> future = null;
public AiEvalLeftButton(Composite parent, int style,TenderProjectEntity curTender) {
super(parent, SWT.CENTER|SWT.NONE);
this.setTopMargin(3);
......@@ -83,6 +92,15 @@ public class AiEvalLeftButton extends ImageButton{
HttpResponse httpResponse = HttpUtils.doPost(httpUrl);
downLoadPath = new File(FileConstants.getBiddingFilePath(curTender.getId()) + "ai.pdf");
if(StringUtils.isNotEmpty(downLoadPath.getAbsolutePath()) && downLoadPath.exists()) {
if(null == listener) {
listener = new MouseAdapter() {
public void mouseUp(MouseEvent e) {
if(!AiEvalLeftButton.this.getEnabled()) return;
RuntimeUtils.openFIle(downLoadPath);
}
};
AiEvalLeftButton.this.addMouseListener(listener);
}
return;
}
downloadBiddingFile(httpResponse);
......@@ -119,6 +137,7 @@ public class AiEvalLeftButton extends ImageButton{
String downLoadPaths = downLoadPath.getAbsolutePath();
downLoadFile(downUrl, downLoadPaths);
}else {
AiEvalLeftButton.this.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/hourglass.png"));
String progress = httpResponse.getDataParam("progress");
String waitTime = httpResponse.getDataParam("waitTime");
showAiProcessShell = new ShowAiProcessShell(getShell(), AiEvalLeftButton.this, ObjectUtils.getIntValue(progress, 0), waitTime);
......@@ -131,41 +150,85 @@ public class AiEvalLeftButton extends ImageButton{
private void downLoadFile(String downLoadUrl, String downLoadPaths){
// callBackMsg("开始下载招标文件...");
HttpURLDown httpURLDown = new HttpURLDown(downLoadUrl, downLoadPaths, new CallBack() {
});
HttpURLDown httpURLDown = new HttpURLDown(downLoadUrl, downLoadPaths, new CallBack() {});
// 初始化ExecutorService
ExecutorService executor = Executors.newSingleThreadExecutor();
// 定义异步任务
Callable<Boolean> downLoadTask = () -> {
// 模拟下载任务
System.out.println("Starting download task...");
Thread.sleep(100);
return httpURLDown.downLoad("标书比对相似度分析");
};
// 提交异步任务
synchronized (AiEvalLeftButton.class) {
if (future == null || future.isDone()) {
future = executor.submit(downLoadTask);
// 调用异步前的操作
AiEvalLeftButton.this.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, "icons/btn/white/hourglass.png"));
// showAiProcessShell = new ShowAiProcessShell(getShell(), AiEvalLeftButton.this, ObjectUtils.getIntValue("0", 0), "0s", title, todo);
// showAiProcessShell.open();
} else {
System.out.println("A task is already running. Not submitting a new task.");
}
}
// 使用ScheduledExecutorService定期检查任务状态,其实只检查了一次
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
Runnable checkTask = new Runnable() {
@Override
public void run() {
lock.lock();
try {
showAiProcessShell = new ShowAiProcessShell(getShell(), AiEvalLeftButton.this, ObjectUtils.getIntValue("0", 0), "10s");
showAiProcessShell.open();
boolean downFlag = httpURLDown.downLoad("标书比对相似度分析");
showAiProcessShell.close();
showAiProcessShell = new ShowAiProcessShell(getShell(), AiEvalLeftButton.this, ObjectUtils.getIntValue("100", 0), "0s");
showAiProcessShell.open();
// callBackMsg("招标文件下载结束!");
// 下载成功并且是.zip文件才进行解压操作
if(downFlag){
final AiEvalLeftButton groupButton = AiEvalLeftButton.this;
groupButton.setToolTipText("标书比对相似度分析");
if(null == listener) {
listener = new MouseAdapter() {
public void mouseUp(MouseEvent e) {
if(!groupButton.getEnabled()) return;
RuntimeUtils.openFIle(new File(downLoadPaths));
Random random = new Random();
int index = 0;
int time = 5;
while (!future.isDone()) {
// 每隔5秒检查一次
Thread.sleep(5000);
int increment = random.nextInt(6) + 1; // 生成1到10的随机数
index += increment;
time += 5;
System.out.println("task status do do do...");
if (future.isDone()) {
boolean downFlag = future.get();
if (downFlag) {
changeStyle("100", time + "s", "icons/btn/white/view.png");
}
};
groupButton.addMouseListener(listener);
} else {
// 任务还在进行中
changeStyle("" + Math.min(index, 95), time + "s", "icons/btn/white/hourglass.png");
}
// unZipFile(savePath, FileConstants.getBiddingFilePath(curTender.getId()));
}
} catch (IOException e) {
// LOG.error("招标文件下载失败", e);
// callBackMsg("招标文件下载文件出现错误");
// callBackMsg("错误信息为:"+e.getMessage());
return;
} catch (InterruptedException | ExecutionException e) {
((Throwable) e).printStackTrace();
} finally {
lock.unlock();
// 关闭ExecutorService
executor.shutdown();
// 任务完成,关闭scheduler
scheduler.shutdown();
System.out.println("Scheduler shutdown.");
}
}
};
// 每隔5秒检查一次任务状态
scheduler.scheduleAtFixedRate(checkTask, 0, 5, TimeUnit.SECONDS);
}
// HttpUrl httpUrl = HttpUtils.getProjectHttpUrl(curTender, PropertiesUtils.getWebserviceProperty(WebserviceConstants.GET_AI_RESULT_METHOD, "bidOpeningHS.do?downloadOpenBidSupplierAiResult"));
// HttpResponse httpResponse = HttpUtils.doPost(httpUrl);
// downloadBiddingFile(httpResponse);
private void changeStyle(String start, String end, String picture) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
// showAiProcessShell = new ShowAiProcessShell(getShell(), AiEvalLeftButton.this, ObjectUtils.getIntValue(start, 0), end, title, todo);
// showAiProcessShell.open();
AiEvalLeftButton.this.setImage(ResourceManager.getPluginImage(IconsActivator.PLUGIN_ID, picture));
}
});
}
}
......@@ -45,88 +45,14 @@ public class ShowAiProcessShell extends Shell {
*/
public ShowAiProcessShell(final Shell shell, AiEvalLeftButton shortMenu, int process, String needTime) {
super(shell, SWT.NO_TRIM | SWT.TOP);
this.groupMenuBtn = shortMenu;
// this.process = process;
// this.needTime = needTime;
// super(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.TOOL);
// addDisposeListener(new DisposeListener() {
// public void widgetDisposed(DisposeEvent e) {
// removeListener(SWT.Deactivate, deactivateListener);
// }
// });
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = 1;
gridLayout.marginWidth = 1;
setLayout(gridLayout);
setBackground(shortMenu.getActiveBackgroundColor());
// setBackground(shortMenu.getBackground());
setBackgroundMode(SWT.INHERIT_FORCE);
curComposite = new Composite(this, SWT.NONE);
curComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 2));
GridLayout gl_curComposite = new GridLayout(1, false);
gl_curComposite.marginHeight = 0;
gl_curComposite.marginWidth = 0;
gl_curComposite.marginRight = 5;
curComposite.setLayout(gl_curComposite);
curComposite.setBackground(shortMenu.getActiveBackgroundColor());
// curComposite.setBackground(SWTResourceManager.getColor(123, 13, 15));
curBtn = new ImageButton(curComposite, SWT.NONE);
curBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
curBtn.setImage(shortMenu.getImage());
// curBtn.setTopMargin(3);
// curBtn.setBottomMargin(3);
curBtn.setLeftMargin(5);
curBtn.setRightMargin(5);
composite = new Composite(this, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.marginWidth = 0;
gl_composite.horizontalSpacing = 0;
gl_composite.marginHeight = 0;
gl_composite.verticalSpacing = 0;
composite.setLayout(gl_composite);
composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
Label labe = new Label(composite, SWT.None);
labe.setText("标书相似度分析进度");
messageComposite = new Composite(composite, SWT.NONE);
messageComposite.setLayout(new GridLayout(4, false));
messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
// messageComposite.setVisible(false);
Label lblNewLabel = new Label(messageComposite, SWT.NONE);
lblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblNewLabel.setText(Messages.ShowViewAiProcessDialog_lblNewLabel_text);
lblNewLabel_1 = new Label(messageComposite, SWT.NONE);
lblNewLabel_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
GridData gd_lblNewLabel_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblNewLabel_1.widthHint = 40;
lblNewLabel_1.setLayoutData(gd_lblNewLabel_1);
lblNewLabel_1.setText(process + "%");
Label lblNewLabel_2 = new Label(messageComposite, SWT.NONE);
lblNewLabel_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblNewLabel_2.setText(" 预计还需要:");
Label lblNewLabel_3 = new Label(messageComposite, SWT.NONE);
lblNewLabel_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel_3.setText(needTime);
initStruct(shortMenu, process, needTime, "标书相似度分析进度", " 预计还需要:");
}
ProgressBar progressBar = new ProgressBar(composite, SWT.NONE);
progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
progressBar.setSelection(process);
init();
createContents();
public ShowAiProcessShell(final Shell shell, AiEvalLeftButton shortMenu, int process, String needTime, String title, String todo) {
super(shell, SWT.NO_TRIM | SWT.TOP);
initStruct(shortMenu, process, needTime, title, todo);
}
private void init(){
deactivateListener = new Listener(){
......@@ -195,4 +121,77 @@ public class ShowAiProcessShell extends Shell {
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
private void initStruct(AiEvalLeftButton shortMenu, int process, String needTime, String title, String todo) {
this.groupMenuBtn = shortMenu;
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = 1;
gridLayout.marginWidth = 1;
setLayout(gridLayout);
setBackground(shortMenu.getActiveBackgroundColor());
setBackgroundMode(SWT.INHERIT_FORCE);
curComposite = new Composite(this, SWT.NONE);
curComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 2));
GridLayout gl_curComposite = new GridLayout(1, false);
gl_curComposite.marginHeight = 0;
gl_curComposite.marginWidth = 0;
gl_curComposite.marginRight = 5;
curComposite.setLayout(gl_curComposite);
curComposite.setBackground(shortMenu.getActiveBackgroundColor());
curBtn = new ImageButton(curComposite, SWT.NONE);
curBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
curBtn.setImage(shortMenu.getImage());
// curBtn.setTopMargin(3);
// curBtn.setBottomMargin(3);
curBtn.setLeftMargin(5);
curBtn.setRightMargin(5);
composite = new Composite(this, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
GridLayout gl_composite = new GridLayout(1, false);
gl_composite.marginWidth = 0;
gl_composite.horizontalSpacing = 0;
gl_composite.marginHeight = 0;
gl_composite.verticalSpacing = 0;
composite.setLayout(gl_composite);
composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
Label labe = new Label(composite, SWT.None);
labe.setText(title);
messageComposite = new Composite(composite, SWT.NONE);
messageComposite.setLayout(new GridLayout(4, false));
messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
// messageComposite.setVisible(false);
Label lblNewLabel = new Label(messageComposite, SWT.NONE);
lblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblNewLabel.setText(Messages.ShowViewAiProcessDialog_lblNewLabel_text);
lblNewLabel_1 = new Label(messageComposite, SWT.NONE);
lblNewLabel_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
GridData gd_lblNewLabel_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblNewLabel_1.widthHint = 45;
lblNewLabel_1.setLayoutData(gd_lblNewLabel_1);
lblNewLabel_1.setText(process + "%");
Label lblNewLabel_2 = new Label(messageComposite, SWT.NONE);
lblNewLabel_2.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblNewLabel_2.setText(todo);
Label lblNewLabel_3 = new Label(messageComposite, SWT.NONE);
lblNewLabel_3.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
lblNewLabel_3.setText(needTime);
ProgressBar progressBar = new ProgressBar(composite, SWT.NONE);
progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
progressBar.setSelection(process);
init();
createContents();
}
}
......@@ -44,6 +44,7 @@ import com.gx.obe.components.core.enumeration.CommonEnum;
import com.gx.obe.components.core.enumeration.TenderProjectEnum;
import com.gx.obe.config.utils.PropertiesUtils;
import com.gx.obe.message.Messages;
import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.web.entity.expert.Expert;
import com.gx.obe.web.entity.tender.TenderProjectEntity;
import com.gx.obe.web.service.TenderProjectService;
......@@ -611,20 +612,28 @@ public class BatchRemoteBidOpeningDialog extends EDialog {
}
List<Expert> expertList= expertService.getExpertListByTenderId(tenderProject.getId());
if(null != expertList && expertList.size() > 0) {
for(Expert expert : expertList) {
if(ExpertEnum.BIDDING.equals(expert.getExpertType())) {
break;
}
MessageDialog.openError(getShell(), "请先在评标管理中设置招标人代表!");//(getShell(), message.toString());
tenderPackList.clear();
return ;
}
}else {
Expert expertCheck = CollectionUtils.get(expertList, item -> ExpertEnum.BIDDING.equals(item.getExpertType()));
if(expertCheck == null) {
MessageDialog.openError(getShell(), "请先在评标管理中设置招标人代表!");//(getShell(), message.toString());
tenderPackList.clear();
return ;
}
// if(null != expertList && expertList.size() > 0) {
// for(Expert expert : expertList) {
// if(ExpertEnum.BIDDING.equals(expert.getExpertType())) {
// break;
// }
//
// MessageDialog.openError(getShell(), "请先在评标管理中设置招标人代表!");//(getShell(), message.toString());
// tenderPackList.clear();
// return ;
// }
// }else {
// MessageDialog.openError(getShell(), "请先在评标管理中设置招标人代表!");//(getShell(), message.toString());
// tenderPackList.clear();
// return ;
// }
}
if(isFocus){
StringBuilder msg = new StringBuilder();
......
......@@ -41,11 +41,13 @@ public class TabHandler<T extends ISelection> {
public <R> TabHandler<T> hand(R r, BiConsumer<T, R> setBiConsumer, Consumer<R> consumer) {
T t = iTabFunction.apply(composite);
//设置对比表标题,此处t为composite,r为数据evaluationContent,等同于 t.setText(r.data)
setBiConsumer.accept(t, r);
t.addMouseListener(MouseListener.mouseUpAdapter($ -> {
tab.setSelection(false);
tab = t;
tab.setSelection(true);
//设置表数据
consumer.accept(r);
}));
if (firstCall == null) firstCall = () -> consumer.accept(r);
......
......@@ -21,8 +21,11 @@ import com.gx.obe.common.widget.button.RectangleRadioButton;
import com.gx.obe.component.handler.TabHandler;
import com.gx.obe.component.rx.RxSwt;
import com.gx.obe.message.Messages;
import com.gx.obe.struct.beans.TemplateTable;
import com.gx.obe.struct.enums.DataCategoryEnum;
import com.gx.obe.struct.service.EvaluationContentService;
import com.gx.obe.struct.service.TemplateTableService;
import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.web.entity.Supplier;
import com.gx.obe.web.entity.evaluation.EvaluationContent;
import com.swtdesigner.SWTResourceManager;
......@@ -31,6 +34,8 @@ public class TemplateTableListComposite extends Composite {
private final EvaluationContentService evaluationContentService = new EvaluationContentService();
private final TemplateTableService templateTableService = new TemplateTableService();
private final Prop<TemplateTableData> templateTableData = new Prop<>();
private class TemplateTableData {
......@@ -85,6 +90,9 @@ public class TemplateTableListComposite extends Composite {
TabHandler<RectangleRadioButton> handler = new TabHandler<>(tabComposite, t -> new RectangleRadioButton(t, SWT.NONE));
/**
* 回调渲染根据方法refresh的结果集来决定d的值
*/
this.templateTableData.bind(d -> {
if (d.evaluationContentList.isEmpty()) {
topControlConsumer.accept(composite_1);
......@@ -100,9 +108,19 @@ public class TemplateTableListComposite extends Composite {
TemplateTableComparisonComposite comparisonComposite = new TemplateTableComparisonComposite(composite, SWT.NONE);
comparisonComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
this.templateTableComparisonData.bind(d -> comparisonComposite.refresh(d.tenderId, d.relChapterType, d.dataCode, d.dataCategory, d.supplierList));
/**
* 首次渲染什么都不做,等待d值,也就是selectAction的data结果集,拿到后refresh ktable
*/
this.templateTableComparisonData.bind(d ->
comparisonComposite.refresh(d.tenderId, d.relChapterType, d.dataCode, d.dataCategory, d.supplierList));
}
/**
* 回调函数selectAction,填充数据data用于渲染ktable表格数据
* @param tenderId
* @param evaluationContent
* @param supplierList
*/
private void selectAction(String tenderId, EvaluationContent evaluationContent, List<Supplier> supplierList) {
TemplateTableComparisonData data = new TemplateTableComparisonData();
data.tenderId = tenderId;
......@@ -110,15 +128,36 @@ public class TemplateTableListComposite extends Composite {
data.dataCode = evaluationContent.getDataCode();
data.dataCategory = evaluationContent.getDataCategory();
data.supplierList = supplierList;
//携带data,回调渲染表格数据templateTableComparisonData
this.templateTableComparisonData.set(data);
}
/**
* 异步获取结果集
* @param tenderId
* @param factorCode
* @param supplierList
*/
public void refresh(String tenderId, String factorCode, List<Supplier> supplierList) {
RxSwt.run(() -> evaluationContentService.getEvaluationContentListByFactorCode(tenderId, factorCode)).checkWidget(this).other(ArrayList::new).exe(l -> {
TemplateTableData data = new TemplateTableData();
data.tenderId = tenderId;
data.evaluationContentList = l.stream().filter(t -> (DataCategoryEnum.TT.getKey().equals(t.getDataCategory()) || DataCategoryEnum.MD.getKey().equals(t.getDataCategory()))).collect(Collectors.toList());
data.evaluationContentList = l.stream().filter(t -> {
if(DataCategoryEnum.TT.getKey().equals(t.getDataCategory())) {
List<TemplateTable> templateTableList = templateTableService.getTemplateTableList(tenderId, t.getRelChapterType(), t.getDataCode());
if (CollectionUtils.isNull(templateTableList)) {
return false;
}
return true;
}
if(DataCategoryEnum.MD.getKey().equals(t.getDataCategory())){
return true;
}
return false;
}).collect(Collectors.toList());
//data.evaluationContentList = l.stream().filter(t -> DataCategoryEnum.MD.getKey().equals(t.getDataCategory())).collect(Collectors.toList());
data.supplierList = supplierList;
//在set后调用回调函数bind
this.templateTableData.set(data);
});
}
......
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