Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

buzhanyi 2 anni fa
parent
commit
b020541e9d

+ 39 - 6
purchase-admin/src/main/java/com/ozs/web/controller/base/BaseProfessionalController.java

@@ -3,21 +3,32 @@ package com.ozs.web.controller.base;
 import com.ozs.base.domain.BaseProfessional;
 import com.ozs.base.domain.vo.BaseProfessionalVo;
 import com.ozs.base.service.BaseProfessionalService;
+import com.ozs.common.config.PurchaseConfig;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.core.domain.AjaxResult;
+import com.ozs.common.core.domain.R;
 import com.ozs.common.core.domain.model.LoginUser;
 import com.ozs.common.exception.ServiceException;
 import com.ozs.common.utils.StringUtils;
+import com.ozs.common.utils.file.FileUtils;
 import com.ozs.common.utils.poi.ExcelUtil;
 import com.ozs.plan.doman.ProvisionalPlan;
 import com.ozs.plan.doman.vo.requestVo.ProvisionalPlanVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.FileInputStream;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.util.List;
 
 /**
@@ -28,12 +39,13 @@ import java.util.List;
 @Api(tags = "专业库管理")
 @RestController
 @RequestMapping("/base/professional")
+@Slf4j
 public class BaseProfessionalController extends BaseController {
 
     @Autowired
     private BaseProfessionalService baseProfessionalService;
 
-    @ApiOperation(value = "新增专业库", notes = "必传 专业库名称、一级分类、编码、父级编码;没有父级编码传0")
+    @ApiOperation(value = "新增专业库" , notes = "必传 专业库名称、一级分类、编码、父级编码;没有父级编码传0")
     @PostMapping("/insertProfessional")
     public AjaxResult insertProfessional(@RequestBody BaseProfessional baseProfessional) {
         if (StringUtils.isNull(baseProfessional)
@@ -46,7 +58,7 @@ public class BaseProfessionalController extends BaseController {
         return toAjax(baseProfessionalService.save(baseProfessional));
     }
 
-    @ApiOperation(value = "删除专业库", notes = "必传 id")
+    @ApiOperation(value = "删除专业库" , notes = "必传 id")
     @PostMapping("/deleteProfessional")
     public AjaxResult deleteProfessional(@RequestBody BaseProfessional baseProfessional) {
         if (StringUtils.isNull(baseProfessional) || StringUtils.isNull(baseProfessional.getId())) {
@@ -55,14 +67,14 @@ public class BaseProfessionalController extends BaseController {
         return toAjax(baseProfessionalService.removeById(baseProfessional.getId()));
     }
 
-    @ApiOperation(value = "批量删除专业库", notes = "必传 idList")
+    @ApiOperation(value = "批量删除专业库" , notes = "必传 idList")
     @PostMapping("/deleteIds")
     public AjaxResult deleteByIdLIst(@RequestBody BaseProfessionalVo baseProfessionalVo) {
         baseProfessionalService.deleteIds(baseProfessionalVo.getDeleteIds());
         return success();
     }
 
-    @ApiOperation(value = "修改专业库", notes = "必传 id 及修改数据")
+    @ApiOperation(value = "修改专业库" , notes = "必传 id 及修改数据")
     @PostMapping("/updateProfessional")
     public AjaxResult updateProfessional(@RequestBody BaseProfessional baseProfessional) {
         if (StringUtils.isNull(baseProfessional) || StringUtils.isNull(baseProfessional.getId())) {
@@ -71,14 +83,14 @@ public class BaseProfessionalController extends BaseController {
         return toAjax(baseProfessionalService.updateById(baseProfessional));
     }
 
-    @ApiOperation(value = "查询专业库树结构", notes = "非必传 查询条件:品目名称")
+    @ApiOperation(value = "查询专业库树结构" , notes = "非必传 查询条件:品目名称")
     @PostMapping("/selectBaseProfessional")
     public AjaxResult selectBaseProfessional(@RequestBody BaseProfessionalVo baseProfessionalVo) {
         List<BaseProfessionalVo> baseSupplierList = baseProfessionalService.selectBaseProfessionalVo(baseProfessionalVo);
         return success(baseSupplierList);
     }
 
-    @ApiOperation(value = "导入专业库", notes = "导入表格")
+    @ApiOperation(value = "导入专业库" , notes = "导入表格")
     @PostMapping("/importBaseProfessional")
     public AjaxResult importBaseProfessional(MultipartFile file, boolean updateSupport) throws Exception {
         ExcelUtil<BaseProfessional> util = new ExcelUtil<>(BaseProfessional.class);
@@ -98,4 +110,25 @@ public class BaseProfessionalController extends BaseController {
         ExcelUtil<BaseProfessional> util = new ExcelUtil<>(BaseProfessional.class);
         util.exportExcel(response, list, "专业库数据");
     }
+
+    @ApiOperation("文件下载")
+    @GetMapping("/downloaExcel")
+    public void downloadZip(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            // 文件路径
+            String downloadPath = this.getClass().getResource("/").getPath() + "template/专业库模板.xlsx";
+            log.info("downloadPath:{}",downloadPath);
+            // 下载文件
+            String realFileName = "专业库模板.xlsx";
+            String filePath = downloadPath;
+            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+            FileUtils.setAttachmentResponseHeader(response, realFileName);
+            FileUtils.writeBytes(filePath, response.getOutputStream());
+
+        } catch (Exception e) {
+            log.error("下载文件失败" , e);
+        }
+    }
+
+
 }

+ 1 - 1
purchase-admin/src/main/java/com/ozs/web/controller/common/CommonController.java

@@ -60,7 +60,7 @@ public class CommonController {
                 throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
             }
             String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
-            String filePath = PurchaseConfig.getDownloadPath() + fileName;
+            String filePath = PurchaseConfig.getDownloadPath() + fileName.substring("/profile/upload/".length(),fileName.length());
 
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, realFileName);

+ 59 - 3
purchase-admin/src/main/resources/application-prod.yml

@@ -23,7 +23,7 @@ server:
     # tomcat的URI编码
     uri-encoding: UTF-8
     # 连接数满后的排队数,默认为100
-    accept-count: 1000
+    accept-count: 100
     threads:
       # tomcat最大线程数,默认为200
       max: 800
@@ -46,6 +46,62 @@ user:
 
 # Spring配置
 spring:
+  datasource:
+    type: com.alibaba.druid.pool.DruidDataSource
+    driverClassName: com.mysql.cj.jdbc.Driver
+    druid:
+      # 主库数据源
+      master:
+        url: jdbc:mysql://127.0.0.1:3306/purchase?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+        username: root
+        password: 123.asd
+      # 从库数据源
+      slave:
+        # 从数据源开关/默认关闭
+        enabled: false
+        url:
+        username:
+        password:
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: purchase
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1000
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+
   # 资源信息
   messages:
     # 国际化资源文件路径
@@ -67,11 +123,11 @@ spring:
     # 地址
     host: 127.0.0.1
     # 端口,默认为6379
-    port: 7001
+    port: 6379
     # 数据库索引
     database: 0
     # 密码
-    password: 106@qwe123
+    password: tysfrz123
     # 连接超时时间
     timeout: 100s
     lettuce:

+ 1 - 0
purchase-admin/src/main/resources/application.yml

@@ -11,3 +11,4 @@ server:
 spring:
   profiles:
     active: druid,test
+#    active: prod

BIN
purchase-admin/src/main/resources/template/专业库模板.xlsx


+ 1 - 1
purchase-common/src/main/java/com/ozs/common/config/PurchaseConfig.java

@@ -135,7 +135,7 @@ public class PurchaseConfig
      */
     public static String getDownloadPath()
     {
-        return getProfile() + "/download/";
+        return getProfile() + "/upload/";
     }
 
     /**

+ 2 - 2
purchase-common/src/main/java/com/ozs/common/core/domain/entity/SysDept.java

@@ -201,8 +201,8 @@ public class SysDept extends BaseEntity
         this.phone = phone;
     }
 
-    @Email(message = "邮箱格式不正确")
-    @Size(min = 0, max = 50, message = "邮长度不能超过50个字符")
+    @NotBlank(message = "邮政格式不正确")
+    @Size(min = 0, max = 50, message = "邮长度不能超过50个字符")
     public String getEmail()
     {
         return email;

+ 12 - 0
purchase-system/src/main/java/com/ozs/base/service/BaseProfessionalService.java

@@ -3,7 +3,10 @@ package com.ozs.base.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ozs.base.domain.BaseProfessional;
 import com.ozs.base.domain.vo.BaseProfessionalVo;
+import com.ozs.common.core.domain.AjaxResult;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 public interface BaseProfessionalService extends IService<BaseProfessional> {
@@ -13,4 +16,13 @@ public interface BaseProfessionalService extends IService<BaseProfessional> {
     void deleteIds(List<Integer> deleteIds);
 
     String importBaseProfessional(List<BaseProfessional> userList, boolean updateSupport);
+
+    /**
+     * 下载模板
+     * @param downloadPath
+     * @param request
+     * @param response
+     * @return
+     */
+    AjaxResult downloadPathFile(String downloadPath, HttpServletRequest request, HttpServletResponse response);
 }

+ 50 - 0
purchase-system/src/main/java/com/ozs/base/service/impl/BaseProfessionalServiceImpl.java

@@ -5,6 +5,7 @@ import com.ozs.base.domain.BaseProfessional;
 import com.ozs.base.domain.vo.BaseProfessionalVo;
 import com.ozs.base.mapper.BaseProfessionalMapper;
 import com.ozs.base.service.BaseProfessionalService;
+import com.ozs.common.core.domain.AjaxResult;
 import com.ozs.common.core.domain.entity.SysDictType;
 import com.ozs.common.core.domain.entity.SysUser;
 import com.ozs.common.exception.ServiceException;
@@ -15,7 +16,10 @@ import com.ozs.common.utils.bean.BeanValidators;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Validator;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -78,6 +82,52 @@ public class BaseProfessionalServiceImpl extends ServiceImpl<BaseProfessionalMap
         return successMsg.toString();
     }
 
+    @Override
+    public AjaxResult downloadPathFile(String downloadPath, HttpServletRequest request, HttpServletResponse response) {
+        //设置文件路径
+        File file = new File(downloadPath);
+        //获取文件名称
+        String fileName = file.getName();
+        //判断文件是否存在
+        if (file.exists()) {
+            response.setContentType("application/force-download");// 设置强制下载不打开
+            response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);// 设置文件名
+            byte[] buffer = new byte[1024];
+            FileInputStream fis = null;
+            BufferedInputStream bis = null;
+            try {
+                fis = new FileInputStream(file);
+                bis = new BufferedInputStream(fis);
+                OutputStream os = response.getOutputStream();
+                int i = bis.read(buffer);
+                while (i != -1) {
+                    os.write(buffer, 0, i);
+                    i = bis.read(buffer);
+                }
+                file.delete();
+                return AjaxResult.success("下载成功");
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                if (bis != null) {
+                    try {
+                        bis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                if (fis != null) {
+                    try {
+                        fis.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+        return AjaxResult.success("下载失败");
+    }
+
     @Override
     public List<BaseProfessionalVo> selectBaseProfessionalVo(BaseProfessionalVo baseProfessionalVo) {
         List<BaseProfessional> allList = new ArrayList<>();

+ 44 - 0
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -131,6 +131,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         PmDemand pmDemand = this.getById(demandId);
         if (pmDemand != null) {
             PmDemandResVo vo = new PmDemandResVo();
+            vo.setProjectName(pmDemand.getProjectName());
             vo.setDemandId(demandId);
             if ("1".equals(detailType)) { //项目计划
 
@@ -814,6 +815,10 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         if (ObjectUtils.isEmpty(pmDemand)) {
             throw new Exception("参数错误");
         }
+        if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
+            throw new Exception("上传附件不能为空");
+        }
+
         PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
         BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
         if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
@@ -1110,6 +1115,12 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
         }
     }
 
+    /**
+     * 填写中标
+     * @param pmBidWinningReqVo
+     * @return
+     * @throws Exception
+     */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
@@ -1170,6 +1181,23 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
             if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
 
                 uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
+
+
+                //发布公告生成后,会默认将该数据同步到公告管理和首页中
+                PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
+                BaseNotice baseNotice = new BaseNotice();
+                baseNotice.setName(pmDemand.getProjectName());
+                baseNotice.setTitle(pmDemand.getProjectName() + "中标公告");
+                LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                lambdaQueryWrapper.eq(BaseNoticeType::getName, "中标公告");
+                BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
+                if (baseNoticeType == null) {
+                    throw new Exception("中标公告 公告类型不存在");
+                }
+                baseNotice.setType(baseNoticeType.getId());
+                baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
+                 this.baseNoticeService.saveOrUpdate(baseNotice);
+
                 PmDemand pmDemandUpdate = new PmDemand();
                 pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
                 pmDemandUpdate.setProjectStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
@@ -1286,6 +1314,22 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
             }
 
             uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
+
+            //发布公告生成后,会默认将该数据同步到公告管理和首页中
+            PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
+            BaseNotice baseNotice = new BaseNotice();
+            baseNotice.setName(pmDemand.getProjectName());
+            baseNotice.setTitle(pmDemand.getProjectName() + "流标公告");
+            LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.eq(BaseNoticeType::getName, "流标公告");
+            BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
+            if (baseNoticeType == null) {
+                throw new Exception("流标公告 公告类型不存在");
+            }
+            baseNotice.setType(baseNoticeType.getId());
+            baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
+            this.baseNoticeService.saveOrUpdate(baseNotice);
+
             PmDemand pmDemandUpdate = new PmDemand();
             pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
             pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());