| | |
| | | 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.IdUtil; |
| | | import com.consum.base.core.utils.MapUtils; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | |
| | | import com.consum.base.pojo.RecordUserInfoVO; |
| | | import com.consum.base.pojo.UseRecordSkuVO; |
| | | import com.consum.base.pojo.dto.UseRecordDTO; |
| | | import com.consum.base.pojo.excel.TransferExcelTemplate; |
| | | 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.base.pojo.response.TransferInfoVO; |
| | | import com.consum.base.service.*; |
| | | import com.consum.model.po.*; |
| | | import com.consum.model.vo.LWhFormOutputVo; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.LWhFormTransferCoreService; |
| | | import com.consum.base.service.LWhFormTransferService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | | import com.consum.base.service.LWhProcureModelUserRecordServiceImpl; |
| | | import com.consum.base.service.LWhProcureModelUserServiceImpl; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormTransfer; |
| | | import com.consum.model.po.LWhProcureModelUser; |
| | | import com.consum.model.po.LWhProcureModelUserRecord; |
| | | 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.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | 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.*; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description 调拨管理 |
| | |
| | | public class LWhFormTransferController extends BaseController { |
| | | |
| | | @Autowired |
| | | private LWhFormTransferServiceImpl lWhFormTransferService; |
| | | private LWhFormTransferService lWhFormTransferService; |
| | | @Autowired |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private LWhProcureModelUserRecordServiceImpl lWhProcureModelUserRecordService; |
| | | @Autowired |
| | | private BaseGoodsModelsServiceImpl baseGoodsModelsService; |
| | | @Autowired |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | private BaseWarehouseService baseWarehouseService; |
| | | |
| | | /** |
| | | * @Description 新增 |
| | |
| | | @ApiOperation(value = "单据新增", notes = "单据新增") |
| | | @ApiImplicitParam(name = "param", value = "单据新增", required = true, dataType = "LWhFormTransferParam") |
| | | @PostMapping("/add") |
| | | public ResponseValue add(@RequestBody LWhFormTransferParam param) throws Exception { |
| | | public ResponseValue add() throws Exception { |
| | | LWhFormTransferParam param = CommonUtil.getObjFromReqBody(LWhFormTransferParam.class); |
| | | LWhFormTransferParam param2 = new LWhFormTransferParam(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | |
| | | if (CollectionUtils.isEmpty(transferGoods)) { |
| | | return ResponseValue.error("调拨单不能为空"); |
| | | } |
| | | int result = this.lWhFormTransferService.add(param, this.getSysInfo()); |
| | | if (result > 0) { |
| | | return ResponseValue.success(); |
| | | long id = this.lWhFormTransferService.add(param, this.getSysInfo()); |
| | | |
| | | Integer transferBusinessType = param.getTransferBusinessType(); |
| | | //部门分发业务需要处理 |
| | | if (transferBusinessType == 1) { |
| | | // 先出库,再入库 |
| | | // 出库前 设置出库仓库 |
| | | FinSysTenantUser sysTenantUser = this.getSysInfo(); |
| | | String agencyId = sysTenantUser.getTenantId(); |
| | | List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getByAgencyId(Long.valueOf(agencyId), (short) 1, (short) 1); |
| | | if (CollectionUtils.isEmpty(baseWarehouseList)) { |
| | | return ResponseValue.error("机构无默认仓库!"); |
| | | } |
| | | BaseWarehouse baseWarehouse = baseWarehouseList.get(0); |
| | | Long wareHouseId = baseWarehouse.getId(); |
| | | String warehouseName = baseWarehouse.getWarehouseName(); |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); |
| | | lWhFormTransfer.setOutWarehouseId(wareHouseId); |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser()); |
| | | |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser()); |
| | | } |
| | | return ResponseValue.error("新增失败!"); |
| | | |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParam(name = "param", value = "条件参数", required = true, dataType = "TransferQry"), |
| | | }) |
| | | @GetMapping("/list") |
| | | public ResponseValue queryFormTransferList(TransferQry param) { |
| | | public ResponseValue queryFormTransferList() { |
| | | TransferQry param = CommonUtil.getObjFromReq(TransferQry.class); |
| | | TransferQry param2 = new TransferQry(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | |
| | | @ApiImplicitParam(name = "param", value = "条件", required = true, dataType = "TransferQry"), |
| | | }) |
| | | @GetMapping("/detail/list") |
| | | public ResponseValue queryFormTransferDetailList(TransferQry param) { |
| | | public ResponseValue queryFormTransferDetailList() { |
| | | TransferQry param = CommonUtil.getObjFromReq(TransferQry.class); |
| | | TransferQry param2 = new TransferQry(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | /** |
| | | * @Description 导出调拨出库单 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @GetMapping("/export") |
| | | public ResponseValue export(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("调拨单id为空"); |
| | | |
| | | @ApiOperation(value = "调拨单导出", notes = "调拨单导出") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"), |
| | | @ApiImplicitParam(name = "type", value = "导出类型 1 入库 2 出库", required = true, dataType = "Integer"), |
| | | }) |
| | | @GetMapping("/list/export") |
| | | public void export(Long id, Integer type, HttpServletResponse response) throws Exception { |
| | | |
| | | TemplateExportParams params; |
| | | String fileName; |
| | | if (type == 1) { |
| | | params = new TemplateExportParams("import/调拨入库单.xls"); |
| | | fileName = "调拨入库单"; |
| | | } else { |
| | | params = new TemplateExportParams("import/调拨出库单.xls"); |
| | | fileName = "调拨出库单"; |
| | | } |
| | | LWhFormOutputVo vo = this.lWhFormTransferService.export(id, this.getCurrentUser()); |
| | | return ResponseValue.success(vo); |
| | | params.setHeadingStartRow(2); |
| | | List<TransferExcelTemplate> export = this.lWhFormTransferService.export(id, type); |
| | | |
| | | int countNum = export.stream().filter(item -> item.getNum() != null).mapToInt(TransferExcelTemplate::getNum).sum(); |
| | | int totalAmount = export.stream().filter(item -> item.getTotalAmount() != null).mapToInt(TransferExcelTemplate::getTotalAmount).sum(); |
| | | Optional<TransferExcelTemplate> first = export.stream().findFirst(); |
| | | TransferExcelTemplate entity = first.get(); |
| | | String businessFormCode = entity.getBusinessFormCode(); |
| | | Long createTime = entity.getCreateTime(); |
| | | String operatorName = entity.getOperatorName(); |
| | | String tenantName = entity.getTenantName(); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("code", businessFormCode); |
| | | map.put("date", DateUtils.toShowDate(createTime)); |
| | | map.put("tenantName", tenantName); |
| | | map.put("name", operatorName); |
| | | map.put("countNum", countNum); |
| | | map.put("totalAmount", totalAmount); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, TransferExcelTemplate.class, export, map); |
| | | downLoadExcel(fileName, response, workbook); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 部门物品分发列表明细 |
| | | * |
| | | * @param transferQry |
| | | * @param |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "部门物品分发列表明细", notes = "部门物品分发列表明细") |
| | |
| | | @ApiImplicitParam(name = "transferQryDto", value = "调拨单查询条件", required = true) |
| | | }) |
| | | @GetMapping("/department/list") |
| | | public ResponseValue departmentTransferList(TransferQry transferQry) { |
| | | public ResponseValue departmentTransferList() { |
| | | TransferQry param = CommonUtil.getObjFromReq(TransferQry.class); |
| | | TransferQry param2 = new TransferQry(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = this.lWhFormTransferService.queryTransferInfo(transferQry); |
| | | GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = this.lWhFormTransferService.queryTransferInfo(param); |
| | | return ResponseValue.success(transferInfoDetailsVoGenericPager); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParam(name = "procureModelInfoDto", value = "使用信息", required = true) |
| | | }) |
| | | @PostMapping("/useInfo/update") |
| | | public ResponseValue infoUpdate(@RequestBody List<ProcureModelInfoParam> procureModelInfoParam) { |
| | | public ResponseValue infoUpdate() { |
| | | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | } |
| | | // TODO 使用人修改调用 |
| | | |
| | | return ResponseValue.success(); |
| | | } |
| | |
| | | if (CollectionUtils.isEmpty(useRecordDTOList)) { |
| | | return ResponseValue.error("未查询到使用记录"); |
| | | } |
| | | List<GoodsUseRecordVO> result = Lists.newArrayList(); |
| | | List<GoodsUseRecordVO> goodsUseRecordList = Lists.newArrayList(); |
| | | //分组 |
| | | Map<Long, Map<Long, List<UseRecordDTO>>> collect = useRecordDTOList.stream() |
| | | .collect(Collectors.groupingBy(UseRecordDTO::getId, Collectors.groupingBy(UseRecordDTO::getBaseGoodsModelsId))); |
| | |
| | | useRecordSkuVO.setRecordUserInfos(recordUserInfoList); |
| | | useRecordSkuList.add(useRecordSkuVO); |
| | | goodsUseRecordVO.setRecordSkuDtoList(useRecordSkuList); |
| | | result.add(goodsUseRecordVO); |
| | | goodsUseRecordList.add(goodsUseRecordVO); |
| | | } |
| | | } |
| | | } |
| | | //分组之后重新排序 |
| | | List<GoodsUseRecordVO> result = goodsUseRecordList.stream() |
| | | .sorted(Comparator.comparing(GoodsUseRecordVO::getUpdateTime |
| | | , Comparator.nullsFirst(Long::compareTo)).reversed()) |
| | | .collect(Collectors.toList()); |
| | | return ResponseValue.success(result); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "查询部门下的分发单", notes = "查询部门下的分发单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "agencyId", value = "机构id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @GetMapping("/query/detail") |
| | | public ResponseValue queryDepartmentTransferOrder(Long agencyId) { |
| | | |
| | | TransferInfoVO transferInfoVO = new TransferInfoVO(); |
| | | |
| | | lWhFormTransferService.queryDepartmentTransferOrder(); |
| | | return ResponseValue.success(transferInfoVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询部门下的分发单", notes = "查询部门下的分发单") |
| | | @ApiImplicitParams({ |