Commit 764e13b7 by jiang'yun

修改

parent 06c00f6f
package com.zjsgfa.project.zjsgfa.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjsgfa.framework.aspectj.lang.annotation.Log;
import com.zjsgfa.framework.aspectj.lang.enums.BusinessType;
import com.zjsgfa.project.zjsgfa.domain.CommonFile;
import com.zjsgfa.project.zjsgfa.service.ICommonFileService;
import com.zjsgfa.framework.web.controller.BaseController;
import com.zjsgfa.framework.web.domain.AjaxResult;
import com.zjsgfa.common.utils.poi.ExcelUtil;
import com.zjsgfa.framework.web.page.TableDataInfo;
/**
* 文件Controller
*
* @author ruoyi
* @date 2025-10-27
*/
@RestController
@RequestMapping("/system/commonFile")
public class CommonFileController extends BaseController
{
@Autowired
private ICommonFileService commonFileService;
/**
* 查询文件列表
*/
//@PreAuthorize("@ss.hasPermi('system:commonFile:list')")
@GetMapping("/list")
public TableDataInfo list(CommonFile commonFile)
{
// startPage();
List<CommonFile> list = commonFileService.selectCommonFileList(commonFile);
return getDataTable(list);
}
/**
* 导出文件列表
*/
//@PreAuthorize("@ss.hasPermi('system:commonFile:export')")
@Log(title = "文件", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CommonFile commonFile)
{
List<CommonFile> list = commonFileService.selectCommonFileList(commonFile);
ExcelUtil<CommonFile> util = new ExcelUtil<CommonFile>(CommonFile.class);
util.exportExcel(response, list, "文件数据");
}
/**
* 获取文件详细信息
*/
//@PreAuthorize("@ss.hasPermi('system:commonFile:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(commonFileService.selectCommonFileById(id));
}
/**
* 新增文件
*/
//@PreAuthorize("@ss.hasPermi('system:commonFile:add')")
@Log(title = "文件", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CommonFile commonFile)
{
return toAjax(commonFileService.insertCommonFile(commonFile));
}
/**
* 修改文件
*/
//@PreAuthorize("@ss.hasPermi('system:commonFile:edit')")
@Log(title = "文件", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CommonFile commonFile)
{
return toAjax(commonFileService.updateCommonFile(commonFile));
}
/**
* 删除文件
*/
//@PreAuthorize("@ss.hasPermi('system:commonFile:remove')")
@Log(title = "文件", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(commonFileService.deleteCommonFileByIds(ids));
}
}
......@@ -17,14 +17,17 @@ import com.deepoove.poi.plugin.table.LoopColumnTableRenderPolicy;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.zjsgfa.common.constant.Constants;
import com.zjsgfa.common.utils.SecurityUtils;
import com.zjsgfa.common.utils.StringUtils;
import com.zjsgfa.common.utils.bean.BeanUtils;
import com.zjsgfa.common.utils.file.FileUploadUtils;
import com.zjsgfa.framework.config.RuoYiConfig;
import com.zjsgfa.framework.config.ServerConfig;
import com.zjsgfa.project.zjsgfa.domain.*;
import com.zjsgfa.project.zjsgfa.domain.Vo.DrillingFluidConstant;
import com.zjsgfa.project.zjsgfa.mapper.*;
import com.zjsgfa.project.zjsgfa.service.ICommonFileService;
import com.zjsgfa.project.zjsgfa.service.ISjZjyFdxnbService;
import com.zjsgfa.project.zjsgfa.util.CxszhUtil;
import com.zjsgfa.project.zjsgfa.util.ImageProcessUtil;
......@@ -205,6 +208,10 @@ public class SjDjjcController extends BaseController
private SjFdfxMapper sjFdfxMapper;
@Autowired
private ICommonFileService commonFileService;
......@@ -382,6 +389,25 @@ public class SjDjjcController extends BaseController
@ResponseBody
public AjaxResult importData(MultipartFile file, boolean updateSupport,SjDjjc sjDjjc) throws Exception
{
String name = file.getOriginalFilename();
String type = StringUtils.substringAfterLast(name, ".");
String fileNameYs = name.substring(0,name.lastIndexOf("."));
String filePath1 = RuoYiConfig.getUploadPath();
String fileName1 = FileUploadUtils.upload(filePath1, file);
CommonFile upFile = new CommonFile();
upFile.setFileName(fileNameYs);//文件名
upFile.setFilePath(fileName1);//文件路径
upFile.setFileSuffix(type);//后缀
upFile.setFileType(type);//文件类型
upFile.setTemplateName("模板数据导入");//文件类型
upFile.setType("施工方案设计");//文件类型
upFile.setBusinessId(sjDjjc.getId().toString());//文件类型
// upFile.setCreatedBy(SecurityUtils.getUsername());//创建人
upFile.setCreatedTime(new Date());//创建时间
commonFileService.insertCommonFile(upFile);
XSSFWorkbook workbook = null;
try {
//装载流
......@@ -1864,6 +1890,30 @@ public class SjDjjcController extends BaseController
return AjaxResult.success(sjFdfxList);
}
@PostMapping("/dr")
@ResponseBody
public AjaxResult importData(MultipartFile file,CommonFile upFile) throws Exception{
String name = file.getOriginalFilename();
String type = StringUtils.substringAfterLast(name, ".");
String fileNameYs = name.substring(0,name.lastIndexOf("."));
String filePath = RuoYiConfig.getUploadPath();
String fileName = FileUploadUtils.upload(filePath, file);
upFile.setFileName(fileNameYs);//文件名
upFile.setFilePath(fileName);//文件路径
upFile.setFileSuffix(type);//后缀
upFile.setFileType(type);//文件类型
// upFile.setCreatedBy(SecurityUtils.getUsername());//创建人
upFile.setCreatedTime(new Date());//创建时间
int i = commonFileService.insertCommonFile(upFile);
return AjaxResult.success("上传成功");
}
/**
* 计算邻井井组
......
package com.zjsgfa.project.zjsgfa.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zjsgfa.framework.aspectj.lang.annotation.Excel;
import com.zjsgfa.framework.web.domain.BaseEntity;
import lombok.Data;
/**
* 文件对象 common_file
*
* @author ruoyi
* @date 2025-10-27
*/
@Data
public class CommonFile extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 业务id */
@Excel(name = "业务id")
private String businessId;
/** 文件名 */
@Excel(name = "文件名")
private String fileName;
/** 后缀名 */
@Excel(name = "后缀名")
private String fileSuffix;
/** 文件类型 */
@Excel(name = "文件类型")
private String fileType;
/** 文件路径 */
@Excel(name = "文件路径")
private String filePath;
/** 业务类型 */
@Excel(name = "业务类型")
private String type;
/** 模板名 */
@Excel(name = "模板名")
private String templateName;
/** 创建人 */
@Excel(name = "创建人")
private String createdBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdTime;
/** 备用1 */
@Excel(name = "备用1")
private String ext1;
/** 备用2 */
@Excel(name = "备用2")
private String ext2;
/** 备用3 */
@Excel(name = "备用3")
private String ext3;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long height;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long width;
}
package com.zjsgfa.project.zjsgfa.mapper;
import java.util.List;
import com.zjsgfa.project.zjsgfa.domain.CommonFile;
/**
* 文件Mapper接口
*
* @author ruoyi
* @date 2025-10-27
*/
public interface CommonFileMapper
{
/**
* 查询文件
*
* @param id 文件主键
* @return 文件
*/
public CommonFile selectCommonFileById(Long id);
/**
* 查询文件列表
*
* @param commonFile 文件
* @return 文件集合
*/
public List<CommonFile> selectCommonFileList(CommonFile commonFile);
/**
* 新增文件
*
* @param commonFile 文件
* @return 结果
*/
public int insertCommonFile(CommonFile commonFile);
/**
* 修改文件
*
* @param commonFile 文件
* @return 结果
*/
public int updateCommonFile(CommonFile commonFile);
/**
* 删除文件
*
* @param id 文件主键
* @return 结果
*/
public int deleteCommonFileById(Long id);
/**
* 批量删除文件
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCommonFileByIds(Long[] ids);
}
package com.zjsgfa.project.zjsgfa.service;
import java.util.List;
import com.zjsgfa.project.zjsgfa.domain.CommonFile;
/**
* 文件Service接口
*
* @author ruoyi
* @date 2025-10-27
*/
public interface ICommonFileService
{
/**
* 查询文件
*
* @param id 文件主键
* @return 文件
*/
public CommonFile selectCommonFileById(Long id);
/**
* 查询文件列表
*
* @param commonFile 文件
* @return 文件集合
*/
public List<CommonFile> selectCommonFileList(CommonFile commonFile);
/**
* 新增文件
*
* @param commonFile 文件
* @return 结果
*/
public int insertCommonFile(CommonFile commonFile);
/**
* 修改文件
*
* @param commonFile 文件
* @return 结果
*/
public int updateCommonFile(CommonFile commonFile);
/**
* 批量删除文件
*
* @param ids 需要删除的文件主键集合
* @return 结果
*/
public int deleteCommonFileByIds(Long[] ids);
/**
* 删除文件信息
*
* @param id 文件主键
* @return 结果
*/
public int deleteCommonFileById(Long id);
}
package com.zjsgfa.project.zjsgfa.service.impl;
import java.util.List;
import com.zjsgfa.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zjsgfa.project.zjsgfa.mapper.CommonFileMapper;
import com.zjsgfa.project.zjsgfa.domain.CommonFile;
import com.zjsgfa.project.zjsgfa.service.ICommonFileService;
/**
* 文件Service业务层处理
*
* @author ruoyi
* @date 2025-10-27
*/
@Service
public class CommonFileServiceImpl implements ICommonFileService
{
@Autowired
private CommonFileMapper commonFileMapper;
/**
* 查询文件
*
* @param id 文件主键
* @return 文件
*/
@Override
public CommonFile selectCommonFileById(Long id)
{
return commonFileMapper.selectCommonFileById(id);
}
/**
* 查询文件列表
*
* @param commonFile 文件
* @return 文件
*/
@Override
public List<CommonFile> selectCommonFileList(CommonFile commonFile)
{
return commonFileMapper.selectCommonFileList(commonFile);
}
/**
* 新增文件
*
* @param commonFile 文件
* @return 结果
*/
@Override
public int insertCommonFile(CommonFile commonFile)
{
return commonFileMapper.insertCommonFile(commonFile);
}
/**
* 修改文件
*
* @param commonFile 文件
* @return 结果
*/
@Override
public int updateCommonFile(CommonFile commonFile)
{
commonFile.setUpdateTime(DateUtils.getNowDate());
return commonFileMapper.updateCommonFile(commonFile);
}
/**
* 批量删除文件
*
* @param ids 需要删除的文件主键
* @return 结果
*/
@Override
public int deleteCommonFileByIds(Long[] ids)
{
return commonFileMapper.deleteCommonFileByIds(ids);
}
/**
* 删除文件信息
*
* @param id 文件主键
* @return 结果
*/
@Override
public int deleteCommonFileById(Long id)
{
return commonFileMapper.deleteCommonFileById(id);
}
}
<?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="com.zjsgfa.project.zjsgfa.mapper.CommonFileMapper">
<resultMap type="CommonFile" id="CommonFileResult">
<result property="id" column="id" />
<result property="businessId" column="business_id" />
<result property="fileName" column="file_name" />
<result property="fileSuffix" column="file_suffix" />
<result property="fileType" column="file_type" />
<result property="filePath" column="file_path" />
<result property="type" column="type" />
<result property="templateName" column="template_name" />
<result property="createdBy" column="created_by" />
<result property="createdTime" column="created_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="ext1" column="ext1" />
<result property="ext2" column="ext2" />
<result property="ext3" column="ext3" />
<result property="height" column="height" />
<result property="width" column="width" />
</resultMap>
<sql id="selectCommonFileVo">
select id, business_id, file_name, file_suffix, file_type, file_path, type, template_name, created_by, created_time, update_by, update_time, ext1, ext2, ext3, height, width from common_file
</sql>
<select id="selectCommonFileList" parameterType="CommonFile" resultMap="CommonFileResult">
<include refid="selectCommonFileVo"/>
<where>
<if test="businessId != null and businessId != ''"> and business_id = #{businessId}</if>
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
<if test="fileSuffix != null and fileSuffix != ''"> and file_suffix = #{fileSuffix}</if>
<if test="fileType != null and fileType != ''"> and file_type = #{fileType}</if>
<if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="ext1 != null and ext1 != ''"> and ext1 = #{ext1}</if>
<if test="ext2 != null and ext2 != ''"> and ext2 = #{ext2}</if>
<if test="ext3 != null and ext3 != ''"> and ext3 = #{ext3}</if>
<if test="height != null "> and height = #{height}</if>
<if test="width != null "> and width = #{width}</if>
</where>
order by createdTime desc
</select>
<select id="selectCommonFileById" parameterType="Long" resultMap="CommonFileResult">
<include refid="selectCommonFileVo"/>
where id = #{id}
</select>
<insert id="insertCommonFile" parameterType="CommonFile" useGeneratedKeys="true" keyProperty="id">
insert into common_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="businessId != null">business_id,</if>
<if test="fileName != null">file_name,</if>
<if test="fileSuffix != null">file_suffix,</if>
<if test="fileType != null">file_type,</if>
<if test="filePath != null">file_path,</if>
<if test="type != null">type,</if>
<if test="templateName != null">template_name,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="ext1 != null">ext1,</if>
<if test="ext2 != null">ext2,</if>
<if test="ext3 != null">ext3,</if>
<if test="height != null">height,</if>
<if test="width != null">width,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="businessId != null">#{businessId},</if>
<if test="fileName != null">#{fileName},</if>
<if test="fileSuffix != null">#{fileSuffix},</if>
<if test="fileType != null">#{fileType},</if>
<if test="filePath != null">#{filePath},</if>
<if test="type != null">#{type},</if>
<if test="templateName != null">#{templateName},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="ext1 != null">#{ext1},</if>
<if test="ext2 != null">#{ext2},</if>
<if test="ext3 != null">#{ext3},</if>
<if test="height != null">#{height},</if>
<if test="width != null">#{width},</if>
</trim>
</insert>
<update id="updateCommonFile" parameterType="CommonFile">
update common_file
<trim prefix="SET" suffixOverrides=",">
<if test="businessId != null">business_id = #{businessId},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="fileSuffix != null">file_suffix = #{fileSuffix},</if>
<if test="fileType != null">file_type = #{fileType},</if>
<if test="filePath != null">file_path = #{filePath},</if>
<if test="type != null">type = #{type},</if>
<if test="templateName != null">template_name = #{templateName},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="ext1 != null">ext1 = #{ext1},</if>
<if test="ext2 != null">ext2 = #{ext2},</if>
<if test="ext3 != null">ext3 = #{ext3},</if>
<if test="height != null">height = #{height},</if>
<if test="width != null">width = #{width},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCommonFileById" parameterType="Long">
delete from common_file where id = #{id}
</delete>
<delete id="deleteCommonFileByIds" parameterType="String">
delete from common_file where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
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