Browse Source

feat:[系统管理][存储位置]

master
HanLong 3 weeks ago
parent
commit
9f38cea657
9 changed files with 246 additions and 22 deletions
  1. +30
    -1
      hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/utils/DateUtils.java
  2. +20
    -10
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspRkjlController.java
  3. +100
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StorageLocationController.java
  4. +10
    -6
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/gsp/ImportGspRkjlDto.java
  5. +68
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/storage/ImportStorageLocationDto.java
  6. +1
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/gsp/GspRkjlForm.java
  7. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/IStorageLocationService.java
  8. +1
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/GspRkjlServiceImpl.java
  9. +9
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StorageLocationServiceImpl.java

+ 30
- 1
hxhq-common/hxhq-common-core/src/main/java/com/hxhq/common/core/utils/DateUtils.java View File

@ -27,8 +27,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
private static String[] parsePatterns = {
public static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
@ -188,4 +189,32 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
/**
* 校验是否是正确的时间格式
* @param dateStr 时间字符串
* @param format 时间格式
* @return
*/
public static boolean isValidTimeFormat(String dateStr, String format) {
SimpleDateFormat sdf = new SimpleDateFormat(format);
sdf.setLenient(false); // 设置为非宽容模式这样解析失败会抛出异常
try {
Date date = sdf.parse(dateStr); // 尝试解析字符串
sdf.format(date); // 再次格式化日期确保格式正确
return true;
} catch (ParseException e) {
return false; // 解析失败返回false
}
}
public static boolean isValidTimeFormat(String dateStr, String[] formats) {
for (String format : formats) {
boolean validTimeFormat = isValidTimeFormat(dateStr, format);
if(!validTimeFormat) {
return false;
}
}
return true;
}
}

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

