From 5506edbe54883b31db3cc8e4a1d9d0795a18a3c9 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 27 十二月 2024 14:37:54 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1

---
 server/service/src/main/java/com/doumee/service/business/impl/CompanySolutionServiceImpl.java |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 109 insertions(+), 7 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/CompanySolutionServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/CompanySolutionServiceImpl.java
index 89015f3..3aee62d 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/CompanySolutionServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/CompanySolutionServiceImpl.java
@@ -1,25 +1,38 @@
 package com.doumee.service.business.impl;
 
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.model.LoginUserInfo;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.CompanyMapper;
 import com.doumee.dao.business.CompanySolutionMapper;
+import com.doumee.dao.business.MultifileMapper;
+import com.doumee.dao.business.SolutionsMapper;
 import com.doumee.dao.business.join.CompanySolutionJoinMapper;
-import com.doumee.dao.business.model.Company;
-import com.doumee.dao.business.model.CompanySolution;
-import com.doumee.dao.business.model.Solutions;
+import com.doumee.dao.business.model.*;
+import com.doumee.dao.system.model.SystemUser;
 import com.doumee.service.business.CompanySolutionService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.doumee.service.business.third.SignService;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import oshi.driver.linux.Sysfs;
 
+import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 浼佷笟鍙敤淇濋櫓鏂规鍏宠仈琛⊿ervice瀹炵幇
@@ -33,6 +46,16 @@
     private CompanySolutionJoinMapper companySolutionJoinMapper;
     @Autowired
     private CompanySolutionMapper companySolutionMapper;
+    @Autowired
+    private CompanyMapper companyMapper;
+    @Autowired
+    private MultifileMapper multifileMapper;
+    @Autowired
+    private SolutionsMapper solutionsMapper;
+    @Autowired
+    private SystemDictDataBiz systemDictDataBiz;
+    @Autowired
+    private SignService signService;
 
     @Override
     public Integer create(CompanySolution companySolution) {
@@ -90,14 +113,30 @@
         csWrapper.selectAll(CompanySolution.class);
         csWrapper.selectAs(Solutions::getType,CompanySolution::getSolutionType);
         csWrapper.selectAs(Solutions::getName,CompanySolution::getSolutionName);
-        csWrapper.selectAs(Company::getName,CompanySolution::getShopName);
+        csWrapper.selectAs(Company::getName,CompanySolution::getCompanyName);
+        csWrapper.selectAs(SystemUser::getRealname,CompanySolution::getSignUserName);
+        csWrapper.select(" t4.name as shopName ");
         csWrapper.leftJoin(Solutions.class,Solutions::getId,CompanySolution::getSolutionBaseId);
-        csWrapper.leftJoin(Company.class, Company::getId,CompanySolution::getShopId);
-        csWrapper.eq(CompanySolution::getCompanyId,companySolution.getCompanyId());
+        csWrapper.leftJoin(Company.class, Company::getId,CompanySolution::getCompanyId);
+        csWrapper.leftJoin(SystemUser.class, SystemUser::getId,CompanySolution::getSignUserId);
+        csWrapper.leftJoin(" company t4 on t4.id = t.shop_id ");
+        csWrapper.eq(Objects.nonNull(companySolution.getCompanyId()),CompanySolution::getCompanyId,companySolution.getCompanyId());
+        csWrapper.eq(Objects.nonNull(companySolution.getSolutionId()),CompanySolution::getSolutionBaseId,companySolution.getSolutionId());
         csWrapper.eq(CompanySolution::getIsdeleted, Constants.ZERO);
         csWrapper.eq(Solutions::getIsdeleted, Constants.ZERO);
+        csWrapper.orderByAsc(CompanySolution::getCreateDate);
         csWrapper.orderByAsc(CompanySolution::getSortnum);
-        return companySolutionJoinMapper.selectJoinList(CompanySolution.class,csWrapper);
+        List<CompanySolution> companySolutionList = companySolutionJoinMapper.selectJoinList(CompanySolution.class,csWrapper);
+        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(companySolutionList)){
+            String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+
+                    systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode();
+            for (CompanySolution c:companySolutionList) {
+                if(StringUtils.isNotBlank(c.getFileSignUrl())){
+                    c.setFileSignUrl(url + c.getFileSignUrl());
+                }
+            }
+        }
+        return companySolutionList;
     }
     @Override
     public List<CompanySolution> findList(CompanySolution companySolution) {
@@ -166,4 +205,67 @@
         QueryWrapper<CompanySolution> wrapper = new QueryWrapper<>(companySolution);
         return companySolutionMapper.selectCount(wrapper);
     }
