| | |
| | | package com.consum.base.controller; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.core.utils.PageUtil; |
| | | import com.consum.base.pojo.LWhFormOutputParam; |
| | | import com.consum.base.pojo.query.LWhFormOutputQry; |
| | | import com.consum.base.pojo.response.FormOutputGoodsVO; |
| | |
| | | import com.consum.base.pojo.response.LWhFormOutputExtendVO; |
| | | import com.consum.base.service.LWarehouseFlowService; |
| | | import com.consum.base.service.LWhFormOutputServiceImpl; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormOutput; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.net.URLEncoder; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | private LWhFormOutputServiceImpl lWhFormOutputService; |
| | | @Autowired |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Resource |
| | | private LWarehouseFlowService lWarehouseFlowService; |
| | | |
| | |
| | | */ |
| | | @ApiOperation(value = "新增出库单", notes = "新增出库单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "param", value = "出库单实体", required = true, dataType = "LWhFormOutputInsertParam", paramType = "body") |
| | | @ApiImplicitParam(name = "param", value = "出库单实体", dataType = "lWhFormOutputParam", dataTypeClass = LWhFormOutputParam.class, paramType = "body") |
| | | }) |
| | | @PostMapping("/add") |
| | | public ResponseValue add() { |
| | |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | |
| | | /*当前登录人只能看到自己机构下的列表*/ |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | String tenantId = sysInfo.getTenantId(); |
| | | if (param.getAgencyId() == null) { |
| | | param.setAgencyId(Long.valueOf(tenantId)); |
| | | } |
| | | GenericPager genericPager = lWhFormOutputService.queryFormOutputList(param); |
| | | List<LWhFormOutput> data = genericPager.getDatas(); |
| | | |
| | |
| | | } |
| | | try { |
| | | Field fieldDatas = GenericPager.class.getDeclaredField("datas"); |
| | | fieldDatas.setAccessible(true); |
| | | fieldDatas.set(genericPager, resultList); |
| | | // fieldDatas.setAccessible(true); |
| | | // fieldDatas.set(genericPager, resultList); |
| | | ReflectUtil.setFieldValue(genericPager, fieldDatas, resultList); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | LWhFormOutput lWhFormOutput = lWhFormOutputService.get(new LWhFormOutput(id)); |
| | | LWhFormOutputExtendVO lWhFormOutputExtendVO = new LWhFormOutputExtendVO(); |
| | | BeanUtils.copyProperties(lWhFormOutput, lWhFormOutputExtendVO); |
| | | lWhFormOutputExtendVO.setDoc(lWhFormOutput.getOutputDoc()); |
| | | |
| | | String sql = "SELECT bgt.id, CATEGORY_ID, CATEGORY_NAME, GOODS_NAME " |
| | | + "FROM l_wh_procure_model pm LEFT JOIN base_goods_models bgm ON bgm.id = pm.BASE_GOODS_MODELS_ID " |
| | |
| | | return ResponseValue.success("查询成功!", lWhFormOutputExtendVO); |
| | | } |
| | | |
| | | /** |
| | | * @Description 根据仓库id和型号id 查询库存 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/11/2 |
| | | */ |
| | | @ApiOperation(value = "根据仓库id和型号id 查询库存", notes = "根据仓库id和型号id 查询库存") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "warehouseId", value = "仓库id", required = true, dataType = "Long", paramType = "query"), |
| | | @ApiImplicitParam(name = "baseGoodsModelsId", value = "型号id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @GetMapping("/select/number") |
| | | public ResponseValue selectNumber(Long warehouseId, Long baseGoodsModelsId) { |
| | | if (warehouseId == null || baseGoodsModelsId == null) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | int num = this.lWhGoodsService.queryGoodsModelNum(0, warehouseId, baseGoodsModelsId, (short) 1, null); |
| | | return ResponseValue.success(num); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询出库单详情明细", notes = "查询出库单详情明细") |
| | | @ApiImplicitParam(name = "formOutputQry", value = "出库单详情查询条件", required = true, dataType = "LWhFormOutputQry", paramType = "query") |
| | |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | GenericPager<Map<String, Object>> mapGenericPager = lWarehouseFlowService.queryBusinessFlowDetail(formOutputQry); |
| | | return ResponseValue.success(mapGenericPager); |
| | | PageUtil genericPager = lWarehouseFlowService.queryAllBusinessFlow(formOutputQry); |
| | | return ResponseValue.success(genericPager); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "出库单导出", notes = "出库单导出") |
| | | @GetMapping("/list/export") |
| | | public void export(Long id, HttpServletResponse response) throws IOException { |
| | | ClassPathResource classPathResource = new ClassPathResource("import/采购退货单.xls"); |
| | | // 获取文件输入流 |
| | | InputStream inputStream = classPathResource.getInputStream(); |
| | | Workbook wb = new HSSFWorkbook(inputStream); |
| | | TemplateExportParams params = new TemplateExportParams(); |
| | | params.setTemplateWb(wb); |
| | | |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | String userName = sysInfo.getUserName(); |
| | | |
| | | Map<String, Object> map = lWhFormOutputService.getExportList(id, userName); |
| | | if (CollectionUtils.isEmpty(map)) { |
| | | throw new RuntimeException("数据为空"); |
| | | } |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, map); |
| | | downLoadExcel("采购退货单", response, workbook); |
| | | |
| | | } |
| | | |
| | | private void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) { |
| | | try (OutputStream out = response.getOutputStream()) { |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-Type", "application/vnd.ms-excel"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xls", "UTF-8")); |
| | | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
| | | workbook.write(baos); |
| | | response.setHeader("Content-Length", String.valueOf(baos.size())); |
| | | out.write(baos.toByteArray()); |
| | | } catch (Exception e) { |
| | | logger.error("导出文件失败", e); |
| | | } |
| | | } |
| | | |
| | | } |