| | |
| | | package com.consum.base.controller; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.CodeGeneratorEnum; |
| | | import com.consum.base.core.CodeGeneratorService; |
| | | import com.consum.base.core.WhBusinessEnum; |
| | | import com.consum.base.pojo.*; |
| | | import com.consum.base.service.*; |
| | | import com.consum.model.po.*; |
| | | import com.consum.base.pojo.LWhFormTransferParam; |
| | | import com.consum.base.pojo.LWhProcureModelParams; |
| | | import com.consum.base.pojo.ProcureModelInfoDto; |
| | | import com.consum.base.pojo.UseRecordDto; |
| | | import com.consum.base.pojo.UseRecordSkuDto; |
| | | import com.consum.base.pojo.query.TransferQryDto; |
| | | 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.LWhProcureModelService; |
| | | import com.consum.base.service.LWhProcureModelUserRecordServiceImpl; |
| | | import com.consum.base.service.LWhProcureModelUserServiceImpl; |
| | | import com.consum.base.core.utils.IdUtil; |
| | | import com.consum.model.po.BaseGoodsModels; |
| | | 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.consum.model.vo.LWhFormTransferVo; |
| | | import com.consum.model.vo.LWhProcureModelVo; |
| | | 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.infrastructure.utils.NumberGenerator; |
| | | import com.walker.web.ResponseValue; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | 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.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 调拨管理 |
| | | * @Description 调拨管理 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/pc/l/wh/form/transfer") |
| | | @Api(tags = "调拨分发管理") |
| | | public class LWhFormTransferController extends BaseController { |
| | | |
| | | @Autowired |
| | |
| | | private BaseWarehouseServiceImpl baseWarehouseService; |
| | | @Autowired |
| | | private LWhProcureModelService lWhProcureModelService; |
| | | @Autowired |
| | | private LWhFormTransferCoreService lWhFormTransferCoreService; |
| | | @Autowired |
| | | private LWhProcureModelUserServiceImpl lWhProcureModelUserService; |
| | | @Autowired |
| | | private LWhProcureModelUserRecordServiceImpl lWhProcureModelUserRecordService; |
| | | @Autowired |
| | | private BaseGoodsModelsServiceImpl baseGoodsModelsService; |
| | | |
| | | /** |
| | | * @Description 新增 |
| | | */ |
| | | @ApiOperation(value = "单据新增", notes = "单据新增") |
| | | @ApiImplicitParam(name = "param", value = "单据新增", required = true, dataType = "LWhFormTransferParam") |
| | | @PostMapping("/add") |
| | | public ResponseValue add(@RequestBody LWhFormTransferParam param) { |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | |
| | | if (CollectionUtils.isEmpty(transferGoods)) { |
| | | return ResponseValue.error("调拨单不能为空"); |
| | | } |
| | | int result = this.lWhFormTransferService.add(param, currentUser,this.getSysInfo()); |
| | | if (result > 0) return ResponseValue.success(1); |
| | | int result = this.lWhFormTransferService.add(param, currentUser, this.getSysInfo()); |
| | | if (result > 0) { |
| | | return ResponseValue.success(1); |
| | | } |
| | | return ResponseValue.error("新增失败!"); |
| | | } |
| | | |
| | | /** |
| | | * @Description 列表查询 |
| | | * @Description 列表查询(调拨明细) |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | // 1.查询调拨单 |
| | | // 2.查询物品型号 |
| | | @GetMapping("/list") |
| | | public ResponseValue queryFormTransferList(LWhFormTransferParam param) { |
| | | public ResponseValue queryFormTransferList(TransferQryDto param) { |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | FinSysTenantUser sysInfo = getSysInfo(); |
| | | |
| | | //只能查询本级 及以下机构的进货单 |
| | | //只能查询本级 及以下机构的调拨单 |
| | | //?????? |
| | | |
| | | GenericPager genericPager = lWhFormTransferService.queryFormTransferList(param); |
| | | List<LWhFormTransfer> datas = genericPager.getDatas(); |
| | | ArrayList<LWhFormProcureExtend> newDatas = new ArrayList<>(); |
| | | ArrayList<LWhFormTransferVo> newDatas = new ArrayList<>(); |
| | | if (!CollectionUtils.isEmpty(datas)) { |
| | | datas.forEach(item -> { |
| | | // 查询型号数量 |
| | | LWhProcureModel lWhProcureModel = new LWhProcureModel(); |
| | | lWhProcureModel.setBusinessType(2); |
| | | 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()); |
| | | |
| | | LWhFormTransferVo formTransferExtend = new LWhFormTransferVo(); |
| | | BeanUtils.copyProperties(item, formTransferExtend); |
| | | |
| | | List<LWhProcureModel> models = lWhProcureModelService.select(lWhProcureModel); |
| | | LWhFormProcureExtend formProcureExtend = new LWhFormProcureExtend(); |
| | | BeanUtils.copyProperties(item, formProcureExtend); |
| | | formProcureExtend.setModels(models); |
| | | newDatas.add(formProcureExtend); |
| | | 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 { |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // genericPager.setDatas(newDatas); |
| | | return ResponseValue.success(genericPager); |
| | | } |
| | | |
| | | /** |
| | | * @Description 根据id查询详情 |
| | | * @Description 根据id查询详情 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | @GetMapping("/detail") |
| | | public ResponseValue getById(Long id) throws IllegalAccessException { |
| | | public ResponseValue getById(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("调拨单id为空"); |
| | | } |
| | |
| | | return ResponseValue.success(vo); |
| | | } |
| | | |
| | | /** |
| | | * 撤销 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/31 |
| | | */ |
| | | @PostMapping("/updStatus") |
| | | public ResponseValue updateStatus(Long id) { |
| | | if (id == null) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | |
| | | int num = this.lWhFormTransferService.updateStatus(id); |
| | | return num > 0 ? ResponseValue.success(1) : ResponseValue.error("修改失败!"); |
| | | } |
| | | |
| | | /** |
| | | * @Description 调拨入库 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @PostMapping("/income") |
| | | public ResponseValue income(Long id) { |
| | | lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser()); |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | /** |
| | | * @Description 调拨出库 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/31 |
| | | */ |
| | | @PostMapping("/output") |
| | | public ResponseValue output(Long id) { |
| | | lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser()); |
| | | 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); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 部门物品分发列表明细 |
| | | * |
| | | * @param transferQryDto |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "部门物品分发列表明细", notes = "部门物品分发列表明细") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "transferQryDto", value = "调拨单查询条件", required = true) |
| | | }) |
| | | @GetMapping("/department/list") |
| | | public ResponseValue departmentTransferList(TransferQryDto transferQryDto) { |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = this.lWhFormTransferService.queryTransferInfo(transferQryDto); |
| | | return ResponseValue.success(transferInfoDetailsVoGenericPager); |
| | | } |
| | | |
| | | /** |
| | | * 部门物品使用记录 |
| | | * |
| | | * @param procureModelInfoDto |
| | | * @return |
| | | */ |
| | | @PostMapping("/useInfo/update") |
| | | public ResponseValue infoUpdate(@RequestBody List<ProcureModelInfoDto> procureModelInfoDto) { |
| | | |
| | | S_user_core currentUser = this.getCurrentUser(); |
| | | if (currentUser == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | if (CollectionUtils.isEmpty(procureModelInfoDto)) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | |
| | | for (ProcureModelInfoDto procureModelInfo : procureModelInfoDto) { |
| | | |
| | | String transferOrderId = procureModelInfo.getTransferOrderId(); |
| | | String baseGoodModelId = procureModelInfo.getBaseGoodModelId(); |
| | | |
| | | 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()); |
| | | |
| | | 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); |
| | | }); |
| | | } |
| | | return ResponseValue.success(); |
| | | } |
| | | |
| | | /** |
| | | * 部门物品使用记录 |
| | | * |
| | | * @param transferOrderId |
| | | * @return |
| | | */ |
| | | @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); |
| | | |
| | | } |
| | | 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(); |
| | | return ResponseValue.success(transferInfoVO); |
| | | } |
| | | } |