| | |
| | | import com.vincent.rsf.server.common.domain.KeyValVo; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.controller.params.AsnOrderAndItemsParams; |
| | | import com.vincent.rsf.server.manager.entity.WkOrder; |
| | | import com.vincent.rsf.server.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.service.CheckOrderService; |
| | | 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 org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | @PostMapping("/check/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AsnOrder, BaseParam> pageParam = new PageParam<>(baseParam, AsnOrder.class); |
| | | QueryWrapper<AsnOrder> wrapper = pageParam.buildWrapper(true); |
| | | PageParam<WkOrder, BaseParam> pageParam = new PageParam<>(baseParam, WkOrder.class); |
| | | QueryWrapper<WkOrder> wrapper = pageParam.buildWrapper(true); |
| | | wrapper.eq("type", OrderType.ORDER_CHECK.type); |
| | | return R.ok().add(checkOrderService.page(pageParam, wrapper)); |
| | | } |
| | |
| | | @PreAuthorize("hasAuthority('manager:check:save')") |
| | | @OperationLog("Create 字典数据集") |
| | | @PostMapping("/check/save") |
| | | public R save(@RequestBody AsnOrder order) { |
| | | public R save(@RequestBody WkOrder order) { |
| | | order.setType(OrderType.ORDER_CHECK.type); |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_CHECK_RULE_CODE, order); |
| | | if (Objects.isNull(ruleCode)) { |
| | |
| | | @PreAuthorize("hasAuthority('manager:check:update')") |
| | | @OperationLog("Update 字典数据集") |
| | | @PostMapping("/check/update") |
| | | public R update(@RequestBody AsnOrder order) { |
| | | public R update(@RequestBody WkOrder order) { |
| | | order.setUpdateTime(null); |
| | | order.setUpdateBy(getLoginUserId()); |
| | | if (!checkOrderService.updateById(order)) { |
| | |
| | | @PostMapping("/check/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<AsnOrder> wrapper = new LambdaQueryWrapper<>(); |
| | | LambdaQueryWrapper<WkOrder> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(AsnOrder::getCode, condition); |
| | | wrapper.like(WkOrder::getCode, condition); |
| | | } |
| | | checkOrderService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getCode())) |
| | |
| | | @PreAuthorize("hasAuthority('manager:check:list')") |
| | | @PostMapping("/check/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | List<AsnOrder> orders = new ArrayList<>(); |
| | | List<WkOrder> orders = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | orders = checkOrderService.list(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, map.get("ids"))); |
| | | orders = checkOrderService.list(new LambdaQueryWrapper<WkOrder>().in(WkOrder::getId, map.get("ids"))); |
| | | } else { |
| | | orders = checkOrderService.list(); |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(orders, AsnOrder.class), response); |
| | | ExcelUtil.build(ExcelUtil.create(orders, WkOrder.class), response); |
| | | } |
| | | |
| | | @PostMapping("/check/items/save") |
| | | @ApiOperation("保存主单及明细") |
| | | @PreAuthorize("hasAuthority('manager:check:save')") |
| | | public R saveOutStock(@RequestBody AsnOrderAndItemsParams params) throws Exception { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return checkOrderService.saveCheckOrder(params, getLoginUserId()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 盘点单导入 |
| | | * @param file |
| | | * @return |
| | | */ |
| | | @PostMapping("/check/import") |
| | | @ApiOperation("ASN导入接口") |
| | | @PreAuthorize("hasAuthority('manager:check:update')") |
| | | public R importExcel(@RequestParam(value = "file") MultipartFile file) throws Exception { |
| | | if (Objects.isNull(file)) { |
| | | return R.error("文件不能为空!!"); |
| | | } |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | return checkOrderService.excelImport(file, hashMap, getLoginUserId()); |
| | | } |
| | | |
| | | |
| | | } |