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