|
@@ -1,20 +1,30 @@
|
|
|
package com.bofeng.service;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.toolkit.IdWorker;
|
|
|
import com.bofeng.JwtHelper;
|
|
|
import com.bofeng.dao.*;
|
|
|
import com.bofeng.entity.*;
|
|
|
+import com.google.common.base.Strings;
|
|
|
import com.yvan.PageDb;
|
|
|
import com.yvan.platform.StringUtils;
|
|
|
+import lombok.val;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.shiro.util.CollectionUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -22,6 +32,8 @@ import java.util.Map;
|
|
|
@Transactional(readOnly = true)
|
|
|
public class SweepCodeService {
|
|
|
|
|
|
+ @Value("${upload-file-path}")
|
|
|
+ private String uploadFilePath;
|
|
|
@Autowired
|
|
|
private SweepCodeMapper sweepCodeMapper;
|
|
|
@Autowired
|
|
@@ -40,6 +52,8 @@ public class SweepCodeService {
|
|
|
private MsReportMapper msReportMapper;
|
|
|
@Autowired
|
|
|
private VaccineMapper vaccineMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysFileMapper sysFileMapper;
|
|
|
|
|
|
public List<SysUptownHouse> selectCode(PageDb pageDb, Map<String, Object> queryParam) {
|
|
|
List<SysUptownHouse> sysUptownHouses = sweepCodeMapper.selectCode(pageDb,queryParam);
|
|
@@ -505,4 +519,56 @@ public class SweepCodeService {
|
|
|
map.put("unitType", 7000); // 对应的sql查询中部门大于7000
|
|
|
return vaccineMapper.exSelectVaccine(map);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传凭证图片
|
|
|
+ * @param file
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
+ public int uploadVaccine(MultipartFile file, Long userId, String userName) {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+ File url = new File(uploadFilePath + "/" + sdf.format(new Date()));
|
|
|
+ if (!url.exists()) {
|
|
|
+ url.mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String ext = getExt(fileName);
|
|
|
+ Long fileId = IdWorker.getId();
|
|
|
+ String fileUrl = url + "/" + fileId + "." + ext;
|
|
|
+ file.transferTo(new File(fileUrl));
|
|
|
+ SysFile sysFile = new SysFile();
|
|
|
+ sysFile.setFileId(fileId);
|
|
|
+ sysFile.setModuleId(1);
|
|
|
+ sysFile.setFileName(fileName);
|
|
|
+ sysFile.setFileExt(getExt(fileName));
|
|
|
+ sysFile.setFileSize(file.getSize());
|
|
|
+ sysFile.setFileUrl("/" + sdf.format(new Date()) + "/" + fileId + "." + ext);
|
|
|
+ sysFile.setUserId(userId);
|
|
|
+ sysFile.setUserName(userName);
|
|
|
+ sysFile.setTimeCreate(new Date());
|
|
|
+ sysFile.setTimeUpdate(new Date());
|
|
|
+ sysFileMapper.insert(sysFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取文件扩展名
|
|
|
+ */
|
|
|
+ private String getExt(String name) {
|
|
|
+ if (Strings.isNullOrEmpty(name)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ val pos = name.lastIndexOf(".");
|
|
|
+ if (pos < 0) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return name.substring(pos + 1).toLowerCase();
|
|
|
+ }
|
|
|
}
|