Browse Source

fix:[资源库管理][供试品入库记录]导入

master
HanLong 2 months ago
parent
commit
8458e71a6b
3 changed files with 101 additions and 1 deletions
  1. +67
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java
  2. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlService.java
  3. +27
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java

+ 67
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java View File

@ -1,18 +1,26 @@
package com.hxhq.business.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import cn.hutool.json.JSONUtil;
import com.hxhq.business.domain.GspFfjlJcgj;
import com.hxhq.business.domain.GspRkjlJcgj;
import com.hxhq.business.dto.gsp.ImportGspRkjlDto;
import com.hxhq.business.form.gsp.*;
import com.hxhq.business.form.mjy.*;
import com.hxhq.business.service.IGspRkjlJcgjService;
import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.utils.StringUtils;
import com.hxhq.common.core.utils.poi.ExcelUtil;
import com.hxhq.common.security.annotation.RequiresPermissions;
import com.hxhq.common.security.utils.SecurityUtils;
import com.hxhq.system.api.domain.SysUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -21,6 +29,7 @@ import com.hxhq.business.service.IGspRkjlService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@ -193,7 +202,64 @@ public class GspRkjlController extends BaseController
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
ExcelUtil<ImportGspRkjlDto> util = new ExcelUtil<ImportGspRkjlDto>(ImportGspRkjlDto.class);
util.importTemplateExcel(response, "【模板】供试品入库记录");
}
@PostMapping("/importData")
public void importData(MultipartFile file, GspRkjlForm form, HttpServletResponse response) throws IOException
{
ExcelUtil<ImportGspRkjlDto> util = new ExcelUtil<ImportGspRkjlDto>(ImportGspRkjlDto.class);
List<ImportGspRkjlDto> gspRkjlDtoList = util.importExcel(file.getInputStream());
int i = 2;
List<String> importList = new ArrayList<>();
for (ImportGspRkjlDto importGspRkjlDto : gspRkjlDtoList) {
if(StringUtils.isEmpty(importGspRkjlDto.getMc())) {
throw new ServiceException("第【" + i + "】行名称不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getPh())) {
throw new ServiceException("第【" + i + "】行批号不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getGg())) {
throw new ServiceException("第【" + i + "】行规格不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getRksj())) {
throw new ServiceException("第【" + i + "】行入库时间不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getRkl())) {
throw new ServiceException("第【" + i + "】行入库量不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getRkdw())) {
throw new ServiceException("第【" + i + "】行单位不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getCctj())) {
throw new ServiceException("第【" + i + "】行保存条件不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getYxq())) {
throw new ServiceException("第【" + i + "】行有效期不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getZysx())) {
throw new ServiceException("第【" + i + "】行注意事项不能为空");
}
String checkData = importGspRkjlDto.getMc() + importGspRkjlDto.getPh() + importGspRkjlDto.getGg() + importGspRkjlDto.getRksj();
if(importList.contains(checkData)) {
throw new ServiceException("第【" + i + "】行存在重复数据");
}
importList.add(checkData);
GspRkjlForm gspRkjlForm = new GspRkjlForm();
BeanUtils.copyProperties(importGspRkjlDto, gspRkjlForm);
GspRkjl gspRkjl = gspRkjlService.queryInfo(gspRkjlForm);
if(gspRkjl != null) {
throw new ServiceException("第【" + i + "】行系统已有记录");
}
Date rksj = DateUtils.parseDate(importGspRkjlDto.getRksj());
gspRkjlForm.setRksj(rksj);
Date yxq = DateUtils.parseDate(importGspRkjlDto.getYxq());
gspRkjlForm.setYxq(yxq);
}
}
}

+ 7
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IGspRkjlService.java View File

@ -29,6 +29,13 @@ public interface IGspRkjlService extends IService
void add(GspRkjlForm form);
/**
* 导入供试品入库记录
* @param gspRkjlFormList
* @param form
*/
void addBatch(List<GspRkjlForm> gspRkjlFormList, GspRkjlForm form);
/**
* 根据名称规格批号入库时间查询供试品入库记录
* @param form
* @return

+ 27
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java View File

@ -102,6 +102,33 @@ public class GspRkjlServiceImpl extends ServiceImpl impl
}
@Override
public void addBatch(List<GspRkjlForm> gspRkjlFormList, GspRkjlForm form) {
SysUser qmr = sysUserService.selectUserById(form.getQmrId());
sysUserService.checkPassword(qmr, form.getQmrmm(), false);
List<GspRkjl> gspRkjlList = new ArrayList<>();
for (GspRkjlForm gspRkjlForm : gspRkjlFormList) {
GspRkjl gspRkjl = new GspRkjl();
BeanUtils.copyProperties(gspRkjlForm, gspRkjl);
gspRkjl.setJlzt(JlztEnum.wsd.getValue());
gspRkjl.setJyzt(JyztEnum.wjy.getValue());
gspRkjlList.add(gspRkjl);
}
this.saveBatch(gspRkjlList);
for (GspRkjl gspRkjl : gspRkjlList) {
Map<String, String> formData = new LinkedHashMap<>();
formData.put("备注", form.getQmbz());
Map<String, String> formDataEn = new LinkedHashMap<>();
formDataEn.put("Comment", form.getQmbz());
gspRkjlJcgjService.saveJcgj(gspRkjl, JcgjlxEnum.lc.getValue(), "新增供试品入库记录", "Add", JcmcysEnum.blue.getValue(),
JctUtil.formatStr(formData), JctUtil.formatStr(formDataEn), qmr);
}
}
@Override
public GspRkjl queryInfo(GspRkjlForm form) {
LambdaQueryWrapper<GspRkjl> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GspRkjl::getMc, form.getMc())

Loading…
Cancel
Save