This commit is contained in:
zhouzy062 2024-01-23 20:34:36 +08:00
commit 2d6b540764
12 changed files with 146 additions and 59 deletions

View File

@ -141,7 +141,7 @@ public class MaType extends BaseEntity {
/** 图片路径 */
@ApiModelProperty(value = "图片路径")
private String photoUrl = "https://zlpt-1259760603.cos.ap-nanjing.myqcloud.com/zhcc/405D4B1F-0942-424e-B45A-C66FDDA74EEA.png";
private String photoUrl;
/** 文档名称 */
@ApiModelProperty(value = "文档名称")

View File

@ -103,7 +103,8 @@ public class MaTypeController extends BaseController {
if (level == 2) {
// 查询二级
if (parentId == 0){
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(null,keyword));
List<MaType> maTypes = maTypeMapper.selectMaTypeListByLevelNotFour(null, keyword);
return AjaxResult.success(maTypes);
}else {
return AjaxResult.success(maTypeMapper.selectMaTypeListByLevelNotFour(parentId.toString(),keyword));
}

View File

@ -361,8 +361,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select m.type_id, m.type_name, m.parent_id, m.status, m.num, m.unit_id, m.manage_type,
m.lease_price, m.eff_time, m.rent_price, m.buy_price, m.pay_price, m.level, m.rated_load, m.test_load,
m.holding_time, m.warn_num, m.del_flag, m.create_by, m.create_time,
m.remark, m.company_id
m.remark, m.company_id,mtf.file_url photoUrl
from ma_type m
left join (select * from ma_type_file where file_type = '1') mtf on m.type_id = mtf.type_id
<where>
m.level != 4
<if test="parentId!= null and parentId != ''">

View File

@ -1,17 +1,20 @@
package com.bonus.sgzb.system.controller;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Arrays;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import cn.hutool.core.util.IdUtil;
import com.bonus.sgzb.common.core.domain.R;
import com.bonus.sgzb.common.core.utils.DateTimeHelper;
import com.bonus.sgzb.system.api.domain.SysFile;
import com.bonus.sgzb.system.domain.FileInfo;
import com.bonus.sgzb.system.service.SysFileService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.bonus.sgzb.common.core.utils.StringUtils;
import com.bonus.sgzb.common.core.utils.file.FileTypeUtils;
import com.bonus.sgzb.common.core.utils.file.MimeTypeUtils;
@ -22,10 +25,14 @@ import com.bonus.sgzb.common.log.enums.BusinessType;
import com.bonus.sgzb.common.security.service.TokenService;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import com.bonus.sgzb.system.api.RemoteFileService;
import com.bonus.sgzb.system.api.domain.SysFile;
import com.bonus.sgzb.system.api.domain.SysUser;
import com.bonus.sgzb.system.api.model.LoginUser;
import com.bonus.sgzb.system.service.ISysUserService;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* 个人信息 业务处理
@ -44,6 +51,9 @@ public class SysProfileController extends BaseController {
@Autowired
private RemoteFileService remoteFileService;
@Resource
private SysFileService sysFileService;
/**
* 个人信息
*/
@ -113,27 +123,27 @@ public class SysProfileController extends BaseController {
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) {
if (!file.isEmpty()) {
LoginUser loginUser = SecurityUtils.getLoginUser();
String extension = FileTypeUtils.getExtension(file);
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
return error("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file,String fileType) throws Exception {
FileInfo fileInfo = sysFileService.uploadHeadPic(file, fileType);
if (!file.isEmpty()) {
LoginUser loginUser = SecurityUtils.getLoginUser();
String extension = FileTypeUtils.getExtension(file);
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
return error("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
}
if (ObjectUtils.isEmpty(fileInfo)) {
return error("文件服务异常,请联系管理员");
}
String url = fileInfo.getFileUrl();
if (userService.updateUserAvatar(loginUser.getUsername(), url)) {
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", url);
// 更新缓存用户头像
loginUser.getSysUser().setAvatar(url);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
R<SysFile> fileResult = remoteFileService.upload(file);
if (StringUtils.isNull(fileResult) || StringUtils.isNull(fileResult.getData())) {
return error("文件服务异常,请联系管理员");
}
String url = fileResult.getData().getUrl();
if (userService.updateUserAvatar(loginUser.getUsername(), url)) {
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", url);
// 更新缓存用户头像
loginUser.getSysUser().setAvatar(url);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
return error("上传图片异常,请联系管理员");
}
}

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.system.service;
import com.bonus.sgzb.system.domain.FileInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@ -20,4 +21,6 @@ public interface SysFileService
*/
FileInfo uploadFile(HttpServletRequest request) throws Exception;
FileInfo uploadHeadPic(MultipartFile file,String fileType) throws Exception;
}

View File

@ -27,7 +27,7 @@ import java.util.*;
/**
* 本地文件存储
*
*
* @author zys
*/
@Primary
@ -39,7 +39,7 @@ public class SysFileServiceImpl implements SysFileService {
/**
* 本地文件上传接口
*
*
* @return 访问地址
* @throws Exception
*/
@ -55,11 +55,11 @@ public class SysFileServiceImpl implements SysFileService {
MultipartFile item = items.get(0);
try {
String url = saveFile(request, item, photoType);
if(url != null){
if (url != null) {
int words = getFileText(item);
String fileName = item.getOriginalFilename();
String type = fileName.substring(fileName.lastIndexOf(".") + 1);
long size = item.getSize()/1024/1024;
long size = item.getSize() / 1024 / 1024;
file.setFileName(fileName);
file.setFileUrl(url);
file.setCreator(userId.toString());
@ -76,6 +76,40 @@ public class SysFileServiceImpl implements SysFileService {
return file;
}
/**
* 头像上传
*
* @return 访问地址
* @throws Exception
*/
@Override
public FileInfo uploadHeadPic(MultipartFile item,String fileType) {
FileInfo file = new FileInfo();
Long userId = SecurityUtils.getUserId();
try {
String url = saveFilePic(item, fileType);
if (url != null) {
int words = getFileText(item);
String fileName = item.getOriginalFilename();
String type = fileName.substring(fileName.lastIndexOf(".") + 1);
long size = item.getSize() / 1024 / 1024;
file.setFileName(fileName);
file.setFileUrl(url);
file.setCreator(userId.toString());
file.setType(type);
file.setSize(size + "M");
file.setWords(words);
file.setCreateBy(SecurityUtils.getUserId().toString());
file.setCreateTime(new Date());
dao.insertFileInfo(file);
}
} catch (Exception e) {
e.printStackTrace();
}
return file;
}
public HashMap<String, Object> getFile(StandardMultipartHttpServletRequest request) {
MultipartFile multipartFile;
HashMap<String, Object> map = new HashMap<String, Object>();
@ -86,7 +120,7 @@ public class SysFileServiceImpl implements SysFileService {
multipartFile = request.getFile(itr.next());
tmps.add(multipartFile);
}
map.put("filePath",tmps);
map.put("filePath", tmps);
} catch (Exception e) {
e.printStackTrace();
}
@ -97,22 +131,60 @@ public class SysFileServiceImpl implements SysFileService {
String url = "";
String tmpName = multipartFile.getOriginalFilename();// 完整路径 IE
tmpName = tmpName.substring(tmpName.lastIndexOf("\\") + 1);
tmpName = IdUtil.fastSimpleUUID() + System.currentTimeMillis() +tmpName.substring(tmpName.lastIndexOf("."),tmpName.length());
String imageFiles="/data/sgzb/" + fileType + "/";
tmpName = IdUtil.fastSimpleUUID() + System.currentTimeMillis() + tmpName.substring(tmpName.lastIndexOf("."), tmpName.length());
String imageFiles = "/data/sgzb/" + fileType + "/";
String os = System.getProperty("os.name");
if(os.toLowerCase().startsWith("win")){
imageFiles="D://files/" + fileType + "/";
if (os.toLowerCase().startsWith("win")) {
imageFiles = "D://files/" + fileType + "/";
}
String year = DateTimeHelper.getNowYear();
String month = DateTimeHelper.getNowMonths();
String day = DateTimeHelper.getNowDay();
String specfile = imageFiles + year +"/" + month +"/"+ day;
String specfile = imageFiles + year + "/" + month + "/" + day;
File file = new File(specfile + "/" + tmpName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
url = "/" + fileType + "/" + year +"/" + month +"/"+ day + "/" + tmpName;
url = "/" + fileType + "/" + year + "/" + month + "/" + day + "/" + tmpName;
if (!multipartFile.isEmpty()) {
try {
FileOutputStream fos = new FileOutputStream(file);
InputStream in = multipartFile.getInputStream();
byte[] bytes = new byte[1024];
int len = 0;
while ((len = in.read(bytes)) != -1) {
fos.write(bytes, 0, len);
}
fos.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return url;
}
public String saveFilePic(MultipartFile multipartFile, String fileType) throws Exception {
String url = "";
String tmpName = multipartFile.getOriginalFilename();// 完整路径 IE
tmpName = tmpName.substring(tmpName.lastIndexOf("\\") + 1);
tmpName = IdUtil.fastSimpleUUID() + System.currentTimeMillis() + tmpName.substring(tmpName.lastIndexOf("."), tmpName.length());
String imageFiles = "/data/sgzb/" + fileType + "/";
String os = System.getProperty("os.name");
if (os.toLowerCase().startsWith("win")) {
imageFiles = "D://files/" + fileType + "/";
}
String year = DateTimeHelper.getNowYear();
String month = DateTimeHelper.getNowMonths();
String day = DateTimeHelper.getNowDay();
String specfile = imageFiles + year + "/" + month + "/" + day;
File file = new File(specfile + "/" + tmpName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
url = "/" + fileType + "/" + year + "/" + month + "/" + day + "/" + tmpName;
if (!multipartFile.isEmpty()) {
try {
FileOutputStream fos = new FileOutputStream(file);

View File

@ -287,16 +287,16 @@ export default {
required:true,message:'请选择工程',trigger:'change',type:'number'
}
],
leasePerson: [
{
required: true, message: '请输入领料人', trigger: 'blur',
}
],
phone: [
{required: true, message: '请输入领料人手机号', trigger: 'change'},
{ validator: validatePhone, trigger: "blur" },
{ min: 11, message: "手机号不足11位", trigger: "blur" },
],
// leasePerson: [
// {
// required: true, message: '', trigger: 'blur',
// }
// ],
// phone: [
// {required: true, message: '', trigger: 'change'},
// { validator: validatePhone, trigger: "blur" },
// { min: 11, message: "11", trigger: "blur" },
// ],
},
unitList:[], //
proList:[], //

View File

@ -267,7 +267,7 @@ export default {
//
async subAuditLeaseByCompany(){
const params = JSON.parse(JSON.stringify(this.queryParams))
params.taskStatus ++
params.taskStatus = params.taskStatus+1
params.leaseApplyInfoList.forEach(v => {
this.$set(v,'companyAuditRemark',params.companyAuditRemarks)
this.$set(v,'companyAuditBy',this.user.id)

View File

@ -210,7 +210,7 @@ import { getLeaseAuditListAll, getUnitData, getProData, getTaskDetail } from '@/
import { getInfo } from '@/api/login'
import vueEasyPrint from 'vue-easy-print';
export default {
name: "ReceiveManage",
// name: "ReceiveManage",
data() {
return {
//

View File

@ -266,7 +266,7 @@
size="mini"
type="primary"
icon="el-icon-edit"
:disabled="scope.row.taskStatus == '38'"
v-if="scope.row.taskStatus == '37'"
@click="handleUpdate(scope.row, 'update')"
>审核</el-button
>

View File

@ -140,7 +140,7 @@
ref="dynamicValidateFormTwo"
:model="dynamicValidateFormTwo"
class="demo-dynamic"
label-width="90px"
label-width="100px"
>
<div
v-for="(domain, index) in dynamicValidateFormTwo.premiumListTwo"

View File

@ -449,7 +449,7 @@ export default {
},
//
handleView(row) {
this.query.taskId = row.id
this.query.taskId = row.taskId
this.getDialogTable()
this.open = true;
this.showHandle = false