销售发货,产品调整
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.gear.oa.controller;
|
||||
|
||||
import com.gear.common.annotation.Log;
|
||||
import com.gear.common.annotation.RepeatSubmit;
|
||||
import com.gear.common.core.controller.BaseController;
|
||||
import com.gear.common.core.domain.PageQuery;
|
||||
import com.gear.common.core.domain.R;
|
||||
import com.gear.common.core.page.TableDataInfo;
|
||||
import com.gear.common.core.validate.AddGroup;
|
||||
import com.gear.common.core.validate.EditGroup;
|
||||
import com.gear.common.enums.BusinessType;
|
||||
import com.gear.oa.domain.bo.GearShippingOrderDetailBo;
|
||||
import com.gear.oa.domain.vo.GearShippingOrderDetailVo;
|
||||
import com.gear.oa.service.IGearShippingOrderDetailService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/oa/shippingOrderDetail")
|
||||
public class GearShippingOrderDetailController extends BaseController {
|
||||
|
||||
private final IGearShippingOrderDetailService iGearShippingOrderDetailService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<GearShippingOrderDetailVo> list(GearShippingOrderDetailBo bo, PageQuery pageQuery) {
|
||||
return iGearShippingOrderDetailService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
@GetMapping("/{detailId}")
|
||||
public R<GearShippingOrderDetailVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long detailId) {
|
||||
return R.ok(iGearShippingOrderDetailService.queryById(detailId));
|
||||
}
|
||||
|
||||
@Log(title = "发货单据明细", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody GearShippingOrderDetailBo bo) {
|
||||
return toAjax(iGearShippingOrderDetailService.insertByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "发货单据明细", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody GearShippingOrderDetailBo bo) {
|
||||
return toAjax(iGearShippingOrderDetailService.updateByBo(bo));
|
||||
}
|
||||
|
||||
@Log(title = "发货单据明细", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{detailIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] detailIds) {
|
||||
return toAjax(iGearShippingOrderDetailService.deleteWithValidByIds(Arrays.asList(detailIds), true));
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import com.gear.common.core.page.TableDataInfo;
|
||||
import com.gear.common.core.validate.AddGroup;
|
||||
import com.gear.common.core.validate.EditGroup;
|
||||
import com.gear.common.enums.BusinessType;
|
||||
import com.gear.common.exception.ServiceException;
|
||||
import com.gear.common.utils.StringUtils;
|
||||
import com.gear.common.utils.poi.ExcelUtil;
|
||||
import com.gear.oa.domain.bo.GearStockIoOrderBo;
|
||||
import com.gear.oa.domain.bo.GearStockIoOrderWithDetailBo;
|
||||
@@ -54,23 +56,39 @@ public class GearStockIoOrderController extends BaseController {
|
||||
}
|
||||
|
||||
@GetMapping("/materialFlow")
|
||||
public R<IGearStockIoOrderService.MaterialFlowResp> materialFlow(@NotNull(message = "物料ID不能为空") @RequestParam Long itemId,
|
||||
public R<IGearStockIoOrderService.MaterialFlowResp> materialFlow(@RequestParam(required = false) Long itemId,
|
||||
@RequestParam(required = false) String factory,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
return R.ok(stockIoOrderService.queryMaterialFlow(itemId, startTime, endTime));
|
||||
if (itemId != null) {
|
||||
return R.ok(stockIoOrderService.queryMaterialFlow(itemId, startTime, endTime));
|
||||
}
|
||||
if (StringUtils.isBlank(factory)) {
|
||||
return R.fail("请选择物料或填写厂家");
|
||||
}
|
||||
return R.ok(stockIoOrderService.queryMaterialFlowByFactory(factory, startTime, endTime));
|
||||
}
|
||||
|
||||
@Log(title = "物料出入库统计", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/materialFlow/export")
|
||||
public void exportMaterialFlow(@NotNull(message = "物料ID不能为空") @RequestParam Long itemId,
|
||||
public void exportMaterialFlow(@RequestParam(required = false) Long itemId,
|
||||
@RequestParam(required = false) String factory,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime,
|
||||
HttpServletResponse response) {
|
||||
IGearStockIoOrderService.MaterialFlowResp resp = stockIoOrderService.queryMaterialFlow(itemId, startTime, endTime);
|
||||
IGearStockIoOrderService.MaterialFlowResp resp;
|
||||
if (itemId != null) {
|
||||
resp = stockIoOrderService.queryMaterialFlow(itemId, startTime, endTime);
|
||||
} else if (StringUtils.isNotBlank(factory)) {
|
||||
resp = stockIoOrderService.queryMaterialFlowByFactory(factory, startTime, endTime);
|
||||
} else {
|
||||
throw new ServiceException("请选择物料或填写厂家");
|
||||
}
|
||||
List<MaterialFlowExportRow> exportRows = new ArrayList<>();
|
||||
|
||||
MaterialFlowExportRow summary = new MaterialFlowExportRow();
|
||||
summary.setItemId(resp.getItemId());
|
||||
summary.setFactory(factory);
|
||||
summary.setStartTime(resp.getStartTime());
|
||||
summary.setEndTime(resp.getEndTime());
|
||||
summary.setAction("汇总");
|
||||
@@ -85,6 +103,7 @@ public class GearStockIoOrderController extends BaseController {
|
||||
for (IGearStockIoOrderService.MaterialFlowRow r : resp.getRows()) {
|
||||
MaterialFlowExportRow row = new MaterialFlowExportRow();
|
||||
row.setItemId(resp.getItemId());
|
||||
row.setFactory(factory);
|
||||
row.setTime(r.getTime());
|
||||
row.setAction(r.getAction());
|
||||
row.setOrderCode(r.getOrderCode());
|
||||
@@ -105,6 +124,8 @@ public class GearStockIoOrderController extends BaseController {
|
||||
public static class MaterialFlowExportRow {
|
||||
@ExcelProperty(value = "物料ID")
|
||||
private Long itemId;
|
||||
@ExcelProperty(value = "厂家")
|
||||
private String factory;
|
||||
@ExcelProperty(value = "开始时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@@ -144,6 +165,14 @@ public class GearStockIoOrderController extends BaseController {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public String getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public void setFactory(String factory) {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@@ -62,4 +62,8 @@ public class GearOrderDetail extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal noTaxPrice;
|
||||
|
||||
private String spec;
|
||||
|
||||
private String model;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.gear.oa.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.gear.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("gear_shipping_order_detail")
|
||||
public class GearShippingOrderDetail extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "detail_id")
|
||||
private Long detailId;
|
||||
|
||||
private Long shippingId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private String productCode;
|
||||
|
||||
private String productName;
|
||||
|
||||
private String spec;
|
||||
|
||||
private String model;
|
||||
|
||||
private BigDecimal quantity;
|
||||
|
||||
private String unit;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
@TableLogic(value = "0", delval = "2")
|
||||
private String delFlag;
|
||||
}
|
||||
@@ -63,5 +63,9 @@ public class GearOrderDetailBo extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal noTaxPrice;
|
||||
|
||||
private String spec;
|
||||
|
||||
private String model;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public class GearReceivableBo extends BaseEntity {
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
private Long salesmanId;
|
||||
|
||||
/**
|
||||
* 到期日
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gear.oa.domain.bo;
|
||||
|
||||
import com.gear.common.core.domain.BaseEntity;
|
||||
import com.gear.common.core.validate.AddGroup;
|
||||
import com.gear.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class GearShippingOrderDetailBo extends BaseEntity {
|
||||
|
||||
private Long detailId;
|
||||
|
||||
@NotNull(message = "发货单据ID不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long shippingId;
|
||||
|
||||
@NotNull(message = "产品ID不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long productId;
|
||||
|
||||
private String productCode;
|
||||
|
||||
private String productName;
|
||||
|
||||
private String spec;
|
||||
|
||||
private String model;
|
||||
|
||||
@NotNull(message = "数量不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private BigDecimal quantity;
|
||||
|
||||
private String unit;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gear.oa.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.gear.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class GearShippingOrderDetailVo extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long detailId;
|
||||
|
||||
private Long shippingId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private String productCode;
|
||||
|
||||
private String productName;
|
||||
|
||||
private String spec;
|
||||
|
||||
private String model;
|
||||
|
||||
private BigDecimal quantity;
|
||||
|
||||
private String unit;
|
||||
|
||||
private String remark;
|
||||
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gear.oa.mapper;
|
||||
|
||||
import com.gear.common.core.mapper.BaseMapperPlus;
|
||||
import com.gear.oa.domain.GearShippingOrderDetail;
|
||||
import com.gear.oa.domain.vo.GearShippingOrderDetailVo;
|
||||
|
||||
public interface GearShippingOrderDetailMapper extends BaseMapperPlus<GearShippingOrderDetailMapper, GearShippingOrderDetail, GearShippingOrderDetailVo> {
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface MatMaterialSimpleMapper {
|
||||
@@ -13,7 +14,9 @@ public interface MatMaterialSimpleMapper {
|
||||
"from mat_material where material_id = #{materialId} and del_flag = 0 limit 1")
|
||||
Map<String, Object> selectSnapshot(@Param("materialId") Long materialId);
|
||||
|
||||
@Select("select material_id from mat_material where del_flag = 0 and factory like concat('%', #{factory}, '%')")
|
||||
List<Long> selectIdsByFactory(@Param("factory") String factory);
|
||||
|
||||
@Update("update mat_material set current_stock = ifnull(current_stock, 0) + #{delta} where material_id = #{materialId} and del_flag = 0")
|
||||
int updateStockDelta(@Param("materialId") Long materialId, @Param("delta") BigDecimal delta);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gear.oa.service;
|
||||
|
||||
import com.gear.common.core.domain.PageQuery;
|
||||
import com.gear.common.core.page.TableDataInfo;
|
||||
import com.gear.oa.domain.bo.GearShippingOrderDetailBo;
|
||||
import com.gear.oa.domain.vo.GearShippingOrderDetailVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface IGearShippingOrderDetailService {
|
||||
|
||||
GearShippingOrderDetailVo queryById(Long detailId);
|
||||
|
||||
TableDataInfo<GearShippingOrderDetailVo> queryPageList(GearShippingOrderDetailBo bo, PageQuery pageQuery);
|
||||
|
||||
List<GearShippingOrderDetailVo> queryList(GearShippingOrderDetailBo bo);
|
||||
|
||||
Boolean insertByBo(GearShippingOrderDetailBo bo);
|
||||
|
||||
Boolean updateByBo(GearShippingOrderDetailBo bo);
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -35,6 +35,8 @@ public interface IGearStockIoOrderService {
|
||||
|
||||
MaterialFlowResp queryMaterialFlow(Long itemId, Date startTime, Date endTime);
|
||||
|
||||
MaterialFlowResp queryMaterialFlowByFactory(String factory, Date startTime, Date endTime);
|
||||
|
||||
@lombok.Data
|
||||
class MaterialFlowResp {
|
||||
private Long itemId;
|
||||
|
||||
@@ -13,9 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.gear.oa.domain.bo.GearOrderBo;
|
||||
import com.gear.oa.domain.vo.GearOrderVo;
|
||||
import com.gear.oa.domain.GearOrder;
|
||||
import com.gear.oa.domain.GearShippingOrder;
|
||||
import com.gear.oa.mapper.GearOrderMapper;
|
||||
import com.gear.oa.mapper.GearShippingOrderMapper;
|
||||
import com.gear.oa.service.IGearOrderService;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,51 +31,13 @@ import java.util.Collection;
|
||||
public class GearOrderServiceImpl implements IGearOrderService {
|
||||
|
||||
private final GearOrderMapper baseMapper;
|
||||
private final GearShippingOrderMapper shippingOrderMapper;
|
||||
|
||||
/**
|
||||
* 查询订单主
|
||||
*/
|
||||
@Override
|
||||
public GearOrderVo queryById(Long orderId){
|
||||
GearOrderVo vo = baseMapper.selectVoById(orderId);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
Integer derived = deriveOrderStatusByShipping(orderId, vo.getOrderStatus());
|
||||
if (derived != null && vo.getOrderStatus() != null && !derived.equals(vo.getOrderStatus())) {
|
||||
baseMapper.update(null, Wrappers.<GearOrder>lambdaUpdate()
|
||||
.eq(GearOrder::getOrderId, orderId)
|
||||
.ne(GearOrder::getOrderStatus, 3)
|
||||
.in(GearOrder::getOrderStatus, 0, 1)
|
||||
.set(GearOrder::getOrderStatus, derived));
|
||||
vo.setOrderStatus(derived);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
private Integer deriveOrderStatusByShipping(Long orderId, Integer currentStatus) {
|
||||
if (orderId == null) return currentStatus;
|
||||
if (currentStatus != null && currentStatus == 3) return 3;
|
||||
|
||||
QueryWrapper<GearShippingOrder> qw = new QueryWrapper<>();
|
||||
qw.select("MAX(CAST(status AS SIGNED))");
|
||||
qw.eq("order_id", orderId);
|
||||
qw.eq("del_flag", "0");
|
||||
List<Object> objs = shippingOrderMapper.selectObjs(qw);
|
||||
Integer maxStatus = null;
|
||||
if (objs != null && !objs.isEmpty() && objs.get(0) != null) {
|
||||
try {
|
||||
maxStatus = Integer.parseInt(String.valueOf(objs.get(0)));
|
||||
} catch (Exception ignored) {
|
||||
maxStatus = null;
|
||||
}
|
||||
}
|
||||
|
||||
int st = currentStatus == null ? 0 : currentStatus;
|
||||
if (maxStatus != null && maxStatus >= 3 && (st == 0 || st == 1)) return 2;
|
||||
if (maxStatus != null && maxStatus >= 2 && st == 0) return 1;
|
||||
return currentStatus;
|
||||
return baseMapper.selectVoById(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,8 +58,6 @@ public class GearOrderServiceImpl implements IGearOrderService {
|
||||
lqw.eq(bo.getSalesmanId() != null, "o.salesman_id", bo.getSalesmanId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getSalesManager()), "s.name", bo.getSalesManager());
|
||||
lqw.eq(bo.getOrderStatus() != null, "o.order_status", bo.getOrderStatus());
|
||||
lqw.apply(bo.getOrderStatus() != null && bo.getOrderStatus() == 0,
|
||||
"NOT EXISTS (SELECT 1 FROM gear_shipping_order so WHERE so.order_id = o.order_id AND so.del_flag = '0' AND CAST(so.status AS SIGNED) >= 2)");
|
||||
lqw.eq(bo.getTradeType() != null, "o.trade_type", bo.getTradeType());
|
||||
lqw.eq(bo.getTaxAmount() != null, "o.tax_amount", bo.getTaxAmount());
|
||||
lqw.eq(bo.getNoTaxAmount() != null, "o.no_tax_amount", bo.getNoTaxAmount());
|
||||
|
||||
@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.gear.oa.domain.GearJournal;
|
||||
import com.gear.oa.domain.GearOrder;
|
||||
import com.gear.oa.mapper.GearCustomerMapper;
|
||||
import com.gear.oa.mapper.GearJournalMapper;
|
||||
import com.gear.oa.mapper.GearOrderMapper;
|
||||
import com.gear.oa.service.IGearJournalService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -24,9 +26,11 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 应收款管理(宽松版)Service业务层处理
|
||||
@@ -39,6 +43,7 @@ import java.util.Collection;
|
||||
public class GearReceivableServiceImpl implements IGearReceivableService {
|
||||
|
||||
private final GearReceivableMapper baseMapper;
|
||||
private final GearOrderMapper orderMapper;
|
||||
@Resource
|
||||
private GearJournalMapper journalMapper;
|
||||
@Resource
|
||||
@@ -67,7 +72,16 @@ public class GearReceivableServiceImpl implements IGearReceivableService {
|
||||
QueryWrapper<GearReceivable> lqw = Wrappers.query();
|
||||
lqw.eq("r.del_flag", 0);
|
||||
lqw.eq(bo.getCustomerId() != null, "r.customer_id", bo.getCustomerId());
|
||||
lqw.eq(bo.getOrderId() != null, "r.order_id", bo.getOrderId());
|
||||
if (bo.getOrderId() != null) {
|
||||
lqw.eq("r.order_id", bo.getOrderId());
|
||||
} else if (bo.getSalesmanId() != null) {
|
||||
List<Long> orderIds = queryOrderIdsBySalesman(bo.getSalesmanId());
|
||||
if (orderIds.isEmpty()) {
|
||||
lqw.eq("r.receivable_id", -1L);
|
||||
} else {
|
||||
lqw.in("r.order_id", orderIds);
|
||||
}
|
||||
}
|
||||
lqw.eq(bo.getDueDate() != null, "r.due_date", bo.getDueDate());
|
||||
lqw.eq(bo.getAmount() != null, "r.amount", bo.getAmount());
|
||||
lqw.eq(bo.getPaidAmount() != null, "r.paid_amount", bo.getPaidAmount());
|
||||
@@ -77,6 +91,19 @@ public class GearReceivableServiceImpl implements IGearReceivableService {
|
||||
lqw.between(bo.getStartTime() != null && bo.getEndTime() != null, "r.create_time", bo.getStartTime(), bo.getEndTime());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
private List<Long> queryOrderIdsBySalesman(Long salesmanId) {
|
||||
if (salesmanId == null) return Collections.emptyList();
|
||||
LambdaQueryWrapper<GearOrder> lqw = Wrappers.lambdaQuery();
|
||||
lqw.select(GearOrder::getOrderId);
|
||||
lqw.eq(GearOrder::getSalesmanId, salesmanId);
|
||||
lqw.eq(GearOrder::getDelFlag, 0);
|
||||
List<GearOrder> list = orderMapper.selectList(lqw);
|
||||
if (list == null || list.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return list.stream().map(GearOrder::getOrderId).filter(id -> id != null).distinct().collect(Collectors.toList());
|
||||
}
|
||||
/**
|
||||
* 查询应收款管理(宽松版)列表
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.gear.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gear.common.core.domain.PageQuery;
|
||||
import com.gear.common.core.page.TableDataInfo;
|
||||
import com.gear.common.utils.StringUtils;
|
||||
import com.gear.oa.domain.GearShippingOrderDetail;
|
||||
import com.gear.oa.domain.bo.GearShippingOrderDetailBo;
|
||||
import com.gear.oa.domain.vo.GearShippingOrderDetailVo;
|
||||
import com.gear.oa.mapper.GearShippingOrderDetailMapper;
|
||||
import com.gear.oa.service.IGearShippingOrderDetailService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class GearShippingOrderDetailServiceImpl implements IGearShippingOrderDetailService {
|
||||
|
||||
private final GearShippingOrderDetailMapper baseMapper;
|
||||
|
||||
@Override
|
||||
public GearShippingOrderDetailVo queryById(Long detailId) {
|
||||
return baseMapper.selectVoById(detailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<GearShippingOrderDetailVo> queryPageList(GearShippingOrderDetailBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<GearShippingOrderDetail> lqw = buildQueryWrapper(bo);
|
||||
Page<GearShippingOrderDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GearShippingOrderDetailVo> queryList(GearShippingOrderDetailBo bo) {
|
||||
LambdaQueryWrapper<GearShippingOrderDetail> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<GearShippingOrderDetail> buildQueryWrapper(GearShippingOrderDetailBo bo) {
|
||||
LambdaQueryWrapper<GearShippingOrderDetail> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getDetailId() != null, GearShippingOrderDetail::getDetailId, bo.getDetailId());
|
||||
lqw.eq(bo.getShippingId() != null, GearShippingOrderDetail::getShippingId, bo.getShippingId());
|
||||
lqw.eq(bo.getProductId() != null, GearShippingOrderDetail::getProductId, bo.getProductId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getProductName()), GearShippingOrderDetail::getProductName, bo.getProductName());
|
||||
lqw.orderByAsc(GearShippingOrderDetail::getSort);
|
||||
lqw.orderByAsc(GearShippingOrderDetail::getCreateTime);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(GearShippingOrderDetailBo bo) {
|
||||
GearShippingOrderDetail add = BeanUtil.toBean(bo, GearShippingOrderDetail.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setDetailId(add.getDetailId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(GearShippingOrderDetailBo bo) {
|
||||
GearShippingOrderDetail update = BeanUtil.toBean(bo, GearShippingOrderDetail.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
private void validEntityBeforeSave(GearShippingOrderDetail entity) {
|
||||
boolean isInsert = entity.getDetailId() == null;
|
||||
if (entity.getDetailId() == null) {
|
||||
entity.setDetailId(IdUtil.getSnowflakeNextId());
|
||||
}
|
||||
if (isInsert) {
|
||||
if (StringUtils.isBlank(entity.getDelFlag())) {
|
||||
entity.setDelFlag("0");
|
||||
}
|
||||
if (entity.getSort() == null) {
|
||||
entity.setSort(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,6 @@ public class GearShippingOrderServiceImpl implements IGearShippingOrderService {
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setShippingId(add.getShippingId());
|
||||
syncOrderStatusIfShipped(add);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@@ -122,43 +121,9 @@ public class GearShippingOrderServiceImpl implements IGearShippingOrderService {
|
||||
GearShippingOrder update = BeanUtil.toBean(bo, GearShippingOrder.class);
|
||||
validEntityBeforeSave(update);
|
||||
boolean ok = baseMapper.updateById(update) > 0;
|
||||
if (ok) {
|
||||
syncOrderStatusIfShipped(update);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
private void syncOrderStatusIfShipped(GearShippingOrder entity) {
|
||||
if (entity == null || entity.getOrderId() == null) return;
|
||||
Integer statusNum = null;
|
||||
try {
|
||||
if (StringUtils.isNotBlank(entity.getStatus())) {
|
||||
statusNum = Integer.parseInt(entity.getStatus());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
statusNum = null;
|
||||
}
|
||||
if (statusNum == null) return;
|
||||
// 发货单据状态与订单状态联动:
|
||||
// - 发货单据 >=2(已发货):若订单仍为预订单(0),推进到进行中(1)
|
||||
// - 发货单据 >=3(已完成):若订单为预订单(0)/进行中(1),推进到已完成(2)
|
||||
// - 订单若已取消(3),不做推进
|
||||
if (statusNum >= 3) {
|
||||
orderMapper.update(null, Wrappers.<GearOrder>lambdaUpdate()
|
||||
.eq(GearOrder::getOrderId, entity.getOrderId())
|
||||
.ne(GearOrder::getOrderStatus, 3)
|
||||
.in(GearOrder::getOrderStatus, 0, 1)
|
||||
.set(GearOrder::getOrderStatus, 2));
|
||||
return;
|
||||
}
|
||||
if (statusNum >= 2) {
|
||||
orderMapper.update(null, Wrappers.<GearOrder>lambdaUpdate()
|
||||
.eq(GearOrder::getOrderId, entity.getOrderId())
|
||||
.eq(GearOrder::getOrderStatus, 0)
|
||||
.set(GearOrder::getOrderStatus, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void validEntityBeforeSave(GearShippingOrder entity) {
|
||||
boolean isInsert = entity.getShippingId() == null;
|
||||
// 发货单据ID:项目内大部分业务表使用雪花ID,这里保持一致
|
||||
|
||||
@@ -362,6 +362,32 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
|
||||
if (itemId == null) {
|
||||
throw new ServiceException("物料ID不能为空");
|
||||
}
|
||||
return queryMaterialFlowByItemIds(java.util.Collections.singletonList(itemId), itemId, startTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialFlowResp queryMaterialFlowByFactory(String factory, Date startTime, Date endTime) {
|
||||
if (StringUtils.isBlank(factory)) {
|
||||
throw new ServiceException("厂家不能为空");
|
||||
}
|
||||
List<Long> ids = matMaterialMapper.selectIdsByFactory(factory);
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
MaterialFlowResp resp = new MaterialFlowResp();
|
||||
resp.setItemId(null);
|
||||
resp.setStartTime(startTime);
|
||||
resp.setEndTime(endTime);
|
||||
resp.setConfirmInQty(BigDecimal.ZERO);
|
||||
resp.setOutQty(BigDecimal.ZERO);
|
||||
resp.setRevokeInQty(BigDecimal.ZERO);
|
||||
resp.setRevokeOutQty(BigDecimal.ZERO);
|
||||
resp.setNetQty(BigDecimal.ZERO);
|
||||
resp.setRows(new ArrayList<>());
|
||||
return resp;
|
||||
}
|
||||
return queryMaterialFlowByItemIds(ids, null, startTime, endTime);
|
||||
}
|
||||
|
||||
private MaterialFlowResp queryMaterialFlowByItemIds(List<Long> itemIds, Long singleItemId, Date startTime, Date endTime) {
|
||||
List<GearStockIoOrder> confirmOrders = baseMapper.selectList(Wrappers.<GearStockIoOrder>lambdaQuery()
|
||||
.eq(GearStockIoOrder::getIoType, "I")
|
||||
.eq(GearStockIoOrder::getConfirmInFlag, "1")
|
||||
@@ -400,7 +426,7 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
|
||||
List<GearStockIoOrderDetail> details = detailMapper.selectList(Wrappers.<GearStockIoOrderDetail>lambdaQuery()
|
||||
.in(GearStockIoOrderDetail::getOrderId, orderIds)
|
||||
.eq(GearStockIoOrderDetail::getItemType, "material")
|
||||
.eq(GearStockIoOrderDetail::getItemId, itemId)
|
||||
.in(GearStockIoOrderDetail::getItemId, itemIds)
|
||||
.eq(GearStockIoOrderDetail::getDelFlag, "0"));
|
||||
for (GearStockIoOrderDetail d : details) {
|
||||
if (d == null || d.getOrderId() == null) continue;
|
||||
@@ -468,7 +494,7 @@ public class GearStockIoOrderServiceImpl implements IGearStockIoOrderService {
|
||||
BigDecimal net = confirmInQty.subtract(outQty).add(revokeOutQty).subtract(revokeInQty);
|
||||
|
||||
MaterialFlowResp resp = new MaterialFlowResp();
|
||||
resp.setItemId(itemId);
|
||||
resp.setItemId(singleItemId);
|
||||
resp.setStartTime(startTime);
|
||||
resp.setEndTime(endTime);
|
||||
resp.setConfirmInQty(confirmInQty);
|
||||
|
||||
Reference in New Issue
Block a user