Browse Source

参数库类

chenr 5 months ago
parent
commit
6b53963187

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ParameterElementController.java

@@ -193,7 +193,7 @@ public class ParameterElementController extends BladeController {
     @ApiOperationSupport(order = 9)
     @ApiOperation("根据参数id获取项目合同信息")
     public R<List<ProjectInfoVO1>> getProjectContract(@RequestParam Long parameterId){
-        String sql="select a.project_id,b.project_name from m_parameter_element a left join m_project_info b on a.project_id=b.id where a.parameter_id="+parameterId+" and a.is_deleted=0";
+        String sql="select distinct a.project_id,b.project_name from m_parameter_element a left join m_project_info b on a.project_id=b.id where a.parameter_id="+parameterId+" and a.is_deleted=0";
         List<ProjectInfoVO1> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ProjectInfoVO1.class));
         return R.data(list);
     }

+ 42 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ParameterElementMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.mapper;
+
+import org.springblade.manager.entity.ParameterElement;
+import org.springblade.manager.vo.ParameterElementVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 参数库元素表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+public interface ParameterElementMapper extends BaseMapper<ParameterElement> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param parameterElement
+	 * @return
+	 */
+	List<ParameterElementVO> selectParameterElementPage(IPage page, ParameterElementVO parameterElement);
+
+}

+ 30 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ParameterElementMapper.xml

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.manager.mapper.ParameterElementMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="parameterElementResultMap" type="org.springblade.manager.entity.ParameterElement">
+        <result column="id" property="id"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="parameter_id" property="parameterId"/>
+        <result column="element_name" property="elementName"/>
+        <result column="type" property="type"/>
+        <result column="element_type" property="elementType"/>
+        <result column="project_id" property="projectId"/>
+        <result column="project_name" property="projectName"/>
+        <result column="contract_id" property="contractId"/>
+        <result column="contract_name" property="contractName"/>
+    </resultMap>
+
+
+    <select id="selectParameterElementPage" resultMap="parameterElementResultMap">
+        select * from m_parameter_element where is_deleted = 0
+    </select>
+
+</mapper>

+ 42 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ParameterMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.mapper;
+
+import org.springblade.manager.entity.Parameter;
+import org.springblade.manager.vo.ParameterVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 参数库 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+public interface ParameterMapper extends BaseMapper<Parameter> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param parameter
+	 * @return
+	 */
+	List<ParameterVO> selectParameterPage(IPage page, ParameterVO parameter);
+
+}

+ 26 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ParameterMapper.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.manager.mapper.ParameterMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="parameterResultMap" type="org.springblade.manager.entity.Parameter">
+        <result column="id" property="id"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="param_name" property="paramName"/>
+        <result column="param_type" property="paramType"/>
+        <result column="type" property="type"/>
+        <result column="remarks" property="remarks"/>
+    </resultMap>
+
+
+    <select id="selectParameterPage" resultMap="parameterResultMap">
+        select * from m_parameter where is_deleted = 0
+    </select>
+
+</mapper>

+ 45 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IParameterElementService.java

@@ -0,0 +1,45 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service;
+
+import org.springblade.manager.dto.ParameterElementDTO;
+import org.springblade.manager.entity.ParameterElement;
+import org.springblade.manager.vo.ParameterElementVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import java.util.List;
+
+/**
+ * 参数库元素表 服务类
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+public interface IParameterElementService extends BaseService<ParameterElement> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param parameterElement
+	 * @return
+	 */
+	IPage<ParameterElementVO> selectParameterElementPage(IPage<ParameterElementVO> page, ParameterElementVO parameterElement);
+
+    List<ParameterElementVO> getParameterElementList(ParameterElementDTO dto);
+}

+ 41 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IParameterService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service;
+
+import org.springblade.manager.entity.Parameter;
+import org.springblade.manager.vo.ParameterVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 参数库 服务类
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+public interface IParameterService extends BaseService<Parameter> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param parameter
+	 * @return
+	 */
+	IPage<ParameterVO> selectParameterPage(IPage<ParameterVO> page, ParameterVO parameter);
+
+}

+ 91 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ParameterElementServiceImpl.java

