feat(stock): 添加库存出入库记录导出功能
| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.service.StockInRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | return AjaxResult.success(stockInRecordService.batchDelete(ids)); |
| | | } |
| | | |
| | | @PostMapping("/exportStockInRecord") |
| | | @ApiOperation("导åºå
¥åºè®°å½") |
| | | public void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto) { |
| | | stockInRecordService.exportStockInRecord(response,stockInRecordDto); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import com.ruoyi.stock.service.StockOutRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | } |
| | | return AjaxResult.success(stockOutRecordService.batchDelete(ids)); |
| | | } |
| | | |
| | | @PostMapping("/exportStockOutRecord") |
| | | @ApiOperation("导åºåºåºè®°å½") |
| | | public void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto) { |
| | | stockOutRecordService.exportStockOutRecord(response,stockOutRecordDto); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.execl; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class StockInRecordExportData { |
| | | |
| | | @Excel(name = "å
¥åºæ¹æ¬¡") |
| | | private String inboundBatches; |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | @Excel(name = "è§æ ¼åå·") |
| | | private String model; |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | @Excel(name = "å
¥åºæ¥æº") |
| | | private String recordType; |
| | | @Excel(name = "å
¥åºæ°é") |
| | | private String stockInNum; |
| | | @Excel(name = "å
¥åºæ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Excel(isExport = false) |
| | | private String type; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.stock.execl; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class StockOutRecordExportData { |
| | | @Excel(name = "åºåºæ¹æ¬¡") |
| | | private String outboundBatches; |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | @Excel(name = "è§æ ¼åå·") |
| | | private String model; |
| | | @Excel(name = "åä½") |
| | | private String unit; |
| | | @Excel(name = "åºåºæ¥æº") |
| | | private String recordType; |
| | | @Excel(name = "åºåºæ°é") |
| | | private String stockInNum; |
| | | @Excel(name = "åºåºæ¶é´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Excel(isExport = false) |
| | | private String type; |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface StockInRecordMapper extends BaseMapper<StockInRecord> { |
| | | IPage<StockInRecordDto> listPage(Page page, @Param("params") StockInRecordDto stockInRecordDto); |
| | | |
| | | List<StockInRecordExportData> listStockInRecordExportData(@Param("params") StockInRecordDto stockInRecordDto); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.execl.StockOutRecordExportData; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public interface StockOutRecordMapper extends BaseMapper<StockOutRecord> { |
| | | IPage<StockOutRecordDto> listPage(Page page, @Param("params") StockOutRecordDto stockOutRecordDto); |
| | | |
| | | List<StockOutRecordExportData> listStockOutRecordExportData(@Param("params") StockOutRecordDto stockOutRecordDto); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.pojo.StockInRecord; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | public interface StockInRecordService extends IService<StockInRecord> { |
| | |
| | | |
| | | int batchDelete(List<Long> ids); |
| | | |
| | | void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto); |
| | | } |
| | |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.pojo.StockOutRecord; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | int update(Long id, StockOutRecordDto stockOutRecordDto); |
| | | |
| | | int batchDelete(List<Long> ids); |
| | | |
| | | void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.staff.pojo.StaffOnJob; |
| | | import com.ruoyi.stock.dto.StockInRecordDto; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.execl.StockInventoryExportData; |
| | | import com.ruoyi.stock.mapper.StockInRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | } |
| | | return stockInRecordMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockInRecord(HttpServletResponse response, StockInRecordDto stockInRecordDto) { |
| | | List<StockInRecordExportData> list = stockInRecordMapper.listStockInRecordExportData(stockInRecordDto); |
| | | for (StockInRecordExportData stockInRecordExportData : list) { |
| | | if (stockInRecordExportData.getType().equals("0")) { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockQualifiedRecordTypeEnum.class, Integer.valueOf(stockInRecordExportData.getRecordType())).getValue()); |
| | | }else { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockUnQualifiedRecordTypeEnum.class, Integer.valueOf(stockInRecordExportData.getRecordType())).getValue()); |
| | | } |
| | | } |
| | | ExcelUtil<StockInRecordExportData> util = new ExcelUtil<>(StockInRecordExportData.class); |
| | | util.exportExcel(response,list, "å
¥åºè®°å½ä¿¡æ¯"); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public R importStockInventory(MultipartFile file) { |
| | | try { |
| | | final StringBuffer[] errorMsg = {new StringBuffer()}; |
| | | //æ¥è¯¢ææç产å |
| | | List<SalesLedgerProduct> salesLedgerProducts =salesLedgerProductMapper.selectProduct(); |
| | | |
| | | ExcelUtil<StockInventoryExportData> util = new ExcelUtil<StockInventoryExportData>(StockInventoryExportData.class); |
| | | List<StockInventoryExportData> list = util.importExcel(file.getInputStream()); |
| | | list.stream().forEach(dto -> { |
| | | salesLedgerProducts.stream().forEach(item->{ |
| | | if (item.getProductCategory().equals(dto.getProductName())&&item.getSpecificationModel().equals(dto.getModel())) { |
| | | //æ´æ°åºå |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setRecordId(0L); |
| | | stockInventoryDto.setRecordType(StockQualifiedRecordTypeEnum.CUSTOMIZATION_STOCK_IN.getCode()); |
| | | stockInventoryDto.setQualitity(dto.getQualitity()); |
| | | stockInventoryDto.setProductModelId(item.getProductModelId()); |
| | | this.addstockInventory(stockInventoryDto); }else { |
| | | errorMsg[0] = errorMsg[0].append("产ååç§°ï¼"+dto.getProductName()+"è§æ ¼ï¼"+dto.getModel()+"ä¸åå¨").append("\n"); |
| | | } |
| | | }); |
| | | }); |
| | | return R.ok(errorMsg[0]); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.enums.StockQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockUnQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.EnumUtil; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.stock.dto.StockInventoryDto; |
| | | import com.ruoyi.stock.dto.StockOutRecordDto; |
| | | import com.ruoyi.stock.dto.StockUninventoryDto; |
| | | import com.ruoyi.stock.execl.StockInRecordExportData; |
| | | import com.ruoyi.stock.execl.StockOutRecordExportData; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.mapper.StockOutRecordMapper; |
| | | import com.ruoyi.stock.mapper.StockUninventoryMapper; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | } |
| | | return stockOutRecordMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void exportStockOutRecord(HttpServletResponse response, StockOutRecordDto stockOutRecordDto) { |
| | | List<StockOutRecordExportData> list = stockOutRecordMapper.listStockOutRecordExportData(stockOutRecordDto); |
| | | for (StockOutRecordExportData stockInRecordExportData : list) { |
| | | if (stockInRecordExportData.getType().equals("0")) { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockQualifiedRecordTypeEnum.class, Integer.valueOf(stockInRecordExportData.getRecordType())).getValue()); |
| | | }else { |
| | | stockInRecordExportData.setRecordType(EnumUtil.fromCode(StockUnQualifiedRecordTypeEnum.class, Integer.valueOf(stockInRecordExportData.getRecordType())).getValue()); |
| | | } |
| | | } |
| | | ExcelUtil<StockOutRecordExportData> util = new ExcelUtil<>(StockOutRecordExportData.class); |
| | | util.exportExcel(response,list, "åºåºè®°å½ä¿¡æ¯"); |
| | | } |
| | | } |
| | |
| | | <select id="listPage" resultType="com.ruoyi.stock.dto.StockInRecordDto"> |
| | | SELECT |
| | | sir.*, |
| | | p.product_name as productName, |
| | | p.product_name as product_name, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | | FROM stock_in_record as sir |
| | | LEFT JOIN product_model as pm on sir.product_model_id = pm.id |
| | | LEFT JOIN product as p on pm.product_id = p.id |
| | | LEFT JOIN sys_user as u on sir.create_user = u.user_id |
| | | <where> |
| | | <if test="params.timeStr != null and params.timeStr != ''"> |
| | | and sir.create_time like concat('%',#{params.timeStr},'%') |
| | | </if> |
| | | <if test="params.productName != null and params.productName != ''"> |
| | | and p.product_name like concat('%',#{params.productName},'%') |
| | | </if> |
| | | <if test="params.type != null and params.type != ''"> |
| | | and sir.type = #{params.type} |
| | | </if> |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sir.record_type = #{params.recordType} |
| | | </if> |
| | | </where> |
| | | order by sir.id desc |
| | | </select> |
| | | <select id="listStockInRecordExportData" resultType="com.ruoyi.stock.execl.StockInRecordExportData"> |
| | | SELECT |
| | | sir.*, |
| | | p.product_name as product_name, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | |
| | | select si.qualitity, |
| | | pm.model, |
| | | pm.unit, |
| | | p.product_name |
| | | p.product_name, |
| | | si.remark, |
| | | si.update_time |
| | | from stock_inventory si |
| | | left join product_model pm on si.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | |
| | | </where> |
| | | order by sor.id desc |
| | | </select> |
| | | <select id="listStockOutRecordExportData" resultType="com.ruoyi.stock.execl.StockOutRecordExportData"> |
| | | SELECT |
| | | sor.*, |
| | | p.product_name as productName, |
| | | pm.model, |
| | | pm.unit, |
| | | u.nick_name as createBy |
| | | FROM stock_out_record as sor |
| | | LEFT JOIN product_model as pm on sor.product_model_id = pm.id |
| | | LEFT JOIN product as p on pm.product_id = p.id |
| | | LEFT JOIN sys_user as u on sor.create_user = u.user_id |
| | | <where> |
| | | <if test="params.timeStr != null and params.timeStr != ''"> |
| | | and sor.create_time like concat('%',#{params.timeStr},'%') |
| | | </if> |
| | | <if test="params.productName != null and params.productName != ''"> |
| | | and p.product_name like concat('%',#{params.productName},'%') |
| | | </if> |
| | | <if test="params.type != null and params.type != ''"> |
| | | and sor.type = #{params.type} |
| | | </if> |
| | | <if test="params.recordType != null and params.recordType != ''"> |
| | | and sor.record_type = #{params.recordType} |
| | | </if> |
| | | </where> |
| | | order by sor.id desc |
| | | </select> |
| | | |
| | | </mapper> |