|
|
@@ -18,10 +18,9 @@ package org.springblade.salesPart.produce.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
@@ -30,17 +29,19 @@ import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.salesPart.produce.entity.ProductWorkmanship;
|
|
|
-import org.springblade.salesPart.produce.entity.ProductWorkmanshipItems;
|
|
|
-import org.springblade.salesPart.produce.service.IProductWorkmanshipItemsService;
|
|
|
-import org.springblade.salesPart.produce.service.IProductWorkmanshipService;
|
|
|
-import org.springblade.salesPart.produce.vo.ProductWorkmanshipVO;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.salesPart.entity.PjShip;
|
|
|
+import org.springblade.salesPart.entity.PjShipItems;
|
|
|
import org.springblade.salesPart.ship.service.IShipItemsService;
|
|
|
import org.springblade.salesPart.ship.service.IShipService;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -55,45 +56,86 @@ import java.util.stream.Collectors;
|
|
|
@Api(value = "生成订单", tags = "生成订单接口")
|
|
|
public class ProductionOrderController extends BladeController {
|
|
|
|
|
|
- private final IProductWorkmanshipService productWorkmanshipService;
|
|
|
-
|
|
|
- private final IProductWorkmanshipItemsService productWorkmanshipItemsService;
|
|
|
-
|
|
|
private final IShipService shipService;
|
|
|
|
|
|
private final IShipItemsService shipItemsService;
|
|
|
|
|
|
+ private final IUserClient userClient;
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
- @GetMapping("/detail")
|
|
|
- public R<ProductWorkmanship> detail(ProductWorkmanship productWorkmanship) {
|
|
|
- ProductWorkmanship detail = productWorkmanshipService.detail(productWorkmanship);
|
|
|
+ @GetMapping("/detailProduction")
|
|
|
+ public R<PjShip> detailProduction(PjShip ship) {
|
|
|
+ PjShip detail = shipService.detailProduction(ship);
|
|
|
return R.data(detail);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分页 生成订单
|
|
|
*/
|
|
|
- @GetMapping("/list")
|
|
|
- public R<IPage<ProductWorkmanship>> list(ProductWorkmanship productWorkmanship, Query query) {
|
|
|
- LambdaQueryWrapper<ProductWorkmanship> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(ProductWorkmanship::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ProductWorkmanship::getIsDeleted, 0)
|
|
|
- .like(ObjectUtils.isNotNull(productWorkmanship.getGoodsName()), ProductWorkmanship::getGoodsName, productWorkmanship.getGoodsName())
|
|
|
- .orderByDesc(ProductWorkmanship::getCreateTime);
|
|
|
- IPage<ProductWorkmanship> pages = productWorkmanshipService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
- if (!pages.getRecords().isEmpty()) {
|
|
|
- List<Long> ids = pages.getRecords().stream().map(ProductWorkmanship::getId).collect(Collectors.toList());
|
|
|
- List<ProductWorkmanshipItems> attributeItemsList = productWorkmanshipItemsService.list(new LambdaQueryWrapper<ProductWorkmanshipItems>()
|
|
|
- .eq(ProductWorkmanshipItems::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ProductWorkmanshipItems::getIsDeleted, 0)
|
|
|
- .in(ProductWorkmanshipItems::getPid, ids));
|
|
|
- for (ProductWorkmanship item : pages.getRecords()) {
|
|
|
- if (!attributeItemsList.isEmpty()) {
|
|
|
- item.setCount(attributeItemsList.stream().filter(e -> e.getPid().equals(item.getId())).count());
|
|
|
- } else {
|
|
|
- item.setCount(0L);
|
|
|
+ @GetMapping("/listProduction")
|
|
|
+ public R<IPage<PjShip>> listProduction(PjShip ship, Query query) {
|
|
|
+ LambdaQueryWrapper<PjShip> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.select(PjShip::getId, PjShip::getBillno, PjShip::getOrdNo, PjShip::getBizTypeName,
|
|
|
+ PjShip::getCustomerName, PjShip::getStorageName, PjShip::getStockClerkName, PjShip::getStockClerkId,
|
|
|
+ PjShip::getSendTotalNum, PjShip::getGoodsTotalNum, PjShip::getStatusName, PjShip::getBusinesDate,
|
|
|
+ PjShip::getCreateUser, PjShip::getContacts, PjShip::getRemarks, PjShip::getBusinesDate, PjShip::getGoodsName,
|
|
|
+ PjShip::getCompletedDate)
|
|
|
+ .eq(PjShip::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjShip::getIsDeleted, 0)
|
|
|
+ .like(ObjectUtil.isNotEmpty(ship.getOrdNo()), PjShip::getOrdNo, ship.getOrdNo())
|
|
|
+ .like(ObjectUtil.isNotEmpty(ship.getBillno()), PjShip::getBillno, ship.getBillno())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getStorageId()), PjShip::getStorageId, ship.getStorageId())
|
|
|
+ .like(ObjectUtil.isNotEmpty(ship.getStorageName()), PjShip::getStorageName, ship.getStorageName())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getGoodsId()), PjShip::getGoodsId, ship.getGoodsId())
|
|
|
+ .like(ObjectUtil.isNotEmpty(ship.getGoodsName()), PjShip::getGoodsName, ship.getGoodsName())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getCustomerId()), PjShip::getCustomerId, ship.getCustomerId())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getStatusName()), PjShip::getStatusName, ship.getStatusName())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getStockClerkName()), PjShip::getStockClerkName, ship.getStockClerkName())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getStockClerkId()), PjShip::getStockClerkId, ship.getStockClerkId())
|
|
|
+ .eq(ObjectUtil.isNotEmpty(ship.getBsType()), PjShip::getBsType, ship.getBsType())
|
|
|
+ .like(ObjectUtil.isNotEmpty(ship.getCustomerName()), PjShip::getCustomerName, ship.getCustomerName())
|
|
|
+ //单据类型
|
|
|
+ .apply(ObjectUtil.isNotEmpty(ship.getBizTypeName()), "find_in_set(biz_type_name,'" + ship.getBizTypeName() + "')");
|
|
|
+
|
|
|
+ if (ship.getBusinesDateList() != null && ship.getBusinesDateList().size() > 1) {
|
|
|
+ lambdaQueryWrapper.ge(PjShip::getBusinesDate, ship.getBusinesDateList().get(0));
|
|
|
+ lambdaQueryWrapper.le(PjShip::getBusinesDate, ship.getBusinesDateList().get(1));
|
|
|
+ }
|
|
|
+ if (ship.getCompletedDateList() != null && ship.getCompletedDateList().size() > 1) {
|
|
|
+ lambdaQueryWrapper.ge(PjShip::getCompletedDate, ship.getCompletedDateList().get(0));
|
|
|
+ lambdaQueryWrapper.le(PjShip::getCompletedDate, ship.getCompletedDateList().get(1));
|
|
|
+ }
|
|
|
+ lambdaQueryWrapper.orderByDesc(PjShip::getCreateTime);
|
|
|
+ if (!AuthUtil.getUserRole().contains("admin") && !AuthUtil.getUserRole().contains("老板")) {
|
|
|
+ if (AuthUtil.getUserRole().contains("库管")) {
|
|
|
+ lambdaQueryWrapper.and(i -> i.eq(PjShip::getStockClerkId, AuthUtil.getUserId()).or().isNull(PjShip::getStockClerkId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ IPage<PjShip> pages = shipService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(pages.getRecords())) {
|
|
|
+ List<Long> createUser = pages.getRecords().stream().map(PjShip::getCreateUser).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ StringBuilder user = new StringBuilder();
|
|
|
+ List<User> userList = new ArrayList<>();
|
|
|
+ for (Long item : createUser) {
|
|
|
+ user.append(item).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(user.toString())) {
|
|
|
+ userList = userClient.selectUserList(user.substring(0, user.length() - 1));
|
|
|
+ }
|
|
|
+ List<Long> ids = pages.getRecords().stream().map(PjShip::getId).collect(Collectors.toList());
|
|
|
+ List<PjShipItems> pjOrderItemsList = shipItemsService.list(new LambdaQueryWrapper<PjShipItems>().eq(PjShipItems::getIsDeleted, 0)
|
|
|
+ .in(PjShipItems::getPid, ids));
|
|
|
+ for (PjShip item : pages.getRecords()) {
|
|
|
+ if (ObjectUtil.isNotEmpty(userList)) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getCreateUser())) {
|
|
|
+ userList.stream().filter(e -> e.getId().equals(item.getCreateUser()))
|
|
|
+ .findFirst().ifPresent(users -> item.setCreateUserName(users.getRealName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!pjOrderItemsList.isEmpty()) {
|
|
|
+ item.setItem(pjOrderItemsList.stream().filter(e -> e.getPid().equals(item.getId())).count() + "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -103,18 +145,34 @@ public class ProductionOrderController extends BladeController {
|
|
|
/**
|
|
|
* 新增或修改 生成订单
|
|
|
*/
|
|
|
- @PostMapping("/submit")
|
|
|
- public R submit(@Valid @RequestBody ProductWorkmanship productWorkmanship) {
|
|
|
- return productWorkmanshipService.submit(productWorkmanship);
|
|
|
+ @PostMapping("/submitProduction")
|
|
|
+ public R submitProduction(@Valid @RequestBody PjShip ship) {
|
|
|
+ return shipService.submitProduction(ship);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 删除 生成订单
|
|
|
*/
|
|
|
- @PostMapping("/remove")
|
|
|
+ @PostMapping("/removeProduction")
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- return R.status(productWorkmanshipService.removeByIds(Func.toLongList(ids)));
|
|
|
+ return R.status(shipService.removeByIds(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 完工
|
|
|
+ */
|
|
|
+ @PostMapping("/completed")
|
|
|
+ public R completed(@Valid @RequestBody PjShip ship) {
|
|
|
+ return shipService.completed(ship);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 撤销完工
|
|
|
+ */
|
|
|
+ @PostMapping("/revokeCompleted")
|
|
|
+ public R revokeCompleted(@Valid @RequestBody PjShip ship) {
|
|
|
+ return shipService.revokeCompleted(ship);
|
|
|
}
|
|
|
|
|
|
|