This commit is contained in:
牛子源 2025-05-17 09:38:32 +08:00
parent c1176934a8
commit ca9ac3413f
6 changed files with 62 additions and 66 deletions

View File

@ -8,7 +8,7 @@
<version>3.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.syjiaer.pharmacy.proxy</groupId>
<groupId>com.syjiaer.clinic.server</groupId>
<artifactId>server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>server</name>

View File

@ -27,7 +27,7 @@ public class CacheUtil {
}
public JSONObject get(String key) {
return JSONObject.parseObject(JSON.toJSONString(redisTemplate.opsForValue().get(key)));
return JSONObject.parseObject(redisTemplate.opsForValue().get(key).toString());
}
public void delete(String key) {

View File

@ -1,8 +1,10 @@
package com.syjiaer.clinic.server.controller.common;
import com.alibaba.fastjson2.JSONObject;
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.vo.Result;
import com.syjiaer.clinic.server.controller.BaseController;
import com.syjiaer.clinic.server.service.common.FileService;
@ -10,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
@ -28,17 +31,41 @@ import java.util.UUID;
public class FileController extends BaseController {
@Autowired
private FileService fileService;
@Autowired
private CacheUtil cacheUtil;
@RequestMapping("/upload")
@NoAuthCheck
public Result<?> handleFileUpload(@RequestParam("file") MultipartFile file) {
return success(fileService.uploadFile(file));
}
@GetMapping("/getImage/{fileName}")
@RequestMapping("/getImage/{fileName}")
@NoAuthCheck
public ResponseEntity<Resource> getImage(@PathVariable String fileName) {
return fileService.getImage(fileName);
}
@RequestMapping("/download/{token}")
@NoAuthCheck
public ResponseEntity<Resource> download(@PathVariable String token){
JSONObject jsonObject =cacheUtil.get(token);
String filename=jsonObject.getString("path");
Path path = Paths.get(filename);
Resource resource= null;
try {
resource = new UrlResource(path.toUri());
} catch (MalformedURLException e) {
throw new MessageException("创建下载失败");
}
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/octet-stream"))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
.body(resource);
}
}

View File

@ -1,7 +1,9 @@
package com.syjiaer.clinic.server.controller.inventory;
import com.syjiaer.clinic.server.common.annotations.RecordCommonLog;
import com.syjiaer.clinic.server.common.constants.Constants;
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.Page;
import com.syjiaer.clinic.server.common.vo.Result;
import com.syjiaer.clinic.server.controller.BaseController;
@ -10,11 +12,21 @@ import com.syjiaer.clinic.server.entity.inventory.InventoryPurchase;
import com.syjiaer.clinic.server.entity.inventory.dto.PurchaseOrderQuery;
import com.syjiaer.clinic.server.entity.inventory.vo.InventoryPurchaseVo;
import com.syjiaer.clinic.server.service.inventory.InventoryPurchaseService;
import okhttp3.Cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.net.MalformedURLException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -31,8 +43,8 @@ import java.util.Map;
public class InventoryPurchaseController extends BaseController {
@Autowired
private InventoryPurchaseService inventoryPurchaseService;
@Autowired
private CacheUtil cacheUtil;
/**
* 创建采购单
* @return
@ -47,6 +59,7 @@ public class InventoryPurchaseController extends BaseController {
}
/**
* 分页查采购单
* @return
@ -117,4 +130,15 @@ public class InventoryPurchaseController extends BaseController {
return success();
}
@RequestMapping("/toExcel")
public Result toExcel() {
List<Integer> cateIdList = parmsUtil.getIntList("cateIdList");
String excelFilePath = inventoryPurchaseService.toExcel(cateIdList);
String file_token= StringUtil.generateRandomId();
Map<String,Object> map=new HashMap<>();
map.put("path",excelFilePath);
cacheUtil.set(file_token, map, 60*10);
return success(file_token);
}
}

View File

@ -428,6 +428,10 @@ public class InventoryPurchaseService extends BaseService {
}
public String toExcel(List<Integer> cateIdList){
if(cateIdList==null||cateIdList.isEmpty()){
throw new MessageException("请选择分类");
}
//查询goodsCate
QueryWrapper<GoodsCate> goodsCateQueryWrapper = new QueryWrapper<>();
goodsCateQueryWrapper.in("id", cateIdList);

View File

@ -44,68 +44,10 @@ public class SocialDirectoryUpinfoService {
* @param updtTime 更新时间
* @param pageNum 页码
*/
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> update(String updtTime, int pageNum) {
if (updtTime == null) {
throw new MessageException("更新时间不能为空");
}
LocalDate updateDate=LocalDate.parse(updtTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
//如果当前时间是在早上六点到晚上19点之间
if (LocalDateTime.now().getHour() <6 || LocalDateTime.now().getHour() >19) {
//如果更新时间是30天外
if (updateDate.isBefore(LocalDate.now().minusDays(30))) {
throw new MessageException("因医保限制早6点到晚19点间只可以更新30天内数据");
}
}
updtTime=updtTime+" 00:00:00";
IM1312 im1312 = new IM1312();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
im1312.setUpdtTime(LocalDateTime.parse(updtTime, formatter));
im1312.setValiFlag("1");
im1312.setPageNum(pageNum);
im1312.setPageSize(1000);
OM1312 om1312 = socialRequest.call1312(im1312);
List<Map<String, Object>> data = om1312.getData();
for (Map<String, Object> datum : data) {
SocialDirectoryUpinfo socialDirectoryUpinfo = new SocialDirectoryUpinfo();
socialDirectoryUpinfo.setRid(new BigInteger(datum.get("rid").toString()));
socialDirectoryUpinfo.setCode(datum.get("hilist_code").toString());
socialDirectoryUpinfo.setBegndate(DateUtil.getDateTime(datum.get("begndate").toString()));
if(datum.get("enddate")==null){
socialDirectoryUpinfo.setEnddate(null);
}else{
socialDirectoryUpinfo.setEnddate(DateUtil.getDateTime(datum.get("enddate").toString()));
}
socialDirectoryUpinfo.setLmtUsedFlag(datum.get("lmt_used_flag").toString());
socialDirectoryUpinfo.setChrgitmLv(datum.get("chrgitm_lv").toString());
socialDirectoryUpinfo.setMedChrgitmType(datum.get("med_chrgitm_type").toString());
socialDirectoryUpinfo.setPinyin(datum.get("pinyin").toString());
socialDirectoryUpinfo.setWubi(datum.get("wubi").toString());
String code = socialDirectoryUpinfo.getCode();
// 检索数据库中是否存在该主键对应的记录
SocialDirectoryUpinfo existingUpinfo = socialDirectoryUpinfoMapper.selectById(code);
if (existingUpinfo == null) {
socialDirectoryUpinfoMapper.insert(socialDirectoryUpinfo);
} else {
// 记录存在比较 rid 的值
BigInteger newRid = socialDirectoryUpinfo.getRid();
BigInteger oldRid = existingUpinfo.getRid();
if (newRid.compareTo(oldRid) > 0) {
socialDirectoryUpinfoMapper.updateById(socialDirectoryUpinfo);
}
}
}
Map<String, Object> map = new HashMap<>();
map.put("pages", om1312.getPages());
return map;
}
public Map<String, Object> getPage(String updtTime, int pageNum) {
JSONObject result = call(updtTime, pageNum);
System.out.println(result);
int recordCounts = result.getInteger("recordCounts");
int pages = result.getInteger("pages");
JSONArray json_list = result.getJSONArray("data");
@ -151,7 +93,6 @@ public class SocialDirectoryUpinfoService {
}
private JSONObject call(String updt_time, int page_num) {
System.out.println("正在处理:" + page_num);
Map<String, Object> map = new HashMap<>();
map.put("updt_time", updt_time);
map.put("page_num", page_num);