|
@@ -1,5 +1,7 @@
|
|
|
package thyyxxk.webserver.service.medicine;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
import org.apache.poi.ss.usermodel.DateUtil;
|
|
@@ -20,13 +22,13 @@ import thyyxxk.webserver.service.hutoolcache.UserCache;
|
|
|
import thyyxxk.webserver.utils.DecimalUtil;
|
|
|
import thyyxxk.webserver.utils.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.StringUtil;
|
|
|
-import thyyxxk.webserver.utils.TokenUtil;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
@@ -76,7 +78,10 @@ public class YpPlanService {
|
|
|
* @Date 2025/2/21 9:55
|
|
|
*/
|
|
|
public ResultVo<List<YpPlanDetail>> selectYpPlanDetail(YpPlanDetail detail){
|
|
|
- List<YpPlanDetail> list = detailDao.selectYpPlanDetail(detail);
|
|
|
+ QueryWrapper<YpPlanDetail> querywrapper = new QueryWrapper<>();
|
|
|
+ querywrapper.eq("file_id", detail.getFileId());
|
|
|
+ querywrapper.like("supply_name", detail.getSupplyName());
|
|
|
+ List<YpPlanDetail> list = detailDao.selectList(querywrapper);
|
|
|
return ResultVoUtil.success(list);
|
|
|
}
|
|
|
|
|
@@ -96,10 +101,14 @@ public class YpPlanService {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
String fileId = info.getFileId();
|
|
|
String fileName = info.getFileName();
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ int year = now.getYear();
|
|
|
+ int month = now.getMonthValue();
|
|
|
+ String ny = year + "" + (month < 10 ? "0" + month : month);
|
|
|
MultipartFile file = info.getFile();
|
|
|
try {
|
|
|
// 解析导入的数据
|
|
|
- List<YpPlanDetail> list = callYpPlanImportData(fileId, file);
|
|
|
+ List<YpPlanDetail> list = callYpPlanImportData(fileId, file, ny);
|
|
|
if(list.isEmpty()){
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "导入药品申请与审核药品明细为空,请确认!");
|
|
|
}
|
|
@@ -107,6 +116,12 @@ public class YpPlanService {
|
|
|
BigDecimal totalFee = BigDecimal.ZERO;
|
|
|
for(YpPlanDetail d : list){
|
|
|
totalFee = DecimalUtil.add(totalFee, d.getBuyMoney());
|
|
|
+ // 计算当月累计已审批计划量
|
|
|
+ int plan = detailDao.selectYpPlanTotalByMonth(d.getChargeCode(), ny);
|
|
|
+ d.setPlanTotal(Convert.toStr(plan, "0"));
|
|
|
+ // 计算当月累计实际入库量
|
|
|
+ int real = detailDao.selectYpRealTotalByMonth(d.getChargeCode(), ny);
|
|
|
+ d.setRealTotal(Convert.toStr(real, "0"));
|
|
|
}
|
|
|
info.setTotalFee(totalFee);
|
|
|
UserInfo user = userCache.getUserInfoByToken();
|
|
@@ -140,10 +155,11 @@ public class YpPlanService {
|
|
|
* @Author hsh
|
|
|
* @param fileId 文件id
|
|
|
* @param file 文件
|
|
|
+ * @param ny 年月
|
|
|
* @return list
|
|
|
* @Date 2025/2/21 16:19
|
|
|
*/
|
|
|
- private List<YpPlanDetail> callYpPlanImportData(String fileId, MultipartFile file) throws IOException {
|
|
|
+ public List<YpPlanDetail> callYpPlanImportData(String fileId, MultipartFile file, String ny) throws IOException {
|
|
|
InputStream is = null;
|
|
|
Workbook workbook;
|
|
|
// 导入数据接收list
|
|
@@ -177,40 +193,47 @@ public class YpPlanService {
|
|
|
}
|
|
|
imp.setRemark(stirs[0]);
|
|
|
imp.setSupplyName(stirs[1]);
|
|
|
- imp.setDrugName(stirs[2]);
|
|
|
- imp.setSpecification(stirs[3]);
|
|
|
- if(StringUtil.notBlank(stirs[4])){
|
|
|
- imp.setPackRetprice(new BigDecimal(stirs[4]));
|
|
|
- imp.setPackRetprice1(stirs[4]);
|
|
|
+ imp.setChargeCode(stirs[2]);
|
|
|
+ imp.setDrugName(stirs[3]);
|
|
|
+ imp.setSpecification(stirs[4]);
|
|
|
+ imp.setDrugKind(stirs[5]);
|
|
|
+ imp.setIsWinning(stirs[6]);
|
|
|
+ if(StringUtil.notBlank(stirs[7])){
|
|
|
+ imp.setPackRetprice(new BigDecimal(stirs[7]));
|
|
|
+ imp.setPackRetprice1(stirs[7]);
|
|
|
}
|
|
|
- if(StringUtil.notBlank(stirs[5])){
|
|
|
- imp.setBuyPrice(new BigDecimal(stirs[5]));
|
|
|
- imp.setBuyPrice1(stirs[5]);
|
|
|
- }
|
|
|
- if(StringUtil.notBlank(stirs[6])){
|
|
|
- imp.setAmount(new BigDecimal(stirs[6]));
|
|
|
- }
|
|
|
- imp.setManuName(stirs[7]);
|
|
|
if(StringUtil.notBlank(stirs[8])){
|
|
|
- imp.setAmount3(new BigDecimal(stirs[8]));
|
|
|
+ imp.setBuyPrice(new BigDecimal(stirs[8]));
|
|
|
+ imp.setBuyPrice1(stirs[8]);
|
|
|
}
|
|
|
if(StringUtil.notBlank(stirs[9])){
|
|
|
- imp.setAmount7(new BigDecimal(stirs[9]));
|
|
|
- }
|
|
|
- if(StringUtil.notBlank(stirs[10])){
|
|
|
- imp.setAmount14(new BigDecimal(stirs[10]));
|
|
|
+ imp.setAmount(new BigDecimal(stirs[9]));
|
|
|
}
|
|
|
+ imp.setManuName(stirs[10]);
|
|
|
if(StringUtil.notBlank(stirs[11])){
|
|
|
- imp.setAmount30(new BigDecimal(stirs[11]));
|
|
|
+ imp.setAmount3(new BigDecimal(stirs[11]));
|
|
|
}
|
|
|
if(StringUtil.notBlank(stirs[12])){
|
|
|
- imp.setAmount60(new BigDecimal(stirs[12]));
|
|
|
+ imp.setAmount7(new BigDecimal(stirs[12]));
|
|
|
+ }
|
|
|
+ if(StringUtil.notBlank(stirs[13])){
|
|
|
+ imp.setAmount14(new BigDecimal(stirs[13]));
|
|
|
}
|
|
|
- imp.setDays(stirs[13]);
|
|
|
if(StringUtil.notBlank(stirs[14])){
|
|
|
- imp.setBuyAmount(new BigDecimal(stirs[14]));
|
|
|
+ imp.setAmount30(new BigDecimal(stirs[14]));
|
|
|
+ }
|
|
|
+ if(StringUtil.notBlank(stirs[15])){
|
|
|
+ imp.setAmount60(new BigDecimal(stirs[15]));
|
|
|
+ }
|
|
|
+ imp.setDays(stirs[16]);
|
|
|
+ if(StringUtil.notBlank(stirs[17])){
|
|
|
+ imp.setBuyAmount(new BigDecimal(stirs[17]));
|
|
|
+ }
|
|
|
+ // 单位
|
|
|
+ if(stirs.length >= 19 && StringUtil.notBlank(stirs[18])){
|
|
|
+ imp.setUnit(stirs[18]);
|
|
|
}
|
|
|
- imp.setUnit(stirs[15]);
|
|
|
+ // 购入价金额
|
|
|
if(null == imp.getBuyPrice() || null == imp.getBuyAmount()){
|
|
|
imp.setBuyFee(BigDecimal.ZERO);
|
|
|
imp.setBuyMoney(BigDecimal.ZERO);
|
|
@@ -218,14 +241,16 @@ public class YpPlanService {
|
|
|
imp.setBuyFee(DecimalUtil.multiply(imp.getBuyPrice(), imp.getBuyAmount()));
|
|
|
imp.setBuyMoney(DecimalUtil.multiply(imp.getBuyPrice(), imp.getBuyAmount()));
|
|
|
}
|
|
|
- if(stirs.length == 18 && StringUtil.notBlank(stirs[17])){
|
|
|
- imp.setContent(stirs[17]);
|
|
|
+ // 主任意见
|
|
|
+ if(stirs.length == 21 && StringUtil.notBlank(stirs[20])){
|
|
|
+ imp.setContent(stirs[20]);
|
|
|
}
|
|
|
imp.setFileId(fileId);
|
|
|
// 常量
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
imp.setImpDate(now.format(sdf));
|
|
|
+ imp.setMonth(ny);
|
|
|
impList.add(imp);
|
|
|
str = new StringBuilder();
|
|
|
}
|
|
@@ -233,6 +258,7 @@ public class YpPlanService {
|
|
|
is.close();
|
|
|
} catch (Exception e) {
|
|
|
log.info("导入药品计划出错:" + e.getMessage());
|
|
|
+ ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "药品计划导入失败!" + e.getMessage());
|
|
|
} finally {
|
|
|
if(is != null){
|
|
|
is.close();
|