diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SpWarehouseExportVO.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SpWarehouseExportVO.java new file mode 100644 index 0000000..b7df03d --- /dev/null +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SpWarehouseExportVO.java @@ -0,0 +1,61 @@ +package com.hnac.hzims.spare.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.hnac.hzims.spare.entity.SpWarehouseOutEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + +/** + * 模型VO + * + * @author Chill + */ +@Data +public class SpWarehouseExportVO { + + private static final long serialVersionUID = 1L; + /** + * 单据号 + */ + @ColumnWidth(25) + @ExcelProperty(value = "单据编码", index = 0) + @ApiModelProperty(value = "单据号") + private String code; + + /** + * 仓库名称 + */ + @ColumnWidth(20) + @ExcelProperty(value = "出库库房", index = 1) + @ApiModelProperty(value = "仓库名称") + private String warehouseName; + /** + * 出库类型名称 + */ + @ColumnWidth(20) + @ExcelProperty(value = "出库类型", index = 2) + @ApiModelProperty(value = "出库类型名称") + private String typeName; + /** + * 用户名称 + */ + @ColumnWidth(20) + @ExcelProperty(value = "领用人", index = 3) + @ApiModelProperty(value = "用户名称") + private String userName; + + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ColumnWidth(20) + @ExcelProperty(value = "出库时间", index = 4) + @ApiModelProperty("创建时间") + private String createTime; + +} diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/SpWarehouseOutController.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/SpWarehouseOutController.java index 8c61f78..aa98038 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/SpWarehouseOutController.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/SpWarehouseOutController.java @@ -1,5 +1,6 @@ package com.hnac.hzims.spare.controller; +import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; @@ -7,20 +8,33 @@ import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.spare.entity.SpWarehouseOutEntity; import com.hnac.hzims.spare.service.ISpWarehouseOutService; +import com.hnac.hzims.spare.vo.SpWarehouseExportVO; import com.hnac.hzims.spare.vo.SpWarehouseOutVO; +import com.hnac.hzims.vo.VoteChartVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; /** @@ -62,6 +76,44 @@ public class SpWarehouseOutController extends BladeController { return R.data(pages); } /** + * 分页 代码自定义代号 + */ + @ApiLog + @GetMapping("/exportList") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入sp_warehouse_out") + @OperationAnnotation(moduleName = "资产管理",title = "出库单",operatorType = OperatorType.MOBILE,businessType = + BusinessType.GENCODE, + action = "导出出库单列表") + public void exportList(HttpServletResponse response, SpWarehouseOutVO warehouseOutVO) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + throw new ServiceException("暂无权限查看,请稍后重试"); + } + List outVOList=sp_warehouse_outService.exportList(warehouseOutVO); + List list = outVOList.stream().map(s -> { + SpWarehouseExportVO spWarehouseExportVO = new SpWarehouseExportVO(); + BeanUtil.copy(s, spWarehouseExportVO); + spWarehouseExportVO.setCreateTime(DateUtil.formatDateTime(s.getCreateTime())); + return spWarehouseExportVO; + }).collect(Collectors.toList()); + String nowTime = DateUtil.formatDateTime(new Date()); + // 下载导出 + String filename = nowTime +"出库单"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), SpWarehouseExportVO.class).autoCloseStream(Boolean.TRUE).sheet(1,"出库单") + .doWrite(list); + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + /** * 工单预警 */ @GetMapping("/warnList") diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.java index b43a9bc..78bb951 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.spare.entity.SpWarehouseOutEntity; import com.hnac.hzims.spare.vo.SpWarehouseOutVO; +import feign.Param; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; @@ -26,6 +27,8 @@ public interface SpWarehouseOutMapper extends UserDataScopeBaseMapper selectPageList(IPage page, Map params); +// @UserDataAuth + List selectListByCondition( Map params); /** * 根据工单ID查询出库单编码 * @param ticketId diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.xml b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.xml index d3349a8..8c384e0 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.xml +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.xml @@ -76,6 +76,53 @@ order by wo.CREATE_TIME desc + + diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/ISpWarehouseOutService.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/ISpWarehouseOutService.java index ab86be7..3ac2520 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/ISpWarehouseOutService.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/ISpWarehouseOutService.java @@ -6,6 +6,8 @@ import com.hnac.hzims.spare.vo.SpWarehouseOutVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; +import java.util.List; + /** * 服务类 * @@ -43,6 +45,12 @@ public interface ISpWarehouseOutService extends BaseService selectPageList(IPage page, SpWarehouseOutVO warehouseOutVO) ; + /** + * 导出列表 + * @param warehouseOutVO + * @return + */ + List exportList( SpWarehouseOutVO warehouseOutVO) ; /** * 修改状态 diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/SpWarehouseOutServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/SpWarehouseOutServiceImpl.java index 0639864..df050df 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/SpWarehouseOutServiceImpl.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/SpWarehouseOutServiceImpl.java @@ -277,7 +277,6 @@ public class SpWarehouseOutServiceImpl extends BaseServiceImpl selectPageList(IPage page, SpWarehouseOutVO warehouseOutVO) { Map params = new HashMap<>(); @@ -328,6 +327,63 @@ public class SpWarehouseOutServiceImpl extends BaseServiceImpl exportList( SpWarehouseOutVO warehouseOutVO) { + Map params = new HashMap<>(); + if(null !=warehouseOutVO.getCode()){ + params.put("code",warehouseOutVO.getCode()); + } + if(null !=warehouseOutVO.getType()){ + params.put("type",warehouseOutVO.getType()); + } + if(null !=warehouseOutVO.getStatus()){ + params.put("status",warehouseOutVO.getStatus()); + } + if(null !=warehouseOutVO.getStartDate()){ + params.put("startDate",warehouseOutVO.getStartDate()); + } + if(null !=warehouseOutVO.getEndDate()){ + params.put("endDate",warehouseOutVO.getEndDate()); + } + List longList = new ArrayList<>(); + if(null!=warehouseOutVO.getDeptId()){ + R> deptList = sysClient.getDeptChild(warehouseOutVO.getDeptId()); + for (int i = 0; i < deptList.getData().size(); i++) { + longList.add(deptList.getData().get(i).getId()); + } + longList.add(warehouseOutVO.getDeptId()); + }else{ +// longList = personClient.getShuiChangId(AuthUtil.getDeptId()); + } + if(longList.size()>0){ + params.put("deptList",longList); + } + if(null!=warehouseOutVO.getStorageRoom()){ + params.put("warehouseId",warehouseOutVO.getStorageRoom()); + } + params.put("tenantId", AuthUtil.getTenantId()); + Query query = new Query(); + query.setCurrent(0); + query.setSize(100); + List list = baseMapper.selectListByCondition(params); + List result = new ArrayList<>(); + for (int i = 0; i < list.size(); i++) { + SpWarehouseOutVO entity = list.get(i); + if(null!=entity.getCreateUser()){ + R user = userClient.userInfoById(entity.getCreateUser()); + if(null!=user.getData()){ + entity.setUserName(user.getData().getName()); + } + } + if(null!=entity.getType()){ + WarehouseOutType typeName = WarehouseOutType.getTypeName(entity.getType().intValue()); + entity.setTypeName(typeName.getName()); + } + result.add(entity); + } + return result; + } + public synchronized boolean updateStatus(SpWarehouseOutEntity warehouseOutEntity) { warehouseOutEntity.setStatus(3); Map params = new HashMap<>(); diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java index 86f64bd..a166dff 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java @@ -59,6 +59,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import javax.xml.ws.WebServiceException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -539,9 +540,9 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl data = new ArrayList<>(); data = JSONArray.parseArray(JSON.toJSONString(entityList), WtSpBasicEntity.class).stream() .filter(entity -> Func.isNotEmpty(entity.getCode())).collect(Collectors.toList());