工序V4.0

highway
zhaoxiaolin 1 year ago
parent 2dbf3601f6
commit e5161c6ad4

@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -93,10 +94,10 @@ public class SysFileController {
@GetMapping("/downLoadFile")
public void downLoadFile(HttpServletRequest request, HttpServletResponse response) {
OutputStream out = null;
response.setHeader("Content-Disposition", "attachment;fileName=1.png");
byte[] io = sysFileService.imageOnline(request.getParameter("id"));
response.setContentLength(io.length);
try {
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(request.getParameter("fileName"), "UTF-8"));
byte[] io = sysFileService.imageOnline(request.getParameter("id"));
response.setContentLength(io.length);
out = response.getOutputStream();
out.write(io);
} catch (IOException e) {

@ -90,14 +90,14 @@ public class MongoFileImpl implements ISysFileService {
public String uploadFile(MultipartFile file) throws Exception {
String fileName = file.getOriginalFilename();
String id = this.mongoService.uploadFile(file, fileName);
String url = domain + "/online?id=" + id;
String url = domain + "/downLoadFile?id=" + id+"&fileName="+fileName;
return url;
}
/**
*
*
* @param imageid
* @param
* @return
*/
@Override

@ -1,10 +1,13 @@
package com.op.mes.domain;
import com.op.common.core.annotation.Excel;
import com.op.common.core.domain.BaseFileData;
import com.op.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* pro_process
@ -48,6 +51,7 @@ public class ProProcess extends BaseEntity
private Long attr4;
private String fileList;
private List<BaseFile> files;
//s:拆分 m合并
private String splitMerge;
//拆分合并数量
@ -59,6 +63,14 @@ public class ProProcess extends BaseEntity
//工作时长
private Double workTime;
public List<BaseFile> getFiles() {
return files;
}
public void setFiles(List<BaseFile> files) {
this.files = files;
}
public String getWorkCenter() {
return workCenter;
}

@ -64,4 +64,8 @@ public interface BaseFileMapper {
public int deleteBaseFileByFileIds(String[] fileIds);
Boolean insertBaseFileBatch(@Param("baseFiles") List<BaseFileData> baseFiles);
List<BaseFile> getBaseFileBatch(String processId);
void deleteBaseFileBySourceId(String processId);
}

@ -6,6 +6,7 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.BaseFile;
import com.op.mes.domain.ProProcess;
import com.op.mes.mapper.BaseFileMapper;
import com.op.mes.mapper.ProProcessMapper;
@ -14,6 +15,7 @@ import com.op.mes.service.IProProcessService;
import com.op.system.api.RemoteUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
@ -43,7 +45,12 @@ public class ProProcessServiceImpl implements IProProcessService
@Override
public ProProcess selectProProcessByProcessId(String processId)
{
return proProcessMapper.selectProProcessByProcessId(processId);
ProProcess p = proProcessMapper.selectProProcessByProcessId(processId);
List<BaseFile> files = baseFileMapper.getBaseFileBatch(processId);
if(!CollectionUtils.isEmpty(files)){
p.setFiles(files);
}
return p;
}
/**
@ -108,6 +115,7 @@ public class ProProcessServiceImpl implements IProProcessService
for(String id:ids){
file = new BaseFileData();
file.setFileId(IdUtils.fastSimpleUUID());
file.setFileName(id.split("&fileName=")[1]);
file.setFileAddress(id);
file.setSourceId(proProcess.getProcessId());
file.setCreateBy(SecurityUtils.getUsername());
@ -129,6 +137,26 @@ public class ProProcessServiceImpl implements IProProcessService
@Override
public int updateProProcess(ProProcess proProcess)
{
//上传附件
if(StringUtils.isNotEmpty(proProcess.getFileList())){
baseFileMapper.deleteBaseFileBySourceId(proProcess.getProcessId());
String[] ids = proProcess.getFileList().split(",");
List<BaseFileData> files = new ArrayList<>();
BaseFileData file = null;
for(String id:ids){
file = new BaseFileData();
file.setFileId(IdUtils.fastSimpleUUID());
file.setFileAddress(id);
file.setFileName(id.split("&fileName=")[1]);
file.setSourceId(proProcess.getProcessId());
file.setCreateBy(SecurityUtils.getUsername());
file.setCreateTime(new Date());
files.add(file);
}
baseFileMapper.insertBaseFileBatch(files);
}
proProcess.setUpdateTime(DateUtils.getNowDate());
return proProcessMapper.updateProProcess(proProcess);
}

@ -21,7 +21,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectBaseFileVo">
select file_id, file_name, file_address, source_id, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from base_file
select file_id, file_name, file_address, source_id, remark, attr1,
attr2, attr3, attr4, create_by, create_time, update_by,
update_time from base_file
</sql>
<select id="selectBaseFileList" parameterType="BaseFile" resultMap="BaseFileResult">
@ -41,8 +43,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectBaseFileVo"/>
where file_id = #{fileId}
</select>
<select id="getBaseFileBatch" resultMap="BaseFileResult">
<include refid="selectBaseFileVo"/>
where source_id = #{sourceId}
</select>
<insert id="insertBaseFile" parameterType="BaseFile">
<insert id="insertBaseFile" parameterType="BaseFile">
insert into base_file
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="fileId != null">file_id,</if>
@ -120,4 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{fileId}
</foreach>
</delete>
<delete id="deleteBaseFileBySourceId">
delete from base_file where source_id = #{sourceId}
</delete>
</mapper>

Loading…
Cancel
Save