@ -18,6 +18,8 @@ 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 com.hxhq.system.service.ISysUserService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -48,6 +50,9 @@ public class GspRkjlController extends BaseController
@Autowired
private IGspRkjlJcgjService gspRkjlJcgjService;
@Autowired
private ISysUserService sysUserService;
/**
* 查询供试品入库记录列表
*/
@ -218,13 +223,19 @@ public class GspRkjlController extends BaseController
@PostMapping("/importData")
public void importData(MultipartFile file, GspRkjlForm form, HttpServletResponse response) throws IOException
public AjaxResult importData(MultipartFile file, GspRkjlForm form, HttpServletResponse response) throws IOException
{
form.setQmrId(SecurityUtils.getUserId());
sysUserService.checkPassword(SecurityUtils.getUserId(), form.getQmrmm(), false);
ExcelUtil<ImportGspRkjlDto> util = new ExcelUtil<ImportGspRkjlDto>(ImportGspRkjlDto.class);
List<ImportGspRkjlDto> gspRkjlDtoList = util.importExcel(file.getInputStream());
if(CollectionUtils.isEmpty(gspRkjlDtoList)) {
throw new ServiceException("导入数据表格为空");
}
int i = 2;
List<String> importList = new ArrayList<>();
List<GspRkjlForm> importDataList = new ArrayList<>();
for (ImportGspRkjlDto importGspRkjlDto : gspRkjlDtoList) {
if(StringUtils.isEmpty(importGspRkjlDto.getMc())) {
throw new ServiceException("第【" + i + "】行名称不能为空");
@ -235,8 +246,8 @@ public class GspRkjlController extends BaseController
if(StringUtils.isEmpty(importGspRkjlDto.getGg())) {
throw new ServiceException("第【" + i + "】行规格不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getRksj())) {
throw new ServiceException("第【" + i + "】行入库时间不能为空");
if(importGspRkjlDto.getRksj() == null) {
throw new ServiceException("第【" + i + "】行入库时间为空或时间格式错误");
}
if(StringUtils.isEmpty(importGspRkjlDto.getRkl())) {
throw new ServiceException("第【" + i + "】行入库量不能为空");
@ -247,8 +258,8 @@ public class GspRkjlController extends BaseController
if(StringUtils.isEmpty(importGspRkjlDto.getCctj())) {
throw new ServiceException("第【" + i + "】行保存条件不能为空");
}
if(StringUtils.isEmpty(importGspRkjlDto.getYxq())) {
throw new ServiceException("第【" + i + "】行有效期不能为空");
if(importGspRkjlDto.getYxq() == null) {
throw new ServiceException("第【" + i + "】行有效期为空或时间格式错误");
}
if(StringUtils.isEmpty(importGspRkjlDto.getZysx())) {
throw new ServiceException("第【" + i + "】行注意事项不能为空");
@ -264,12 +275,11 @@ public class GspRkjlController extends BaseController
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);
importDataList.add(gspRkjlForm);
}
gspRkjlService.addBatch(importDataList, form);
return success();
}
}

+ 100
- 3
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StorageLocationController.java View File

@ -1,17 +1,32 @@
package com.hxhq.business.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hxhq.business.domain.GspRkjl;
import com.hxhq.business.domain.StorageLocationJcgj;
import com.hxhq.business.domain.YqJcgj;
import com.hxhq.business.dto.gsp.ImportGspRkjlDto;
import com.hxhq.business.dto.storage.ImportStorageLocationDto;
import com.hxhq.business.form.gsp.GspRkjlForm;
import com.hxhq.business.form.yq.StorageLocationForm;
import com.hxhq.business.form.yq.StorageLocationSearchForm;
import com.hxhq.business.service.IStorageLocationJcgjService;
import com.hxhq.common.core.exception.ServiceException;
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.SysDept;
import com.hxhq.system.api.domain.SysDictData;
import com.hxhq.system.service.ISysDeptService;
import com.hxhq.system.service.ISysDictDataService;
import com.hxhq.system.service.ISysUserService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.StorageLocation;
@ -19,6 +34,9 @@ import com.hxhq.business.service.IStorageLocationService;
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;
/**
@ -37,6 +55,13 @@ public class StorageLocationController extends BaseController
@Autowired
private IStorageLocationJcgjService storageLocationJcgjService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysDeptService sysDeptService;
/**
* 查询仪器稽查轨迹列表
*/
@ -110,4 +135,76 @@ public class StorageLocationController extends BaseController
storageLocationService.updateStorageLocation(form);
return success();
}
@PostMapping("/importTemplate")
@RequiresPermissions("business:storageLocation:import")
public void importTemplate(HttpServletResponse response) throws IOException
{
ExcelUtil<ImportStorageLocationDto> util = new ExcelUtil<ImportStorageLocationDto>(ImportStorageLocationDto.class);
util.importTemplateExcel(response, "【模板】存储位置");
}
@PostMapping("/importData")
@RequiresPermissions("business:storageLocation:import")
public AjaxResult importData(MultipartFile file, StorageLocationForm form, HttpServletResponse response) throws IOException
{
form.setQmrId(SecurityUtils.getUserId());
sysUserService.checkPassword(SecurityUtils.getUserId(), form.getQmrmm(), false);
List<SysDept> sysDepts = sysDeptService.selectDeptList(new SysDept());
Map<String, Long> sysDeptMap = new HashMap<>();
for (SysDept sysDept : sysDepts) {
sysDeptMap.put(sysDept.getDeptName(), sysDept.getDeptId());
}
List<StorageLocation> list = storageLocationService.list();
List<String> storageLocationNameList = list.stream().map(StorageLocation::getName).collect(Collectors.toList());
ExcelUtil<ImportStorageLocationDto> util = new ExcelUtil<ImportStorageLocationDto>(ImportStorageLocationDto.class);
List<ImportStorageLocationDto> storageLocationDtos = util.importExcel(file.getInputStream());
if(CollectionUtils.isEmpty(storageLocationDtos)) {
throw new ServiceException("导入数据表格为空");
}
int i = 2;
List<String> importList = new ArrayList<>();
List<StorageLocation> importDataList = new ArrayList<>();
for (ImportStorageLocationDto importStorageLocationDto : storageLocationDtos) {
if(StringUtils.isEmpty(importStorageLocationDto.getLocation())) {
throw new ServiceException("第【" + i + "】行放置地点不能为空");
}
if(StringUtils.isEmpty(importStorageLocationDto.getName())) {
throw new ServiceException("第【" + i + "】行设备名称或编号不能为空");
}
if(storageLocationNameList.contains(importStorageLocationDto.getName())) {
throw new ServiceException("第【" + i + "】行设备名称或编号【" + importStorageLocationDto.getName() + "】已存在");
}
if(StringUtils.isEmpty(importStorageLocationDto.getShelfPlacement())) {
throw new ServiceException("第【" + i + "】行放置货架不能为空");
}
if(StringUtils.isEmpty(importStorageLocationDto.getCompartment())) {
throw new ServiceException("第【" + i + "】行温层不能为空");
}
if(StringUtils.isEmpty(importStorageLocationDto.getDeptName())) {
throw new ServiceException("第【" + i + "】行所属部门不能为空");
}
Long deptId = sysDeptMap.get(importStorageLocationDto.getDeptName());
if(deptId == null) {
throw new ServiceException("第【" + i + "】行所属部门【" + importStorageLocationDto.getDeptName() + "】名称有误,无法匹配对应数据");
}
if(importList.contains(importStorageLocationDto.getName())) {
throw new ServiceException("第【" + i + "】行存在重复数据【" + importStorageLocationDto.getName() + "】");
}
importList.add(importStorageLocationDto.getName());
StorageLocation storageLocationForm = new StorageLocation();
BeanUtils.copyProperties(importStorageLocationDto, storageLocationForm);
storageLocationForm.setDeptId(deptId);
storageLocationForm.setStatus(10);
importDataList.add(storageLocationForm);
}
storageLocationService.addBatch(importDataList, form);
return success();
}
}

+ 10
- 6
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/gsp/ImportGspRkjlDto.java View File

@ -1,6 +1,10 @@
package com.hxhq.business.dto.gsp;
import com.hxhq.common.core.annotation.Excel;
import com.hxhq.common.core.utils.DateUtils;
import java.text.DateFormat;
import java.util.Date;
public class ImportGspRkjlDto {
@ -14,7 +18,7 @@ public class ImportGspRkjlDto {
private String gg;
@Excel(name = "入库时间")
private String rksj;
private Date rksj;
@Excel(name = "入库量")
private String rkl;
@ -26,7 +30,7 @@ public class ImportGspRkjlDto {
private String cctj;
@Excel(name = "有效期")
private String yxq;
private Date yxq;
@Excel(name = "注意事项")
private String zysx;
@ -55,11 +59,11 @@ public class ImportGspRkjlDto {
this.gg = gg;
}
public String getRksj() {
public Date getRksj() {
return rksj;
}
public void setRksj(String rksj) {
public void setRksj(Date rksj) {
this.rksj = rksj;
}
@ -87,11 +91,11 @@ public class ImportGspRkjlDto {
this.cctj = cctj;
}
public String getYxq() {
public Date getYxq() {
return yxq;
}
public void setYxq(String yxq) {
public void setYxq(Date yxq) {
this.yxq = yxq;
}

+ 68
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/storage/ImportStorageLocationDto.java View File

@ -0,0 +1,68 @@
package com.hxhq.business.dto.storage;
import com.baomidou.mybatisplus.annotation.TableField;
import com.hxhq.common.core.annotation.Compare;
import com.hxhq.common.core.annotation.Excel;
import java.util.Date;
public class ImportStorageLocationDto {
@Excel(name = "放置地点")
private String location;
/** 设备名称或编号 */
@Excel(name = "设备名称或编号")
private String name;
/** 放置货架 */
@Excel(name = "放置货架")
private String shelfPlacement;
/** 温层 */
@Excel(name = "温层")
private String compartment;
@Excel(name = "所属部门")
private String deptName;
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getShelfPlacement() {
return shelfPlacement;
}
public void setShelfPlacement(String shelfPlacement) {
this.shelfPlacement = shelfPlacement;
}
public String getCompartment() {
return compartment;
}
public void setCompartment(String compartment) {
this.compartment = compartment;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
}

+ 1
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/form/gsp/GspRkjlForm.java View File

@ -35,7 +35,7 @@ public class GspRkjlForm {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date rksj;
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date yxq;
/** 存储条件 */

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

@ -42,4 +42,11 @@ public interface IStorageLocationService extends IService
* @param form
*/
void updateStorageLocation(StorageLocationForm form);
/**
* 批量添加存储位置
* @param importDataList
* @param form
*/
void addBatch(List<StorageLocation> importDataList, StorageLocationForm form);
}

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

@ -139,7 +139,7 @@ public class GspRkjlServiceImpl extends ServiceImpl impl
queryWrapper.eq(GspRkjl::getMc, form.getMc())
.eq(GspRkjl::getPh, form.getPh())
.eq(GspRkjl::getGg, form.getGg())
.eq(GspRkjl::getGgdw, form.getGgdw())
// .eq(GspRkjl::getGgdw, form.getGgdw())
.eq(GspRkjl::getRksj, form.getRksj());
return getOne(queryWrapper);
}

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

@ -148,4 +148,13 @@ public class StorageLocationServiceImpl extends ServiceImpl
storageLocationJcgjService.saveBatchWithLog(storageLocation, jcgjList);
}
@Override
public void addBatch(List<StorageLocation> importDataList, StorageLocationForm form) {
this.saveBatch(importDataList);
for (StorageLocation storageLocation : importDataList) {
storageLocationJcgjService.saveJcgj(storageLocation, JcgjlxEnum.bj.getValue(),
"新增存储位置", "Add Storage Location", JcmcysEnum.blue.getValue(), null, null);
}
}
}

Loading…
Cancel
Save