Compare commits
2 Commits
fd770581a7
...
2bb5b01136
| Author | SHA1 | Date |
|---|---|---|
|
|
2bb5b01136 | |
|
|
4acba24634 |
|
|
@ -27,7 +27,9 @@ public class CacheUtil {
|
|||
}
|
||||
|
||||
public JSONObject get(String key) {
|
||||
return JSONObject.parseObject(redisTemplate.opsForValue().get(key).toString());
|
||||
String json = (String) redisTemplate.opsForValue().get(key);
|
||||
if (json == null) return null;
|
||||
return JSONObject.parseObject(json);
|
||||
}
|
||||
|
||||
public void delete(String key) {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import com.syjiaer.clinic.server.common.annotations.NoAuthCheck;
|
|||
import com.syjiaer.clinic.server.common.annotations.RecordCommonLog;
|
||||
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||
import com.syjiaer.clinic.server.common.util.CacheUtil;
|
||||
import com.syjiaer.clinic.server.common.util.StringUtil;
|
||||
import com.syjiaer.clinic.server.common.vo.Result;
|
||||
import com.syjiaer.clinic.server.controller.BaseController;
|
||||
import com.syjiaer.clinic.server.service.common.FileService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
|
|
@ -24,8 +26,11 @@ import java.net.MalformedURLException;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("file")
|
||||
public class FileController extends BaseController {
|
||||
|
|
@ -72,7 +77,29 @@ public class FileController extends BaseController {
|
|||
|
||||
}
|
||||
|
||||
@RequestMapping("/uploadToTemp")
|
||||
@NoAuthCheck
|
||||
public String uploadToTemp(MultipartFile file) {
|
||||
try {
|
||||
// 获取文件的后缀名
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String fileExtension = null;
|
||||
if (originalFilename != null) {
|
||||
fileExtension = originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
}
|
||||
|
||||
|
||||
//生成系统临时文件
|
||||
File tempfile = File.createTempFile("temp", fileExtension);
|
||||
file.transferTo(tempfile);
|
||||
String file_token= StringUtil.generateRandomId();
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
map.put("path",tempfile.getAbsolutePath());
|
||||
cacheUtil.set(file_token, map, 60*10);
|
||||
return file_token;
|
||||
} catch (IOException e) {
|
||||
log.error("文件上传失败:",e);
|
||||
throw new MessageException("文件上传失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,4 +141,16 @@ public class InventoryPurchaseController extends BaseController {
|
|||
cacheUtil.set(file_token, map, 60*10);
|
||||
return success(file_token);
|
||||
}
|
||||
@RequestMapping("/fromExcel")
|
||||
public Result fromExcel() {
|
||||
String file_token = parmsUtil.getString("token");
|
||||
Map<String,Object> map=cacheUtil.get(file_token);
|
||||
if (map==null) {
|
||||
return error("文件不存在");
|
||||
}
|
||||
String excelFilePath = (String) map.get("path");
|
||||
Map<String,Object> result=inventoryPurchaseService.fromExcel(excelFilePath);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -611,7 +611,6 @@ public class InventoryPurchaseService extends BaseService {
|
|||
infoMap.put("whole_number",whole_number);
|
||||
infoMap.put("purchase_unit_price",getCellValueAsString(row.getCell(8)));
|
||||
infoMap.put("production_batch_code",getCellValueAsString(row.getCell(9)));
|
||||
|
||||
infoMap.put("production_date",transformDate(getCellValueAsString(row.getCell(10))));
|
||||
infoMap.put("expiry_date",transformDate(getCellValueAsString(row.getCell(11))));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue