Compare commits

..

No commits in common. "2bb5b0113638b16bf41448e055f1dca3929b7ee8" and "fd770581a716d77471483a572b17a2a6b69966d9" have entirely different histories.

4 changed files with 3 additions and 43 deletions

View File

@ -27,9 +27,7 @@ public class CacheUtil {
}
public JSONObject get(String key) {
String json = (String) redisTemplate.opsForValue().get(key);
if (json == null) return null;
return JSONObject.parseObject(json);
return JSONObject.parseObject(redisTemplate.opsForValue().get(key).toString());
}
public void delete(String key) {

View File

@ -5,11 +5,9 @@ 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;
@ -26,11 +24,8 @@ 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 {
@ -77,29 +72,7 @@ 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());
}
}
}

View File

@ -141,16 +141,4 @@ 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);
}
}

View File

@ -611,6 +611,7 @@ 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))));