调整餐饮人员照片
This commit is contained in:
parent
d3dc294b37
commit
01fbcf0e55
@ -55,8 +55,8 @@ public class RzRestaurantImagesController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@RequestMapping("/uploadDispatchings")
|
@RequestMapping("/uploadDispatchings")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult uploadPDF(@RequestParam("name") String name,@RequestParam("file") MultipartFile filePath){
|
public AjaxResult uploadPDF(RzRestaurantImages rzRestaurantImages){
|
||||||
return rzRestaurantImagesService.insertRzRestaurantImages(name,filePath);
|
return rzRestaurantImagesService.insertRzRestaurantImages(rzRestaurantImages);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
package com.evo.restaurant.domain;
|
package com.evo.restaurant.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.evo.common.annotation.Excel;
|
import com.evo.common.annotation.Excel;
|
||||||
import com.evo.common.core.domain.BaseEntity;
|
import com.evo.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
@ -11,6 +13,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||||||
* @author chenyj
|
* @author chenyj
|
||||||
* @date 2024-10-25
|
* @date 2024-10-25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
public class RzRestaurantImages extends BaseEntity
|
public class RzRestaurantImages extends BaseEntity
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@ -29,42 +33,8 @@ public class RzRestaurantImages extends BaseEntity
|
|||||||
/** 删除标识 */
|
/** 删除标识 */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
public void setId(Long id)
|
@TableField(exist = false)
|
||||||
{
|
private Long fileId;
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public void setImageUrl(String imageUrl)
|
|
||||||
{
|
|
||||||
this.imageUrl = imageUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImageUrl()
|
|
||||||
{
|
|
||||||
return imageUrl;
|
|
||||||
}
|
|
||||||
public void setDelFlag(String delFlag)
|
|
||||||
{
|
|
||||||
this.delFlag = delFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDelFlag()
|
|
||||||
{
|
|
||||||
return delFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|||||||
@ -37,5 +37,5 @@ public interface IRzRestaurantImagesService extends IService<RzRestaurantImages>
|
|||||||
* @param name 照片管理
|
* @param name 照片管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public AjaxResult insertRzRestaurantImages(String name, MultipartFile filePath);
|
public AjaxResult insertRzRestaurantImages(RzRestaurantImages rzRestaurantImages);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.evo.common.constant.Constants;
|
import com.evo.common.constant.Constants;
|
||||||
import com.evo.common.core.domain.AjaxResult;
|
import com.evo.common.core.domain.AjaxResult;
|
||||||
|
import com.evo.common.core.domain.entity.RzUpload;
|
||||||
import com.evo.common.utils.Collections;
|
import com.evo.common.utils.Collections;
|
||||||
import com.evo.common.utils.DateUtils;
|
import com.evo.common.utils.DateUtils;
|
||||||
import com.evo.common.utils.SecurityUtils;
|
import com.evo.common.utils.SecurityUtils;
|
||||||
@ -18,10 +19,13 @@ import com.evo.restaurant.domain.RzRestaurantStatistics;
|
|||||||
import com.evo.restaurant.mapper.RzRestaurantImagesMapper;
|
import com.evo.restaurant.mapper.RzRestaurantImagesMapper;
|
||||||
import com.evo.restaurant.mapper.RzRestaurantStatisticsMapper;
|
import com.evo.restaurant.mapper.RzRestaurantStatisticsMapper;
|
||||||
import com.evo.restaurant.service.IRzRestaurantImagesService;
|
import com.evo.restaurant.service.IRzRestaurantImagesService;
|
||||||
|
import com.evo.system.service.RzUploadService;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -38,7 +42,8 @@ public class RzRestaurantImagesServiceImpl extends ServiceImpl<RzRestaurantImage
|
|||||||
private RzRestaurantStatisticsMapper rzRestaurantStatisticsMapper; //餐饮统计
|
private RzRestaurantStatisticsMapper rzRestaurantStatisticsMapper; //餐饮统计
|
||||||
@Resource
|
@Resource
|
||||||
private IEqSnDetailService eqSnDetailService;//餐饮统计
|
private IEqSnDetailService eqSnDetailService;//餐饮统计
|
||||||
|
@Resource
|
||||||
|
private RzUploadService rzUploadService;//文件上传
|
||||||
/**
|
/**
|
||||||
* 查询餐饮照片管理列表
|
* 查询餐饮照片管理列表
|
||||||
*
|
*
|
||||||
@ -102,74 +107,48 @@ public class RzRestaurantImagesServiceImpl extends ServiceImpl<RzRestaurantImage
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult insertRzRestaurantImages(String name, MultipartFile filePath)
|
public AjaxResult insertRzRestaurantImages(RzRestaurantImages rzRestaurantImages)
|
||||||
{
|
{
|
||||||
String originalFilename = filePath.getOriginalFilename();
|
|
||||||
//校验文件后缀
|
if(rzRestaurantImages.getId() != null){
|
||||||
String suffix = originalFilename.substring(originalFilename.lastIndexOf(".") + 1); // 输出 "txt"
|
int i = getBaseMapper().updateById(rzRestaurantImages);
|
||||||
//判断是否是图片文件
|
if(i < 1){
|
||||||
if(!"jpg".equals(suffix)&&!"jpeg".equals(suffix)&&!"png".equals(suffix)){
|
return AjaxResult.error();
|
||||||
return AjaxResult.error("禁止非法文件上传!");
|
}
|
||||||
}else{
|
}else{
|
||||||
//保存图片
|
int i = getBaseMapper().insert(rzRestaurantImages);
|
||||||
InputStream is = null;
|
if(i < 1){
|
||||||
FileOutputStream fos = null;
|
return AjaxResult.error();
|
||||||
BufferedOutputStream bos = null;
|
}
|
||||||
try {
|
//餐饮统计
|
||||||
is = filePath.getInputStream();
|
RzRestaurantStatistics rzRestaurantStatistics = new RzRestaurantStatistics();
|
||||||
byte[] bytes = new byte[is.available()];
|
rzRestaurantStatistics.setStaffId(rzRestaurantImages.getId());
|
||||||
is.read(bytes);
|
rzRestaurantStatistics.setName(rzRestaurantImages.getName());
|
||||||
File file = new File(com.evo.equipment.constant.Constants.STAFF_IMAGE_ADDRESS+originalFilename);
|
rzRestaurantStatistics.setMonth(DateUtils.getNowDate());
|
||||||
fos = new FileOutputStream(file);
|
rzRestaurantStatistics.setCreateTime(DateUtils.getNowDate());
|
||||||
bos = new BufferedOutputStream(fos);
|
rzRestaurantStatistics.setDelFlag(Constants.DELETE_FLAG_0);
|
||||||
bos.write(bytes);
|
rzRestaurantStatistics.setCreateBy(SecurityUtils.getUsername());
|
||||||
} catch (Exception e) {
|
i = rzRestaurantStatisticsMapper.insertRzRestaurantStatistics(rzRestaurantStatistics);
|
||||||
e.printStackTrace();
|
if(i < 1){
|
||||||
return AjaxResult.error();
|
return AjaxResult.error();
|
||||||
}finally {
|
|
||||||
try{
|
|
||||||
if(StringUtils.isNotNull(bos)){
|
|
||||||
bos.flush();
|
|
||||||
bos.close();
|
|
||||||
}
|
|
||||||
if(StringUtils.isNotNull(fos)){
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
if(StringUtils.isNotNull(is)){
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//写入数据库
|
if(ObjectUtils.isNotEmpty(rzRestaurantImages.getFileId())){
|
||||||
RzRestaurantImages rzRestaurantImages = new RzRestaurantImages();
|
RzUpload upload = null;
|
||||||
rzRestaurantImages.setName(name);
|
try {
|
||||||
rzRestaurantImages.setImageUrl(com.evo.equipment.constant.Constants.STAFF_IMAGE_URL+originalFilename);
|
upload = rzUploadService.selectById(rzRestaurantImages.getFileId());
|
||||||
rzRestaurantImages.setCreateBy(SecurityUtils.getUsername());
|
upload.setBusinessId(rzRestaurantImages.getId());
|
||||||
rzRestaurantImages.setCreateTime(DateUtils.getNowDate());
|
rzUploadService.updateUploadBusinessId(upload);
|
||||||
rzRestaurantImages.setDelFlag(Constants.DELETE_FLAG_0);
|
} catch (Exception e) {
|
||||||
int i = getBaseMapper().insertRzRestaurantImages(rzRestaurantImages);
|
log.error("处理上传照片信息出现错误", e);
|
||||||
if(i < 1){
|
}
|
||||||
return AjaxResult.error();
|
//下发照片
|
||||||
|
// eqSnDetailService.sendPhoto(Collections.asList(com.evo.equipment.constant.Constants.EQ_DEVICE_CODE),
|
||||||
|
// Collections.asList(Collections.asMap("userId", String.valueOf(rzRestaurantImages.getId()),
|
||||||
|
// "name", rzRestaurantImages.getName(), "photoUrl", rzRestaurantImages.getImageUrl())));
|
||||||
}
|
}
|
||||||
//餐饮统计
|
|
||||||
RzRestaurantStatistics rzRestaurantStatistics = new RzRestaurantStatistics();
|
|
||||||
rzRestaurantStatistics.setStaffId(rzRestaurantImages.getId());
|
|
||||||
rzRestaurantStatistics.setName(rzRestaurantImages.getName());
|
|
||||||
rzRestaurantStatistics.setMonth(DateUtils.getNowDate());
|
|
||||||
rzRestaurantStatistics.setCreateTime(DateUtils.getNowDate());
|
|
||||||
rzRestaurantStatistics.setDelFlag(Constants.DELETE_FLAG_0);
|
|
||||||
rzRestaurantStatistics.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
i = rzRestaurantStatisticsMapper.insertRzRestaurantStatistics(rzRestaurantStatistics);
|
|
||||||
if(i < 1){
|
|
||||||
return AjaxResult.error();
|
|
||||||
}
|
|
||||||
//下发照片
|
|
||||||
eqSnDetailService.sendPhoto(Collections.asList(com.evo.equipment.constant.Constants.EQ_DEVICE_CODE),
|
|
||||||
Collections.asList(Collections.asMap("userId", String.valueOf(rzRestaurantImages.getId()),
|
|
||||||
"name", name, "photoUrl", com.evo.equipment.constant.Constants.STAFF_IMAGE_URL+originalFilename)));
|
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user