@@ -0,0 +1,91 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service.impl;
+
+import org.springblade.manager.dto.ParameterElementDTO;
+import org.springblade.manager.entity.ContractInfo;
+import org.springblade.manager.entity.ParameterElement;
+import org.springblade.manager.entity.ProjectInfo;
+import org.springblade.manager.vo.ParameterElementVO;
+import org.springblade.manager.mapper.ParameterElementMapper;
+import org.springblade.manager.service.IParameterElementService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 参数库元素表 服务实现类
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+@Service
+public class ParameterElementServiceImpl extends BaseServiceImpl<ParameterElementMapper, ParameterElement> implements IParameterElementService {
+
+    @Resource
+    private JdbcTemplate jdbcTemplate;
+	@Override
+	public IPage<ParameterElementVO> selectParameterElementPage(IPage<ParameterElementVO> page, ParameterElementVO parameterElement) {
+		return page.setRecords(baseMapper.selectParameterElementPage(page, parameterElement));
+	}
+
+    @Override
+    public List<ParameterElementVO> getParameterElementList(ParameterElementDTO dto) {
+        StringBuilder SQL=new StringBuilder("SELECT a.*,b.name FROM m_parameter_element a left join blade_user b on a.create_user=b.id where a.parameter_id="+dto.getParameterId()+" and a.is_deleted=0 ");
+        if(dto.getProjectId()!=null){
+            SQL.append(" and a.project_id="+dto.getProjectId());
+        }
+        if(dto.getContractId()!=null&&!dto.getContractId().equals("")){
+            SQL.append(" and a.contract_id like '%"+dto.getContractId()+"%'");
+        }
+        if(dto.getElementName()!=null&&!dto.getElementName().equals("")){
+            SQL.append(" and a.element_name like '%"+dto.getElementName()+"%'");
+        }
+
+        List<ParameterElementVO> vos = jdbcTemplate.query(SQL.toString(), new BeanPropertyRowMapper<>(ParameterElementVO.class));
+        if(vos.size()>0){
+            for (ParameterElementVO vo : vos) {
+                if(vo.getProjectId()!=null&&!vo.getProjectId().equals("")){
+                    String sql1="select project_name from m_project_info where id="+vo.getProjectId()+" and is_deleted=0";
+                    List<ProjectInfo> query = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
+                    vo.setProjectName(query.get(0).getProjectName());
+                }
+                if (vo.getContractId()!=null&&!vo.getContractId().equals("")) {
+                    String contractIds =vo.getContractId();
+                    String[] ids = contractIds.split(",");
+                    String contractName="";
+                    for (String id : ids) {
+                        String sql2="select contract_name from m_contract_info where id="+id+" and is_deleted=0";
+                        List<ContractInfo> query1 = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(ContractInfo.class));
+                        contractName=contractName+","+query1.get(0).getContractName();
+                    }
+                    if (contractName.startsWith(",")) {
+                        contractName = contractName.substring(1);
+                    }
+                    vo.setContractName(contractName);
+                }
+            }
+        }
+        return vos;
+    }
+
+}

+ 41 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ParameterServiceImpl.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.service.impl;
+
+import org.springblade.manager.entity.Parameter;
+import org.springblade.manager.vo.ParameterVO;
+import org.springblade.manager.mapper.ParameterMapper;
+import org.springblade.manager.service.IParameterService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 参数库 服务实现类
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+@Service
+public class ParameterServiceImpl extends BaseServiceImpl<ParameterMapper, Parameter> implements IParameterService {
+
+	@Override
+	public IPage<ParameterVO> selectParameterPage(IPage<ParameterVO> page, ParameterVO parameter) {
+		return page.setRecords(baseMapper.selectParameterPage(page, parameter));
+	}
+
+}

+ 49 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/wrapper/ParameterElementWrapper.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.manager.entity.ParameterElement;
+import org.springblade.manager.vo.ParameterElementVO;
+import java.util.Objects;
+
+/**
+ * 参数库元素表包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2025-02-21
+ */
+public class ParameterElementWrapper extends BaseEntityWrapper<ParameterElement, ParameterElementVO>  {
+
+	public static ParameterElementWrapper build() {
+		return new ParameterElementWrapper();
+ 	}
+
+	@Override
+	public ParameterElementVO entityVO(ParameterElement parameterElement) {
+		ParameterElementVO parameterElementVO = Objects.requireNonNull(BeanUtil.copy(parameterElement, ParameterElementVO.class));
+
+		//User createUser = UserCache.getUser(parameterElement.getCreateUser());
+		//User updateUser = UserCache.getUser(parameterElement.getUpdateUser());
+		//parameterElementVO.setCreateUserName(createUser.getName());
+		//parameterElementVO.setUpdateUserName(updateUser.getName());
+
+		return parameterElementVO;
+	}
+
+}

+ 49 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/wrapper/ParameterWrapper.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.manager.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.manager.entity.Parameter;
+import org.springblade.manager.vo.ParameterVO;
+import java.util.Objects;
+
+/**
+ * 参数库包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2025-02-20
+ */
+public class ParameterWrapper extends BaseEntityWrapper<Parameter, ParameterVO>  {
+
+	public static ParameterWrapper build() {
+		return new ParameterWrapper();
+ 	}
+
+	@Override
+	public ParameterVO entityVO(Parameter parameter) {
+		ParameterVO parameterVO = Objects.requireNonNull(BeanUtil.copy(parameter, ParameterVO.class));
+
+		//User createUser = UserCache.getUser(parameter.getCreateUser());
+		//User updateUser = UserCache.getUser(parameter.getUpdateUser());
+		//parameterVO.setCreateUserName(createUser.getName());
+		//parameterVO.setUpdateUserName(updateUser.getName());
+
+		return parameterVO;
+	}
+
+}