Browse Source

修复:物资库存台账导入空模板报错

新增:出库单导出接口
zhongwei
ty 11 months ago
parent
commit
84115472a6
  1. 61
      hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SpWarehouseExportVO.java
  2. 52
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/SpWarehouseOutController.java
  3. 3
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.java
  4. 47
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.xml
  5. 8
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/ISpWarehouseOutService.java
  6. 58
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/SpWarehouseOutServiceImpl.java
  7. 8
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java

61
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;
}

52
hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/SpWarehouseOutController.java

@ -1,5 +1,6 @@
package com.hnac.hzims.spare.controller; package com.hnac.hzims.spare.controller;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation; 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.common.logs.enums.OperatorType;
import com.hnac.hzims.spare.entity.SpWarehouseOutEntity; import com.hnac.hzims.spare.entity.SpWarehouseOutEntity;
import com.hnac.hzims.spare.service.ISpWarehouseOutService; 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.spare.vo.SpWarehouseOutVO;
import com.hnac.hzims.vo.VoteChartVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog; 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.Condition;
import org.springblade.core.mp.support.Query; 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.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.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; 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); 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<SpWarehouseOutVO> outVOList=sp_warehouse_outService.exportList(warehouseOutVO);
List<SpWarehouseExportVO> 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") @GetMapping("/warnList")

