| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.enums.OrderWorkType; |
| | | 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.manager.controller.params.AsnOrderAndItemsParams; |
| | | import com.vincent.rsf.server.manager.controller.params.BatchUpdateParam; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrder; |
| | | import com.vincent.rsf.server.manager.entity.Matnr; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderItem; |
| | | import com.vincent.rsf.server.manager.entity.excel.AsnOrderTemplate; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderService; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.mail.Multipart; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:list')") |
| | | @PostMapping("/asnOrder/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AsnOrder, BaseParam> pageParam = new PageParam<>(baseParam, AsnOrder.class); |
| | | return R.ok().add(asnOrderService.page(pageParam, pageParam.buildWrapper(true))); |
| | | QueryWrapper<AsnOrder> queryWrapper = pageParam.buildWrapper(true); |
| | | List<String> asList = Arrays.asList(OrderType.ORDER_OUT.type); |
| | | queryWrapper.notIn("type", asList); |
| | | return R.ok().add(asnOrderService.page(pageParam, queryWrapper)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:list')") |
| | |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:remove')") |
| | | @OperationLog("Delete ASN单据") |
| | | @PostMapping("/asnOrder/remove/{ids}") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!asnOrderService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | if (!asnOrderService.remove(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, Arrays.asList(ids)).eq(AsnOrder::getExceStatus, AsnExceStatus.ASN_EXCE_STATUS_UN_EXCE.val))) { |
| | | return R.error("任务中单据不可删除!!"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | for (Long id : ids) { |
| | | List<AsnOrderItem> list = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, id)); |
| | | if (!list.isEmpty()) { |
| | | if (!asnOrderItemService.remove(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getAsnId, ids))) { |
| | | throw new CoolException("Details Delete Fail"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok("删除成功!!").add(ids); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:list')") |
| | |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | List<AsnOrder> orders = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | orders = asnOrderService.list(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, map.get("ids")).eq(AsnOrder::getStatus, 1)); |
| | | List<Long> ids = JSONArray.parseArray(JSONObject.toJSONString(map.get("ids")), Long.class); |
| | | if (!ids.isEmpty()) { |
| | | orders = asnOrderService.list(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, ids)); |
| | | } else { |
| | | orders = asnOrderService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | } else { |
| | | orders = asnOrderService.list(new LambdaQueryWrapper<AsnOrder>().last("limit 1")); |
| | | orders = asnOrderService.list(); |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(orders, AsnOrder.class), response); |
| | | List<AsnOrderTemplate> orderTemplates = new ArrayList<>(); |
| | | for (AsnOrder order : orders) { |
| | | List<AsnOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().eq(AsnOrderItem::getAsnId, order.getId())); |
| | | for (AsnOrderItem item : orderItems) { |
| | | if (Objects.isNull(item)) { |
| | | continue; |
| | | } |
| | | AsnOrderTemplate template = new AsnOrderTemplate(); |
| | | template.setCode(order.getCode()) |
| | | .setType(OrderType.getValType(order.getType())) |
| | | .setWkType(OrderWorkType.getWorkDesc(order.getWkType())) |
| | | .setAnfme(item.getAnfme() + "") |
| | | .setMaktx(item.getMaktx()) |
| | | .setMemo(item.getMemo()) |
| | | .setMatnrCode(item.getMatnrCode()) |
| | | .setPoCode(item.getPoCode()) |
| | | .setSplrName(item.getSplrName()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setSplrBatch(item.getSplrBatch()) |
| | | .setSplrCode(item.getSplrCode()); |
| | | orderTemplates.add(template); |
| | | } |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(orderTemplates, AsnOrderTemplate.class), response); |
| | | } |
| | | |
| | | /** |
| | | * 质检上报 |
| | | * |
| | | * @param orders |
| | | * @return |
| | | */ |
| | |
| | | @PostMapping("/asnOrder/matnr/list") |
| | | @ApiOperation("物料获取订单") |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:list')") |
| | | public R getListByMatnr(@RequestBody Map<String, String> params){ |
| | | public R getListByMatnr(@RequestBody Map<String, String> params) { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("查询条件不能为空!!"); |
| | | } |
| | |
| | | @PreAuthorize("hasAuthority('manager:asnOrder:save')") |
| | | public R orderAndItem(@RequestBody AsnOrderAndItemsParams params) throws Exception { |
| | | if (Objects.isNull(params)) { |
| | | return R.error("参数不能为空!!"); |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return asnOrderService.saveOrderAndItems(params, getLoginUserId()); |
| | | } |