diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java index cd50891..3429862 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java @@ -44,10 +44,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.util.*; @Slf4j @RestController @@ -159,6 +156,18 @@ public class OrderController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } + //兼容前端多个传参方式 todo 后续统一前端删除单据传参方式 + if (CollUtil.isEmpty(deleteRequest.getIds())) { + List ids = new ArrayList<>(); + if (StrUtil.isNotBlank(deleteRequest.getOrderId())) { + ids.add(deleteRequest.getOrderId()); + } + if (StrUtil.isNotBlank(deleteRequest.getId())) { + ids.add(deleteRequest.getId()); + } + deleteRequest.setIds(ids); + } + if (CollUtil.isNotEmpty(deleteRequest.getIds())) { //全部删除 orderService.deleteOrders(deleteRequest.getIds()); diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java b/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java index 8b10823..0c3aff6 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java @@ -25,6 +25,7 @@ import com.glxp.udi.admin.service.auth.CustomerService; import com.glxp.udi.admin.service.basic.BussinessTypeService; import com.glxp.udi.admin.service.inout.*; import com.glxp.udi.admin.service.param.SystemParamCustomerConfigService; +import com.glxp.udi.admin.service.product.StackOrderService; import com.glxp.udi.admin.thread.TransInoutService; import com.glxp.udi.admin.util.*; import org.apache.commons.lang3.StringUtils; @@ -65,6 +66,8 @@ public class WareHouseController { private GennerOrderUtils gennerOrderUtils; @Resource private CustomerService customerService; + @Resource + private StackOrderService stackOrderService; @AuthRuleAnnotation("") @PostMapping("warehouse/inout/postOrders") @@ -320,6 +323,57 @@ public class WareHouseController { } } + if (code.contains("DH")) { + //扫描的是垛号,直接添加到临时码表,校验等操作后置到处理单据的流程中做 + String orderId = addOrderRequest.getOrderId(); + + //先生成扫码单据 + OrderEntity orderEntity = orderService.findById(orderId); + if (StringUtils.isBlank(orderId) || orderEntity == null) { + String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trim(bussinessType.getPrefix()), "yyyyMMdd")); + orderId = orderNo; + + OrderEntity orderSaveRequest = new OrderEntity(); + orderSaveRequest.setOrderId(orderId); + if (addOrderRequest.getActDate() != null) { + orderSaveRequest.setActDate(addOrderRequest.getActDate()); + } + + long customerId = customerService.getCustomerId(); + orderSaveRequest.setMainAction(bussinessType.getMainAction()); + orderSaveRequest.setAction(bussinessType.getAction()); + orderSaveRequest.setActor(addOrderRequest.getActor()); + orderSaveRequest.setCorpOrderId(addOrderRequest.getCorpOrderId()); + orderSaveRequest.setLocStorageCode(addOrderRequest.getLocStorageCode()); + orderSaveRequest.setFromCorpId(addOrderRequest.getFromCorpId()); + orderSaveRequest.setFromCorp(addOrderRequest.getFromCorp()); + orderSaveRequest.setFromType("网页新增"); + orderSaveRequest.setStatus(ConstantStatus.ORDER_STATUS_TEMP_SAVE); + orderSaveRequest.setExportStatus("未上传"); + orderSaveRequest.setReceiveStatus(ConstantStatus.RECEIVE_UN); + orderSaveRequest.setCustomerId(customerId); + orderService.insertOrder(orderSaveRequest); + } + + //将垛号插入临时码表 + WarehousetempEntity warehousetemp = new WarehousetempEntity(); + warehousetemp.setOrderId(orderId); + warehousetemp.setCode(code); + warehousetemp.setLocStorageCode(addOrderRequest.getLocStorageCode()); + warehousetemp.setActor(addOrderRequest.getActor()); + warehousetemp.setFromCorp(addOrderRequest.getFromCorp()); + warehousetemp.setFromCorpId(addOrderRequest.getFromCorpId()); + warehousetemp.setMainAction(bussinessType.getMainAction()); + warehousetemp.setAction(bussinessType.getAction()); + warehousetemp.setCorpOrderId(addOrderRequest.getCorpOrderId()); + warehousetemp.setCustomerId(Long.valueOf(addOrderRequest.getCustomerId())); + warehouseTempService.insertTempWarehouses(Arrays.asList(warehousetemp)); + + addCodeResult.setOrderId(orderId); + return ResultVOUtils.success(addCodeResult); + } + + UdiEntity udiEntity = FilterUdiUtils.getUdi(code); if (udiEntity == null) { return ResultVOUtils.error(500, "无效条码!"); @@ -422,7 +476,6 @@ public class WareHouseController { warehousetempEntity.setFromCorp(addOrderRequest.getFromCorp()); warehousetempEntity.setBatchNo(udiEntity.getBatchNo()); warehousetempEntity.setProduceDate(udiEntity.getProduceDate()); - warehousetempEntity.setLocStorageCode(addOrderRequest.getInvWarehouseCode()); warehousetempEntity.setNameCode(udiEntity.getNameCode()); warehousetempEntity.setExpireDate(udiEntity.getExpireDate()); warehousetempEntity.setSerialNo(udiEntity.getSerialNo()); diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java index af579e7..7f02ca5 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java @@ -59,4 +59,11 @@ public interface CodesDao extends BaseMapper { * @param orderId */ void updateActDateByOrderId(@Param("actDate") String actDate, @Param("orderId") String orderId); + + /** + * 批量插入条码数据 + * + * @param list + */ + void batchInsert(List list); } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java index 49eed38..1dec08f 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/InvProductDetailDao.java @@ -27,4 +27,11 @@ public interface InvProductDetailDao extends BaseMapper * @param orderId */ void deleteByOrderId(@Param("orderId") String orderId); + + /** + * 批量插入 + * + * @param list + */ + void batchInsert(List list); } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java index 0d4eb25..8069d18 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/OrderDetailDao.java @@ -5,6 +5,8 @@ import com.glxp.udi.admin.entity.inout.OrderDetailEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 单据详情数据接口 */ @@ -25,4 +27,11 @@ public interface OrderDetailDao extends BaseMapper { */ void update(OrderDetailEntity orderDetailEntity); + /** + * 批量插入 + * + * @param list + */ + void batchInsert(List list); + } diff --git a/src/main/java/com/glxp/udi/admin/entity/inout/OrderEntity.java b/src/main/java/com/glxp/udi/admin/entity/inout/OrderEntity.java index 614176b..b238dd0 100644 --- a/src/main/java/com/glxp/udi/admin/entity/inout/OrderEntity.java +++ b/src/main/java/com/glxp/udi/admin/entity/inout/OrderEntity.java @@ -3,6 +3,7 @@ package com.glxp.udi.admin.entity.inout; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -17,19 +18,25 @@ public class OrderEntity { @TableId private String orderId; + @TableField(value = "action") private String action; + @TableField(value = "corpOrderId") private String corpOrderId; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private String actDate; + @TableField(value = "fromCorpId") private String fromCorpId; + @TableField(value = "actor") private String actor; + @TableField(value = "mainAction") private String mainAction; + @TableField(value = "fromCorp") private String fromCorp; /** @@ -40,15 +47,19 @@ public class OrderEntity { * 3.已完成 * 9.异常 */ + @TableField(value = "status") private Integer status; + @TableField(value = "remark") private String remark; /** * 导出状态 */ + @TableField(value = "exportStatus") private String exportStatus; + @TableField(value = "fromType") private String fromType; /** @@ -56,24 +67,32 @@ public class OrderEntity { * * 上传状态(0:未上传,1:已上传) */ + @TableField(value = "uploadStatus") private String uploadStatus; + @TableField(value = "customerId") private Long customerId; + @TableField(value = "locStorageCode") private String locStorageCode; //复制单号,多个单号之间使用英文逗号,分隔 + @TableField(value = "replicateNo") private String replicateNo; //补单单号 + @TableField(value = "supplementNo") private String supplementNo; //验收状态,0,未验收,1.已验收,2.不需要验收 + @TableField(value = "receiveStatus") private Integer receiveStatus; + @TableField(value = "reviewUser") private Integer reviewUser; //单据更新时间 + @TableField(value = "updateTime") private Date updateTime; public void setActDate(String actDate) { diff --git a/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java b/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java index c709e50..67f2952 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/InvProductDetailService.java @@ -1,6 +1,7 @@ package com.glxp.udi.admin.service.inout; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -113,4 +114,17 @@ public class InvProductDetailService { return null; } + /** + * 批量插入库存详情数据 + * + * @param invProductDetailEntities + */ + public void insertInvProductDetail(List invProductDetailEntities) { + if (CollUtil.isNotEmpty(invProductDetailEntities)) { + List> invDetailList = ListUtil.split(invProductDetailEntities, 1000); + for (List list : invDetailList) { + invProductDetailDao.batchInsert(list); + } + } + } } diff --git a/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java b/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java index b808dec..d8966f6 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/OrderDetailService.java @@ -1,6 +1,7 @@ package com.glxp.udi.admin.service.inout; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -30,8 +31,10 @@ public class OrderDetailService { public void insertOrderDetail(List orderDetailEntities) { if (CollUtil.isNotEmpty(orderDetailEntities)) { - for (OrderDetailEntity orderDetailEntity : orderDetailEntities) { - orderDetailDao.insert(orderDetailEntity); + //批量插入数据,提高速度 + List> detailList = ListUtil.split(orderDetailEntities, 1000); + for (List list : detailList) { + orderDetailDao.batchInsert(list); } } } diff --git a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java index 395c979..7391766 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java @@ -1,6 +1,7 @@ package com.glxp.udi.admin.service.inout; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -71,8 +72,10 @@ public class WarehouseService { public void insertWarehouses(List warehouseEntities) { if (CollUtil.isNotEmpty(warehouseEntities)) { - for (WarehouseEntity warehouseEntity : warehouseEntities) { - codesDao.insert(warehouseEntity); + //对条码进行拆分,使用批量插入,提高插入数据速度 + List> codePageList = ListUtil.split(warehouseEntities, 1000); + for (List list : codePageList) { + codesDao.batchInsert(list); } } } diff --git a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java index e66e4d7..9844851 100644 --- a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java +++ b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -131,6 +132,7 @@ public class InvProductsTrService { warehouseQueryRequest.setBatchNo(invProductEntity.getBatchNo()); List warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); if (CollUtil.isNotEmpty(warehouseEntities)) { + List invProductDetailEntities = new ArrayList<>(warehouseEntities.size()); for (WarehouseEntity warehouseEntity : warehouseEntities) { UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId); InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); @@ -148,8 +150,9 @@ public class InvProductsTrService { invProductDetailEntity.setUpdateTime(new Date()); invProductDetailEntity.setCustomerId(customerId); invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode()); - invProductDetailService.insertInvProduct(invProductDetailEntity); + invProductDetailEntities.add(invProductDetailEntity); } + invProductDetailService.insertInvProductDetail(invProductDetailEntities); } } diff --git a/src/main/resources/mybatis/mapper/inout/CodesDao.xml b/src/main/resources/mybatis/mapper/inout/CodesDao.xml index 3e348e6..f0beb15 100644 --- a/src/main/resources/mybatis/mapper/inout/CodesDao.xml +++ b/src/main/resources/mybatis/mapper/inout/CodesDao.xml @@ -37,4 +37,19 @@ set actDate = #{actDate} where orderId = #{orderId} + + + insert io_codes (code, orderId, corpOrderId, action, mainAction, nameCode, batchNo, serialNo, produceDate, + expireDate, fromCorp, fromCorpId, customerId, packageLevel, supId, supName, relId, count, + locStorageCode, actor, actDate) + values + + (#{item.code}, #{item.orderId}, #{item.corpOrderId}, #{item.action}, #{item.mainAction}, #{item.nameCode}, + #{item.batchNo}, + #{item.serialNo}, #{item.produceDate}, #{item.expireDate}, #{item.fromCorp}, #{item.fromCorpId}, + #{item.customerId}, + #{item.packageLevel}, #{item.supId}, #{item.supName}, #{item.relId}, #{item.count}, #{item.locStorageCode}, + #{item.actor}, #{item.actDate}) + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml b/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml index 41b92ad..62a796f 100644 --- a/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml +++ b/src/main/resources/mybatis/mapper/inout/InvProductDetailDao.xml @@ -13,4 +13,16 @@ from io_inv_product_detail where orderIdFk = #{orderId} + + + insert into io_inv_product_detail (code, productIdFk, orderIdFk, customerId, mainAction, action, count, + updateTime, batchNo, productDate, expireDate, invProductIdFk, + locStorageCode) VALUES + + (#{item.code}, #{item.productIdFk}, #{item.orderIdFk}, #{item.customerId}, #{item.mainAction}, + #{item.action}, #{item.count}, + #{item.updateTime}, #{item.batchNo}, #{item.productDate}, #{item.expireDate}, #{item.invProductIdFk}, + #{item.locStorageCode}) + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml b/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml index 6fa9fdc..58802bf 100644 --- a/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml +++ b/src/main/resources/mybatis/mapper/inout/OrderDetailDao.xml @@ -31,4 +31,18 @@ invoiceDate = #{invoiceDate} where id = #{id} + + + insert into io_order_detail (orderIdFk, relId, uuidFk, nameCode, batchNo, productName, productCompany, + produceDate, expireDate, zczbhhzbapzbh, ggxh, packRatio, reCount, count, price, + firstSalesInvNo, secSalesInvNo, secSalesListNo, invoiceDate) + VALUES + + (#{item.orderIdFk}, #{item.relId}, #{item.uuidFk}, #{item.nameCode}, #{item.batchNo}, #{item.productName}, + #{item.productCompany}, #{item.produceDate}, #{item.expireDate}, #{item.zczbhhzbapzbh}, #{item.ggxh}, + #{item.packRatio}, + #{item.reCount}, #{item.count}, #{item.price}, #{item.firstSalesInvNo}, #{item.secSalesInvNo}, + #{item.secSalesListNo}, #{item.invoiceDate}) + + \ No newline at end of file