|  |  | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | import com.vincent.rsf.framework.common.Cools; | 
 |  |  | import com.vincent.rsf.framework.common.R; | 
 |  |  | import com.vincent.rsf.framework.exception.CoolException; | 
 |  |  | import com.vincent.rsf.server.common.utils.ExcelUtil; | 
 |  |  | import com.vincent.rsf.server.common.annotation.OperationLog; | 
 |  |  | import com.vincent.rsf.server.common.domain.BaseParam; | 
 |  |  | import com.vincent.rsf.server.common.domain.KeyValVo; | 
 |  |  | import com.vincent.rsf.server.common.domain.PageParam; | 
 |  |  | import com.vincent.rsf.server.manager.controller.params.AsnOrderAndItemsParams; | 
 |  |  | import com.vincent.rsf.server.manager.controller.params.OrgLocParams; | 
 |  |  | import com.vincent.rsf.server.manager.controller.params.TransferItemParams; | 
 |  |  | import com.vincent.rsf.server.manager.entity.Transfer; | 
 |  |  | import com.vincent.rsf.server.manager.entity.excel.CheckOrderTemplate; | 
 |  |  | import com.vincent.rsf.server.manager.service.OutStockService; | 
 |  |  | import com.vincent.rsf.server.manager.service.TransferService; | 
 |  |  | import com.vincent.rsf.server.system.constant.SerialRuleCode; | 
 |  |  | import com.vincent.rsf.server.system.controller.BaseController; | 
 |  |  | import com.vincent.rsf.server.system.utils.SerialRuleUtils; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiOperation; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.security.access.prepost.PreAuthorize; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  | 
 |  |  | import javax.servlet.http.HttpServletResponse; | 
 |  |  | import java.util.*; | 
 |  |  |  | 
 |  |  | @Api("调拔单") | 
 |  |  | @RestController | 
 |  |  | public class TransferController extends BaseController { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private TransferService transferService; | 
 |  |  |     @Autowired | 
 |  |  |     private OutStockService outStockService; | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:list')") | 
 |  |  |     @PostMapping("/transfer/page") | 
 |  |  | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<Transfer, BaseParam> pageParam = new PageParam<>(baseParam, Transfer.class); | 
 |  |  |         return R.ok().add(transferService.page(pageParam, pageParam.buildWrapper(true))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("获取调拔单关联订单") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:list')") | 
 |  |  |     @PostMapping("/transfer/orders/page") | 
 |  |  |     public R getTransferInfo(@RequestBody Map<String, Object> map) { | 
 |  |  |         BaseParam baseParam = buildParam(map, BaseParam.class); | 
 |  |  |         PageParam<Transfer, BaseParam> pageParam = new PageParam<>(baseParam, Transfer.class); | 
 |  |  |         return R.ok().add(transferService.transfersPage(pageParam, pageParam.buildWrapper(true))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("调拔单生成出库单") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:list')") | 
 |  |  |     @PostMapping("/transfer/pub/outStock") | 
 |  |  |     public R genOutstock(@RequestBody Transfer transfer) { | 
 |  |  |         if (Objects.isNull(transfer)) { | 
 |  |  |             throw new CoolException("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         return R.ok(transferService.genOutStock(transfer, getLoginUserId())); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:list')") | 
 |  |  | 
 |  |  |         transfer.setCreateTime(new Date()); | 
 |  |  |         transfer.setUpdateBy(getLoginUserId()); | 
 |  |  |         transfer.setUpdateTime(new Date()); | 
 |  |  |  | 
 |  |  |         if (Objects.isNull(transfer.getCode())) { | 
 |  |  |             String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TRANSFER_ORDER_CODE, transfer); | 
 |  |  |             transfer.setCode(ruleCode); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (!transferService.save(transfer)) { | 
 |  |  |             return R.error("Save Fail"); | 
 |  |  |         } | 
 |  |  | 
 |  |  |     @OperationLog("Delete 调拔单") | 
 |  |  |     @PostMapping("/transfer/remove/{ids}") | 
 |  |  |     public R remove(@PathVariable Long[] ids) { | 
 |  |  |         if (!transferService.removeByIds(Arrays.asList(ids))) { | 
 |  |  |             return R.error("Delete Fail"); | 
 |  |  |         List<Long> list = Arrays.asList(ids); | 
 |  |  |         if (list.isEmpty()) { | 
 |  |  |             return R.error("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         if (!transferService.removeTransfer(list)) { | 
 |  |  |             throw new CoolException("调拔单移除失败!!"); | 
 |  |  |         } | 
 |  |  |         return R.ok("Delete Success").add(ids); | 
 |  |  |     } | 
 |  |  | 
 |  |  |         return R.ok().add(vos); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("/transfer/items/save") | 
 |  |  |     @ApiOperation("保存主单及明细") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:save')") | 
 |  |  |     public R saveOutStock(@RequestBody TransferItemParams params) throws Exception { | 
 |  |  |         if (Objects.isNull(params)) { | 
 |  |  |             return R.error("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         return transferService.saveTransfer(params, getLoginUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @ApiOperation("单据信息修改") | 
 |  |  |     @PostMapping("/transfer/items/update") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:update')") | 
 |  |  |     public R orderAndrItemUpdate(@RequestBody TransferItemParams params) { | 
 |  |  |         if (Objects.isNull(params)) { | 
 |  |  |             return R.error("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         return transferService.updateTransfer(params, getLoginUserId()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @ApiOperation("获取原库区物料信息") | 
 |  |  |     @PostMapping("/transfer/locs/items") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:list')") | 
 |  |  |     public R locsPage(@RequestBody OrgLocParams params) { | 
 |  |  |         if (Objects.isNull(params)) { | 
 |  |  |             return R.error("参数不能为空!!"); | 
 |  |  |         } | 
 |  |  |         return R.ok().add(transferService.getLocsItems(params, getLoginUserId())); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @author Ryan | 
 |  |  |      * @description 下载模板 | 
 |  |  |      * @param | 
 |  |  |      * @return | 
 |  |  |      * @time 2025/4/18 08:17 | 
 |  |  |      */ | 
 |  |  |     @PostMapping("/transfer/template/download") | 
 |  |  |     @ApiOperation("下载盘点单模板") | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:update')") | 
 |  |  |     public void downloadTemplate(@RequestBody Map<String, Object> map, HttpServletResponse response) { | 
 |  |  |         CheckOrderTemplate template = ExcelUtil.mockData(CheckOrderTemplate.class); | 
 |  |  |         List<CheckOrderTemplate> list = Arrays.asList(template); | 
 |  |  |         ExcelUtil.build(ExcelUtil.create(list, CheckOrderTemplate.class, true), response); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PreAuthorize("hasAuthority('manager:transfer:list')") | 
 |  |  |     @PostMapping("/transfer/export") | 
 |  |  |     public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |