hfxc226 3 лет назад
Родитель
Сommit
20a1813c85

+ 14 - 0
platform-dao/src/main/java/com/platform/dao/config/DataSourceConfig.java

@@ -58,6 +58,20 @@ public class DataSourceConfig {
         return dataSource;
     }
 
+    @Bean
+    @ConfigurationProperties("spring.datasource.druid.qykh")
+    public DataSource qykhDataSource() {
+        DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
+        WallConfig wallConfig = new WallConfig();
+        wallConfig.setMultiStatementAllow(true);
+        WallFilter wallFilter = new WallFilter();
+        wallFilter.setConfig(wallConfig);
+        List<Filter> filterList = ListUtils.newArrayList();
+        filterList.add(wallFilter);
+        dataSource.setProxyFilters(filterList);
+        return dataSource;
+    }
+
     @Bean("myRoutingDataSource")
     public DataSource myRoutingDataSource(@Qualifier("masterDataSource") DataSource masterDataSource,
                                           @Qualifier("slave1DataSource") DataSource slave1DataSource) {

+ 1 - 1
platform-dao/src/main/java/com/platform/dao/dto/check/CheckStandardDTO.java

@@ -113,7 +113,7 @@ public class CheckStandardDTO extends BaseDTO implements Serializable {
      */
     private Integer actionType;
     /**
-     * 检查类型: 1-点检 2-巡检
+     * 检查类型: 1-点检 2-保养 3-润滑
      */
     private Integer type;
 

+ 68 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/qykh/PlanVO.java

@@ -0,0 +1,68 @@
+package com.platform.dao.vo.query.qykh;
+
+import lombok.Data;
+import com.platform.common.bean.BaseVO;
+import com.platform.common.bean.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表VO结果类
+ * @Author xc
+ * @Date 2022-05-30 19:50:16
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class PlanVO extends BaseVO implements Serializable{
+
+    /**
+     * 主键id
+     */
+        private Integer id;
+        /**
+     * 方案类别名称
+     */
+        private String planname;
+        /**
+     * 类别说明
+     */
+        private String plandes;
+        /**
+     * 
+     */
+        private String shortdesc;
+        /**
+     * 
+     */
+        private Integer pid;
+        /**
+     * 
+     */
+        private Integer level;
+        /**
+     * 
+     */
+        private String purl;
+        /**
+     * 
+     */
+        private String bannerurl;
+        /**
+     * 
+     */
+        private Integer seoid;
+        /**
+     * 
+     */
+        private Integer ord;
+    
+
+
+}

+ 68 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/qykh/PlandetailsVO.java

@@ -0,0 +1,68 @@
+package com.platform.dao.vo.query.qykh;
+
+import lombok.Data;
+import com.platform.common.bean.BaseVO;
+import com.platform.common.bean.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表VO结果类
+ * @Author xc
+ * @Date 2022-05-30 19:50:40
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class PlandetailsVO extends BaseVO implements Serializable {
+
+    /**
+     *
+     */
+    private Integer id;
+    /**
+     * 详情标题
+     */
+    private String plantitle;
+    /**
+     *
+     */
+    private String plancontext;
+    /**
+     *
+     */
+    private String shortdesc;
+    /**
+     * 对应的类别id
+     */
+    private Integer planid;
+    /**
+     *
+     */
+    private Integer orderid;
+    /**
+     *
+     */
+    private String digest;
+    /**
+     *
+     */
+    private String keywords;
+    /**
+     *
+     */
+    private Integer seoid;
+    /**
+     *
+     */
+    private String time;
+
+
+}

+ 64 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/qykh/ProductHelpVO.java

@@ -0,0 +1,64 @@
+package com.platform.dao.vo.query.qykh;
+
+import lombok.Data;
+import com.platform.common.bean.BaseVO;
+import com.platform.common.bean.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表VO结果类
+ * @Author xc
+ * @Date 2022-05-30 19:45:56
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class ProductHelpVO extends BaseVO implements Serializable{
+
+    /**
+     * 
+     */
+        private Integer id;
+        /**
+     * 
+     */
+        private String title;
+        /**
+     * 
+     */
+        private String descr;
+        /**
+     * 
+     */
+        private String purl;
+        /**
+     * 对应的产品id
+     */
+        private Integer pid;
+        /**
+     * 
+     */
+        private String keywords;
+        /**
+     * 
+     */
+        private Integer ord;
+        /**
+     * 
+     */
+        private String digest;
+        /**
+     * 
+     */
+        private String time;
+    
+
+
+}

+ 84 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/qykh/ProductVO.java

@@ -0,0 +1,84 @@
+package com.platform.dao.vo.query.qykh;
+
+import lombok.Data;
+import com.platform.common.bean.BaseVO;
+import com.platform.common.bean.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义报表VO结果类
+ * @Author xc
+ * @Date 2022-05-30 19:49:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class ProductVO extends BaseVO implements Serializable{
+
+    /**
+     * 
+     */
+        private Integer id;
+        /**
+     * 
+     */
+        private Integer level;
+        /**
+     * 
+     */
+        private Integer pid;
+        /**
+     * 产品名称
+     */
+        private String pname;
+        /**
+     * 产品说明
+     */
+        private String desrc;
+        /**
+     * 
+     */
+        private String shortdesc;
+        /**
+     * 产品图片路径
+     */
+        private String purl;
+        /**
+     * 
+     */
+        private String bannerurl;
+        /**
+     * 
+     */
+        private Integer ord;
+        /**
+     * 
+     */
+        private String oname;
+        /**
+     * 
+     */
+        private Integer seoid;
+        /**
+     * 
+     */
+        private Integer iszt;
+        /**
+     * 
+     */
+        private String zturl;
+        /**
+     * 
+     */
+        private Integer iszhutui;
+    
+
+
+}

+ 32 - 0
platform-dao/src/main/resources/application-daoDev.yml

@@ -62,6 +62,38 @@ spring:
         #间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
         time-between-eviction-runs-millis: 60000
         validation-query: SELECT 'x'
+      qykh:
+        driver-class-name: com.mysql.cj.jdbc.Driver
+        url: jdbc:mysql://139.159.196.89:33306/qykh?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&allowMultiQueries=true
+        username: qykh
+        password: qykh@CQDWJS@!123
+        filters: wall,stat
+        filter:
+          stat:
+            log-slow-sql: true
+            #慢sql
+            slow-sql-millis: 1000
+        #初始化大小、最小、最大
+        initial-size: 1
+        max-active: 50
+        max-pool-prepared-statement-per-connection-size: 20
+        #获取连接等待超时的时间
+        max-wait: 60000
+        #一个连接在池中最小生存的时间,单位是毫秒
+        min-evictable-idle-time-millis: 300000
+        min-idle: 5
+        #打开PSCache,并且指定每个连接上PSCache的大小
+        #如果用Oracle,则把poolPreparedStatements配置为true,mysql可以配置为false。分库分表较多的数据库,建议配置为false。
+        pool-prepared-statements: false
+        test-on-borrow: true
+        test-on-return: true
+        test-while-idle: true
+        #间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        time-between-eviction-runs-millis: 60000
+        validation-query: SELECT 'x'
+        stat-view-servlet:
+          login-password: platform8888
+          login-username: root
       stat-view-servlet:
         login-password: platform8888
         login-username: root

+ 71 - 0
platform-rest/src/main/java/com/platform/rest/controller/qykh/QykhPlanDetails.java

@@ -0,0 +1,71 @@
+package com.platform.rest.controller.qykh;
+
+import com.platform.common.util.R;
+import com.platform.common.validation.group.AddGroup;
+import com.platform.common.validation.group.UpdateGroup;
+import com.platform.dao.dto.sb.SbTypeDTO;
+import com.platform.dao.entity.sb.SbType;
+import com.platform.dao.vo.query.qykh.PlandetailsVO;
+import com.platform.rest.log.annotation.SysLog;
+import com.platform.service.qykh.QykhPlanDetailsService;
+import lombok.AllArgsConstructor;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/qykh/plan/details")
+public class QykhPlanDetails {
+    private final QykhPlanDetailsService qykhPlanDetailsService;
+    /**
+     * 通过id查询单条记录
+     *
+     * @param id 主键
+     * @return R
+     */
+    @GetMapping("/{id}")
+    public R getById(@PathVariable("id") Integer id) {
+        return new R(qykhPlanDetailsService.selectSingle(id));
+    }
+
+    /**
+     * 新增记录
+     *
+     * @param sbTypeDTO 设备类别DTO
+     * @return R
+     */
+    @SysLog("新增设备类别")
+    @PostMapping
+    @PreAuthorize("@pms.hasPermission('sb-types-add')")
+    public R save(@Validated({AddGroup.class}) @RequestBody PlandetailsVO sbTypeDTO) {
+        return new R<>(qykhPlanDetailsService.insertSingle(sbTypeDTO));
+    }
+    
+    /**
+     * 获取分页
+     *
+     * @param pageNum 当前页码
+     * @param pageSize 每页条数
+     * @return R
+     */
+    @GetMapping("/page")
+    public R query(PlandetailsVO dto, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
+        return new R(qykhPlanDetailsService.selectPage(pageNum,pageSize,dto));
+    }
+
+    /**
+     * 修改某条记录
+     * @param infoAdapterVO 电子保函表DTO
+     * @return R
+     */
+    @SysLog("修改")
+    @PutMapping("/{id}")
+    @PreAuthorize("@pms.hasPermission('guarantee-guarantee-infos-edit')")
+    public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody PlandetailsVO infoAdapterVO) {
+        qykhPlanDetailsService.modModel(infoAdapterVO);
+        return new R();
+    }
+
+
+}

+ 41 - 0
platform-service/src/main/java/com/platform/service/qykh/QykhPlanDetailsService.java

@@ -0,0 +1,41 @@
+package com.platform.service.qykh;
+
+import com.platform.dao.bean.MyVOPage;
+import com.platform.dao.vo.query.qykh.PlandetailsVO;
+
+public interface QykhPlanDetailsService {
+
+    /**
+     * 单个数据插入
+     * @param vo
+     */
+    String insertSingle(PlandetailsVO vo);
+
+    /**
+     * 单个数据查询
+     *
+     * @param vo
+     */
+    String selectSingle(Integer id);
+
+    /**
+     * 更新
+     *
+     * @param vo
+     */
+    void modModel(PlandetailsVO vo);
+
+    /**
+     * 分页查询
+     * @param pageNum
+     * @param pageSize
+     * @param plandetailsVO 查询对象
+     */
+    MyVOPage<PlandetailsVO> selectPage(int pageNum, int pageSize, PlandetailsVO plandetailsVO );
+
+    /**
+     * 统一手动插入
+     * @param sql
+     */
+    void centerInsertBatch(String sql);
+}

+ 266 - 0
platform-service/src/main/java/com/platform/service/qykh/impl/QykhPlanDetailsServiceImpl.java

@@ -0,0 +1,266 @@
+package com.platform.service.qykh.impl;
+
+import com.github.pagehelper.Page;
+import com.platform.common.exception.BusinessException;
+import com.platform.common.exception.DeniedException;
+import com.platform.common.util.*;
+import com.platform.dao.bean.MyVOPage;
+import com.platform.dao.vo.query.qykh.PlandetailsVO;
+import com.platform.service.qykh.QykhPlanDetailsService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.sql.*;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service("qykhPlanDetailsService")
+@Slf4j
+public class QykhPlanDetailsServiceImpl implements QykhPlanDetailsService {
+    @Resource
+    private DataSource qykhDataSource;
+
+    @Value("${qykh.plandetails}")
+    private String info_table_name;
+
+    @Override
+    public MyVOPage<PlandetailsVO> selectPage(int pageNum, int pageSize, PlandetailsVO guaranteeInfoDTO) {
+        MyVOPage<PlandetailsVO> myVOPage = new MyVOPage<>();
+        myVOPage.setPageNum(pageNum);
+        myVOPage.setPageSize(pageSize);
+        Connection conn = null;
+        Statement stmt = null;
+        ResultSet rs = null;
+        StringBuffer querySql = new StringBuffer("select " +
+                "id," +
+                "plantitle," +
+                "plancontext," +
+                "shortdesc," +
+                "planid," +
+                "orderid," +
+                "digest," +
+                "keywords," +
+                "seoid, " +
+                "time ");
+        StringBuffer countSql = new StringBuffer("select count(*) ");
+        StringBuffer sql = new StringBuffer(" from " + info_table_name + " where 1 = 1 ");
+        if (StringUtils.isNotBlank(guaranteeInfoDTO.getPlantitle())) {
+            sql.append("and ProjectNo like '%" + guaranteeInfoDTO.getPlantitle() + "%' ");
+        }
+        sql.append(" order by Insert_Time desc ");
+        try {
+            conn = qykhDataSource.getConnection();
+            stmt = conn.createStatement();
+            // 获取总条数
+            rs = stmt.executeQuery(countSql.append(sql).toString());
+            rs.next();
+            long total = rs.getLong(1);
+            Page page = new Page(pageNum, pageSize);
+            page.setTotal(total);
+            myVOPage.setPages(page.getPages());
+            myVOPage.setTotal(total);
+            if (total < 1) {
+                myVOPage.setRows(new ArrayList<PlandetailsVO>());
+                return myVOPage;
+            }
+            int startNum = (pageNum - 1) * pageSize;
+            sql.append("limit " + startNum + "," + pageSize);
+            rs = stmt.executeQuery(querySql.append(sql).toString());
+            // 封装数据
+            myVOPage.setRows(packageInfo(rs));
+            rs.close();
+            stmt.close();
+            conn.close();
+            return myVOPage;
+        } catch (SQLException e1) {
+            e1.printStackTrace();
+            throw new DeniedException("获取宿州数据库连接失败" + e1.getCause().getMessage());
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (stmt != null) {
+                    stmt.close();
+                }
+                if (conn != null) {
+                    conn.close();
+                }
+            } catch (Exception e) {
+
+            }
+        }
+    }
+
+    @Override
+    public void modModel(PlandetailsVO vo) {
+        Connection conn = null;
+        Statement stmt = null;
+        StringBuffer updateSql = new StringBuffer("update " + info_table_name + " set " +
+                "plantitle='" + vo.getPlantitle() +
+                "',plancontext='" + vo.getPlancontext() +
+                "',shortdesc='" + vo.getShortdesc() +
+                "',planid='" + vo.getPlanid() +
+                "',orderid='" + vo.getOrderid() +
+                "',digest='" + vo.getDigest() +
+                "',keywords='" + vo.getKeywords() +
+                "',seoid='" + vo.getSeoid() +
+                "',time='" + vo.getTime() +
+                "' where id='" + vo.getId() + "'");
+        log.info("更新数据:" + updateSql);
+        try {
+            conn = qykhDataSource.getConnection();
+            stmt = conn.createStatement();
+            // 获取总条数
+            int result = stmt.executeUpdate(updateSql.toString());
+            if (result != 1) {
+                throw new BusinessException("");
+            }
+            stmt.close();
+            conn.close();
+        } catch (SQLException e1) {
+            e1.printStackTrace();
+            throw new DeniedException("获取宿州数据库连接失败" + e1.getCause().getMessage());
+        } finally {
+            try {
+                if (stmt != null) {
+                    stmt.close();
+                }
+                if (conn != null) {
+                    conn.close();
+                }
+            } catch (Exception e) {
+
+            }
+        }
+    }
+
+    private List<PlandetailsVO> packageInfo(ResultSet rs) throws SQLException {
+        List<PlandetailsVO> list = new ArrayList<>();
+        while (rs.next()) {
+            PlandetailsVO vo = new PlandetailsVO();
+            vo.setId(rs.getInt(1));
+            vo.setPlantitle(rs.getString(2));
+            vo.setPlancontext(rs.getString(3));
+            vo.setShortdesc(rs.getString(4));
+            vo.setPlanid(rs.getInt(5));
+            vo.setOrderid(rs.getInt(6));
+            vo.setDigest(rs.getString(7));
+            vo.setKeywords(rs.getString(8));
+            vo.setSeoid(rs.getInt(9));
+            vo.setTime(rs.getString(10));
+            list.add(vo);
+        }
+        return list;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public String insertSingle(PlandetailsVO vo) {
+        try {
+            if (vo != null) {
+                if (vo.getTime() == null) {
+                    vo.setTime(DateUtils.dateToString(LocalDateTime.now(), DateUtils.PATTERN_YMD_HMS));
+                }
+                StringBuffer sql = new StringBuffer();
+                sql.append("insert into " + info_table_name +
+                        " (plantitle,plancontext,shortdesc,planid,orderid,digest,keywords,seoid,time) values ");
+                sql.append("('");
+                sql.append("'" + vo.getPlantitle() + "',");
+                sql.append("'" + vo.getPlancontext() + "',");
+                sql.append("'" + vo.getShortdesc() + "',");
+                sql.append("'" + vo.getPlanid() + "',");
+                sql.append("'" + vo.getOrderid() + "',");
+                sql.append("'" + vo.getDigest() + "',");
+                sql.append("'" + vo.getKeywords() + "',");
+                sql.append("'" + vo.getSeoid() + "',");
+                sql.append("'" + vo.getTime() + "',");
+                sql.append(")");
+                log.info("----------" + sql.toString());
+                centerInsertBatch(sql.toString());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            //throw new DeniedException("单个宿州交易中心失败,请联系技术处理");
+        }
+        return "推送成功";
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void centerInsertBatch(String sql) {
+        Connection conn = null;
+        Statement stmt = null;
+        try {
+            conn = qykhDataSource.getConnection();
+            stmt = conn.createStatement();
+            stmt.executeUpdate(sql);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                stmt.close();
+                conn.close();
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public String selectSingle(Integer id) {
+        try {
+            StringBuffer sql = new StringBuffer();
+            sql.append("select " +
+                    "plantitle," +
+                    "plancontext," +
+                    "shortdesc," +
+                    "planid," +
+                    "orderid," +
+                    "digest," +
+                    "keywords," +
+                    "seoid, " +
+                    "time " +
+                    "from "
+                    + info_table_name + " where id = '" + id + "'");
+            ResultSet set = queryQykh(sql.toString());
+            log.info(sql.toString());
+            if (set != null) {
+                log.info(JsonUtils.objectToJson(set));
+                return JsonUtils.objectToJson(set);
+            }
+            return id + "";
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public ResultSet queryQykh(String sql) {
+        Connection conn = null;
+        Statement stmt = null;
+        try {
+            conn = qykhDataSource.getConnection();
+            stmt = conn.createStatement();
+            return stmt.executeQuery(sql);
+        } catch (Exception e) {
+            log.info(e.getCause().getMessage());
+            e.printStackTrace();
+            //throw new DeniedException("交易中心插入报错"+e.getCause().getMessage());
+        } finally {
+            try {
+                stmt.close();
+                conn.close();
+            } catch (Exception e1) {
+                e1.printStackTrace();
+            }
+        }
+        return null;
+    }
+}

+ 2 - 0
platform-service/src/main/resources/application-serviceDev.yml

@@ -0,0 +1,2 @@
+qykh:
+  plandetails: qykh_plandetails

+ 2 - 0
platform-service/src/main/resources/application-serviceProd.yml

@@ -0,0 +1,2 @@
+qykh:
+  plandetails: qykh_plandetails

+ 2 - 0
platform-service/src/main/resources/application-serviceTest.yml

@@ -0,0 +1,2 @@
+qykh:
+  plandetails: qykh_plandetails