文件bug修改

This commit is contained in:
guoshengxiong 2024-04-19 13:57:29 +08:00
parent 691772b73b
commit 1d05f53d0a
8 changed files with 118 additions and 23 deletions

View File

@ -12,14 +12,11 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
@ -46,7 +43,8 @@ public class CompanyFileController {
@ApiOperation(value = "分页查询企业的文件资料记录", notes = "分页查询企业的文件资料记录")
@ApiImplicitParams({
@ApiImplicitParam(name = "fileName", value = "文件名称", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "companySn", value = "企业总部sn", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "companySn", value = "企业sn", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "body", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
})
@ -55,6 +53,18 @@ public class CompanyFileController {
return Result.success(companyFileService.selectCompanyFileList(map));
}
@ApiOperation(value = "分页查询自己企业的文件资料记录", notes = "分页查询自己企业的文件资料记录")
@ApiImplicitParams({
@ApiImplicitParam(name = "fileName", value = "文件名称", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "companySn", value = "企业总部sn", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "body", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
})
@PostMapping("/my/list")
public Result<Map<String, Object>> selectMyCompanyFileList(@RequestBody Map<String, Object> map) {
return Result.success(companyFileService.selectMyCompanyFileList(map));
}
/**
* 添加
*

View File

@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -64,4 +63,10 @@ public interface CompanyMapper extends BaseMapper<Company> {
EntityMap getCompanyInfosByProjectSn(String projectSn);
Company getCompanyByUserId(Long userId);
Company getParentCompanySn(Map<String, Object> map);
Company getCompanyForProjectByProjectSn(String projectSn);
}

View File

@ -10,19 +10,38 @@
<select id="selectCompanyFileList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
SELECT a.*,b.company_name
from company_file a LEFT JOIN company b ON a.company_sn=b.company_sn
WHERE a.company_sn=#{param.companySn}
<if test="param.fileName!=null and param.fileName!=''">
WHERE 1=1
<if test="param.companySn != null and param.companySn != ''">
and a.company_sn=#{param.companySn}
</if>
<if test="param.fileName != null and param.fileName != ''">
and a.file_name like CONCAT(CONCAT('%',#{param.fileName}),'%')
</if>
<if test="param.inSnList != null and param.inSnList.size() > 0">
and a.company_sn in
<foreach collection="param.inSnList" item="item" index="index"
separator="," open="(" close=")">
#{item}
</foreach>
</if>
order by a.create_time desc
</select>
<select id="getTotleFileGroup" resultType="java.util.Map" parameterType="map">
SELECT COUNT(DISTINCT a.id) fileNum,IFNULL(SUM(IFNULL(a.download_num,0)),0) downloadNum
from company_file a
WHERE a.company_sn=#{companySn}
<if test="fileName!=null and fileName!=''">
WHERE 1=1
<if test="companySn != null and companySn != ''">
and a.company_sn=#{companySn}
</if>
<if test="fileName != null and fileName != ''">
and a.file_name like CONCAT(CONCAT('%',#{fileName}),'%')
</if>
<if test="inSnList != null and inSnList.size() > 0">
and a.company_sn in
<foreach collection="inSnList" item="item" index="index"
separator="," open="(" close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
</mapper>

View File

@ -298,4 +298,19 @@
and a.project_sn=#{projectSn}
</where>
</select>
<select id="getCompanyByUserId" resultType="com.zhgd.xmgl.modules.basicdata.entity.Company">
select * from company where company_sn = (select sn from system_user where user_id = #{userId})
</select>
<select id="getParentCompanySn" resultType="com.zhgd.xmgl.modules.basicdata.entity.Company">
select * from company c join company p on c.company_id=p.parent_id
where p.company_sn=#{sn}
</select>
<select id="getCompanyForProjectByProjectSn" resultType="com.zhgd.xmgl.modules.basicdata.entity.Company">
select c.* from company c
join project p on p.company_sn=c.company_sn
where p.project_sn=#{projectSn}
</select>
</mapper>

View File

@ -15,6 +15,8 @@ public interface ICompanyFileService extends IService<CompanyFile> {
Map<String, Object> selectCompanyFileList(Map<String, Object> map);
Map<String, Object> selectMyCompanyFileList(Map<String, Object> map);
void updateFileDownloadNum(Map<String, Object> map);
void add(CompanyFile companyFile);

View File

@ -1,27 +1,25 @@
package com.zhgd.xmgl.modules.basicdata.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.basicdata.entity.Company;
import com.zhgd.xmgl.modules.basicdata.entity.CompanyFile;
import com.zhgd.xmgl.modules.basicdata.mapper.CompanyFileMapper;
import com.zhgd.xmgl.modules.basicdata.mapper.CompanyMapper;
import com.zhgd.xmgl.modules.basicdata.service.ICompanyFileService;
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @Description: 企业文件资料
@ -34,9 +32,52 @@ import java.util.Map;
public class CompanyFileServiceImpl extends ServiceImpl<CompanyFileMapper, CompanyFile> implements ICompanyFileService {
@Autowired
private CompanyFileMapper companyFileMapper;
@Autowired
private CompanyMapper companyMapper;
@Autowired
private ICompanyService companyService;
@Override
public Map<String, Object> selectCompanyFileList(Map<String, Object> map) {
String companySn = MapUtils.getString(map, "companySn");
String projectSn = MapUtils.getString(map, "projectSn");
Map<String, Object> data = new HashMap<>();
map.put("companySn", null);
int pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());
Page<EntityMap> page = new Page<>(pageNo, pageSize);
if (StrUtil.isNotBlank(projectSn)) {
Company c = companyMapper.getCompanyForProjectByProjectSn(projectSn);
if (c == null) {
throw new OpenAlertException("企业不存在");
}
map.put("sn", c.getCompanySn());
} else {
map.put("sn", companySn);
}
//查父级企业sn
Set<String> inSnList = new HashSet<>();
inSnList.add(companySn);
Company c1 = null;
do {
c1 = companyMapper.getParentCompanySn(map);
if (c1 != null) {
inSnList.add(c1.getCompanySn());
map.put("sn", c1.getCompanySn());
inSnList.add(c1.getHeadquartersSn());
}
} while (c1 != null);
map.put("inSnList", inSnList);
List<EntityMap> list = companyFileMapper.selectCompanyFileList(page, map);
page.setRecords(list);
Map<String, Object> result = companyFileMapper.getTotleFileGroup(map);
data.put("page", page);
data.put("totalNum", result);
return data;
}
@Override
public Map<String, Object> selectMyCompanyFileList(Map<String, Object> map) {
Map<String, Object> data = new HashMap<>();
int pageNo = Integer.parseInt(map.getOrDefault("pageNo", 1).toString());
int pageSize = Integer.parseInt(map.getOrDefault("pageSize", 10).toString());

View File

@ -29,6 +29,7 @@ import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
import com.zhgd.xmgl.modules.project.entity.Project;
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
import com.zhgd.xmgl.modules.standard.mapper.StandardDevMapper;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.ListUtils;
import com.zhgd.xmgl.util.MessageUtil;
import com.zhgd.xmgl.util.PwUtil;

View File

@ -1309,6 +1309,8 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
throw new OpenAlertException("该机械设备定位设备不存在");
}
result.put("devInfoList", Arrays.asList(dev));
} else {
throw new OpenAlertException("type不能为空");
}
return result;
}