+
+
+
+    @Override
+    public  String getCompanySolutionSignLink(Integer id) {
+        if(id == null ){
+            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        MPJLambdaWrapper<CompanySolution> queryWrapper = new MPJLambdaWrapper<>();
+        queryWrapper.selectAll(CompanySolution.class);
+        queryWrapper.selectAs(Company::getName,CompanySolution::getShopName);
+        queryWrapper.leftJoin(Company.class,Company::getId,CompanySolution::getCompanyId);
+        queryWrapper.eq(CompanySolution::getId,id);
+        queryWrapper.last(" limit 1");
+        CompanySolution companySolution = companySolutionJoinMapper.selectJoinOne(CompanySolution.class,queryWrapper);
+        if(companySolution == null ||!Constants.equalsInteger(companySolution.getIsdeleted(),Constants.ZERO) ){
+            throw  new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
+        Company company = companyMapper.selectById(companySolution.getCompanyId());
+        if(Objects.isNull(company)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌浼佷笟淇℃伅!");
+        }
+        Solutions solutions = solutionsMapper.selectById(companySolution.getSolutionId());
+        if(Objects.isNull(solutions)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鍏宠仈鏂规淇℃伅!");
+        }
+        //濡傛灉鏄┏鍥�,鍙兘鍙┏鍥炲凡绛剧珷鐘舵�佷笅鐨勯��鍥炵敵璇风姸鎬佽繘琛屾搷浣�
+        if(!Constants.equalsInteger(companySolution.getStatus(),Constants.ZERO)){
+            throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀵逛笉璧凤紝璇ヤ紒涓氱殑鏂规纭涔︾姸鎬佸凡娴佽浆锛屽綋鍓嶄笉鏀寔璇ユ搷浣渵");
+        }
+        Multifile f = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda()
+                .eq(Multifile::getObjId,companySolution.getSolutionId())
+                .eq(Multifile::getObjType,Constants.MultiFile.SOLUTIONS_CONFIRMATION_LATTER.getKey())
+                .eq(Multifile::getIsdeleted,Constants.ZERO).last("limit 1"));
+        if(f == null || StringUtils.isBlank(f.getFileurl())){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇寰呯绔犳枃浠跺け璐ワ紝璇疯仈绯荤‘璁ょ缃叉枃浠舵槸鍚︽纭紒");
+        }
+        String url = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+
+                systemDictDataBiz.queryByCode(Constants.OSS,Constants.APPLY_FILE).getCode()+f.getFileurl();
+        String notifyUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode();
+        String applyNo = signService.applySign(solutions.getName(),url,company.getName(),company.getCode(),company.getEmail(),null,company.getSignId(),notifyUrl);
+        if(StringUtils.isBlank(applyNo) ){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
+        }
+        String link = signService.signLink(applyNo,company.getName(),company.getCode());
+        if(StringUtils.isBlank(link) ){
+            throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀵逛笉璧凤紝鑾峰彇鍦ㄧ嚎绛剧珷鍦板潃澶辫触锛岃绋嶅悗閲嶈瘯锛�");
+        }
+        CompanySolution update= new CompanySolution();
+        update.setId(companySolution.getId());
+        update.setEditor(user.getId());
+        update.setEditDate(new Date());
+        update.setApplyNo(applyNo);
+        update.setSignStatus(Constants.ZERO);
+//        update.setSignUserId(user.getId());
+//        update.setSignDate(new Date());
+        companySolutionJoinMapper.updateById(update);
+        return  link;
+    }
+
+
+
 }

--
Gitblit v1.9.3