| | |
| | | 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.pojo.query.TransferQry; |
| | | import com.consum.base.pojo.request.LWhFormTransferParam; |
| | | import com.consum.base.pojo.request.ProcureModelInfoParam; |
| | | import com.consum.base.pojo.request.RecordInfoParam; |
| | | import com.consum.base.pojo.response.FormTransferVO; |
| | | import com.consum.base.pojo.response.FromTransferTemplateInfoVO; |
| | | import com.consum.base.pojo.response.LWHFromTransferExtendVO; |
| | |
| | | import com.consum.model.po.LWhFormTransfer; |
| | | import com.consum.model.po.LWhProcureModelUser; |
| | | import com.consum.model.po.LWhProcureModelUserRecord; |
| | | import com.consum.model.vo.LWhFormOutputVo; |
| | | import com.iplatform.model.po.S_user_core; |
| | | import com.walker.db.page.GenericPager; |
| | | import com.walker.infrastructure.utils.CollectionUtils; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.lang.reflect.Field; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @GetMapping("/export") |
| | | public ResponseValue export(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("调拨单id为空"); |
| | | public void export(Long id, HttpServletResponse response) throws IOException { |
| | | |
| | | TemplateExportParams params = new TemplateExportParams("import/调拨入库单.xlsx"); |
| | | Map<String, Object> map = this.lWhFormTransferService.export(id); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, map); |
| | | try (OutputStream outputStream = response.getOutputStream()) { |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("调拨入库单.xlsx", "utf-8")); |
| | | workbook.write(outputStream); |
| | | workbook.close(); |
| | | } |
| | | LWhFormOutputVo vo = this.lWhFormTransferService.export(id, this.getCurrentUser()); |
| | | return ResponseValue.success(vo); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping("/useInfo/update") |
| | | public ResponseValue infoUpdate() { |
| | | |
| | | List<ProcureModelInfoParam> param = CommonUtil.getObjFromReqBody(List.class); |
| | | List<ProcureModelInfoParam> procureModelInfoParam = Lists.newArrayList(); |
| | | procureModelInfoParam.addAll(param); |
| | | RecordInfoParam param = CommonUtil.getObjFromReqBody(RecordInfoParam.class); |
| | | RecordInfoParam recordInfoParam = new RecordInfoParam(); |
| | | CommonUtil.copyProperties(param, recordInfoParam); |
| | | param = recordInfoParam; |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | if (CollectionUtils.isEmpty(procureModelInfoParam)) { |
| | | if (CollectionUtils.isEmpty(param.getRecordInfoList())) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | |
| | | Map<Long, List<ProcureModelInfoParam>> collect = procureModelInfoParam.stream() |
| | | Map<Long, List<ProcureModelInfoParam>> collect = param.getRecordInfoList().stream() |
| | | .collect(Collectors.groupingBy(ProcureModelInfoParam::getBaseGoodModelId)); |
| | | for (Map.Entry<Long, List<ProcureModelInfoParam>> entry : collect.entrySet()) { |
| | | Long baseGoodModelId = entry.getKey(); |
| | |
| | | lWhProcureModelUserRecordService.insert(lWhProcureModelUserRecord); |
| | | |
| | | List<LWhProcureModelUser> procureModelUserList = Lists.newArrayList(); |
| | | if (CollectionUtils.isEmpty(procureModelInfoList)) { |
| | | if (!CollectionUtils.isEmpty(procureModelInfoList)) { |
| | | for (ProcureModelInfoParam item : procureModelInfoList) { |
| | | LWhProcureModelUser lWhProcureModelUser = new LWhProcureModelUser(); |
| | | lWhProcureModelUser.setId(IdUtil.generateId()); |