|
@@ -1,5 +1,6 @@
|
|
package org.jeecg.modules.inventory.controller;
|
|
package org.jeecg.modules.inventory.controller;
|
|
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -9,20 +10,28 @@ import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
+import org.jeecg.config.JeecgBaseConfig;
|
|
import org.jeecg.modules.inventory.entity.ItdmInventoryBarcode;
|
|
import org.jeecg.modules.inventory.entity.ItdmInventoryBarcode;
|
|
import org.jeecg.modules.inventory.entity.ItdmSampleInventory;
|
|
import org.jeecg.modules.inventory.entity.ItdmSampleInventory;
|
|
import org.jeecg.modules.inventory.service.IItdmInventoryBarcodeService;
|
|
import org.jeecg.modules.inventory.service.IItdmInventoryBarcodeService;
|
|
import org.jeecg.modules.inventory.service.IItdmSampleInventoryService;
|
|
import org.jeecg.modules.inventory.service.IItdmSampleInventoryService;
|
|
|
|
+import org.jeecg.modules.inventory.util.BarcodeUtils;
|
|
import org.jeecg.modules.inventory.vo.BarcodeXialaListVO;
|
|
import org.jeecg.modules.inventory.vo.BarcodeXialaListVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import javax.imageio.ImageIO;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -42,6 +51,8 @@ public class ItdmInventoryBarcodeController extends JeecgController<ItdmInventor
|
|
@Autowired
|
|
@Autowired
|
|
private IItdmSampleInventoryService itdmSampleInventoryService;
|
|
private IItdmSampleInventoryService itdmSampleInventoryService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ JeecgBaseConfig jeecgBaseConfig;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 条码下拉列表
|
|
* 条码下拉列表
|
|
@@ -54,7 +65,6 @@ public class ItdmInventoryBarcodeController extends JeecgController<ItdmInventor
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 分页列表查询
|
|
* 分页列表查询
|
|
*
|
|
*
|
|
@@ -88,7 +98,7 @@ public class ItdmInventoryBarcodeController extends JeecgController<ItdmInventor
|
|
//@RequiresPermissions("org.jeecg.modules:itdm_inventory_barcode:add")
|
|
//@RequiresPermissions("org.jeecg.modules:itdm_inventory_barcode:add")
|
|
@PostMapping(value = "/add")
|
|
@PostMapping(value = "/add")
|
|
@Transactional
|
|
@Transactional
|
|
- public Result<String> add(@RequestBody ItdmInventoryBarcode itdmInventoryBarcode) {
|
|
|
|
|
|
+ public Result<String> add(@RequestBody ItdmInventoryBarcode itdmInventoryBarcode) throws IOException {
|
|
ItdmSampleInventory itdmSampleInventory = itdmSampleInventoryService.getById(itdmInventoryBarcode.getInventoryId());
|
|
ItdmSampleInventory itdmSampleInventory = itdmSampleInventoryService.getById(itdmInventoryBarcode.getInventoryId());
|
|
|
|
|
|
ItdmInventoryBarcode itdmInventoryBarcodeServiceOne = itdmInventoryBarcodeService.getOne(Wrappers.lambdaQuery(ItdmInventoryBarcode.class)
|
|
ItdmInventoryBarcode itdmInventoryBarcodeServiceOne = itdmInventoryBarcodeService.getOne(Wrappers.lambdaQuery(ItdmInventoryBarcode.class)
|
|
@@ -109,6 +119,20 @@ public class ItdmInventoryBarcodeController extends JeecgController<ItdmInventor
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ String fileName = "bracode" + File.separator + System.currentTimeMillis() + ".jpg";
|
|
|
|
+ String filePath = jeecgBaseConfig.getPath().getUpload() + File.separator + fileName;
|
|
|
|
+ FileUtil.touch(filePath);
|
|
|
|
+
|
|
|
|
+ BufferedImage image = BarcodeUtils.insertWords(BarcodeUtils.getBarCode(itdmInventoryBarcode.getBarCode()), itdmInventoryBarcode.getBarCode());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (image == null) {
|
|
|
|
+ throw new JeecgBootException("条码生成失败");
|
|
|
|
+ }
|
|
|
|
+ ImageIO.write(image, "jpg", new File(filePath));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ itdmInventoryBarcode.setImgPath(fileName);
|
|
itdmInventoryBarcode.setDisableStatus("0");
|
|
itdmInventoryBarcode.setDisableStatus("0");
|
|
itdmInventoryBarcode.setUseStatus("0");
|
|
itdmInventoryBarcode.setUseStatus("0");
|
|
itdmInventoryBarcode.setNum("1");
|
|
itdmInventoryBarcode.setNum("1");
|
|
@@ -117,7 +141,6 @@ public class ItdmInventoryBarcodeController extends JeecgController<ItdmInventor
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 编辑
|
|
* 编辑
|
|
*
|
|
*
|