Commit 5131c9a5 by 李小惠

添加代码

parent e81973a5
<component name="libraryTable">
<library name="Maven: org.springframework:spring-web:5.2.5">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/org/springframework/spring-web/5.3.5/spring-web-5.3.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven:cn.afterturn.easypoi-annotation:4.1.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/cn/afterturn/easypoi-annotation/4.1.2/easypoi-annotation-4.1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven:cn.afterturn.easypoi-base:4.1.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/cn/afterturn/easypoi-base/4.1.2/easypoi-base-4.1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven:cn.afterturn.easypoi-spring-boot-starter:4.1.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/cn/afterturn/easypoi-spring-boot-starter/4.1.2/easypoi-spring-boot-starter-4.1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven:cn.afterturn.easypoi-web:4.1.2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/cn/afterturn/easypoi-web/4.1.2/easypoi-web-4.1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven:org.apache.commons.commons-lang3:3.8.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Maven:org.apache.poi:poi:4.1.0">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../repos/org/apache/poi/poi/4.1.0/poi-4.1.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -43,6 +43,14 @@
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
......
package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class EqsSumDto implements Serializable {
//组织机构id
private Long orgId;
//组织机构名称
private String orgName;
//总数(单警柜+仓库)
private Integer totalSum;
//仓库在库数
private Integer inSum;
//仓库出库数
private Integer outSum;
//单警柜出库数
private Integer cabinetOutSum;
//单警柜在库数
private Integer cabinetInSum;
//报废数
private Integer brokenSum;
}
package com.junmp.jyzb.api.bean.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class InOutRecordsDto implements Serializable {
//序号
private String Id;
//操作人员
private String userName;
// 存储名称
private String locationName;
//出入库时间
private Date useTime;
// 出入库状态
private String outInState;
}
......@@ -70,6 +70,7 @@ public class InventoryReq extends BaseRequest {
/**
* 组织机构ID
*/
@NotNull(message = "组织机构不能为空",groups = {export.class})
private Long orgId;
/**
* 单警柜id
......
package com.junmp.jyzb.api.util;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.UUID;
public class ExcelUtils {
/**
* 导出excel到文件
* @param list 数据
* @param title 表头
* @param sheetName sheetName
* @param pojoClass 解析的对象类型
* @param fileName 文件名称
* @param isCreateHeader 是否创建表头
* @return 文件路径
*/
public static String exportExcelToFile(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader) {
OutputStream out = null;
Workbook workbook = null;
try {
ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF);
exportParams.setCreateHeadRows(isCreateHeader);
fileName = encodingFilename(fileName);
out = new FileOutputStream(getAbsoluteFile(fileName));
workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
workbook.write(out);
return fileName;
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
} finally {
if (workbook != null) {
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* excel 导出到文件
* @param list 数据
* @param title 表头
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 文件名
* @return 文件路径
*/
public static String exportExcelToFile(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName) {
return exportExcelToFile(list, title, sheetName, pojoClass, fileName, true);
}
/**
* excel 导出到文件
* @param list 数据
* @param title 表头
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @return 文件路径
*/
public static String exportExcelToFile(List<?> list, String title, String sheetName, Class<?> pojoClass) {
return exportExcelToFile(list, title, sheetName, pojoClass, title, true);
}
/**
* excel 导出到文件
* @param list 数据
* @param fileName 文件名
* @param pojoClass pojo类型
* @return 文件路径
*/
public static String exportExcelToFile(List<?> list, String fileName, Class<?> pojoClass) {
return exportExcelToFile(list, fileName, fileName, pojoClass, fileName, true);
}
/**
* excel 导出通过response的网络形式返回下载(有表头)
* @param list 数据
* @param title 标题
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param isCreateHeader 是否创建表头
* @param response
*/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response) throws IOException {
ExportParams exportParams = new ExportParams(title, sheetName, ExcelType.XSSF);
exportParams.setCreateHeadRows(isCreateHeader);
defaultExport(list, pojoClass, fileName, response, exportParams);
}
/**
* excel 导出通过response的网络形式返回下载(没表头)
* @param list 数据
* @param title 标题
* @param sheetName sheet名称
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param response
*/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response) throws IOException {
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF));
}
/**
*
* @description 在指定的列添加上下拉选的数据
* @param: list
* @param: title
* @param: sheetName
* @param: pojoClass
* @param: fileName
* @param: response
* @param: col
* @param: datas
* @return void
**/
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response, int col, String[] datas) throws IOException {
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName, ExcelType.XSSF), col, datas);
}
/**
* excel 自定义导出格式
* @param list 数据
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param response
* @param exportParams 导出参数
*/
public static void exportExcel(List<?> list, Class<?> pojoClass, String fileName, ExportParams exportParams, HttpServletResponse response) throws IOException {
defaultExport(list, pojoClass, fileName, response, exportParams);
}
/**
* excel 导出
* @param list 数据
* @param fileName 文件名称
* @param response
*/
public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException {
defaultExport(list, fileName, response);
}
/**
* 默认的 excel 导出
* @param list 数据
* @param pojoClass pojo类型
* @param fileName 文件名称
* @param response
* @param exportParams 导出参数
*/
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) throws IOException {
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
downLoadExcel(fileName, response, workbook);
}
// 在指定的列添加导出数据
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName,
HttpServletResponse response, ExportParams exportParams,
int col, String[] datas) throws IOException {
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
selectList(workbook, col, datas);
downLoadExcel(fileName, response, workbook);
}
/**
* 默认的 excel 导出
* @param list 数据
* @param fileName 文件名称
* @param response
*/
private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) throws IOException {
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
downLoadExcel(fileName, response, workbook);
}
/**
* 下载
* @param fileName 文件名称
* @param response
* @param workbook excel数据
*/
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws IOException {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + "." + ExcelTypeEnum.XLSX.getValue(), "UTF-8"));
workbook.write(response.getOutputStream());
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
/**
* excel 导入
* @param filePath excel文件路径
* @param titleRows 标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
if (StringUtils.isBlank(filePath)) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
params.setNeedSave(true);
params.setSaveUrl("/excel/");
try {
return ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) {
throw new IOException("模板不能为空");
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
/**
* excel 导入
* @param file excel文件
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(MultipartFile file, Class<T> pojoClass) throws IOException {
return importExcel(file, 1, 1, pojoClass);
}
/**
* excel 导入
* @param file excel文件
* @param titleRows 标题行
* @param headerRows 表头行
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) throws IOException {
return importExcel(file, titleRows, headerRows, false, pojoClass);
}
/**
* excel 导入
* @param file 上传的文件
* @param titleRows 标题行
* @param headerRows 表头行
* @param needVerify 是否检验excel内容
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, boolean needVerify, Class<T> pojoClass) throws IOException {
if (file == null) {
return null;
}
try {
return importExcel(file.getInputStream(), titleRows, headerRows, needVerify, pojoClass);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
/**
* excel 导入
*
* @param inputStream 文件输入流
* @param titleRows 标题行
* @param headerRows 表头行
* @param needVerify 是否检验excel内容
* @param pojoClass pojo类型
* @param <T>
* @return
*/
public static <T> List<T> importExcel(InputStream inputStream, Integer titleRows, Integer headerRows, boolean needVerify, Class<T> pojoClass) throws IOException {
if (inputStream == null) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
params.setSaveUrl("/excel/");
params.setNeedSave(true);
params.setNeedVerify(needVerify);
try {
return ExcelImportUtil.importExcel(inputStream, pojoClass, params);
} catch (NoSuchElementException e) {
throw new IOException("excel文件不能为空");
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
/**
* @description 生成一个下拉列表
* @param: workbook
* @param: col 要展示的是哪一列
* @param: datas 下拉列表的list
* @return void
**/
public static void selectList(Workbook workbook,int col,String[] datas ){
Sheet sheet = workbook.getSheetAt(0);
//生成下拉列表, 默认就是从2 到 90000列显示 col
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(2, 90000, col, col);
//生成下拉框内容
DataValidationHelper dvHelper = sheet.getDataValidationHelper();
DataValidationConstraint dvConstraint = dvHelper.createExplicitListConstraint(datas);
DataValidation validation = dvHelper.createValidation(dvConstraint, cellRangeAddressList);
//设置错误信息提示
validation.setShowErrorBox(true);
//对sheet页生效
sheet.addValidationData(validation);
}
/**
* 获取下载路径
*
* @param downloadPath 文件名称
*/
private static String getAbsoluteFile(String downloadPath) {
downloadPath = "/excel/" + downloadPath;
File desc = new File(downloadPath);
if (!desc.getParentFile().exists()) {
desc.getParentFile().mkdirs();
}
return downloadPath;
}
/**
* 编码文件名
*/
private static String encodingFilename(String filename) {
filename = UUID.randomUUID().toString() + "_" + filename + "." + ExcelTypeEnum.XLSX.getValue();
return filename;
}
/**
* Excel 类型枚举
*/
enum ExcelTypeEnum {
XLS("xls"), XLSX("xlsx");
private String value;
ExcelTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
}
package com.junmp.jyzb.config.rabbitMQ;
import com.junmp.jyzb.api.bean.dto.OrderDto;
import com.junmp.jyzb.service.OrderService;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class RabbitmqConfig {
@Resource
private OrderService orderService;
//1.交换机
@Bean("LogExchange")
public Exchange bootExchange(){
......@@ -25,20 +34,32 @@ public class RabbitmqConfig {
}
@Bean("OrderExchange")
public Exchange OrderExchange(){
return ExchangeBuilder.directExchange("OrderExchange").durable(true).build();
@Bean
public DirectExchange OrderExchange(){
return new DirectExchange("OrderExchange");
}
//2.队列
@Bean("OrderQueue")
public Queue OrderQueue(){
return QueueBuilder.durable("OrderQueue").build();
@Bean
public List<Queue> OrderQueue(){
List<Queue> queues =new ArrayList<>();
List<OrderDto> orderList = orderService.getOrder();
for (OrderDto orderDto:orderList) {
queues.add(new Queue(orderDto.getEndOrgName()));
}
return queues;
}
//3.队列和交换机的绑定关系(队列,交换机,rountingkey)
@Bean
public Binding bindQueueExchange(@Qualifier("OrderQueue") Queue queue, @Qualifier("OrderExchange")Exchange exchange){
return BindingBuilder.bind(queue).to(exchange).with("1").noargs();
public List<Binding> bindQueueExchange(List<Queue> queue, DirectExchange exchange){
List<Binding> bindings=new ArrayList<>();
List<OrderDto> orderList = orderService.getOrder();
for(int i=0;i<Math.min(queue.size(),orderList.size());i++){
bindings.add(BindingBuilder.bind(queue.get(i)).to(exchange).with(orderList.get(i).getEndOrgId()));
}
return bindings;
}
}
......@@ -4,6 +4,7 @@ import com.junmp.jyzb.api.bean.dto.*;
import com.junmp.jyzb.api.bean.query.*;
import com.junmp.jyzb.api.bean.req.EquipmentBindReq;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.entity.PubOrg;
import com.junmp.jyzb.service.*;
import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.v2.common.bean.request.ValidationApi;
......@@ -16,6 +17,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -136,6 +139,27 @@ public class InventoryController {
return ApiRes.success(inventoryService.AreaInventoryList(req));
}
//导出,通过传递组织机构id,将该组织机构下的所有装备信息进行导出
@PostMapping("/ExportInventoryExcel")
@ApiOperation("组织机构装备导出")
public void ExportInventoryExcel(@RequestBody @Validated(ValidationApi.export.class) InventoryReq req, HttpServletResponse response) throws IOException {
inventoryService.ExportInventoryExcel(req,response);
}
//装备出入库记录(通过装备id)
@PostMapping("/GetInOutRecords")
@ApiOperation("装备出入库记录")
public ApiRes<List<InOutRecordsDto>> getInOutRecords(@RequestBody @Validated(ValidationApi.detail.class) InventoryReq req){
return ApiRes.success(inventoryService.getInOutRecords(req));
}
//根据条件(组织机构,装备类型id,装备型号id,装备型号名称)查询装备总数,在库数,出库数,单警柜在库数,单警柜出库数,报废数
//查询装备数量报表
@PostMapping("/GetListEquipment")
@ApiOperation("根据条件查询数量汇总")
public ApiRes<List<EqsSumDto>> GetListEquipment(@RequestBody InventoryReq req){
return ApiRes.success(inventoryService.GetListEquipment(req));
}
}
......@@ -15,9 +15,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
/**
* Create By Spring-2022/10/29
*/
//@Controller
//@RequestMapping(value = "/mqtt")
//@Api(value = "MqttController", tags = {"MQTT 访问控制"})
@Controller
@RequestMapping(value = "/mqtt")
@Api(value = "MqttController", tags = {"MQTT 访问控制"})
public class MqttController {
//
// @Autowired
......
......@@ -71,20 +71,7 @@ public class OrderController {
req.setExamineState("finished");
return ApiRes.success(orderService.AddOrder(req));
}
//将工作流添加到rabbitmq中去
@PostMapping("/AddOrderRabbitMq")
@ApiOperation("将工作流添加到rabbitmq消息队列中去")
public ApiRes<Boolean> AddOrderRabbitMq(){
List<OrderDto> order = orderService.getOrder();
List<String> orderId=new ArrayList<>();
for (OrderDto orderDto:order) {
rabbitTemplate.convertAndSend("OrderExchange","1",orderDto);
orderId.add(orderDto.getId());
}
//将未被上传的数据进行上传到rabbitmq中,同时添加到数据库,标记为已上传数据,比避免同意数据多次或者重复上传
boolean b = orderLogService.addOrder(orderId);
return ApiRes.success(b);
}
//修改任务单只允许工作流id为空的时候(视为草稿可以进行修改)
@PostMapping("/UpdateOrder")
......@@ -107,15 +94,31 @@ public class OrderController {
List<OrderDetailDto> orderDetail = orderService.getOrderDetail(req);
return ApiRes.success(orderDetail);
}
//将工作单添加到rabbitmq中去
@PostMapping("/AddOrderRabbitMq")
@ApiOperation("将工作单添加到rabbitmq消息队列中去")
public ApiRes<Boolean> AddOrderRabbitMq(){
List<OrderDto> order = orderService.getOrder();
List<String> orderId=new ArrayList<>();
for (OrderDto orderDto:order) {
//将routingKey设置为收物机构id
rabbitTemplate.convertAndSend("OrderExchange",orderDto.getEndOrgId(),orderDto);
orderId.add(orderDto.getId());
}
//将未被上传的数据进行上传到rabbitmq中,同时添加到数据库,标记为已上传数据,比避免同意数据多次或者重复上传
boolean b = orderLogService.addOrder(orderId);
return ApiRes.success(b);
}
//出入日志上报
@PostMapping("/UploadLogs")
@ApiOperation("出入日志上传")
public void AddLogsRabbitMq(){
public ApiRes<Boolean> AddLogsRabbitMq(){
List<LogSummaryDto> logs = logSummaryService.getLogs();
for (LogSummaryDto logSummaryDto:logs) {
rabbitTemplate.convertAndSend("LogExchange","log",logSummaryDto);
}
return ApiRes.success(true);
}
......
package com.junmp.jyzb.controller;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.v2.common.bean.response.ApiRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Slf4j
@RequestMapping("/ToWarehouse")
@RequestMapping("/ToEnter")
@Api(tags = "入库模块")
public class ToWarehouseController {
public class ToEnterController {
//装备入库,添加入库记录
@ApiOperation("添加装备入库记录")
@PostMapping("/AddInRecords")
public ApiRes<Boolean> AddInRecords(InventoryReq req){
return ApiRes.success();
}
}
......@@ -15,9 +15,9 @@ import javax.annotation.Resource;
@RestController
@Slf4j
@RequestMapping("/ToOutWarehouse")
@RequestMapping("/ToOut")
@Api(tags = "出库模块")
public class ToOutWarehouseController {
public class ToOutController {
@Resource
private PoliceEquipmentService policeEquipmentService;
......
......@@ -2,6 +2,7 @@ package com.junmp.jyzb.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.junmp.jyzb.api.bean.dto.EqsBriefDto;
import com.junmp.jyzb.api.bean.dto.EqsSumDto;
import com.junmp.jyzb.api.bean.dto.InventoryDto;
import com.junmp.jyzb.api.bean.query.InventoryReq;
import com.junmp.jyzb.entity.Inventory;
......@@ -37,5 +38,6 @@ public interface InventoryMapper extends BaseMapper<Inventory> {
//通过单警柜箱门id获取箱门下的装备汇总信息
List<InventorySummary> getSumByCabinetBox(String id);
//通过查询条件查询出装备数量报表
List<EqsSumDto> GetListEquipment(InventoryReq req);
}
\ No newline at end of file
......@@ -17,4 +17,5 @@ public interface PubOrgMapper extends BaseMapper<PubOrg> {
void wipeParentIdsData();
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ import com.junmp.jyzb.entity.Inventory;
import com.junmp.jyzb.entity.InventorySummary;
import com.junmp.jyzb.utils.ResponseResult;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -20,8 +22,6 @@ public interface InventoryService extends IService<Inventory> {
boolean setInventoryMsg();
boolean UpdateWarehouseInsNum(WarehouseReq req);
boolean UpdateCabinetInsNum(CabinetReq req);
......@@ -53,5 +53,12 @@ public interface InventoryService extends IService<Inventory> {
//通过单警柜箱门id获取箱门下的装备汇总信息
List<InventorySummary> EqsByCabinetBoxId(CabinetBoxReq req);
//通过组织机构id对该组织机构下的装备进行导出
void ExportInventoryExcel(InventoryReq req, HttpServletResponse response) throws IOException;
//获取装备的出入库记录
List<InOutRecordsDto> getInOutRecords(InventoryReq req);
//通过条件查询装备数量报表
List<EqsSumDto> GetListEquipment(InventoryReq req);
}
......@@ -9,6 +9,6 @@ import java.util.List;
public interface LogSummaryService extends IService<LogSummary> {
//上传操作日志
//上传出入日志
List<LogSummaryDto> getLogs();
}
......@@ -28,4 +28,5 @@ public interface PubOrgService extends IService<PubOrg> {
//根据组织机构id查询出组织机构是否存在
PubOrg PubOrgExist(Long id);
}
......@@ -12,30 +12,27 @@ import com.junmp.jyzb.api.bean.req.EquipmentBindReq;
import com.junmp.jyzb.api.exception.enums.CabinetBoxExceptionEnum;
import com.junmp.jyzb.api.exception.enums.CabinetExceptionEnum;
import com.junmp.jyzb.api.exception.enums.InventoryExceptionEnum;
import com.junmp.jyzb.api.util.ExcelUtils;
import com.junmp.jyzb.entity.*;
import com.junmp.jyzb.service.*;
import com.junmp.jyzb.utils.HttpStatus;
import com.junmp.jyzb.utils.ResponseResult;
import com.junmp.jyzb.utils.ReturnMsg;
import com.junmp.v2.common.exception.base.ServiceException;
import com.junmp.v2.common.util.BeanPlusUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.junmp.jyzb.mapper.InventoryMapper;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.io.IOException;
import java.util.*;
import static com.junmp.jyzb.utils.CheckBlank.checkNotBlank;
import static org.checkerframework.checker.units.qual.Prefix.one;
@Service
@Slf4j
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory> implements InventoryService {
@Resource
private InventoryMapper inventoryMapper;
@Resource
......@@ -64,7 +61,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
private WarehouseAreaService warehouseAreaService;
@Resource
private InventorySummaryService inventorySummaryService;
private LogSummaryService logSummaryService;
@Resource
private LogDetailService logDetailService;
@Override
public InventoryDto getInventoryDetail(InventoryReq req) {
......@@ -179,15 +178,14 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
//判断如果传递了类别,判断传递的值是否为空或者是否不存在
if (ObjectUtil.isNotNull(req.getOrgId())){
pubOrgService.PubOrgExist(req.getOrgId());
}
if (ObjectUtil.isNotNull(req.getWarehouseId())){
} else if (ObjectUtil.isNotNull(req.getWarehouseId())){
warehouseService.WarehoustExist(req.getWarehouseId());
}
if (ObjectUtil.isNotNull(req.getCabinetId())){
} else if (ObjectUtil.isNotNull(req.getCabinetId())){
cabinetService.CabinetExist(req.getCabinetId());
}else {
throw new ServiceException(CabinetExceptionEnum.PARAMETER_ERROR);
}
List<InventoryDto> inventoryDtos = inventoryMapper.EqsBySearchType(req);
return inventoryDtos;
return inventoryMapper.EqsBySearchType(req);
}
//查询箱门(cabinetBox下)所有装备简要信息列表(传递cabinetBoxId)
......@@ -270,6 +268,53 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
}
//通过单警柜箱门id获取箱门下的装备汇总信息
@Override
public List<InventorySummary> EqsByCabinetBoxId(CabinetBoxReq req) {
cabinetBoxService.CabinetBoxExist(req.getId());
return inventoryMapper.getSumByCabinetBox(req.getId());
}
//通过组织机构id将该组织下的装备进行导出
@Override
public void ExportInventoryExcel(InventoryReq req, HttpServletResponse response) throws IOException {
//判断组织机构是否存在
pubOrgService.PubOrgExist(req.getOrgId());
//查询该组织机构下的所有装备信息
List<Inventory> list = list(new LambdaQueryWrapper<Inventory>()
.eq(Inventory::getOrgId, req.getOrgId()));
String filename="装备列表";
//对数据进行导出
ExcelUtils.exportExcel(list,filename,"装备导出",Inventory.class,filename,response);
}
//获取装备的出入库信息
@Override
public List<InOutRecordsDto> getInOutRecords(InventoryReq req) {
//通过装备id获取出入库记录(判断id是否存在
InventoryExist(req.getId());
List<LogDetail> list = logDetailService.list(new LambdaQueryWrapper<LogDetail>()
.eq(LogDetail::getInventoryId, req.getId()));
List<InOutRecordsDto> inOutRecordsDtoList=new ArrayList<>();
for (LogDetail logDetail: list) {
//获取
LogSummary logSummary = logSummaryService.getById(logDetail.getSummaryId());
InOutRecordsDto inOutRecordsDto = new InOutRecordsDto();
BeanPlusUtil.copyProperties(logSummary,inOutRecordsDto);
inOutRecordsDtoList.add(inOutRecordsDto);
}
return inOutRecordsDtoList;
}
//查询装备数量报表
@Override
public List<EqsSumDto> GetListEquipment(InventoryReq req) {
//通过获取传递的查询条件进行查询,得到最终的装备数量报表
inventoryMapper.GetListEquipment(req);
return null;
}
//通过id判断装备是否存在
@Override
public Inventory InventoryExist(String id) {
......@@ -280,12 +325,4 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
return invMap;
}
//通过单警柜箱门id获取箱门下的装备汇总信息
@Override
public List<InventorySummary> EqsByCabinetBoxId(CabinetBoxReq req) {
cabinetBoxService.CabinetBoxExist(req.getId());
return inventoryMapper.getSumByCabinetBox(req.getId());
}
}
\ No newline at end of file
......@@ -359,7 +359,6 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
wrapper.eq(ObjectUtil.isNotEmpty(req.getParentId()), PubOrg::getOrgParentId,req.getParentId() );
wrapper.eq(ObjectUtil.isNotEmpty(req.getOrgCode()), PubOrg::getOrgCode, req.getOrgCode());
return wrapper;
}
......@@ -374,6 +373,7 @@ public class PubOrgServiceImpl extends ServiceImpl<PubOrgMapper, PubOrg> implem
return puborg;
}
}
......
......@@ -78,9 +78,9 @@ delete from base_inventory_summary
<insert id="SetCabinetInventory">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,location_type,create_time,update_time)
select MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,
sum(t.number) as number,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,t.location_type,NOW(),NOW()
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,destruction_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,sum(t.number) as number,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
......@@ -96,7 +96,8 @@ delete from base_inventory_summary
count(*) as number,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS outboundNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) - sum(case when bi.state = 'destory' then 1 else 0 end) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
bi.location_type
FROM base_inventory bi
join base_cabinet_box bcb on bi.location_id = bcb.id
......@@ -110,8 +111,9 @@ delete from base_inventory_summary
</insert>
<insert id="SetWarehouseInventory">
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,location_type,create_time,update_time)
select t.id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,t.locationName,t.number,t.price,t.stockNumber,t.outboundNumber,t.locationType,NOW(),NOW()
INSERT INTO base_inventory_summary (id,org_id_int,org_name,type_id, type_name,size_id,size_name,location_id,location_name,number,price, stock_number, outbound_number,destruction_number,location_type,create_time,update_time)
select
MAX(t.id) as id,t.orgId,t.orgName,t.type_id,t.typeName,t.size_id,t.sizeName,t.locationId,MAX(t.locationName),sum(t.number) as number,sum(t.price)as price,sum(t.stockNumber)as stockNumber,sum(t.outboundNumber)as outboundNumber,sum(t.destructionNumber)as destructionNumber,t.location_type,NOW(),NOW()
FROM
(SELECT
UUID() as id,
......@@ -126,8 +128,9 @@ delete from base_inventory_summary
count(*) as number,
sum(bi.price) as price,
SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS stockNumber,
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END) AS outboundNumber,
bi.location_type as locationType
count(*) - SUM(CASE WHEN location_state = 'in' THEN 1 ELSE 0 END)- sum(case when bi.state = 'destory' then 1 else 0 end) AS outboundNumber,
sum(case when bi.state = 'destory' then 1 else 0 end) as destructionNumber,
bi.location_type
FROM base_inventory bi
join base_warehouse bw on bi.location_id = bw.id
join base_equipment_type t on t.id = bi.type_id
......@@ -135,6 +138,7 @@ delete from base_inventory_summary
join pub_org po on bi.org_id_int = po.org_id
WHERE location_type = 0
GROUP BY type_id,size_id,bi.org_id_int,location_id) as t
GROUP BY t.locationId,t.type_id,t.size_id,t.orgId
</insert>
<select id="EqsBySearchType" resultType="com.junmp.jyzb.api.bean.dto.InventoryDto">
......@@ -274,7 +278,42 @@ delete from base_inventory_summary
WHERE bi.location_type = 1 and bi.location_id=#{id}
GROUP BY location_id, type_id,size_id,bi.org_id_int
</select>
<select id="GetListEquipment" resultType="com.junmp.jyzb.api.bean.dto.EqsSumDto">
SELECT
orgId,
orgName,
(inSum + outSum + cabinetInSum + CabinetOutSum + brokenSum) AS totalSum,
inSum,
outSum,
cabinetInSum,
CabinetOutSum,
brokenSum
FROM (
SELECT
bi.org_id_int as orgId,
pub.org_name as orgName,
SUM(CASE WHEN bi.location_state='in' and bi.location_type='0'THEN 1 ELSE 0 END) AS inSum,
SUM(CASE WHEN bi.location_state='out' AND bi.location_type='0' THEN 1 ELSE 0 END)- SUM(CASE WHEN bi.state='destory' AND bi.location_type='0' THEN 1 ELSE 0 END)AS outSum,
SUM(CASE WHEN bi.location_state='in' AND bi.location_type='1' THEN 1 ELSE 0 END) AS cabinetInSum,
SUM(CASE WHEN bi.location_state='out' AND bi.location_type='1' THEN 1 ELSE 0 END)- SUM(CASE WHEN bi.state='destory' AND bi.location_type='1' THEN 1 ELSE 0 END) AS CabinetOutSum,
SUM(CASE WHEN bi.state='destory'THEN 1 ELSE 0 END) AS brokenSum
FROM base_inventory bi
JOIN pub_org pub ON pub.org_id = bi.org_id_int
join base_equipment_size bes on bes.id=bi.size_id
<where>
<if test="orgId != null and orgId != ''">
and bi.org_id_int=#{orgId}
</if>
<if test="sizeId != null and sizeId != '' and sizeName != null and sizeName != ''">
and bi.size_id=#{sizeId} and bes.name=#{sizeName}
</if>
<if test="typeId != null and typeId != ''">
and bi.type_id=#{typeId}
</if>
</where>
GROUP BY bi.org_id_int, bi.location_type
)as t
</select>
</mapper>
\ No newline at end of file
......@@ -98,4 +98,5 @@ SET p.org_parent_ids = cte.org_parent_ids;
</select>
</mapper>
\ No newline at end of file
......@@ -265,6 +265,45 @@
<artifactId>spring-security-web</artifactId>
<version>5.0.5.RELEASE</version>
</dependency>
<!-- excel导入导出 -->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论