|
|
@ -1,18 +1,26 @@ |
|
|
package com.hxhq.business.controller; |
|
|
package com.hxhq.business.controller; |
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
import com.hxhq.business.domain.GspFfjlJcgj; |
|
|
import com.hxhq.business.domain.GspFfjlJcgj; |
|
|
import com.hxhq.business.domain.GspRkjlJcgj; |
|
|
import com.hxhq.business.domain.GspRkjlJcgj; |
|
|
|
|
|
import com.hxhq.business.dto.gsp.ImportGspRkjlDto; |
|
|
import com.hxhq.business.form.gsp.*; |
|
|
import com.hxhq.business.form.gsp.*; |
|
|
import com.hxhq.business.form.mjy.*; |
|
|
import com.hxhq.business.form.mjy.*; |
|
|
import com.hxhq.business.service.IGspRkjlJcgjService; |
|
|
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.core.utils.poi.ExcelUtil; |
|
|
import com.hxhq.common.security.annotation.RequiresPermissions; |
|
|
import com.hxhq.common.security.annotation.RequiresPermissions; |
|
|
import com.hxhq.common.security.utils.SecurityUtils; |
|
|
import com.hxhq.common.security.utils.SecurityUtils; |
|
|
import com.hxhq.system.api.domain.SysUser; |
|
|
import com.hxhq.system.api.domain.SysUser; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
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.controller.BaseController; |
|
|
import com.hxhq.common.core.web.domain.AjaxResult; |
|
|
import com.hxhq.common.core.web.domain.AjaxResult; |
|
|
import com.hxhq.common.core.web.page.TableDataInfo; |
|
|
import com.hxhq.common.core.web.page.TableDataInfo; |
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
@ -193,7 +202,64 @@ public class GspRkjlController extends BaseController |
|
|
@PostMapping("/importTemplate") |
|
|
@PostMapping("/importTemplate") |
|
|
public void importTemplate(HttpServletResponse response) throws IOException |
|
|
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, "【模板】供试品入库记录"); |
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|