| | |
| | | package com.consum.base.controller; |
| | | |
| | | 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 cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.consum.base.util.ExcelStyleUtil; |
| | | 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.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.core.type.StatesType; |
| | | import com.consum.base.core.type.TransferStatesType; |
| | | 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.GoodsUseRecordVO; |
| | | import com.consum.base.pojo.LWhFormTransferGoodsInfoParam; |
| | | import com.consum.base.pojo.LWhFormTransferParam; |
| | | import com.consum.base.pojo.ProcureModelInfoDto; |
| | | import com.consum.base.pojo.UseRecordDto; |
| | | import com.consum.base.pojo.UseRecordSkuDto; |
| | | 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.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.GoodsTemplateCountVO; |
| | | import com.consum.base.pojo.response.LWHFromTransferExtendVO; |
| | | import com.consum.base.pojo.response.TransferInfoVO; |
| | | import com.consum.base.service.BaseGoodsModelsServiceImpl; |
| | | import com.consum.base.service.BaseWarehouseServiceImpl; |
| | | import com.consum.base.service.LWhFormTransferCoreService; |
| | | import com.consum.base.service.LWhFormTransferServiceImpl; |
| | | 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.LWhProcureModelUserRecordServiceImpl; |
| | | import com.consum.base.service.LWhProcureModelUserServiceImpl; |
| | | import com.consum.model.po.BaseGoodsModels; |
| | | import com.consum.base.service.LWhProcureModelUserRecordService; |
| | | import com.consum.base.service.LWhProcureModelUserService; |
| | | import com.consum.base.service.core.LWhFormTransferCoreService; |
| | | 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.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 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 java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | 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.RequestBody; |
| | | 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 |
| | | private LWhFormTransferCoreService lWhFormTransferCoreService; |
| | | @Autowired |
| | | private LWhProcureModelUserServiceImpl lWhProcureModelUserService; |
| | | private LWhProcureModelUserService lWhProcureModelUserService; |
| | | @Autowired |
| | | private LWhProcureModelUserRecordServiceImpl lWhProcureModelUserRecordService; |
| | | private LWhProcureModelUserRecordService lWhProcureModelUserRecordService; |
| | | @Autowired |
| | | private BaseGoodsModelsServiceImpl baseGoodsModelsService; |
| | | private LGoodsUserRecordCoreService lGoodsUserRecordCoreService; |
| | | @Autowired |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | private LWhGoodsService lWhGoodsService; |
| | | @Autowired |
| | | 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 { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | 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(1); |
| | | long id = this.lWhFormTransferService.add(param, this.getSysInfo(), StrUtil.isEmpty(param.getProcureDoc())); |
| | | if(id == -1L){ |
| | | return ResponseValue.error("您不是库管员"); |
| | | } |
| | | return ResponseValue.error("新增失败!"); |
| | | if(id == -2L){ |
| | | return ResponseValue.error("仓库不存在"); |
| | | } |
| | | |
| | | Integer transferBusinessType = param.getTransferBusinessType(); |
| | | // 部门分发业务需要处理 |
| | | // todo 拆分 新逻辑 |
| | | if (transferBusinessType == 1 && !StrUtil.isEmpty(param.getProcureDoc())) { |
| | | // 先出库,再入库 |
| | | // 出库前 设置出库仓库 |
| | | 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.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, null); |
| | | GoodsInfoDTO goodsInfoDTO = goodsInfoDTOS.stream().findFirst().orElse(null); |
| | | if (ObjectUtils.isEmpty(goodsInfoDTO)) { |
| | | return ResponseValue.error("该型号没有库存可使用"); |
| | | } |
| | | |
| | | Long wareHouseId = goodsInfoDTO.getWarehouseId(); |
| | | String warehouseName = goodsInfoDTO.getWarehouseName(); |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); |
| | | lWhFormTransfer.setOutWarehouseId(wareHouseId); |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | Long l = lWhFormTransferCoreService.doTransferOutPutNew(id, getCurrentUser(), WhBusinessEnum.BUMENFENFA); |
| | | if(l == -1L){ |
| | | return ResponseValue.error("仓库数量不足"); |
| | | } |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), param.getOperatorName()); |
| | | } |
| | | |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 上传分发单(流程修改) |
| | | * |
| | | * @param idStr 调拨单id json |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @PostMapping("import") |
| | | public ResponseValue upload(@RequestBody String idStr) throws Exception { |
| | | Map<String, Object> map = JSONObject.parseObject(idStr, Map.class); |
| | | String type = map.get("type").toString(); |
| | | Long id = Convert.toLong(map.get("idStr")); |
| | | String procureDoc = map.get("procureDoc").toString(); |
| | | // [调拨] |
| | | if ("0".equals(type)) { |
| | | // 修改 |
| | | LWhFormTransfer addLWhFormTransfer = new LWhFormTransfer(); |
| | | addLWhFormTransfer.setId(id); |
| | | addLWhFormTransfer.setProcureDoc(procureDoc); |
| | | int update = lWhFormTransferService.update(addLWhFormTransfer); |
| | | if (update < 1) { |
| | | return ResponseValue.error(); |
| | | } |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | // [分发] |
| | | Long opTime = Convert.toLong(map.get("opTime")); |
| | | // 修改表的文件逻辑 |
| | | LWHFromTransferExtendVO lwhFromTransferExtendVO = lWhFormTransferService.getById(id); |
| | | // 修改 |
| | | LWhFormTransfer addLWhFormTransfer = new LWhFormTransfer(); |
| | | addLWhFormTransfer.setId(id); |
| | | addLWhFormTransfer.setProcureDoc(procureDoc); |
| | | addLWhFormTransfer.setInTime(opTime); |
| | | addLWhFormTransfer.setOutputTime(opTime); |
| | | int update = lWhFormTransferService.update(addLWhFormTransfer); |
| | | if (update < 1) { |
| | | return ResponseValue.error(); |
| | | } |
| | | // 主分发逻辑 |
| | | // 先出库,再入库 |
| | | // 出库前 设置出库仓库 |
| | | 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.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, null); |
| | | GoodsInfoDTO goodsInfoDTO = goodsInfoDTOS.stream().findFirst().orElse(null); |
| | | if (ObjectUtils.isEmpty(goodsInfoDTO)) { |
| | | return ResponseValue.error("该型号没有库存可使用"); |
| | | } |
| | | Long wareHouseId = goodsInfoDTO.getWarehouseId(); |
| | | String warehouseName = goodsInfoDTO.getWarehouseName(); |
| | | LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); |
| | | lWhFormTransfer.setOutWarehouseId(wareHouseId); |
| | | lWhFormTransfer.setOutWarehouseName(warehouseName); |
| | | lWhFormTransferService.update(lWhFormTransfer); |
| | | lWhFormTransferCoreService.doTransferOutPutNew(id, getCurrentUser(), WhBusinessEnum.BUMENFENFA); |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), lwhFromTransferExtendVO.getOperatorName()); |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description 列表查询(调拨明细) |
| | |
| | | * 2.查询物品型号 |
| | | */ |
| | | @ApiOperation(value = "单据列表查询", notes = "单据列表查询") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "size", value = "每页条数", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "param", value = "条件参数", required = true, dataType = "TransferQry"), |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页码", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "size", value = "每页条数", required = true, dataType = "int"), |
| | | @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("登录用户信息不存在"); |
| | |
| | | FormTransferVO formTransferVO = new FormTransferVO(); |
| | | BeanUtils.copyProperties(item, formTransferVO); |
| | | |
| | | List<FromTransferTemplateInfoVO> templateInfoList = Lists.newArrayList(); |
| | | |
| | | // 查询型号数量 |
| | | String sql = "SELECT bgt.id,bgm.GOODS_TEMPLATES_ID,GOODS_NAME,sum( counts ) count FROM " |
| | | + "l_wh_procure_model pm LEFT JOIN base_goods_models bgm ON pm.BASE_GOODS_MODELS_ID = bgm.id " |
| | | + "LEFT JOIN base_goods_template bgt ON bgm.GOODS_TEMPLATES_ID = bgt.id " |
| | | + "WHERE pm.BUSINESS_ID =:id GROUP BY bgm.GOODS_TEMPLATES_ID"; |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("id", item.getId()); |
| | | List<Map<String, Object>> procureModelList = lWhProcureModelService.select(sql, paramMap, new MapperUtil()); |
| | | for (Map<String, Object> map : procureModelList) { |
| | | FromTransferTemplateInfoVO procureTemplateInfoVO = MapUtils.convertMapToObj(map, FromTransferTemplateInfoVO.class); |
| | | templateInfoList.add(procureTemplateInfoVO); |
| | | } |
| | | formTransferVO.setFromTransferTemplateInfoList(templateInfoList); |
| | | List<GoodsTemplateCountVO> goodsTemplateCount = |
| | | lWhProcureModelService.getGoodsTemplateCountByBusinessId(item.getId()); |
| | | formTransferVO.setFromTransferTemplateInfoList(goodsTemplateCount); |
| | | |
| | | result.add(formTransferVO); |
| | | |
| | | |
| | | /*// 查询型号数量 |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | Integer businessType = item.getBusinessType(); |
| | | // TODO 调拨=0 分发=1 退回=2 |
| | | switch (businessType) { |
| | | case 0: |
| | | lWhProcureModel.setBusinessType(2); |
| | | break; |
| | | case 1: |
| | | lWhProcureModel.setBusinessType(4); |
| | | break; |
| | | } |
| | | lWhProcureModel.setBusinessId(item.getId()); |
| | | List<LWhProcureModel> models = lWhProcureModelService.select(lWhProcureModel); |
| | | List<LWhProcureModelVo> lWhProcureModelVoList = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(models)) { |
| | | models.forEach(model -> { |
| | | LWhProcureModelVo lWhProcureModelVo = new LWhProcureModelVo(); |
| | | BeanUtils.copyProperties(model, lWhProcureModelVo); |
| | | |
| | | Long baseGoodsModelsId = model.getBaseGoodsModelsId(); |
| | | Long businessId = model.getBusinessId(); |
| | | Long id = model.getId(); |
| | | LWhProcureModelUser lWhFormTransferUser = new LWhProcureModelUser(); |
| | | lWhFormTransferUser.setTransBusinessId(businessId); |
| | | lWhFormTransferUser.setWhProcureModelId(id); |
| | | lWhFormTransferUser.setBaseGoodsModelsId(baseGoodsModelsId); |
| | | List<LWhProcureModelUser> procureModelUserList = lWhProcureModelUserService.select(lWhFormTransferUser); |
| | | lWhProcureModelVo.setProcureModelUsersList(procureModelUserList); |
| | | lWhProcureModelVoList.add(lWhProcureModelVo); |
| | | }); |
| | | } |
| | | formTransferExtend.setModels(lWhProcureModelVoList); |
| | | newDatas.add(formTransferExtend);*/ |
| | | }); |
| | | } |
| | | try { |
| | | Field fieldDatas = GenericPager.class.getDeclaredField("datas"); |
| | | fieldDatas.setAccessible(true); |
| | | fieldDatas.set(genericPager, result); |
| | | // fieldDatas.setAccessible(true); |
| | | // fieldDatas.set(genericPager, result); |
| | | ReflectUtil.setFieldValue(genericPager, fieldDatas, result); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | * @Date 2023/10/30 |
| | | */ |
| | | @ApiOperation(value = "根据id查询详情", notes = "根据id查询详情") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"), |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @GetMapping("/detail") |
| | | public ResponseValue getById(Long id) { |
| | | if (id == null) { |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "调拨明细列表", notes = "调拨明细列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "param", value = "条件", required = true, dataType = "TransferQry"), |
| | | }) |
| | | @ApiImplicitParams({@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("登录用户信息不存在"); |
| | | } |
| | | String tenantId = sysInfo.getTenantId(); |
| | | if (param.getInAgencyId() == null) { |
| | | param.setInAgencyId(Long.valueOf(tenantId)); |
| | | } |
| | | GenericPager<Map<String, Object>> mapGenericPager = lWhFormTransferService.queryFormTransferDetailList(param); |
| | | |
| | |
| | | * @date 2023/10/31 |
| | | */ |
| | | @ApiOperation(value = "撤销", notes = "撤销") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"), |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @PostMapping("/updStatus") |
| | | public ResponseValue updateStatus(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | LWhFormTransfer lWhFormTransfer = lWhFormTransferService.selectById(id); |
| | | if (lWhFormTransfer.getStates() != TransferStatesType.OUT_PENDING.getValue()) { |
| | | return ResponseValue.error("状态错误,不能撤销"); |
| | | } |
| | | |
| | | int num = this.lWhFormTransferService.updateStatus(id); |
| | |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @ApiOperation(value = "调拨入库", notes = "调拨入库") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"), |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @PostMapping("/income") |
| | | public ResponseValue income(Long id) { |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser()); |
| | | public ResponseValue income(Long id) throws Exception { |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser(), null); |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @ApiOperation(value = "调拨出库", notes = "调拨出库") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"), |
| | | }) |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "调拨单id", required = true, dataType = "Long"),}) |
| | | @PostMapping("/output") |
| | | public ResponseValue output(Long id) { |
| | | // 出库前 设置出库仓库 |
| | | public ResponseValue output(Long id) throws Exception { |
| | | |
| | | 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("机构无默认仓库!"); |
| | | List<BaseWarehouse> baseWarehouseList = |
| | | 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, 1); |
| | | 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(), WhBusinessEnum.DIAOBO); |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | /** |
| | | * @Description 导出调拨出库单 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @GetMapping("/export") |
| | | public ResponseValue export(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("调拨单id为空"); |
| | | } |
| | | LWhFormOutputVo vo = this.lWhFormTransferService.export(id, this.getCurrentUser()); |
| | | return ResponseValue.success(vo); |
| | | } |
| | | @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 ResponseValue<String> export(Long id, Integer type, HttpServletResponse response) throws Exception { |
| | | |
| | | TemplateExportParams params; |
| | | String fileName; |
| | | if (type == 0) { |
| | | params = new TemplateExportParams("import/调拨入库单.xls"); |
| | | fileName = "调拨入库单"; |
| | | }else if (type == 1) { |
| | | params = new TemplateExportParams("import/调拨入库单1.xls"); |
| | | fileName = "调拨入库单"; |
| | | } else { |
| | | params = new TemplateExportParams("import/调拨出库单.xls"); |
| | | fileName = "调拨出库单"; |
| | | } |
| | | params.setHeadingStartRow(2); |
| | | params.setStyle(ExcelStyleUtil.class); |
| | | List<TransferExcelTemplate> export = this.lWhFormTransferService.export(id, type); |
| | | |
| | | int countNum = |
| | | export.stream().filter(item -> item.getNum() != null).mapToInt(TransferExcelTemplate::getNum).sum(); |
| | | double totalAmount = export.stream().filter(item -> item.getTotalAmount() != null) |
| | | .mapToDouble(TransferExcelTemplate::getAmount).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); |
| | | String filePath = downLoadExcel(fileName, workbook); |
| | | return ResponseValue.success("导出成功", filePath); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 部门物品分发列表明细 |
| | | * |
| | | * @param transferQry |
| | | * @param |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "部门物品分发列表明细", notes = "部门物品分发列表明细") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "transferQryDto", value = "调拨单查询条件", required = true) |
| | | }) |
| | | @ApiImplicitParams({@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) { |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = this.lWhFormTransferService.queryTransferInfo(transferQry); |
| | | String tenantId = sysInfo.getTenantId(); |
| | | if (param.getOutAgencyId() == null) { |
| | | param.setOutAgencyId(Long.valueOf(tenantId)); |
| | | } |
| | | GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = |
| | | this.lWhFormTransferService.queryTransferInfo(param); |
| | | return ResponseValue.success(transferInfoDetailsVoGenericPager); |
| | | } |
| | | |
| | | /** |
| | | * 部门物品使用记录 |
| | | * |
| | | * @param procureModelInfoDto |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "使用人修改", notes = "使用人修改") |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "procureModelInfoDto", value = "使用信息", required = true)}) |
| | | @PostMapping("/useInfo/update") |
| | | public ResponseValue infoUpdate(@RequestBody List<ProcureModelInfoDto> procureModelInfoDto) { |
| | | 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(procureModelInfoDto)) { |
| | | if (CollectionUtils.isEmpty(param.getRecordInfoList())) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | |
| | | for (ProcureModelInfoDto procureModelInfo : procureModelInfoDto) { |
| | | 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(); |
| | | |
| | | String transferOrderId = procureModelInfo.getTransferOrderId(); |
| | | String baseGoodModelId = procureModelInfo.getBaseGoodModelId(); |
| | | List<ProcureModelInfoParam> procureModelInfoList = entry.getValue(); |
| | | Optional<ProcureModelInfoParam> first = procureModelInfoList.stream().findFirst(); |
| | | ProcureModelInfoParam procureModelInf = first.get(); |
| | | Long businessId = procureModelInf.getBusinessId(); |
| | | LWhProcureModelUserRecord lWhProcureModelUserRecord = new LWhProcureModelUserRecord(); |
| | | lWhProcureModelUserRecord.setId(IdUtil.generateId()); |
| | | lWhProcureModelUserRecord.setTransBusinessId(businessId); |
| | | FinSysTenantUser sysInfo = getSysInfo(); |
| | | lWhProcureModelUserRecord.setOperatorId(sysInfo.getId()); |
| | | lWhProcureModelUserRecord.setOperatorName(sysInfo.getUserName()); |
| | | lWhProcureModelUserRecord.setDealTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | lWhProcureModelUserRecordService.insert(lWhProcureModelUserRecord); |
| | | |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | lWhProcureModel.setBusinessId(Long.valueOf(transferOrderId)); |
| | | lWhProcureModel.setBaseGoodsModelsId(Long.valueOf(baseGoodModelId)); |
| | | // 部门分发 |
| | | lWhProcureModel.setBusinessType(4); |
| | | List<LWhProcureModel> lWhProcureModelList = lWhProcureModelService.select(lWhProcureModel); |
| | | lWhProcureModelList.forEach(item -> { |
| | | Long id = item.getId(); |
| | | LWhProcureModelUser lWhProcureModelUser = new LWhProcureModelUser(); |
| | | lWhProcureModelUser.setWhProcureModelId(id); |
| | | List<LWhProcureModelUser> procureModelUserList = lWhProcureModelUserService.select(lWhProcureModelUser); |
| | | procureModelUserList.forEach(procureModelUser -> { |
| | | procureModelUser.setNowUserName(procureModelInfo.getUserName()); |
| | | procureModelUser.setNowUserPhone(procureModelInfo.getPhone()); |
| | | List<LWhProcureModelUser> procureModelUserList = Lists.newArrayList(); |
| | | if (!CollectionUtils.isEmpty(procureModelInfoList)) { |
| | | for (ProcureModelInfoParam item : procureModelInfoList) { |
| | | LWhProcureModelUser lWhProcureModelUser = new LWhProcureModelUser(); |
| | | lWhProcureModelUser.setId(IdUtil.generateId()); |
| | | lWhProcureModelUser.setTransBusinessId(businessId); |
| | | lWhProcureModelUser.setProcureModelUserRecordId(lWhProcureModelUserRecord.getId()); |
| | | lWhProcureModelUser.setWhProcureModelId(procureModelInf.getProcureModelId()); |
| | | lWhProcureModelUser.setBaseGoodsModelsId(baseGoodModelId); |
| | | lWhProcureModelUser.setNowUserPhone(item.getPhone()); |
| | | lWhProcureModelUser.setNowUserName(item.getUserName()); |
| | | lWhProcureModelUser.setGoodsNum(item.getCount()); |
| | | |
| | | LWhProcureModelUserRecord lWhProcureModelUserRecord = new LWhProcureModelUserRecord(); |
| | | lWhProcureModelUserRecord.setId(IdUtil.generateId()); |
| | | lWhProcureModelUserRecord.setTransBusinessId(Long.valueOf(transferOrderId)); |
| | | FinSysTenantUser sysInfo = getSysInfo(); |
| | | lWhProcureModelUserRecord.setOperatorId(sysInfo.getId()); |
| | | lWhProcureModelUserRecord.setOperatorName(sysInfo.getUserName()); |
| | | lWhProcureModelUserRecord.setDealTime(DateUtils.getDateTimeNumber(System.currentTimeMillis())); |
| | | lWhProcureModelUserRecordService.insert(lWhProcureModelUserRecord); |
| | | }); |
| | | lWhProcureModelUserService.updateBatch(procureModelUserList); |
| | | }); |
| | | // 设置一下在用数量 |
| | | Long oldProcureModelId = item.getOldProcureModelId(); |
| | | LWhProcureModelUser oldInfo = |
| | | lWhProcureModelUserService.get(new LWhProcureModelUser(oldProcureModelId)); |
| | | lWhProcureModelUser.setUseCount(oldInfo.getUseCount()); |
| | | procureModelUserList.add(lWhProcureModelUser); |
| | | } |
| | | |
| | | lWhProcureModelUserService.insert(procureModelUserList); |
| | | } |
| | | // 使用人修改调用 |
| | | lGoodsUserRecordCoreService.modifyGoodsUser(null, lWhProcureModelUserRecord.getId()); |
| | | } |
| | | |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | |
| | | * @param transferOrderId |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "部门物品使用人记录", notes = "部门物品使用人记录") |
| | | @ApiImplicitParams({@ApiImplicitParam(name = "transferOrderId", value = "调拨单id", required = true)}) |
| | | @GetMapping("/use/record") |
| | | public ResponseValue useRecord(Long transferOrderId) { |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | LWhProcureModelUserRecord lWhProcureModelUserRecord = new LWhProcureModelUserRecord(); |
| | | lWhProcureModelUserRecord.setTransBusinessId(transferOrderId); |
| | | List<LWhProcureModelUserRecord> modelUserRecords = lWhProcureModelUserRecordService.select(lWhProcureModelUserRecord); |
| | | |
| | | List<UseRecordDto> result = Lists.newArrayList(); |
| | | for (LWhProcureModelUserRecord item : modelUserRecords) { |
| | | Long id = item.getId(); |
| | | UseRecordDto useRecordDto = new UseRecordDto(); |
| | | useRecordDto.setId(id); |
| | | useRecordDto.setUpdateUserName(item.getOperatorName()); |
| | | useRecordDto.setUpdateTime(DateUtils.toShowDate(item.getDealTime())); |
| | | |
| | | LWhProcureModelUser lWhProcureModelUser = new LWhProcureModelUser(); |
| | | lWhProcureModelUser.setWhProcureModelId(id); |
| | | List<LWhProcureModelUser> procureModelUserList = lWhProcureModelUserService.select(lWhProcureModelUser); |
| | | |
| | | List<UseRecordSkuDto> recordSkuDtoList = Lists.newArrayList(); |
| | | procureModelUserList.forEach(procureModelUser -> { |
| | | UseRecordSkuDto useRecordSkuDto = new UseRecordSkuDto(); |
| | | |
| | | BaseGoodsModels baseGoodsModels = new BaseGoodsModels(); |
| | | baseGoodsModels.setId(procureModelUser.getBaseGoodsModelsId()); |
| | | BaseGoodsModels baseGoodsModel = baseGoodsModelsService.getByModelNameAndGoodsTemplatesId(baseGoodsModels); |
| | | String unit = baseGoodsModel.getUnit(); |
| | | useRecordSkuDto.setBaseUnit(unit); |
| | | useRecordSkuDto.setBaseGoodModelName(baseGoodsModel.getModelName()); |
| | | useRecordSkuDto.setCount(procureModelUser.getGoodsNum()); |
| | | useRecordSkuDto.setPhone(procureModelUser.getNowUserPhone()); |
| | | useRecordSkuDto.setUserName(procureModelUser.getNowUserName()); |
| | | |
| | | recordSkuDtoList.add(useRecordSkuDto); |
| | | }); |
| | | useRecordDto.setRecordSkuDtoList(recordSkuDtoList); |
| | | |
| | | List<UseRecordDTO> useRecordDTOList = lWhProcureModelUserService.selectUseRecord(transferOrderId); |
| | | if (CollectionUtils.isEmpty(useRecordDTOList)) { |
| | | return ResponseValue.error("未查询到使用记录"); |
| | | } |
| | | return ResponseValue.success(result); |
| | | } |
| | | |
| | | List<GoodsUseRecordVO> goodsUseRecordList = useRecordDTOList.stream() |
| | | .collect(Collectors.groupingBy(UseRecordDTO::getId)).entrySet().stream().map(entry -> { |
| | | Long id = entry.getKey(); |
| | | List<UseRecordDTO> useRecordList = entry.getValue(); |
| | | UseRecordDTO useRecordDto = useRecordList.get(0); |
| | | |
| | | GoodsUseRecordVO goodsUseRecordVO = new GoodsUseRecordVO(); |
| | | goodsUseRecordVO.setId(id); |
| | | goodsUseRecordVO.setUpdateUserName(useRecordDto.getUpdateUserName()); |
| | | goodsUseRecordVO.setUpdateTime(useRecordDto.getUpdateTime()); |
| | | |
| | | List<UseRecordSkuVO> useRecordSkuList = |
| | | useRecordList.stream().collect(Collectors.groupingBy(UseRecordDTO::getProcureModelId)).values() |
| | | .stream().map(recordList -> { |
| | | UseRecordDTO useRecordDTO = recordList.get(0); |
| | | UseRecordSkuVO useRecordSkuVO = new UseRecordSkuVO(); |
| | | useRecordSkuVO.setBaseGoodModelId(useRecordDTO.getBaseGoodsModelsId()); |
| | | useRecordSkuVO.setBaseGoodModelName(useRecordDTO.getBaseGoodsModelsName()); |
| | | useRecordSkuVO.setUnit(useRecordDTO.getUnit()); |
| | | useRecordSkuVO.setProcureModelId(useRecordDTO.getProcureModelId()); |
| | | |
| | | 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()); |
| | | return recordUserInfoVO; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | useRecordSkuVO.setRecordUserInfos(recordUserInfoList); |
| | | return useRecordSkuVO; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | goodsUseRecordVO.setRecordSkuDtoList(useRecordSkuList); |
| | | return goodsUseRecordVO; |
| | | |
| | | }).sorted(Comparator.comparing(GoodsUseRecordVO::getUpdateTime, Comparator.nullsFirst(Long::compareTo)) |
| | | .reversed()) |
| | | .collect(Collectors.toList()); |
| | | |
| | | return ResponseValue.success(goodsUseRecordList); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询部门下的分发单", notes = "查询部门下的分发单") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "agencyId", value = "机构id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @GetMapping("/query/detail") |
| | | public ResponseValue queryDepartmentTransferOrder(Long agencyId) { |
| | | @ApiImplicitParam(name = "agencyId", value = "机构id", required = true, dataType = "Long", paramType = "query")}) |
| | | @GetMapping("/query/transfList") |
| | | public ResponseValue queryDepartmentTransferOrderList() { |
| | | |
| | | TransferInfoVO transferInfoVO = new TransferInfoVO(); |
| | | |