3
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.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.spare.entity.SpWarehouseOutEntity; import com.hnac.hzims.spare.entity.SpWarehouseOutEntity;
import com.hnac.hzims.spare.vo.SpWarehouseOutVO; import com.hnac.hzims.spare.vo.SpWarehouseOutVO;
import feign.Param;
import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.annotation.UserDataAuth;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
@ -26,6 +27,8 @@ public interface SpWarehouseOutMapper extends UserDataScopeBaseMapper<SpWarehous
*/ */
@UserDataAuth @UserDataAuth
List<SpWarehouseOutVO> selectPageList(IPage<SpWarehouseOutVO> page, Map<String,Object> params); List<SpWarehouseOutVO> selectPageList(IPage<SpWarehouseOutVO> page, Map<String,Object> params);
// @UserDataAuth
List<SpWarehouseOutVO> selectListByCondition( Map<String,Object> params);
/** /**
* 根据工单ID查询出库单编码 * 根据工单ID查询出库单编码
* @param ticketId * @param ticketId

47
hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/SpWarehouseOutMapper.xml

@ -76,6 +76,53 @@
order by wo.CREATE_TIME desc order by wo.CREATE_TIME desc
</select> </select>
<select id="selectListByCondition" resultType="com.hnac.hzims.spare.vo.SpWarehouseOutVO" parameterType="java.util.Map">
SELECT
wo.id,
wo.CODE,
wo.CREATE_USER,
wo.CREATE_TIME,
wo.TYPE,
wo.`STATUS`,
wo.STORAGE_ROOM,
wo.CREATE_DEPT,
sw.`NAME` AS warehouseName,
sw.AFFILIATED_UNIT,
sw.AFFILIATED_NAME AS affiliatedName
FROM
wt_sp_warehouse_out wo
JOIN wt_sp_warehouse sw ON wo.STORAGE_ROOM = sw.id
WHERE wo.IS_DELETED = 0
<if test="code !=null">
and wo.code like concat('%',#{code},'%')
</if>
<if test="type!=null">
and wo.type = #{type}
</if>
<if test="status!=null">
and wo.status = #{status}
</if>
<if test="createTime!=null">
and wo.CREATE_TIME <![CDATA[ <= ]]> #{createTime}
</if>
<if test="startDate!=null">
and wo.CREATE_TIME <![CDATA[ >= ]]> #{startDate}
</if>
<if test="endDate!=null">
and wo.CREATE_TIME <![CDATA[ <= ]]> #{endDate}
</if>
<if test="deptList!=null">
and sw.AFFILIATED_UNIT in
<foreach collection="params.deptList" item="item" open="(" close=")" separator="," >
#{item}
</foreach>
</if>
<if test="warehouseId!=null">
and wo.STORAGE_ROOM = #{params.warehouseId}
</if>
order by wo.CREATE_TIME desc
</select>
<select id="getReceiveCode" resultType="java.lang.String"> <select id="getReceiveCode" resultType="java.lang.String">
select o.`CODE` from spare.wt_sp_warehouse_out o,spare.wt_sp_ticket_relation r where o.ID = r.ORDER_ID and r.TICKET = #{ticektId} select o.`CODE` from spare.wt_sp_warehouse_out o,spare.wt_sp_ticket_relation r where o.ID = r.ORDER_ID and r.TICKET = #{ticektId}
</select> </select>

8
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.base.BaseService;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import java.util.List;
/** /**
* 服务类 * 服务类
* *
@ -43,6 +45,12 @@ public interface ISpWarehouseOutService extends BaseService<SpWarehouseOutEntity
* @return * @return
*/ */
IPage<SpWarehouseOutVO> selectPageList(IPage<SpWarehouseOutVO> page, SpWarehouseOutVO warehouseOutVO) ; IPage<SpWarehouseOutVO> selectPageList(IPage<SpWarehouseOutVO> page, SpWarehouseOutVO warehouseOutVO) ;
/**
* 导出列表
* @param warehouseOutVO
* @return
*/
List<SpWarehouseOutVO> exportList( SpWarehouseOutVO warehouseOutVO) ;
/** /**
* 修改状态 * 修改状态

58
hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/SpWarehouseOutServiceImpl.java

@ -277,7 +277,6 @@ public class SpWarehouseOutServiceImpl extends BaseServiceImpl<SpWarehouseOutMap
spWarehouseOutVO.setBasicVOList(basicVOList); spWarehouseOutVO.setBasicVOList(basicVOList);
return spWarehouseOutVO; return spWarehouseOutVO;
} }
@Override @Override
public IPage<SpWarehouseOutVO> selectPageList(IPage<SpWarehouseOutVO> page, SpWarehouseOutVO warehouseOutVO) { public IPage<SpWarehouseOutVO> selectPageList(IPage<SpWarehouseOutVO> page, SpWarehouseOutVO warehouseOutVO) {
Map<String,Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
@ -328,6 +327,63 @@ public class SpWarehouseOutServiceImpl extends BaseServiceImpl<SpWarehouseOutMap
return page.setRecords(result); return page.setRecords(result);
} }
@Override
public List<SpWarehouseOutVO> exportList( SpWarehouseOutVO warehouseOutVO) {
Map<String,Object> 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<Long> longList = new ArrayList<>();
if(null!=warehouseOutVO.getDeptId()){
R<List<Dept>> 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<SpWarehouseOutVO> list = baseMapper.selectListByCondition(params);
List<SpWarehouseOutVO> result = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
SpWarehouseOutVO entity = list.get(i);
if(null!=entity.getCreateUser()){
R<User> 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) { public synchronized boolean updateStatus(SpWarehouseOutEntity warehouseOutEntity) {
warehouseOutEntity.setStatus(3); warehouseOutEntity.setStatus(3);
Map<String,Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();

8
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 org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebServiceException;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -539,9 +540,9 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl<WtSpBasicMapper, WtSpB
String filename = file.getOriginalFilename(); String filename = file.getOriginalFilename();
ExcelToolListener excelToolListener = new ExcelToolListener(); ExcelToolListener excelToolListener = new ExcelToolListener();
if (org.springframework.util.StringUtils.isEmpty(filename)) { if (org.springframework.util.StringUtils.isEmpty(filename)) {
throw new ExcelException("请上传文件!"); throw new ServiceException("请上传文件!");
} else if (!org.springframework.util.StringUtils.endsWithIgnoreCase(filename, ".xls") && !org.springframework.util.StringUtils.endsWithIgnoreCase(filename, ".xlsx")) { } else if (!org.springframework.util.StringUtils.endsWithIgnoreCase(filename, ".xls") && !org.springframework.util.StringUtils.endsWithIgnoreCase(filename, ".xlsx")) {
throw new ExcelException("请上传正确的excel文件!"); throw new ServiceException("请上传正确的excel文件!");
} else { } else {
try { try {
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
@ -551,6 +552,9 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl<WtSpBasicMapper, WtSpB
} }
} }
List entityList = excelToolListener.getDataList(); List entityList = excelToolListener.getDataList();
if (CollectionUtil.isEmpty(entityList)){
throw new ServiceException("请上传正确的excel文件!");
}
List<WtSpBasicEntity> data = new ArrayList<>(); List<WtSpBasicEntity> data = new ArrayList<>();
data = JSONArray.parseArray(JSON.toJSONString(entityList), WtSpBasicEntity.class).stream() data = JSONArray.parseArray(JSON.toJSONString(entityList), WtSpBasicEntity.class).stream()
.filter(entity -> Func.isNotEmpty(entity.getCode())).collect(Collectors.toList()); .filter(entity -> Func.isNotEmpty(entity.getCode())).collect(Collectors.toList());

Loading…
Cancel
Save