| | |
| | | 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 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.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | 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; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.core.type.StatesType; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.base.pojo.GoodsUseRecordVO; |
| | | import com.consum.base.pojo.LWhFormTransferGoodsInfoParam; |
| | | import com.consum.base.pojo.RecordUserInfoVO; |
| | | import com.consum.base.pojo.UseRecordSkuVO; |
| | | import com.consum.base.pojo.dto.GoodsInfoDTO; |
| | | 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.response.GoodsTemplateCountVO; |
| | | import com.consum.base.pojo.response.LWHFromTransferExtendVO; |
| | | import com.consum.base.pojo.response.TransferInfoVO; |
| | | import com.consum.base.service.*; |
| | | import com.consum.base.service.BaseWarehouseService; |
| | | import com.consum.base.service.LGoodsUserRecordCoreService; |
| | | import com.consum.base.service.LWhFormTransferService; |
| | | import com.consum.base.service.LWhGoodsService; |
| | | import com.consum.base.service.LWhProcureModelService; |
| | | import com.consum.base.service.LWhProcureModelUserRecordService; |
| | | import com.consum.base.service.LWhProcureModelUserService; |
| | | import com.consum.base.service.impl.LWhFormTransferCoreService; |
| | | import com.consum.model.po.*; |
| | | import com.consum.model.po.BaseWarehouse; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.po.LWhFormTransfer; |
| | | import com.consum.model.po.LWhProcureModel; |
| | | 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 com.walker.infrastructure.utils.DateUtils; |
| | | import com.walker.web.ResponseValue; |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description 调拨管理 |
| | |
| | | @Autowired |
| | | private LWhProcureModelUserRecordService lWhProcureModelUserRecordService; |
| | | @Autowired |
| | | private BaseWarehouseService baseWarehouseService; |
| | | @Autowired |
| | | private LGoodsUserRecordCoreService lGoodsUserRecordCoreService; |
| | | @Autowired |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Autowired |
| | | private BaseWarehouseService baseWarehouseService; |
| | | |
| | | /** |
| | | * @Description 新增 |
| | |
| | | if (transferBusinessType == 1) { |
| | | // 先出库,再入库 |
| | | // 出库前 设置出库仓库 |
| | | List<LWhProcureModel> modelByForm = lWhProcureModelService.getModelByForm(WhBusinessEnum.BUMENFENFA, id); |
| | | Set<Long> baseModelIds = |
| | | modelByForm.stream().map(LWhProcureModel::getBaseGoodsModelsId).collect(Collectors.toSet()); |
| | | |
| | | 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("机构无默认仓库!"); |
| | | baseWarehouseService.getBaseWareHouseList(Long.valueOf(agencyId), StatesType.NORMAL.getValue()); |
| | | Set<Long> wareHouseIds = baseWarehouseList.stream().map(BaseWarehouse::getId).collect(Collectors.toSet()); |
| | | // 通过调拨单中的型号id查询出该型号物品所在的仓库位置 |
| | | List<GoodsInfoDTO> goodsInfoDTOS = lWhGoodsService.queryGoodsInfo(baseModelIds, wareHouseIds); |
| | | GoodsInfoDTO goodsInfoDTO = goodsInfoDTOS.stream().findFirst().orElse(null); |
| | | if (ObjectUtils.isEmpty(goodsInfoDTO)) { |
| | | return ResponseValue.error("该型号没有库存可使用"); |
| | | } |
| | | BaseWarehouse baseWarehouse = baseWarehouseList.get(0); |
| | | Long wareHouseId = baseWarehouse.getId(); |
| | | String warehouseName = baseWarehouse.getWarehouseName(); |
| | | |
| | | Long wareHouseId = goodsInfoDTO.getWarehouseId(); |
| | | String warehouseName = goodsInfoDTO.getWarehouseName(); |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); |
| | | lWhFormTransfer.setOutWarehouseId(wareHouseId); |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser()); |
| | | |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser()); |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), param.getOperatorName()); |
| | | } |
| | | |
| | | return ResponseValue.success(); |
| | |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @PostMapping("/income") |
| | | public ResponseValue income(Long id) { |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser()); |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), null); |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @PostMapping("/output") |
| | | public ResponseValue output(Long id) { |
| | | // 出库前 设置出库仓库 |
| | | |
| | | List<LWhProcureModel> modelByForm = lWhProcureModelService.getModelByForm(WhBusinessEnum.DIAOBO, id); |
| | | Set<Long> baseModelIds = |
| | | modelByForm.stream().map(LWhProcureModel::getBaseGoodsModelsId).collect(Collectors.toSet()); |
| | | |
| | | 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("机构无默认仓库!"); |
| | | baseWarehouseService.getBaseWareHouseList(Long.valueOf(agencyId), StatesType.NORMAL.getValue()); |
| | | Set<Long> wareHouseIds = baseWarehouseList.stream().map(BaseWarehouse::getId).collect(Collectors.toSet()); |
| | | |
| | | // 通过调拨单中的型号id查询出该型号物品所在的仓库位置 |
| | | List<GoodsInfoDTO> goodsInfoDTOS = lWhGoodsService.queryGoodsInfo(baseModelIds, wareHouseIds); |
| | | GoodsInfoDTO goodsInfoDTO = goodsInfoDTOS.stream().findFirst().orElse(null); |
| | | if (ObjectUtils.isEmpty(goodsInfoDTO)) { |
| | | return ResponseValue.error("该型号没有库存可使用"); |
| | | } |
| | | BaseWarehouse baseWarehouse = baseWarehouseList.get(0); |
| | | Long wareHouseId = baseWarehouse.getId(); |
| | | String warehouseName = baseWarehouse.getWarehouseName(); |
| | | Long wareHouseId = goodsInfoDTO.getWarehouseId(); |
| | | String warehouseName = goodsInfoDTO.getWarehouseName(); |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); |
| | | lWhFormTransfer.setOutWarehouseId(wareHouseId); |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | // lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser()); |
| | | // lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser()); |
| | | lWhFormTransferCoreService.doTransferOutPutNew(id, getCurrentUser()); |
| | | return ResponseValue.success(); |
| | | } |
| | |
| | | @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 { |
| | | public ResponseValue<String> export(Long id, Integer type, HttpServletResponse response) throws Exception { |
| | | |
| | | TemplateExportParams params; |
| | | String fileName; |
| | |
| | | map.put("totalAmount", totalAmount); |
| | | |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, TransferExcelTemplate.class, export, map); |
| | | downLoadExcel(fileName, response, workbook); |
| | | String filePath = downLoadExcel(fileName, response, workbook); |
| | | return ResponseValue.success("导出成功", filePath); |
| | | |
| | | } |
| | | |
| | |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | String tenantId = sysInfo.getTenantId(); |
| | | if (param.getOutAgencyId() == null) { |
| | | param.setOutAgencyId(Long.valueOf(tenantId)); |
| | | } |
| | | GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = |
| | | this.lWhFormTransferService.queryTransferInfo(param); |
| | |
| | | lWhProcureModelUser.setNowUserPhone(item.getPhone()); |
| | | lWhProcureModelUser.setNowUserName(item.getUserName()); |
| | | lWhProcureModelUser.setGoodsNum(item.getCount()); |
| | | |
| | | // 设置一下在用数量 |
| | | Long oldProcureModelId = item.getOldProcureModelId(); |
| | | LWhProcureModelUser oldInfo = |
| | | lWhProcureModelUserService.get(new LWhProcureModelUser(oldProcureModelId)); |
| | | lWhProcureModelUser.setUseCount(oldInfo.getUseCount()); |
| | | procureModelUserList.add(lWhProcureModelUser); |
| | | } |
| | | |
| | |
| | | |
| | | List<RecordUserInfoVO> recordUserInfoList = recordList.stream().map(userInfo -> { |
| | | RecordUserInfoVO recordUserInfoVO = new RecordUserInfoVO(); |
| | | recordUserInfoVO.setOldProcureModelId(userInfo.getOldProcureModelId()); |
| | | recordUserInfoVO.setUseName(userInfo.getUseName()); |
| | | recordUserInfoVO.setPhone(userInfo.getPhone()); |
| | | recordUserInfoVO.setNum(userInfo.getNum()); |
| | |
| | | |
| | | goodsUseRecordVO.setRecordSkuDtoList(useRecordSkuList); |
| | | return goodsUseRecordVO; |
| | | |
| | | }).sorted(Comparator.comparing(GoodsUseRecordVO::getUpdateTime, Comparator.nullsFirst(Long::compareTo)) |
| | | .reversed()) |
| | | .collect(Collectors.toList()); |