bug
This commit is contained in:
parent
762545d1ee
commit
cc3ce6f481
@ -326,7 +326,7 @@ public class LJStaffServiceImpl extends ServiceImpl<LJStaffMapper, LJStaff> impl
|
||||
InputStream backgroundStream = this.getClass().getClassLoader().getResourceAsStream(backgroundImage);
|
||||
InputStream logoStream = this.getClass().getClassLoader().getResourceAsStream(logoImage);
|
||||
//背景图片路径 loge图片 二维码 输出地址
|
||||
qrCodeUtils.createLogoCodePicture(backgroundStream, logoStream, url, finalPath, staff.getId(),store.getId());
|
||||
qrCodeUtils.createLogoCodePicture(backgroundStream, logoStream, url, finalPath, staff.getId(),store.getId(),null);
|
||||
File file1 = new File("/temp/qrCode/");
|
||||
// 判断目录是否存在
|
||||
if (!file1.exists()) {
|
||||
|
@ -46,7 +46,7 @@ public class QrCodeUtils {
|
||||
* @param staffId 员工id
|
||||
* @param storeId 店铺id
|
||||
*/
|
||||
public void createLogoCodePicture(InputStream backgroundStream, InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId) {
|
||||
public void createLogoCodePicture(InputStream backgroundStream, InputStream logoStream, String url, String outImgPath, Integer staffId, Integer storeId,String urls) {
|
||||
try {
|
||||
// 读取原图片信息
|
||||
//得到文件
|
||||
@ -109,7 +109,11 @@ public class QrCodeUtils {
|
||||
// g.drawString(storeNumber, 200, 800);
|
||||
g.dispose();
|
||||
// 输出图片
|
||||
File file1 = new File("/temp/qrCode/");
|
||||
String urlsss = "/temp/qrCode/";
|
||||
if (ObjectUtils.isNotEmpty(urls)){
|
||||
urlsss = urls;
|
||||
}
|
||||
File file1 = new File(urlsss);
|
||||
// 判断目录是否存在
|
||||
if (!file1.exists()) {
|
||||
file1.mkdirs();
|
||||
|
@ -343,4 +343,8 @@ public class BackendStoreController extends BaseController {
|
||||
//return getSuccessResult(storeService.loginVerification(flag));
|
||||
return null;
|
||||
}
|
||||
@GetMapping("getByStroeName")
|
||||
public ResponseObject getByStroeName(MtStore storeName) {
|
||||
return getSuccessResult(storeService.getByStroeName(storeName));
|
||||
}
|
||||
}
|
||||
|
@ -45,4 +45,5 @@ public interface MtStoreMapper extends BaseMapper<MtStore> {
|
||||
|
||||
int ifDeleteByDeptId(@Param("deptId") Long deptId);
|
||||
|
||||
MtStore getByStroeName(@Param("name") String name);
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getByStroeName" resultType="com.fuint.business.store.entity.MtStore">
|
||||
select * from mt_store where name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="queryByDistance" resultType="com.fuint.repository.bean.StoreDistanceBean">
|
||||
SELECT t.id,(6371 * ACOS(COS( RADIANS(#{latitude}))*COS(RADIANS(t.latitude))*COS(RADIANS(t.longitude ) - RADIANS(#{longitude})) + SIN(RADIANS(#{latitude}))*SIN(RADIANS(t.latitude)))) AS distance
|
||||
FROM mt_store t WHERE t.status = 'q'
|
||||
|
@ -111,4 +111,5 @@ public interface StoreService extends IService<MtStore> {
|
||||
void petrolStationsAreExpired();
|
||||
|
||||
|
||||
List<Map<Object,Object>> getByStroeName(MtStore storeName);
|
||||
}
|
||||
|
@ -568,6 +568,23 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
|
||||
beachDelStore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<Object, Object>> getByStroeName(MtStore storeName) {
|
||||
ArrayList<Map<Object, Object>> objects = new ArrayList<>();
|
||||
String name = storeName.getName();
|
||||
LambdaQueryWrapper<MtStore> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(MtStore::getName, name);
|
||||
List<MtStore> list = list(queryWrapper);
|
||||
/*MtStore mtStore1 = mtStoreMapper.queryStoreByName(name);
|
||||
List<MtStore> byStroeName = mtStoreMapper.getByStroeName(name);*/
|
||||
for (MtStore mtStore : list) {
|
||||
HashMap<Object, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("id",mtStore.getId());
|
||||
hashMap.put("name",mtStore.getName());
|
||||
objects.add(hashMap);
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
|
||||
|
||||
// 将在部门里面删除的在油站中删除
|
||||
|
@ -76,7 +76,7 @@ public class QRCodeServiceImpl extends ServiceImpl<QRCodeMapper, QRCode> impleme
|
||||
InputStream backgroundStream = this.getClass().getClassLoader().getResourceAsStream(backgroundImage);
|
||||
InputStream logoStream = this.getClass().getClassLoader().getResourceAsStream(logoImage);
|
||||
//背景图片路径 loge图片 二维码 输出地址
|
||||
qrCodeUtils.createLogoCodePicture(backgroundStream, logoStream, url, finalPath, null,store.getId());
|
||||
qrCodeUtils.createLogoCodePicture(backgroundStream, logoStream, url, finalPath, null,store.getId(),null);
|
||||
File file1 = new File("/temp/qrCode/");
|
||||
// 判断目录是否存在
|
||||
if (!file1.exists()) {
|
||||
|
@ -10,10 +10,28 @@ import com.fuint.business.tag.service.TagCodeService;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 码牌二维码表(TagCode)表控制层
|
||||
@ -35,7 +53,7 @@ public class TagCodeController extends BaseController {
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseObject selectAll(@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,
|
||||
public ResponseObject selectAll(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
|
||||
@Param("cardFuelDiesel") TagCode tagCode) {
|
||||
Page page = new Page(pageNo, pageSize);
|
||||
@ -60,8 +78,8 @@ public class TagCodeController extends BaseController {
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseObject insert(@RequestBody TagCodeDTO tagCodeDTO) throws Exception {
|
||||
return getSuccessResult(this.tagCodeService.add(tagCodeDTO));
|
||||
public ResponseEntity<InputStreamResource> insert(@RequestBody TagCodeDTO tagCodeDTO ,HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
return this.tagCodeService.add(tagCodeDTO,request,response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,5 +103,53 @@ public class TagCodeController extends BaseController {
|
||||
public ResponseObject delete(@PathVariable("id") Long id) {
|
||||
return getSuccessResult(this.tagCodeService.removeById(id));
|
||||
}
|
||||
|
||||
//private static final String IMAGE_DIRECTORY = "/path/to/image/directory";
|
||||
private static final String IMAGE_DIRECTORY = "D:\\temp\\qrCode";
|
||||
|
||||
@GetMapping("/export-images")
|
||||
public ResponseEntity<InputStreamResource> exportImages(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
List<File> imageFiles = getImageFiles(IMAGE_DIRECTORY);
|
||||
InputStream zipInputStream = createZipInputStream(imageFiles);
|
||||
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"images.zip\"");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.body(new InputStreamResource(zipInputStream));
|
||||
}
|
||||
|
||||
private List<File> getImageFiles(String directory) {
|
||||
ArrayList<File> objects = new ArrayList<>();
|
||||
File imageDir = new File(directory);
|
||||
File[] files = imageDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".jpg") || name.toLowerCase().endsWith(".png"));
|
||||
for (File file : files) {
|
||||
objects.add(file);
|
||||
}
|
||||
return objects;
|
||||
//return files != null ? new ArrayList<>(List.of(files)) : new ArrayList<>();
|
||||
}
|
||||
|
||||
private InputStream createZipInputStream(List<File> imageFiles) throws IOException {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zipOut = new ZipOutputStream(outputStream);
|
||||
|
||||
for (File file : imageFiles) {
|
||||
ZipEntry zipEntry = new ZipEntry(file.getName());
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = fileInputStream.read(buffer)) > 0) {
|
||||
zipOut.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
fileInputStream.close();
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
|
||||
zipOut.close();
|
||||
return new ByteArrayInputStream(outputStream.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,21 @@ package com.fuint.business.tag.controller;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||
import com.baomidou.mybatisplus.extension.api.ApiController;
|
||||
import com.baomidou.mybatisplus.extension.api.R;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.member.entity.LJStaff;
|
||||
import com.fuint.business.member.service.ILJStaffService;
|
||||
import com.fuint.business.tag.dto.TagCodeRecordDTO;
|
||||
import com.fuint.business.tag.entity.OilTag;
|
||||
import com.fuint.business.tag.entity.TagCodeRecord;
|
||||
import com.fuint.business.tag.service.OilTagService;
|
||||
import com.fuint.business.tag.service.TagCodeRecordService;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
@ -39,6 +45,9 @@ public class TagCodeRecordController extends BaseController {
|
||||
@Resource
|
||||
private OilTagService oilTagService;
|
||||
|
||||
@Resource
|
||||
private ILJStaffService mtStaffService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
* @return 所有数据
|
||||
@ -93,16 +102,28 @@ public class TagCodeRecordController extends BaseController {
|
||||
@PutMapping
|
||||
public ResponseObject update(@RequestBody TagCodeRecord tagCodeRecord) {
|
||||
|
||||
TagCodeRecord tagCodeRecord1 = tagCodeRecordService.getById(tagCodeRecord.getId());
|
||||
tagCodeRecord1.setStaffId("");
|
||||
tagCodeRecord1.setStaffName("");
|
||||
this.tagCodeRecordService.updateById(tagCodeRecord1);
|
||||
//更新码牌绑定员工状态
|
||||
OilTag oilTag = new OilTag();
|
||||
oilTag.setId(tagCodeRecord1.getOilTagId());
|
||||
oilTag.setMtStatus("0");
|
||||
oilTagService.updateById(oilTag);
|
||||
return getSuccessResult(true);
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
LambdaQueryWrapper<TagCodeRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TagCodeRecord::getStoreId,nowAccountInfo.getStoreId());
|
||||
queryWrapper.eq(TagCodeRecord::getStaffId,tagCodeRecord.getStaffId());
|
||||
TagCodeRecord tagCodeRecord1 = tagCodeRecordService.getOne(queryWrapper);
|
||||
//TagCodeRecord tagCodeRecord1 = tagCodeRecordService.getById(tagCodeRecord.getStaffId());
|
||||
|
||||
if (ObjectUtils.isNotEmpty(tagCodeRecord1) && ObjectUtils.isNotEmpty(tagCodeRecord1.getStaffId())){
|
||||
LJStaff ljStaff = mtStaffService.selectStaffById(Integer.parseInt(tagCodeRecord1.getStaffId()));
|
||||
ljStaff.setStaffCode("");
|
||||
mtStaffService.updateById(ljStaff);
|
||||
tagCodeRecord1.setStaffId("");
|
||||
tagCodeRecord1.setStaffName("");
|
||||
this.tagCodeRecordService.updateById(tagCodeRecord1);
|
||||
//更新码牌绑定员工状态
|
||||
OilTag oilTag = new OilTag();
|
||||
oilTag.setId(tagCodeRecord1.getOilTagId());
|
||||
oilTag.setMtStatus("0");
|
||||
oilTagService.updateById(oilTag);
|
||||
return getSuccessResult("解绑成功!");
|
||||
}
|
||||
return getSuccessResult("该员工暂未绑定码牌!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,11 @@ package com.fuint.business.tag.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.tag.dto.TagCodeDTO;
|
||||
import com.fuint.business.tag.entity.TagCode;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
/**
|
||||
@ -14,6 +18,6 @@ import java.io.FileNotFoundException;
|
||||
*/
|
||||
public interface TagCodeService extends IService<TagCode> {
|
||||
|
||||
boolean add(TagCodeDTO tagCodeDTO) throws Exception;
|
||||
ResponseEntity<InputStreamResource> add(TagCodeDTO tagCodeDTO, HttpServletRequest request, HttpServletResponse response) throws Exception;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import com.fuint.business.store.entity.MtStore;
|
||||
import com.fuint.business.store.service.StoreService;
|
||||
import com.fuint.business.tag.dto.TagCodeRecordDTO;
|
||||
import com.fuint.business.tag.entity.OilTag;
|
||||
import com.fuint.business.tag.entity.TagCode;
|
||||
import com.fuint.business.tag.mapper.TagCodeRecordMapper;
|
||||
import com.fuint.business.tag.entity.TagCodeRecord;
|
||||
import com.fuint.business.tag.service.OilTagService;
|
||||
@ -80,6 +81,10 @@ public class TagCodeRecordServiceImpl extends ServiceImpl<TagCodeRecordMapper, T
|
||||
|
||||
@Override
|
||||
public IPage<TagCodeRecordVO> selectTagList(Page page, TagCodeRecord tagCodeRecord) {
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
if (ObjectUtils.isNotEmpty(tagCodeRecord) && ObjectUtils.isEmpty(tagCodeRecord.getStoreId())){
|
||||
tagCodeRecord.setStoreId(nowAccountInfo.getStoreId());
|
||||
}
|
||||
return tagCodeRecordMapper.selectTagList(page,tagCodeRecord);
|
||||
}
|
||||
|
||||
@ -91,9 +96,17 @@ public class TagCodeRecordServiceImpl extends ServiceImpl<TagCodeRecordMapper, T
|
||||
LambdaQueryWrapper<TagCodeRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TagCodeRecord::getOilTagId,tagCodeRecordDTO.getOilTagId());
|
||||
TagCodeRecord tagCodeRecord = getOne(queryWrapper);
|
||||
//码牌id查询员工码
|
||||
LambdaQueryWrapper<OilTag> queryWrapper1 = new LambdaQueryWrapper<>();
|
||||
queryWrapper1.eq(OilTag::getId,tagCodeRecordDTO.getOilTagId());
|
||||
OilTag oilTag1 = oilTagService.getOne(queryWrapper1);
|
||||
//绑定员工
|
||||
if (ObjectUtils.isNotEmpty(tagCodeRecordDTO) && ObjectUtils.isNotEmpty(tagCodeRecordDTO.getStaffId())){
|
||||
LJStaff ljStaff = mtStaffService.selectStaffById(Integer.parseInt(tagCodeRecordDTO.getStaffId()));
|
||||
//String tagCodeSn = oilTag1.getTagCodeSn();
|
||||
ljStaff.setStaffCode("https://www.tuofeng.cc/oilStation"+"?storeId="+tagCodeRecordDTO.getStoreId()+"&staffId="+tagCodeRecordDTO.getStaffId());
|
||||
mtStaffService.updateStaff(ljStaff);
|
||||
|
||||
tagCodeRecord.setStaffId(tagCodeRecordDTO.getStaffId());
|
||||
tagCodeRecord.setStaffName(ljStaff.getRealName());
|
||||
//更新码牌记录表
|
||||
@ -104,7 +117,7 @@ public class TagCodeRecordServiceImpl extends ServiceImpl<TagCodeRecordMapper, T
|
||||
oilTag.setMtStatus("1");
|
||||
oilTagService.updateById(oilTag);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,18 +7,37 @@ import com.fuint.business.tag.dto.TagCodeDTO;
|
||||
import com.fuint.business.tag.mapper.TagCodeMapper;
|
||||
import com.fuint.business.tag.entity.TagCode;
|
||||
import com.fuint.business.tag.service.TagCodeService;
|
||||
import com.fuint.common.util.DateUtil;
|
||||
import com.fuint.module.backendApi.controller.BackendFileController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 码牌二维码表(TagCode)表服务实现类
|
||||
@ -35,13 +54,17 @@ public class TagCodeServiceImpl extends ServiceImpl<TagCodeMapper, TagCode> impl
|
||||
@Autowired
|
||||
private BackendFileController backendFileController;
|
||||
|
||||
//private static final String IMAGE_DIRECTORY = "D:\\temp\\qrCode";
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean add(TagCodeDTO tagCodeDTO) throws Exception {
|
||||
public ResponseEntity<InputStreamResource> add(TagCodeDTO tagCodeDTO, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
|
||||
boolean flag = false;
|
||||
if (ObjectUtils.isNotEmpty(tagCodeDTO) && ObjectUtils.isNotEmpty(tagCodeDTO.getTotal())){
|
||||
int total = tagCodeDTO.getTotal();
|
||||
Random random1 = new Random();
|
||||
int i2 = random1.nextInt(1000);
|
||||
for (int i = 0; i < total; i++) {
|
||||
Random random = new Random();
|
||||
int i1 = random.nextInt(90000000);
|
||||
@ -49,7 +72,8 @@ public class TagCodeServiceImpl extends ServiceImpl<TagCodeMapper, TagCode> impl
|
||||
String url = "https://www.tuofeng.cc/oilStation?sn=byx"+i1;
|
||||
// String finalPath="/temp/qrCode/" + oilTag.getSnCode() + ".jpg";
|
||||
//String finalPath="D:\\office\\document\\photos\\tagCode\\"+"str"+i+".jpg";
|
||||
String finalPath="/temp/qrCode/" + "byx"+i1 + ".jpg";
|
||||
//String finalPath="/temp/tagCode/" + "byx"+i1 + ".jpg";
|
||||
//String finalPath="/temp/tagCode/"+ DateUtil.formatDate(new Date(), "yyyyMMdd") + "/"+i2 + "byx"+i1 + ".jpg";
|
||||
|
||||
TagCode tagCode = new TagCode();
|
||||
|
||||
@ -59,8 +83,13 @@ public class TagCodeServiceImpl extends ServiceImpl<TagCodeMapper, TagCode> impl
|
||||
//在图片上生成二维码
|
||||
String backgroundImage = "static/qrCodeImg/huanyingguanglin2.jpg";
|
||||
InputStream backgroundStream = this.getClass().getClassLoader().getResourceAsStream(backgroundImage);
|
||||
qrCodeUtils.createLogoCodePicture(backgroundStream, null, url, finalPath, null,null);
|
||||
File file1 = new File("/temp/qrCode/");
|
||||
String urls = "";
|
||||
urls = "/temp/tagCode/"+ DateUtil.formatDate(new Date(), "yyyyMMdd") + "-"+i2;
|
||||
File file1 = new File(urls);
|
||||
// String finalPath="/temp/tagCode/" + "byx"+i1 + ".jpg";
|
||||
String finalPath=urls+"/" + "byx"+i1 + ".jpg";
|
||||
qrCodeUtils.createLogoCodePicture(backgroundStream, null, url, finalPath, null,null,urls);
|
||||
|
||||
// 判断目录是否存在
|
||||
if (!file1.exists()) {
|
||||
file1.mkdirs();
|
||||
@ -68,6 +97,7 @@ public class TagCodeServiceImpl extends ServiceImpl<TagCodeMapper, TagCode> impl
|
||||
|
||||
File file =new File(finalPath);
|
||||
FileInputStream fileInputStream =new FileInputStream(file);
|
||||
// FileInputStream fileInputStream =new FileInputStream(file1);
|
||||
MultipartFile resFile = new MockMultipartFile("file", file.getName(), null, fileInputStream);
|
||||
// 返回图片路径
|
||||
String saveFile = backendFileController.saveFile(resFile);
|
||||
@ -75,9 +105,66 @@ public class TagCodeServiceImpl extends ServiceImpl<TagCodeMapper, TagCode> impl
|
||||
tagCode.setImageUrl(finalPath);
|
||||
flag = save(tagCode);
|
||||
}
|
||||
|
||||
//导出码牌
|
||||
String IMAGE_DIRECTORY = "D:\\temp\\tagCode\\"+DateUtil.formatDate(new Date(), "yyyyMMdd")+"-"+i2;
|
||||
|
||||
List<File> imageFiles = getImageFiles(IMAGE_DIRECTORY);
|
||||
InputStream zipInputStream = createZipInputStream(imageFiles);
|
||||
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"images.zip\"");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.body(new InputStreamResource(zipInputStream));
|
||||
}else {
|
||||
InputStream inputStream = new InputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
return ResponseEntity.ok()
|
||||
.body(new InputStreamResource(inputStream));
|
||||
}
|
||||
|
||||
return flag;
|
||||
|
||||
//String IMAGE_DIRECTORY = "D:\\temp\\qrCode\\DateUtil.formatDate(new Date(), \"yyyyMMdd\") +";
|
||||
|
||||
|
||||
//return flag;
|
||||
}
|
||||
private List<File> getImageFiles(String directory) {
|
||||
ArrayList<File> objects = new ArrayList<>();
|
||||
File imageDir = new File(directory);
|
||||
File[] files = imageDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".jpg") || name.toLowerCase().endsWith(".png"));
|
||||
for (File file : files) {
|
||||
objects.add(file);
|
||||
}
|
||||
return objects;
|
||||
//return files != null ? new ArrayList<>(List.of(files)) : new ArrayList<>();
|
||||
}
|
||||
|
||||
private InputStream createZipInputStream(List<File> imageFiles) throws IOException {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zipOut = new ZipOutputStream(outputStream);
|
||||
|
||||
for (File file : imageFiles) {
|
||||
ZipEntry zipEntry = new ZipEntry(file.getName());
|
||||
zipOut.putNextEntry(zipEntry);
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = fileInputStream.read(buffer)) > 0) {
|
||||
zipOut.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
fileInputStream.close();
|
||||
zipOut.closeEntry();
|
||||
}
|
||||
|
||||
zipOut.close();
|
||||
return new ByteArrayInputStream(outputStream.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,12 @@ public class BackendDutyController extends BaseController {
|
||||
public ResponseObject updateHandler(HttpServletRequest request, @RequestBody Map<String, Object> param) {
|
||||
String token = request.getHeader("Access-Token");
|
||||
List<Integer> menuIds = (List) param.get("menuIds");
|
||||
String id = param.get("dutyId").toString();
|
||||
String id = "";
|
||||
if (ObjectUtil.isNotEmpty(param.get("dutyId"))){
|
||||
id = param.get("dutyId").toString();
|
||||
}else {
|
||||
id = param.get("id").toString();
|
||||
}
|
||||
String name = param.get("roleName").toString();
|
||||
String type = param.get("roleType").toString();
|
||||
String status = param.get("status").toString();
|
||||
|
Loading…
Reference in New Issue
Block a user