diff --git a/CheckImport.class b/CheckImport.class new file mode 100644 index 000000000..88bed044f Binary files /dev/null and b/CheckImport.class differ diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index e18484e8d..8cc8bfd57 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.3:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java index e34bb9cd4..8ef01baad 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/OmsServiceFeign.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import java.util.List; import java.util.concurrent.CompletableFuture; -@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.4:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017", fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface OmsServiceFeign { @@ -66,4 +66,8 @@ public interface OmsServiceFeign { @ApiOperation("批量推送") @PostMapping("/reservationStockOutOrderApi/batchPushByNumber") public AjaxResult batchPushByNumber(@RequestBody List numberList); + + @ApiOperation("保存电子签名记录") + @PostMapping("/electronicSignatureApi/saveSignature") + public AjaxResult saveSignature(@RequestBody ElectronicSignatureSyncDTO saveDTO); } \ No newline at end of file diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/UserServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/UserServiceFeign.java index 4c43846bc..1d6394bfd 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/UserServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/UserServiceFeign.java @@ -165,6 +165,10 @@ public interface UserServiceFeign { @GetMapping("/userShipperApi/userShipperListAll") public AjaxResult userShipperListAll(); + @ApiOperation("查询租户下全部托运人") + @GetMapping("/userShipperApi/userShipperListAllByOrg") + public AjaxResult userShipperListAllByOrg(@RequestParam("orgCode") Long orgCode); + @ApiOperation("查询租户下全部承运人") @GetMapping("/userDriverApi/userDriverListAll") public AjaxResult userDriverListAll(); diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java index e4a817238..d976fcc98 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WlhyServiceFeign.java @@ -26,7 +26,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; -@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.30:8014",configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class) public interface WlhyServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java index 743be7c29..28bee652c 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/WmsServiceFeign.java @@ -21,7 +21,7 @@ import java.util.Map; * @description: TODO * @date 2024/5/10 8:58 **/ -@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.3:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE, url = "http://10.102.192.32:8016", fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface WmsServiceFeign { /** @@ -141,4 +141,14 @@ public interface WmsServiceFeign { @ApiOperation("生成拣货单") @PostMapping("/stockOutOrderApi/genPickingOrderByOms") public AjaxResult genPickingOrderByOms(@RequestBody com.mhd.system.api.domain.StockOutOrderDTO stockOutOrderDTO); + + /** + * OMS批量签名:更新WMS入/出库单签名字段 + * + *

OMS端勾选记录批量签名后,通过此Feign调用WMS的 /stockSignatureApi/batchSign 接口, + * 同步更新WMS stock_in_order / stock_out_order 表的签名状态、签名时间、签名图片、签名备注。

+ */ + @ApiOperation("OMS批量签名-同步WMS入/出库单签名字段") + @PostMapping("/stockSignatureApi/batchSign") + public AjaxResult batchSignWms(@RequestBody SignatureBatchFeignDTO dto); } \ No newline at end of file diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java index dfac7337f..238ec5f81 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/YmsServiceFeign.java @@ -9,7 +9,7 @@ import com.mhd.system.api.feign.FeignAutoConfiguration; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.*; -@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.4:8018", configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,fallbackFactory = RemoteBmsFeignFallbackFactory.class,url = "http://10.102.192.33:8018", configuration = FeignAutoConfiguration.class) public interface YmsServiceFeign { /** diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/ElectronicSignatureSyncDTO.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/ElectronicSignatureSyncDTO.java new file mode 100644 index 000000000..3d64a289d --- /dev/null +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/ElectronicSignatureSyncDTO.java @@ -0,0 +1,108 @@ +package com.mhd.system.api.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 电子签名同步DTO(WMS端通过Feign调用OMS) + */ +@Data +public class ElectronicSignatureSyncDTO { + + @ApiModelProperty("订单ID") + private Long orderId; + + @ApiModelProperty("订单号") + private String orderNumber; + + @ApiModelProperty("订单类型:IN-入库 OUT-出库") + private String orderType; + + @ApiModelProperty("组织ID") + private Long organizationId; + + @ApiModelProperty("组织名称") + private String organizationName; + + @ApiModelProperty("一级组织ID") + private Long topOrganizationId; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("创建人") + private Long createBy; + + @ApiModelProperty("创建人姓名") + private String createByName; + + @ApiModelProperty("物料明细列表") + private List materialDetailList; + + @Data + public static class MaterialDetailItem { + + @ApiModelProperty("物料基础信息ID") + private Long materialBaseInfoId; + + @ApiModelProperty("物料编码") + private String materialCode; + + @ApiModelProperty("物料名称") + private String materialName; + + @ApiModelProperty("数量") + private BigDecimal quantity; + + @ApiModelProperty("单位代码") + private String unitCode; + + @ApiModelProperty("单位名称") + private String unitName; + + @ApiModelProperty("批次号") + private String batchNumber; + + @ApiModelProperty("LOT编号") + private String lotNumber; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("库区ID") + private Long storageSectionId; + + @ApiModelProperty("库区编码") + private String storageSectionCode; + + @ApiModelProperty("库区名称") + private String storageSectionName; + + @ApiModelProperty("库位ID") + private Long storageLocationId; + + @ApiModelProperty("库位编码") + private String storageLocationCode; + + @ApiModelProperty("库位名称") + private String storageLocationName; + + @ApiModelProperty("业务唯一ID") + private Long uniqueId; + } +} diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/InMaterialDetail.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/InMaterialDetail.java index 00e1e3e2b..ff112e22d 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/InMaterialDetail.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/InMaterialDetail.java @@ -240,9 +240,7 @@ public class InMaterialDetail extends BaseVOEntity { @ApiModelProperty("父级唯一Id") private Long parentUniqueId; - @ApiModelProperty("备注") - @Excel(name = "备注") - private String remark; + @ApiModelProperty("越库单id") private Long overStockId; @@ -376,4 +374,24 @@ public class InMaterialDetail extends BaseVOEntity { @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd") private Date drinkDate; + + @ApiModelProperty("来货验收是否合格;1 合格,0 不合格") + @Excel(name = "来货验收是否合格;1 合格,0 不合格") + private String arrivalAcceptQualified; + + @ApiModelProperty("包装是否破损;1 破损,0 完好") + @Excel(name = "包装是否破损;1 破损,0 完好") + private String packageDamaged; + + @ApiModelProperty("是否解冻 / 水渍;1 是,0 否") + @Excel(name = "是否解冻 / 水渍;1 是,0 否") + private String isThawWaterstain; + + @ApiModelProperty("问题货是否已通知客户;1 已通知,0 未通知") + @Excel(name = "问题货是否已通知客户;1 已通知,0 未通知") + private String notifyCustomerAbnormal; + + @ApiModelProperty("备注") + @Excel(name = "备注") + private String remark; } \ No newline at end of file diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/SignatureBatchFeignDTO.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/SignatureBatchFeignDTO.java new file mode 100644 index 000000000..c3b76451e --- /dev/null +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/SignatureBatchFeignDTO.java @@ -0,0 +1,42 @@ +package com.mhd.system.api.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + +/** + * OMS→WMS 批量签名 Feign DTO + * + *

OMS端批量签名时,通过此DTO调用WMS的批量签名接口, + * 更新WMS stock_in_order / stock_out_order 表的签名字段。

+ */ +@Data +public class SignatureBatchFeignDTO { + + @ApiModelProperty("入库单ID列表") + private List inOrderIds; + + @ApiModelProperty("出库单ID列表") + private List outOrderIds; + + @ApiModelProperty("签名状态:2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64或URL,单张)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; +} diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/WarehouseFeignPO.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/WarehouseFeignPO.java index 04b023713..cdc823580 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/WarehouseFeignPO.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/domain/WarehouseFeignPO.java @@ -124,4 +124,20 @@ public class WarehouseFeignPO extends BaseVOEntity{ @Excel(name = "作业模式") private String workMode; + @ApiModelProperty("订单号生成规则(0-日期累加 1-历史累加)") + @Excel(name = "单号生成规则") + private String orderNoGenerateRule; + + @ApiModelProperty("入库单号首字母前缀") + @Excel(name = "入库单号首字母前缀") + private String inOrderNoPrefix; + + @ApiModelProperty("出库单号首字母前缀") + @Excel(name = "出库单号首字母前缀") + private String outOrderNoPrefix; + + @ApiModelProperty("样品出库单号首字母前缀") + @Excel(name = "样品出库单号首字母前缀") + private String sampleOutOrderNoPrefix; + } \ No newline at end of file diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java index fc4eff84f..891442eb4 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteOmsFeignFallbackFactory.java @@ -90,6 +90,11 @@ public class RemoteOmsFeignFallbackFactory implements FallbackFactory numberList) { return null; } + + @Override + public AjaxResult saveSignature(ElectronicSignatureSyncDTO saveDTO) { + return null; + } }; } } \ No newline at end of file diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteUserFeignFallbackFactory.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteUserFeignFallbackFactory.java index 1cfd41e0f..c98643a6c 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteUserFeignFallbackFactory.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteUserFeignFallbackFactory.java @@ -140,6 +140,11 @@ public class RemoteUserFeignFallbackFactory implements FallbackFactory userShipperListAllByOrg(Long orgCode) { + return null; + } + @Override public AjaxResult userDriverListAll() { return AjaxResult.error("获取租户承运人失败"); diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java index e187b6c4a..1cab68d00 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteWmsFallbackFactory.java @@ -119,6 +119,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory queryVehicles(); + + /** 月台实时概览(总数 / 当前作业中) */ + RealPlatformOverviewPO queryPlatformOverview(); + + /** 今日作业任务数 */ + Long countTodayTasks(); + + /** 车辆状态统计(今日) */ + RealVehicleStatusPO queryVehicleStatusToday(); + + /** 本月任务量 */ + Long countMonthTasks(); + + /** 任务负荷(今日 24 小时) */ + List queryTaskLoadToday(); +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealPlatformOverviewPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealPlatformOverviewPO.java new file mode 100644 index 000000000..bc1948549 --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealPlatformOverviewPO.java @@ -0,0 +1,18 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; +import java.io.Serializable; + +/** + * 月台实时概览(真实数据,来自 TEST_NGWL_YMS.QMS_WINDOW_INFO) + */ +@Data +public class RealPlatformOverviewPO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 月台总数 */ + private Long totalPlatforms; + + /** 当前作业中(月台作业状态=占用) */ + private Long operatingPlatforms; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealPlatformVehiclePO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealPlatformVehiclePO.java new file mode 100644 index 000000000..71112888b --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealPlatformVehiclePO.java @@ -0,0 +1,30 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; +import java.io.Serializable; + +/** + * 月台监测-作业车辆(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS 等) + */ +@Data +public class RealPlatformVehiclePO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 车牌号(qms_main_business.CARNO) */ + private String plateNumber; + + /** 流程状态(qms_main_business.FLOWSTATUS) */ + private String status; + + /** 叫号月台(qms_queue_list.WINDOWNAME) */ + private String platformId; + + /** 月台作业时长,分钟(EXITTIME - ENTRYTIME) */ + private Long platformDuration; + + /** 预约申请时间(qms_main_business.CREATE_TIME) */ + private String appointmentTime; + + /** 作业楼层(qms_window_info.PLATFORMFLOOR) */ + private String workFloor; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskLoadPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskLoadPO.java new file mode 100644 index 000000000..d9c70f669 --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskLoadPO.java @@ -0,0 +1,18 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; +import java.io.Serializable; + +/** + * 任务负荷统计(按小时,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS) + */ +@Data +public class RealTaskLoadPO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 0-23 小时 */ + private Integer hourOfDay; + + /** 该小时段任务数 */ + private Long taskCount; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java new file mode 100644 index 000000000..7f2f782a7 --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java @@ -0,0 +1,24 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; +import java.io.Serializable; + +/** + * 作业车辆状态统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS) + */ +@Data +public class RealVehicleStatusPO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 今日预约车辆 */ + private Long todayReservedVehicles; + + /** 当前未签到 */ + private Long notCheckedIn; + + /** 当前作业中 */ + private Long operatingVehicles; + + /** 作业完成 */ + private Long completedVehicles; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java new file mode 100644 index 000000000..a3c52b08d --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java @@ -0,0 +1,214 @@ +package com.mhd.bi.domain.biPlatformRealData.service; + +import com.mhd.bi.domain.biPlatformRealData.repository.mapper.BiPlatformRealDataMapper; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO; +import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +/** + * 月台监测-真实数据业务层(封装 YMS 跨库查询) + * 注:列名大小写、字段类型需以实际库为准;若 YMS 库无数据/无权限,相关方法应返回空/0,不影响写死字段写入快照 + */ +@Slf4j +@Service +public class BiPlatformRealDataService { + + @Resource + private BiPlatformRealDataMapper biPlatformRealDataMapper; + + public List queryVehicles() { + try { + return biPlatformRealDataMapper.queryVehicles(); + } catch (Exception e) { + log.error("【YMS】查询作业车辆列表失败: {}", e.getMessage(), e); + return java.util.Collections.emptyList(); + } + } + + public RealPlatformOverviewPO queryPlatformOverview() { + try { + RealPlatformOverviewPO po = biPlatformRealDataMapper.queryPlatformOverview(); + if (po == null) { + po = new RealPlatformOverviewPO(); + } + if (po.getTotalPlatforms() == null) po.setTotalPlatforms(0L); + if (po.getOperatingPlatforms() == null) po.setOperatingPlatforms(0L); + return po; + } catch (Exception e) { + log.error("【YMS】查询月台概览失败: {}", e.getMessage(), e); + RealPlatformOverviewPO po = new RealPlatformOverviewPO(); + po.setTotalPlatforms(0L); + po.setOperatingPlatforms(0L); + return po; + } + } + + public long countTodayTasks() { + try { + Long n = biPlatformRealDataMapper.countTodayTasks(); + return n == null ? 0L : n; + } catch (Exception e) { + log.error("【YMS】统计今日作业任务失败: {}", e.getMessage(), e); + return 0L; + } + } + + public RealVehicleStatusPO queryVehicleStatusToday() { + try { + RealVehicleStatusPO po = biPlatformRealDataMapper.queryVehicleStatusToday(); + if (po == null) po = new RealVehicleStatusPO(); + if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L); + if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L); + if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L); + if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L); + return po; + } catch (Exception e) { + log.error("【YMS】统计车辆状态失败: {}", e.getMessage(), e); + RealVehicleStatusPO po = new RealVehicleStatusPO(); + po.setTodayReservedVehicles(0L); + po.setNotCheckedIn(0L); + po.setOperatingVehicles(0L); + po.setCompletedVehicles(0L); + return po; + } + } + + public long countMonthTasks() { + try { + Long n = biPlatformRealDataMapper.countMonthTasks(); + return n == null ? 0L : n; + } catch (Exception e) { + log.error("【YMS】统计本月任务量失败: {}", e.getMessage(), e); + return 0L; + } + } + + public List queryTaskLoadToday() { + try { + return biPlatformRealDataMapper.queryTaskLoadToday(); + } catch (Exception e) { + log.error("【YMS】统计任务负荷失败: {}", e.getMessage(), e); + return java.util.Collections.emptyList(); + } + } + + /** + * 实时组装月台监测数据:真实字段查 YMS 库,写死字段保留静态值。 + * 每次调用实时查库,不经过快照表。 + */ + public PlatformSurveillanceVO buildRealTimePlatformSurveillance() { + Random r = new Random(); + PlatformSurveillanceVO template = BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(r); + + // 作业车辆列表 + List realVehicles = queryVehicles(); + List vehicleVos = new ArrayList<>(); + for (RealPlatformVehiclePO rv : realVehicles) { + PlatformVehicleItemVO v = new PlatformVehicleItemVO(); + v.setAppointmentTime(rv.getAppointmentTime()); + v.setWorkFloor(rv.getWorkFloor()); + v.setPlateNumber(rv.getPlateNumber()); + v.setStatus(translateFlowStatus(rv.getStatus())); + v.setPlatformId(rv.getPlatformId()); + v.setPlatformDuration(rv.getPlatformDuration() == null ? 0 : rv.getPlatformDuration().intValue()); + vehicleVos.add(v); + } + if (!vehicleVos.isEmpty()) { + template.setVehicles(vehicleVos); + } + + // 月台实时概览 + RealPlatformOverviewPO ov = queryPlatformOverview(); + if (template.getPlatformOverview() != null) { + template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue()); + template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue()); + int total = ov.getTotalPlatforms().intValue(); + int occ = ov.getOperatingPlatforms().intValue(); + double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d; + template.getPlatformOverview().setCurrentOccupancyRate(rate); + } + long todayTasks = countTodayTasks(); + if (template.getPlatformOverview() != null) { + template.getPlatformOverview().setTodayTasks((int) todayTasks); + } + + // 作业车辆状态统计 + RealVehicleStatusPO vs = queryVehicleStatusToday(); + if (template.getVehicleStatus() != null) { + template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue()); + template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue()); + template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue()); + template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue()); + } + + // 本月任务统计 taskTotal + long monthTasks = countMonthTasks(); + if (template.getMonthlyTaskStatistics() != null) { + template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks); + } + + // 任务负荷(今日 24 小时) + List loads = queryTaskLoadToday(); + if (!loads.isEmpty() && template.getTaskLoadStatistics() != null) { + Map hourMap = new HashMap<>(); + for (RealTaskLoadPO l : loads) { + hourMap.put(l.getHourOfDay(), l.getTaskCount()); + } + for (TaskLoadItemVO item : template.getTaskLoadStatistics()) { + Integer hour = parseHourFromLabel(item.getTime()); + if (hour != null) { + Long n = hourMap.get(hour); + if (n != null) item.setTaskCount(n.intValue()); + } + } + } + + return template; + } + + private static Integer parseHourFromLabel(String label) { + if (label == null) return null; + try { + String s = label.replace("时", "").trim(); + return Integer.parseInt(s); + } catch (Exception e) { + return null; + } + } + + /** + * FLOW_STATUS 数字转中文:1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消 + */ + private static String translateFlowStatus(String flowStatus) { + if (flowStatus == null) return null; + switch (flowStatus.trim()) { + case "1": return "已预约"; + case "2": return "已签到"; + case "3": return "已叫号"; + case "4": return "已过号"; + case "5": return "已进场"; + case "6": return "已称重"; + case "7": return "已装车"; + case "8": return "二次称重"; + case "9": return "已结算"; + case "10": return "已还卡"; + case "11": return "已出场"; + case "12": return "已取消"; + default: return flowStatus; + } + } +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java index 435c6108f..b3ac1ac64 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java @@ -85,7 +85,7 @@ public final class BiReportSnapshotMapperSupport { .entryOvertimeRate(0).overtimeCount(0).platformOnTimeRate(0) .avgPlatformDuration(0d).yardOnTimeRate(0).avgYardDuration(0d).build()) .platformOverview(PlatformOverviewVO.builder() - .totalPlatforms(0).currentOccupancyRate(0).operatingPlatforms(0).todayTasks(0).build()) + .totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build()) .vehicleStatus(VehicleStatusVO.builder() .todayReservedVehicles(0).notCheckedIn(0).operatingVehicles(0).completedVehicles(0).build()) .avgOperationDurationTrend(Collections.emptyList()) diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java index 2f42acdf8..6df016cbf 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java @@ -13,10 +13,20 @@ import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillance import com.mhd.bi.interfaces.facadeApi.biReport.vo.hkMacaoZone.HkMacaoServiceZoneVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.transportZone.TransportOperationZoneVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperationZoneVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO; +import com.mhd.bi.domain.biPlatformRealData.service.BiPlatformRealDataService; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.HashMap; import java.util.Random; /** @@ -34,6 +44,7 @@ public class BiReportSnapshotSyncService { private final BiSnapshotWriteMapper biSnapshotWriteMapper; private final ObjectMapper objectMapper; + private final BiPlatformRealDataService biPlatformRealDataService; /** * 依次同步各快照表;单表失败不影响其它表,只记日志。 @@ -137,9 +148,87 @@ public class BiReportSnapshotSyncService { return BiSnapshotWeeklyRandomDataBuilder.warehouseTransport(new Random()); } - /** TODO 业务落地:改为查询真实数据。临时实现见 {@link BiSnapshotWeeklyRandomDataBuilder#platformSurveillance(Random)}。 */ + /** TODO 业务落地:部分字段改为真实数据,其余仍写死。 */ protected PlatformSurveillanceVO buildPlatformSurveillanceSnapshot() { - return BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(new Random()); + Random r = new Random(); + // 写死数据复用原 builder + PlatformSurveillanceVO template = BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(r); + + // ====== 真实数据:作业车辆列表 ====== + List realVehicles = biPlatformRealDataService.queryVehicles(); + List vehicleVos = new ArrayList<>(); + for (RealPlatformVehiclePO rv : realVehicles) { + PlatformVehicleItemVO v = new PlatformVehicleItemVO(); + v.setAppointmentTime(rv.getAppointmentTime()); + v.setWorkFloor(rv.getWorkFloor()); + v.setPlateNumber(rv.getPlateNumber()); + v.setStatus(rv.getStatus()); + v.setPlatformId(rv.getPlatformId()); + v.setPlatformDuration(rv.getPlatformDuration() == null ? 0 : rv.getPlatformDuration().intValue()); + vehicleVos.add(v); + } + if (!vehicleVos.isEmpty()) { + template.setVehicles(vehicleVos); + } + + // ====== 真实数据:月台实时概览 ====== + RealPlatformOverviewPO ov = biPlatformRealDataService.queryPlatformOverview(); + if (template.getPlatformOverview() != null) { + template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue()); + template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue()); + int total = ov.getTotalPlatforms().intValue(); + int occ = ov.getOperatingPlatforms().intValue(); + double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d; + template.getPlatformOverview().setCurrentOccupancyRate(rate); + } + long todayTasks = biPlatformRealDataService.countTodayTasks(); + if (template.getPlatformOverview() != null) { + template.getPlatformOverview().setTodayTasks((int) todayTasks); + } + + // ====== 真实数据:作业车辆状态统计 ====== + RealVehicleStatusPO vs = biPlatformRealDataService.queryVehicleStatusToday(); + if (template.getVehicleStatus() != null) { + template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue()); + template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue()); + template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue()); + template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue()); + } + + // ====== 真实数据:本月任务统计 taskTotal ====== + long monthTasks = biPlatformRealDataService.countMonthTasks(); + if (template.getMonthlyTaskStatistics() != null) { + template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks); + } + + // ====== 真实数据:任务负荷(今日 24 小时) ====== + List loads = biPlatformRealDataService.queryTaskLoadToday(); + if (!loads.isEmpty() && template.getTaskLoadStatistics() != null) { + Map hourMap = new HashMap<>(); + for (RealTaskLoadPO l : loads) { + hourMap.put(l.getHourOfDay(), l.getTaskCount()); + } + for (com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO item : template.getTaskLoadStatistics()) { + Integer hour = parseHourFromLabel(item.getTime()); + if (hour != null) { + Long n = hourMap.get(hour); + if (n != null) item.setTaskCount(n.intValue()); + } + } + } + + return template; + } + + private static Integer parseHourFromLabel(String label) { + if (label == null) return null; + // "15时" -> 15 + try { + String s = label.replace("时", "").trim(); + return Integer.parseInt(s); + } catch (Exception e) { + return null; + } } /** diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java index cb72d7b6a..79f0cdd1a 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java @@ -127,6 +127,8 @@ public final class BiSnapshotWeeklyRandomDataBuilder { for (String[] row : Baseline.P_PLATES) { int dur = jitterInt(Integer.parseInt(row[3]), r); vehicles.add(PlatformVehicleItemVO.builder() + .appointmentTime(Baseline.P_APPOINTMENT_TIME) + .workFloor(Baseline.P_WORK_FLOOR) .plateNumber(row[0]) .status(row[1]) .platformId(row[2]) @@ -145,7 +147,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder { PlatformOverviewVO overview = PlatformOverviewVO.builder() .totalPlatforms(Math.max(1, jitterInt(Baseline.P_TOT_PL, r))) - .currentOccupancyRate(jitterPercentInt(Baseline.P_OCC, r)) + .currentOccupancyRate((double) jitterPercentInt(Baseline.P_OCC, r)) .operatingPlatforms(Math.max(0, jitterInt(Baseline.P_OP, r))) .todayTasks(Math.max(0, jitterInt(Baseline.P_TASKS, r))) .build(); @@ -394,6 +396,8 @@ public final class BiSnapshotWeeklyRandomDataBuilder { static final String[] W_CUST_NAMES = {"华东冷链", "华南汽配", "西南快消", "华北家电", "跨境达"}; static final int[] W_CUST_AMT = {198, 172, 205, 189, 221}; + static final String P_APPOINTMENT_TIME = "2026-08-03 09:30:00"; + static final String P_WORK_FLOOR = "一楼"; static final String[][] P_PLATES = { {"粤A12345", "待入场", "#12", "88"}, {"闽D99887", "作业中", "#07", "142"}, diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java index 6d6156940..4aa56c70f 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java +++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java @@ -3,6 +3,7 @@ package com.mhd.bi.interfaces.facadeApi.biReport; import com.mhd.bi.domain.biSnapshotSync.service.BiReportSnapshotSyncService; import com.mhd.bi.domain.biComprehensive.service.BiComprehensiveReportService; import com.mhd.bi.domain.biPlatformSurveillance.service.BiPlatformSurveillanceReportService; +import com.mhd.bi.domain.biPlatformRealData.service.BiPlatformRealDataService; import com.mhd.bi.domain.biOverallOperation.service.BiOverallOperationReportService; import com.mhd.bi.domain.biHkMacaoServiceZone.service.BiHkMacaoServiceZoneReportService; import com.mhd.bi.domain.biTransportOperationZone.service.BiTransportOperationZoneReportService; @@ -48,6 +49,9 @@ public class BiReportApi extends BaseController { @Autowired private BiPlatformSurveillanceReportService biPlatformSurveillanceReportService; + @Autowired + private BiPlatformRealDataService biPlatformRealDataService; + @Autowired private BiOverallOperationReportService biOverallOperationReportService; @@ -92,12 +96,12 @@ public class BiReportApi extends BaseController { } /** - * 月台监测指标查询(按照 del_flag=1,按 create_time 最新一条) + * 月台监测指标查询(实时查 YMS 库,真实字段 + 写死字段) */ - @ApiOperation(value = "月台监测指标查询", notes = "返回 DEL_FLAG=1 且 CREATE_TIME 最新的一条快照") + @ApiOperation(value = "月台监测指标查询", notes = "每次调用实时查询 YMS 库组装;部分字段为真实业务数据,部分为写死数据") @GetMapping("/platformSurveillance") public BiApiResult platformSurveillance() { - PlatformSurveillanceVO data = biPlatformSurveillanceReportService.loadLatestPlatformSurveillance(); + PlatformSurveillanceVO data = biPlatformRealDataService.buildRealTimePlatformSurveillance(); return BiApiResult.ok(data); } //园区物流大屏接口---------------------------------------------------------------------- diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java index a34587b34..fc66de7b5 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java +++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java @@ -18,7 +18,7 @@ public class PlatformOverviewVO { private Integer totalPlatforms; @ApiModelProperty("当前占用率,单位:%") - private Integer currentOccupancyRate; + private Double currentOccupancyRate; @ApiModelProperty("当前作业中,单位:个") private Integer operatingPlatforms; diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformVehicleItemVO.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformVehicleItemVO.java index 8ec4ebc49..f98561c13 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformVehicleItemVO.java +++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformVehicleItemVO.java @@ -14,6 +14,12 @@ import lombok.NoArgsConstructor; @ApiModel("月台监测-作业车辆") public class PlatformVehicleItemVO { + @ApiModelProperty("预约申请时间") + private String appointmentTime; + + @ApiModelProperty("作业楼层") + private String workFloor; + @ApiModelProperty("车牌号码") private String plateNumber; diff --git a/mhd-bi/src/main/resources/bootstrap.yml b/mhd-bi/src/main/resources/bootstrap.yml index fa1d95e1a..376c66f95 100644 --- a/mhd-bi/src/main/resources/bootstrap.yml +++ b/mhd-bi/src/main/resources/bootstrap.yml @@ -16,17 +16,17 @@ spring: # 线上测试环境配置 容器名+端口号 # server-addr: 10.33.0.129:6010 # server-addr: 10.102.192.5:6848 -# username: nacos -# password: manhuoda@2023 - #线上正式环境 - server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 + #线上正式环境 + server-addr: 10.102.192.30:6848 +# username: nacos +# password: manhuoda@2023 config: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 # server-addr: 10.33.0.129:6010 - server-addr: 10.102.192.31:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境 diff --git a/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml b/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml new file mode 100644 index 000000000..6397c6612 --- /dev/null +++ b/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/entity/Warehouse.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/entity/Warehouse.java index 4564aa5b9..e49996bf4 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/entity/Warehouse.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/entity/Warehouse.java @@ -130,4 +130,20 @@ public class Warehouse extends BaseVOEntity{ @Excel(name = "作业模式") private String workMode; + @ApiModelProperty("订单号生成规则0日期累加1历史累加") + @Excel(name = "单号生成规则") + private String orderNoGenerateRule; + + @ApiModelProperty("入库单号首字母前缀") + @Excel(name = "入库单号首字母前缀") + private String inOrderNoPrefix; + + @ApiModelProperty("出库单号首字母前缀") + @Excel(name = "出库单号首字母前缀") + private String outOrderNoPrefix; + + @ApiModelProperty("样品出库单号首字母前缀") + @Excel(name = "样品出库单号首字母前缀") + private String sampleOutOrderNoPrefix; + } \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/po/WarehousePO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/po/WarehousePO.java index 1127d377d..e1b5f239d 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/po/WarehousePO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/po/WarehousePO.java @@ -131,4 +131,21 @@ public class WarehousePO extends BaseVOEntity{ @ApiModelProperty("作业模式") @Excel(name = "作业模式") private String workMode; + + + @ApiModelProperty("订单号生成规则") + @Excel(name = "单号生成规则") + private String orderNoGenerateRule; + + @ApiModelProperty("入库单号首字母前缀") + @Excel(name = "入库单号首字母前缀") + private String inOrderNoPrefix; + + @ApiModelProperty("出库单号首字母前缀") + @Excel(name = "出库单号首字母前缀") + private String outOrderNoPrefix; + + @ApiModelProperty("样品出库单号首字母前缀") + @Excel(name = "样品出库单号首字母前缀") + private String sampleOutOrderNoPrefix; } \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/todo/WarehouseDO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/todo/WarehouseDO.java index 097528ef2..2c0359c90 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/todo/WarehouseDO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/warehouse/repository/todo/WarehouseDO.java @@ -139,4 +139,21 @@ public class WarehouseDO extends BaseVOEntity{ @ApiModelProperty("作业模式") @Excel(name = "作业模式") private String workMode; + + + @ApiModelProperty("订单号生成规则") + @Excel(name = "单号生成规则") + private String orderNoGenerateRule; + + @ApiModelProperty("入库单号首字母前缀") + @Excel(name = "入库单号首字母前缀") + private String inOrderNoPrefix; + + @ApiModelProperty("出库单号首字母前缀") + @Excel(name = "出库单号首字母前缀") + private String outOrderNoPrefix; + + @ApiModelProperty("样品出库单号首字母前缀") + @Excel(name = "样品出库单号首字母前缀") + private String sampleOutOrderNoPrefix; } \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/warehouse/WarehouseDTO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/warehouse/WarehouseDTO.java index 8b1b164aa..ce7bbeecb 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/warehouse/WarehouseDTO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/warehouse/WarehouseDTO.java @@ -144,4 +144,21 @@ public class WarehouseDTO extends BaseVOEntity{ @ApiModelProperty("作业模式") @Excel(name = "作业模式") private String workMode; + + + @ApiModelProperty("订单号生成规则") + @Excel(name = "单号生成规则") + private String orderNoGenerateRule; + + @ApiModelProperty("入库单号首字母前缀") + @Excel(name = "入库单号首字母前缀") + private String inOrderNoPrefix; + + @ApiModelProperty("出库单号首字母前缀") + @Excel(name = "出库单号首字母前缀") + private String outOrderNoPrefix; + + @ApiModelProperty("样品出库单号首字母前缀") + @Excel(name = "样品出库单号首字母前缀") + private String sampleOutOrderNoPrefix; } \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/resources/mapper/basic/warehouse/WarehouseMapper.xml b/mhd-modules/mhd-system/src/main/resources/mapper/basic/warehouse/WarehouseMapper.xml index ec3402469..fe8b9fbe0 100644 --- a/mhd-modules/mhd-system/src/main/resources/mapper/basic/warehouse/WarehouseMapper.xml +++ b/mhd-modules/mhd-system/src/main/resources/mapper/basic/warehouse/WarehouseMapper.xml @@ -39,6 +39,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -47,7 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" warehouse_type, warehouse_type_name, warehouse_structure, warehouse_nature, warm_layer_code, warm_layer_name, director_name, director_phone, region_code, region_name, detail_address, longitude, latitude, building_region, usage_region, remark, opening_up, nullify, create_time, create_by, create_by_name, update_time, update_by, - update_by_name, del_flag, IS_ENABLE ,WORK_MODE,TASK_MODE + update_by_name, del_flag, IS_ENABLE ,WORK_MODE,TASK_MODE,SAMPLE_OUT_ORDER_NO_PREFIX,ORDER_NO_GENERATE_RULE,IN_ORDER_NO_PREFIX, + OUT_ORDER_NO_PREFIX from warehouse diff --git a/mhd-user-center/src/main/java/com/mhd/user/application/service/UserShipperApplicationService.java b/mhd-user-center/src/main/java/com/mhd/user/application/service/UserShipperApplicationService.java index a73ad76d5..fd45a1f66 100644 --- a/mhd-user-center/src/main/java/com/mhd/user/application/service/UserShipperApplicationService.java +++ b/mhd-user-center/src/main/java/com/mhd/user/application/service/UserShipperApplicationService.java @@ -161,11 +161,22 @@ public class UserShipperApplicationService { // 先保存前端传递的 organizationId(如果存在) Long frontendOrganizationId = userShipperDO.getOrganizationId(); - + // 获取当前登录用户的组织信息 Long loginUserOrganizationId = userPo.getOrganizationId(); Long topOrganizationId = userPo.getTopOrganizationId(); - + + // 如果前端传了 orgCode(组织ID),直接按 org_code 过滤查询委托方,不覆盖组织条件 + // orgCode 匹配 user_shipper.org_code JSON 数组中的 code 字段,用于精确查询委托方 + if (StringUtils.isNotBlank(userShipperDO.getOrgCode())) { + // 清空 organizationId / topOrganizationId,避免被数据权限覆盖逻辑拦截 orgCode 已授权的委托方 + userShipperDO.setOrganizationId(null); + userShipperDO.setTopOrganizationId(null); + log.info("托运人列表查询 - 按 orgCode 查询:orgCode={}", userShipperDO.getOrgCode()); + List userShipperList = userShipperDomainService.userShipperList(userShipperDO); + return processShipperList(userShipperList); + } + // 数据权限:根据 organizationId 来设置查询权限 // 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己 if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) { @@ -184,32 +195,13 @@ public class UserShipperApplicationService { log.info("托运人列表查询 - 南光组织查询所有组织:不设置组织过滤条件"); } } else { - // 其他组织:设置 organizationId,只查询当前组织的数据 - // 其他组织只能查询自己组织的数据,不能查询其他组织的数据 - if (frontendOrganizationId != null) { - // 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致 - if (!frontendOrganizationId.equals(loginUserOrganizationId)) { - // 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询 - log.warn("托运人列表查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤", - frontendOrganizationId, loginUserOrganizationId); - userShipperDO.setOrganizationId(loginUserOrganizationId); - if (frontendOrganizationId.equals(2827L)){ - userShipperDO.setOrganizationId(null); - } - } else { - // 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值 - userShipperDO.setOrganizationId(frontendOrganizationId); - } - if (topOrganizationId != null) { - userShipperDO.setTopOrganizationId(topOrganizationId); - } - } else { - // 前端没有传递 organizationId,使用当前登录用户的组织ID - userShipperDO.setOrganizationId(loginUserOrganizationId); - if (topOrganizationId != null) { - userShipperDO.setTopOrganizationId(topOrganizationId); - } - } + // 其他组织:设置 organizationId 为当前登录组织ID。 + // 查询条件为:a.organization_id = 本组织 OR b.org_code LIKE 本组织ID + // 即委托方初始绑定本组织、或 org_code 中包含本组织(被授权给本组织)时,均可查到。 + // 不设置 topOrganizationId,避免跨顶级组织授权(org_code 已包含本组织)被顶级组织条件拦截。 + userShipperDO.setOrganizationId(loginUserOrganizationId); + userShipperDO.setTopOrganizationId(null); + log.info("托运人列表查询 - 其他组织按本组织及 org_code 查询:organizationId={}", loginUserOrganizationId); } log.info("托运人列表查询 - 设置组织ID后,查询参数:organizationId={}, topOrganizationId={}, userId={}", @@ -413,10 +405,15 @@ public class UserShipperApplicationService { shipperDO.setShipperEnterpriseName(companyName); // NC客户编码使用模板中的独立字段,不再复用登录账号 shipperDO.setCustomerNcCode(ncCustomerCode); - // 联系人 -> user表 user_name + user_shipper表 user_name_shipper - shipperDO.setUserName(contactName); + // 公司名称 -> user表 user_name + user_shipper表 user_name_shipper + shipperDO.setUserName(companyName); shipperDO.setUserNameShipper(contactName); - // 联系电话 -> user表 user_phone + // 登录账号 -> user表 user_member_code + shipperDO.setUserMemberCode(userAccount); + // 联系人 -> user表 emergency_contact_name + shipperDO.setEmergencyContactName(contactName); + // 联系电话 -> user表 emergency_contact_phone + shipperDO.setEmergencyContactPhone(contactPhone); shipperDO.setUserPhone(contactPhone); // 地址 -> user表 user_area_name,详细地址 -> user表 user_area_address shipperDO.setUserAreaName(address); @@ -461,16 +458,30 @@ public class UserShipperApplicationService { } /** - * 导入时若账号没有任何角色,则补分配企业货主角色 + * 导入委托方时,确保账号仅绑定企业货主(company)角色。 + * 注意:authShipper 会把“当前登录管理员的所有角色”都分配给导入用户, + * 因此这里必须保证用户最终只绑定 company 角色——若现有角色不是“唯一的 company 角色”, + * 一律删除后重新分配,避免残留 ownerCargo 等多条错误角色。 */ private void assignCompanyRoleIfMissing(Long userId, Long organizationId) { if (userId == null || organizationId == null) { return; } + // 查询用户现有角色 List existingRoles = userRoleDomainService.selectRolesByUserId(userId); - if (CollUtil.isNotEmpty(existingRoles)) { + // 只有恰好绑定了唯一的 company 角色时,才认为正确,无需处理 + boolean onlyCompany = !CollUtil.isEmpty(existingRoles) + && existingRoles.size() == 1 + && RoleEnum.COMPANY.getCode().equals(existingRoles.get(0).getRoleCode()); + if (onlyCompany) { return; } + // 否则:删除所有现有角色(ownerCargo、或多个角色),重新分配 company + if (CollUtil.isNotEmpty(existingRoles)) { + log.info("导入委托方 - 用户{}角色不正确,删除原角色后重新分配company,原角色: {}", + userId, existingRoles.stream().map(UserRoleMenuPO::getRoleCode).collect(Collectors.toList())); + userRoleDomainService.deleteByUserId(userId); + } // 按 role_code + organization_id 精确匹配角色(selectByOrganizationIdAndRoleCode 的 common_where 不含 roleCode 过滤,不适用) RolePO rolePO = roleDomainService.selectByRoleCodeAndOrganizationId(RoleEnum.COMPANY.getCode(), organizationId); if (rolePO == null) { @@ -547,8 +558,15 @@ public class UserShipperApplicationService { userDO.setUserId(userId); if (StringUtils.isNotBlank(userAccount)) { userDO.setUserAccount(userAccount); + // 登录账号 -> user表 user_member_code + userDO.setUserMemberCode(userAccount); } - userDO.setUserName(contactName); + // 公司名称 -> user表 user_name + userDO.setUserName(companyName); + // 联系人 -> user表 emergency_contact_name + userDO.setEmergencyContactName(contactName); + // 联系电话 -> user表 emergency_contact_phone + userDO.setEmergencyContactPhone(contactPhone); userDO.setUserPhone(contactPhone); userDO.setUserAreaName(address); userDO.setUserAreaAddress(detailedAddress); @@ -564,8 +582,8 @@ public class UserShipperApplicationService { userDO.setUserSalt(salt); } userDomainService.updateUser(userDO); - // 如果该账号没有任何角色,补分配企业货主角色,避免登录报“账号未授权角色信息” - assignCompanyRoleIfMissing(userId, existingShipper.getOrganizationId()); + // 如果该账号没有企业货主(company)角色,补分配当前导入组织下的 company 角色,避免登录报“账号未授权角色信息” + assignCompanyRoleIfMissing(userId, currentOrgId); } // 3. 更新 orgCode 中当前组织的 ncCustomer @@ -1306,6 +1324,12 @@ public class UserShipperApplicationService { return userShipperDomainService.userShipperList(userShipperDO); } + public List userShipperListAllByOrg(Long orgCode) { + UserShipperDO userShipperDO = new UserShipperDO(); + userShipperDO.setOrganizationId(orgCode); + return userShipperDomainService.userShipperList(userShipperDO); + } + /** * E签宝回调接口-认证授权完成 * @param jsonObject 回调参数 diff --git a/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserShipperDomainService.java b/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserShipperDomainService.java index 61eaece29..898b90476 100644 --- a/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserShipperDomainService.java +++ b/mhd-user-center/src/main/java/com/mhd/user/domain/userAggregate/service/UserShipperDomainService.java @@ -47,7 +47,7 @@ public class UserShipperDomainService { } } -// @DataPermissions(cacheName = "master") + // @DataPermissions(cacheName = "master") public List userShipperList(UserShipperDO userShipperDO) { // 数据权限逻辑已在 UserShipperApplicationService.userShipperList 中处理 // 这里不再重复处理数据权限,直接使用传入的参数进行查询 diff --git a/mhd-user-center/src/main/java/com/mhd/user/interfaces/facade/UserShipperAPI.java b/mhd-user-center/src/main/java/com/mhd/user/interfaces/facade/UserShipperAPI.java index 39144e917..41ae750a4 100644 --- a/mhd-user-center/src/main/java/com/mhd/user/interfaces/facade/UserShipperAPI.java +++ b/mhd-user-center/src/main/java/com/mhd/user/interfaces/facade/UserShipperAPI.java @@ -212,6 +212,15 @@ public class UserShipperAPI extends BaseController { return AjaxResult.success("操作成功",list); } + @Log(title = "托运人管理-查询租户下所有托运人", description ="查询租户下所有托运人",businessType = BusinessType.INQUIRE) + @ApiOperation("查询租户下所有托运人") + @GetMapping("/userShipperListAllByOrg") + public AjaxResult userShipperListAllByOrg(@RequestParam("orgCode") Long orgCode) { + //转换实体 + List list = userShipperApplicationService.userShipperListAllByOrg(orgCode); + return AjaxResult.success("操作成功",list); + } + @Log(title = "托运人管理-修改授权额度 结算天数 使用额度", description ="修改授权额度 结算天数 使用额度",businessType = BusinessType.INQUIRE) @ApiOperation("修改授权额度和结算天数") @PutMapping("/settlementInfo") diff --git a/mhd-user-center/src/main/resources/bootstrap.yml b/mhd-user-center/src/main/resources/bootstrap.yml index 7b6baaea4..dd13bfba5 100644 --- a/mhd-user-center/src/main/resources/bootstrap.yml +++ b/mhd-user-center/src/main/resources/bootstrap.yml @@ -20,15 +20,15 @@ spring: discovery: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 - server-addr: 10.33.0.129:6010 -# server-addr: 10.102.192.30:6848 +# server-addr: 10.33.0.129:6010 + server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 config: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 - server-addr: 10.33.0.129:6010 -# server-addr: 10.102.192.30:6848 +# server-addr: 10.33.0.129:6010 + server-addr: 10.102.192.31:6848 username: nacos password: manhuoda@2023 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 diff --git a/mhd-user-center/src/main/resources/mapper/UserMapper.xml b/mhd-user-center/src/main/resources/mapper/UserMapper.xml index de6a5b2b1..6caa17751 100644 --- a/mhd-user-center/src/main/resources/mapper/UserMapper.xml +++ b/mhd-user-center/src/main/resources/mapper/UserMapper.xml @@ -781,11 +781,11 @@ /*组织ID - 数据隔离:南光组织(organizationId=2827)查询全部,其他组织查询自己组织的数据*/ AND ( - u.organization_id = #{organizationId} - OR b.org_code LIKE concat('%"code":"', #{organizationId}, '"%') - OR b.org_code LIKE concat('%code:', #{organizationId}, '%') - OR b.org_code LIKE concat('%code: ', #{organizationId}, '%') - OR b.org_code LIKE concat('%"code":', #{organizationId}, '%') + u.organization_id = #{organizationId} + OR b.org_code LIKE concat('%"code":"', #{organizationId}, '"%') + OR b.org_code LIKE concat('%code:', #{organizationId}, '%') + OR b.org_code LIKE concat('%code: ', #{organizationId}, '%') + OR b.org_code LIKE concat('%"code":', #{organizationId}, '%') ) AND u.organization_name IS NOT NULL diff --git a/mhd-user-center/src/main/resources/mapper/UserShipperMapper.xml b/mhd-user-center/src/main/resources/mapper/UserShipperMapper.xml index 38524dcd0..54f8dd8c7 100644 --- a/mhd-user-center/src/main/resources/mapper/UserShipperMapper.xml +++ b/mhd-user-center/src/main/resources/mapper/UserShipperMapper.xml @@ -378,13 +378,23 @@ and b.parent_shipper_id = #{parentShipperId} /*用户组织ID*/ - + /*用户组织ID*/ + AND ( + a.organization_id = #{organizationId} OR b.org_code LIKE concat('%"code":"', #{organizationId}, '"%') OR b.org_code LIKE concat('%code:', #{organizationId}, '%') OR b.org_code LIKE concat('%code: ', #{organizationId}, '%') OR b.org_code LIKE concat('%"code":', #{organizationId}, '%') + + + OR + b.org_code LIKE concat('%code:', #{orgCode}, '%') + OR b.org_code LIKE concat('%code: ', #{orgCode}, '%') + OR b.org_code LIKE concat('%"code":', #{orgCode}, '%') + OR b.org_code LIKE concat('%"code":"', #{orgCode}, '"%') + ) /*组织名称*/ diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java index 3d90a5b76..f528cbb8c 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billManage/BillManageApplicationService.java @@ -7,6 +7,7 @@ import com.mhd.bms.application.server.receiptManage.ReceiptManageApplicationServ import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.entity.BillManage; import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService; +import com.mhd.bms.domain.billManage.repository.facade.IBillManageService; import com.mhd.bms.domain.billManage.repository.mapper.BillDetailMapper; import com.mhd.bms.domain.billManage.repository.po.BillDetailPO; import com.mhd.bms.domain.billManage.repository.po.BillManagePO; @@ -78,6 +79,8 @@ public class BillManageApplicationService { private BillDetailMapper billDetailMapper; @Autowired private NcLogMapper ncLogMapper; + @Autowired + private IBillManageService billManageService; /** @@ -445,6 +448,7 @@ public class BillManageApplicationService { billManageDO.setReconciliationStatus(1); billManageDO.setCreateTime(new Date()); billManageDO.setCreateBy(loginUser.getUserid()); + billManageDO.setSalesmanId(String.valueOf(loginUser.getUserid())); billManageDO.setCreateByName(loginUser.getUserPo().getUserName()); billManageDO.setUpdateTime(new Date()); billManageDO.setUpdateBy(loginUser.getUserid()); @@ -466,6 +470,16 @@ public class BillManageApplicationService { for (BillDetailDTO billDetailDTO : billDetailDTOListNoBillingStatementId) { BillingStatementDTO billingStatementDTO = new BillingStatementDTO(); BeanUtils.copyProperties(billDetailDTO, billingStatementDTO); + + String firstSubjectCode = billDetailDTO.getFirstSubjectCode(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = billingStatementDTO.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + billingStatementDTO.setTaxAmount(taxAmount); + billingStatementDTO.setTaxFreeFee(taxFreeFee); + billingStatementDTO.setTaxRate(taxRate); + billingStatementDTO.setBillingAmount(amount); billingStatementDTO.setAccountExpenseType(billDetailDTO.getBillType()); billingStatementDTO.setBillManageId(billManageDO.getBillManageId()); billingStatementDTO.setBillingState(3); @@ -495,6 +509,33 @@ public class BillManageApplicationService { billingStatementApplicationService.update(billingStatementDO); } //保存账单明细 + double allTaxRate = 0.0d; + BigDecimal allTaxAmount = BigDecimal.ZERO; + BigDecimal allTaxFreeFee = BigDecimal.ZERO; + for (BillDetailDTO item : billDetailDTOList) { + String firstSubjectCode = item.getFirstSubjectCode(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = item.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + item.setTaxAmount(taxAmount); + item.setTaxFreeFee(taxFreeFee); + item.setTaxRate(taxRate); + item.setBillManageId(billManageDO.getBillManageId()); + item.setBillNumber(billManageDO.getBillNumber()); + allTaxRate += taxRate; + allTaxAmount = allTaxAmount.add(taxAmount); + allTaxFreeFee = allTaxFreeFee.add(taxFreeFee); + } + + BillManage billManage = billManageService.getById(billManageDO.getBillManageId()); + if (billManage != null) { + billManage.setTaxRate(allTaxRate); + billManage.setTaxAmount(allTaxAmount); + billManage.setTaxFreeFee(allTaxFreeFee); + billManage.setSalesmanId(String.valueOf(loginUser.getUserid())); + billManageService.updateById(billManage); + } Boolean flagTwo = billDetailDomainService.saveBatch(billDetailDTOList); //保存操作记录 BillOperationLogDO billOperationLogDO = new BillOperationLogDO(); diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java index fa761a104..054b94461 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billingStatement/BillingStatementApplicationService.java @@ -585,6 +585,8 @@ public class BillingStatementApplicationService { 此方法只进行实体返回,并不进行数据保存 */ LoginUser loginUser = SecurityUtils.getLoginUser(); + + billingStatementDO.setAccountExpenseType(billingStatementDO.getAccountExpenseType()); if (ObjectUtil.isNull(loginUser)) { throw new DigitalLogisticsException(UserError.TIMEOUT); } diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java index dd3dd498f..76879467f 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java @@ -274,7 +274,7 @@ public class SettlementCustomersApplicationService { SyncDictCache dictCache, List toInsert, List toUpdate) { - AjaxResult ajaxResult = userServiceFeign.userShipperListAll(); + AjaxResult ajaxResult = userServiceFeign.userShipperListAllByOrg(loginUser.getUserPo().getOrganizationId()); List userShipperPoList = parseFeignList(ajaxResult, UserShipperPo.class); if (userShipperPoList.isEmpty()) { return; diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java index f2cbe3d43..192395468 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/facade/IBillDetailService.java @@ -38,4 +38,6 @@ public interface IBillDetailService extends IService public BillDetailPO getInfo(Long billDetailId); List getDetailsByBillManageId(Long billManageId); -} + + List getDetailsByBillManageIdAndGroup(Long billManageId); +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java index 1ea7709f4..044e5565c 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillDetailMapper.java @@ -5,6 +5,7 @@ import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.repository.po.BillDetailPO; import org.apache.ibatis.annotations.Param; +import java.math.BigDecimal; import java.util.List; /** @@ -17,4 +18,8 @@ public interface BillDetailMapper extends BaseMapper { List getDetailsByBillManageId(@Param("billManageId") Long billManageId); -} + + List getDetailsByBillManageIdAndGroup(@Param("billManageId") Long billManageId); + + Double getTaxRate(@Param("code") String code); +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java index 1a075701b..5a4edf3f3 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/mapper/BillManageMapper.java @@ -44,4 +44,6 @@ public interface BillManageMapper extends BaseMapper String getDeptName(@Param("dictCode") String dictCode); String getOrgCodeNc(@Param("organizationId") Long organizationId); + + Long getShipperId(@Param("userId") Long userId, @Param("organizationId") Long organizationId); } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java index cf62504d6..2aa419a1f 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillDetailImpl.java @@ -75,4 +75,9 @@ public class BillDetailImpl extends ServiceImpl im public List getDetailsByBillManageId(Long billManageId) { return billDetailMapper.getDetailsByBillManageId(billManageId); } -} + + @Override + public List getDetailsByBillManageIdAndGroup(Long billManageId) { + return billDetailMapper.getDetailsByBillManageIdAndGroup(billManageId); + } +} \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java index 014e611f8..61c81134d 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/persistence/BillManageImpl.java @@ -9,8 +9,11 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.mhd.bms.domain.billManage.entity.BillDetail; import com.mhd.bms.domain.billManage.entity.BillManage; +import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService; import com.mhd.bms.domain.billManage.repository.facade.IBillManageService; +import com.mhd.bms.domain.billManage.repository.mapper.BillDetailMapper; import com.mhd.bms.domain.billManage.repository.mapper.BillManageMapper; import com.mhd.bms.domain.billManage.repository.po.BillManagePO; import com.mhd.bms.domain.billManage.repository.todo.BillManageDO; @@ -24,6 +27,9 @@ import com.mhd.bms.domain.ncDataPushConfig.entity.NcDataPushConfig; import com.mhd.bms.domain.ncDataPushConfig.repository.mapper.NcDataPushConfigMapper; import com.mhd.bms.domain.ncLog.entity.NcLog; import com.mhd.bms.domain.ncLog.repository.mapper.NcLogMapper; +import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers; +import com.mhd.bms.domain.settlementCustomers.repository.facade.ISettlementCustomersService; +import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO; import com.mhd.bms.interfaces.dto.billManage.BillManageDTO; import com.mhd.common.core.domain.dto.ReconciliationDTO; import com.mhd.common.core.domain.dto.nc.*; @@ -83,6 +89,12 @@ public class BillManageImpl extends ServiceImpl im @Autowired private BillManageMapper billManageMapper; @Autowired + private IBillDetailService billDetailService; + @Autowired + private IBillManageService billManageService; + @Autowired + private BillDetailMapper billDetailMapper; + @Autowired private BmsInvoiceListMapper bmsInvoiceListMapper; //nc测试环境地址 @@ -103,6 +115,8 @@ public class BillManageImpl extends ServiceImpl im private BmsMakeOutInvoiceMapper bmsMakeOutInvoiceMapper; @Resource private BmsMakeOutInvoiceItemMapper bmsMakeOutInvoiceItemMapper; + @Autowired + private ISettlementCustomersService settlementCustomersService; /** * 查询账单管理列表 */ @@ -177,7 +191,6 @@ public class BillManageImpl extends ServiceImpl im return true; } - public boolean synchronousNc_TY(String businessDocumentDetaliId) { BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); if(reconciliation.getSynchronousStatus()==1){ @@ -190,273 +203,310 @@ public class BillManageImpl extends ServiceImpl im SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); String dateString = sdf.format(date); String invoiceId = reconciliation.getInvoiceId(); - List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); - if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0){ - int count = 0; - for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { - count++; - List ysitemList=new ArrayList(); - String url = ""; - Long organizationId = reconciliation.getOrganizationId(); - String organizationName = reconciliation.getOrganizationName(); - String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); - if (ncUrl!=null&&ncUrl!="") { - url = ncUrl; - } else { - reconciliation.setSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - throw new ServiceException("未找到该组织的推送地址!"); - } - String salesmanId = reconciliation.getSalesmanId(); - String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); - String deptValue = billManageMapper.getDeptValue(customerUserDept); - String deptName = billManageMapper.getDeptName(customerUserDept); - String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); - String salesmanCodeNc=salespersonNcCode; - String appointShipper=make.getActualInvoiceCustomerName(); - String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); - String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); - String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); - if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { - ObjectMapper objectMapper = new ObjectMapper(); - List> listNc = objectMapper.readValue( - customerCodeNcJson, - new TypeReference>>() {} - ); - if (listNc != null && listNc.size() > 0) { - Map targetMap = listNc.stream() - .filter(map -> { - Object codeObj = map.get("code"); - return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); - }) - .findFirst() - .orElse(null); - if (targetMap != null) { - customerCodeNc = (String) targetMap.get("ncCustomer"); - } - } - } - String settlementCurrency=reconciliation.getSettlementCurrency(); - String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); - String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); - String makerCodeNc = documentPreparerNcCode; - String settlementCurrencyNcCode = settlementCurrency; - String invoiceNumber=make.getInvoiceNumber(); - List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); - if (bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0) { - for (BmsMakeOutInvoiceItem item1 : bmsMakeOutInvoiceItems) { - if(item1.getInvoiceValue().compareTo(BigDecimal.ZERO)>0){ - Ysitem item=new Ysitem(); - if (deptValue != null && !deptValue.isEmpty()) { - item.setSo_deptid(deptValue); - } else { - item.setSo_deptid("NG0408"); - } - if (deptValue != null && !deptValue.isEmpty()) { - item.setPk_deptid(deptValue); - } else { - item.setPk_deptid("NG0408"); - } - //业务员nc - item.setPk_psndoc(salesmanCodeNc); - //客户nc - item.setCustomer(customerCodeNc); - item.setObjtype("0"); - item.setDirection("1"); - String invoiceItem = item1.getInvoiceItem(); - List names = new ArrayList<>(); - List nccodes = new ArrayList<>(); - if (invoiceItem != null && !invoiceItem.isEmpty()) { - String[] items = invoiceItem.split(","); - for (String s : items) { - String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); - String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(s); - names.add(invoiceItemName1); - nccodes.add(invoiceItemNcCode1); - } - } - String invoiceItemName = String.join(",", names); - //item.setDef29(invoiceItemName); - if (deptName != null && !deptName.isEmpty()) { - item.setScomment(deptName+":应收"+appointShipper+invoiceItemName+invoiceNumber); - } else { - item.setScomment("业务部:应收"+appointShipper+invoiceItemName+invoiceNumber); - } - // item.setPk_currtype("CNY"); - item.setPk_currtype(settlementCurrencyNcCode); - item.setPurchaseorder(""); - item.setTaxrate(String.valueOf(item1.getTaxRate())); - item.setQuantity_de("0"); - item.setMoney_de(String.valueOf(item1.getInvoiceValue())); - item.setMoney_bal(String.valueOf(item1.getInvoiceValue())); - BigDecimal tax_de=item1.getTaxAmount(); - BigDecimal notax_de=item1.getTaxFreeFee(); - item.setNotax_de(String.valueOf(notax_de)); - item.setLocal_tax_de(String.valueOf(tax_de)); - item.setTax_de(String.valueOf(tax_de)); - item.setPrice(String.valueOf(item1.getInvoiceValue())); - item.setTaxprice(String.valueOf(item1.getInvoiceValue())); -// 费用类别 - String feeType = item1.getFeeType(); - String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); - if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { - item.setDef75(serviceItemsCodeNc); - } else { - item.setDef75("T04"); - } - String invoiceItem1 = item1.getInvoiceItem(); - if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { - String[] split = invoiceItem1.split(","); - item.setDef29(split[0]); - //item.setDef29(invoiceItem1); - } - if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { - item.setDef29(nccodes.get(0)); - } - item.setTaxcodeid("ZL01"); - item.setInvoiceno(invoiceNumber); - ysitemList.add(item); - } - } - } + List billDetails = billDetailService.getDetailsByBillManageIdAndGroup(Long.parseLong(businessDocumentDetaliId)); - Ysbodys bodys=new Ysbodys(); - bodys.setItem(ysitemList); - Ysbillhead billhead=new Ysbillhead(); - billhead.setPk_group("CNK"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - billhead.setPk_org(orgCodeNc); - billhead.setSett_org(orgCodeNc); - } else { - billhead.setPk_org("NG04"); - billhead.setSett_org("NG04"); - } - billhead.setCreationtime(dateString); - billhead.setCreator(makerCodeNc); - billhead.setPk_billtype("F0"); - billhead.setPk_tradetype("D0"); - billhead.setBillclass("ys"); - billhead.setIsinit("N"); - date=reconciliation.getCreateTime(); - dateString = sdf.format(date); - billhead.setBilldate(dateString); - billhead.setSyscode("0"); - billhead.setBillno(""); - billhead.setDef59(""); - billhead.setSrc_syscode("0"); - billhead.setBillstatus("0"); - billhead.setBillmaker(makerCodeNc); - billhead.setPk_busitype(""); - billhead.setBillyear(sdf1.format(date)); - billhead.setBillperiod(sdf2.format(date)); - billhead.setEffectstatus("0"); - billhead.setDef28("nqyw"); - billhead.setDef29(reconciliation.getBillNumber()); - billhead.setBodys(bodys); - Ysbill bill=new Ysbill(); - bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+count); - bill.setBillhead(billhead); - Ysufinterface ufinterface=new Ysufinterface(); - ufinterface.setAccount("NKNC"); - ufinterface.setBilltype("F0"); - ufinterface.setBusinessunitcode(""); - ufinterface.setFilename(""); - ufinterface.setIsexchange("Y"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - ufinterface.setOrgcode(orgCodeNc); - ufinterface.setReceiver(orgCodeNc); - } else { - ufinterface.setOrgcode("NG04"); - ufinterface.setReceiver("NG04"); - } - ufinterface.setReplace("Y"); - ufinterface.setRoottag(""); - ufinterface.setSender("nqyw"); - ufinterface.setBill(bill); - JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); - Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 - StringWriter sw = new StringWriter(); - marshaller.marshal(ufinterface, sw); - String xmlString = sw.toString(); // 这是要发送的XML字符串 - System.out.println(xmlString); - NcLog ncLog=new NcLog(); - ncLog.setOrderId(reconciliation.getBillManageId()); - ncLog.setRequestBody(xmlString); - ncLog.setResponeBody(""); - ncLog.setType(0L); - ncLog.setSendTime(new Date()); - ncLog.setOrganizationId(reconciliation.getOrganizationId()); - ncLog.setOrganizationName(reconciliation.getOrganizationName()); - ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); - ncLogMapper.insert(ncLog); - reconciliation.setSynchronousStatus(1); - reconciliation.setSynchronousTime(new Date()); - reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); - //reconciliationMapper.updateById(reconciliation); - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPost httpPost = new HttpPost(url); - StringEntity postingString = new StringEntity(xmlString, "UTF-8"); - httpPost.setEntity(postingString); - httpPost.setHeader("Content-type", "application/xml"); - try { - CloseableHttpResponse response = httpClient.execute(httpPost); - String responseString = EntityUtils.toString(response.getEntity()); - System.out.println(responseString); - ncLog.setResponeBody(responseString); - // 创建DOM解析器 - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document document = builder.parse(new InputSource(new StringReader(responseString))); - - // 获取根元素 - Element root = document.getDocumentElement(); - - // 获取ufinterface元素的属性 - String billtype = root.getAttribute("billtype"); - String filename = root.getAttribute("filename"); - System.out.println("billtype: " + billtype); - System.out.println("filename: " + filename); - - // 获取sendresult节点 - NodeList sendResultList = root.getElementsByTagName("sendresult"); - if (sendResultList.getLength() > 0) { - Element sendResult = (Element) sendResultList.item(0); - - // 获取子元素内容 - String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); - String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); - String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); - - System.out.println("bdocid: " + bdocid); - System.out.println("resultcode: " + resultcode); - System.out.println("content: " + content); - if(resultcode.equals("1")){ - reconciliation.setSynchronousStatus(1); - }else{ - reconciliation.setSynchronousStatus(2); - } - } - ncLogMapper.updateById(ncLog); - billManageMapper.updateById(reconciliation); - response.close(); - } catch (Exception e) { - reconciliation.setSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - e.printStackTrace(); - } finally { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + //保存税额等 + double allTaxRate = 0.0d; + BigDecimal allTaxAmount = BigDecimal.ZERO; + BigDecimal allTaxFreeFee = BigDecimal.ZERO; + for (BillDetail item : billDetails) { + String firstSubjectCode = item.getInvoiceItem(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = item.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + if (item.getTaxAmount() == null) { + item.setTaxAmount(taxAmount); } + if (item.getTaxFreeFee() == null) { + item.setTaxFreeFee(taxFreeFee); + } + if (item.getTaxRate() == null) { + item.setTaxRate(taxRate); + } + allTaxRate += taxRate; + allTaxAmount = allTaxAmount.add(taxAmount); + allTaxFreeFee = allTaxFreeFee.add(taxFreeFee); + } + + if (reconciliation.getTaxRate() == null) { + reconciliation.setTaxRate(allTaxRate); + } + if (reconciliation.getTaxAmount() == null) { + reconciliation.setTaxAmount(allTaxAmount); + } + if (reconciliation.getTaxFreeFee() == null) { + reconciliation.setTaxFreeFee(allTaxFreeFee); + } + + + List ysitemList=new ArrayList(); + String url = ""; + Long organizationId = reconciliation.getOrganizationId(); + String organizationName = reconciliation.getOrganizationName(); + String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); + if (ncUrl!=null&&ncUrl!="") { + url = ncUrl; } else { reconciliation.setSynchronousStatus(2); billManageMapper.updateById(reconciliation); + throw new ServiceException("未找到该组织的推送地址!"); } + String salesmanId = reconciliation.getSalesmanId(); + String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); + String deptValue = billManageMapper.getDeptValue(customerUserDept); + String deptName = billManageMapper.getDeptName(customerUserDept); + String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); + String salesmanCodeNc=salespersonNcCode; + + Long settlementCustomersId = reconciliation.getSettlementCustomersId(); + SettlementCustomers settlementCustomers = settlementCustomersService.getById(settlementCustomersId); + if (settlementCustomers==null){ + throw new ServiceException("结算对象未找到!"); + } + Long settlementEntityId = settlementCustomers.getSettlementEntityId(); + Long shipperId = billManageMapper.getShipperId(settlementEntityId, organizationId); + if (shipperId==null||shipperId==0){ + throw new ServiceException("结算对象未找到!"); + } + String appointShipper=settlementCustomers.getSettlementEntity(); + String actualInvoiceCustomerId = String.valueOf(shipperId); + String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); + String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); + if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { + ObjectMapper objectMapper = new ObjectMapper(); + List> listNc = objectMapper.readValue( + customerCodeNcJson, + new TypeReference>>() {} + ); + if (listNc != null && listNc.size() > 0) { + Map targetMap = listNc.stream() + .filter(map -> { + Object codeObj = map.get("code"); + return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); + }) + .findFirst() + .orElse(null); + if (targetMap != null) { + customerCodeNc = (String) targetMap.get("ncCustomer"); + } + } + } + String settlementCurrency=reconciliation.getSettlementCurrency(); + String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); + String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); + String makerCodeNc = documentPreparerNcCode; + String settlementCurrencyNcCode = settlementCurrency; + + if (billDetails!=null&&billDetails.size()>0){ + for (BillDetail make : billDetails) { + if(make.getBillingAmount().compareTo(BigDecimal.ZERO)>0){ + Ysitem item=new Ysitem(); + if (deptValue != null && !deptValue.isEmpty()) { + item.setSo_deptid(deptValue); + } else { + item.setSo_deptid("NG0408"); + } + if (deptValue != null && !deptValue.isEmpty()) { + item.setPk_deptid(deptValue); + } else { + item.setPk_deptid("NG0408"); + } + //业务员nc + item.setPk_psndoc(salesmanCodeNc); + //客户nc + item.setCustomer(customerCodeNc); + item.setObjtype("0"); + item.setDirection("1"); + String invoiceItem = make.getInvoiceItem(); + List names = new ArrayList<>(); + List nccodes = new ArrayList<>(); + if (invoiceItem != null && !invoiceItem.isEmpty()) { + String invoiceItemName1 = billManageMapper.getInvoiceItemName(invoiceItem); + String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(invoiceItem); + names.add(invoiceItemName1); + nccodes.add(invoiceItemNcCode1); + } + String invoiceItemName = make.getInvoiceItemName(); + //item.setDef29(invoiceItemName); + if (deptName != null && !deptName.isEmpty()) { + item.setScomment(deptName+":应收"+appointShipper+invoiceItemName); + } else { + item.setScomment("业务部:应收"+appointShipper+invoiceItemName); + } + if (settlementCurrencyNcCode != null && !settlementCurrencyNcCode.isEmpty()) { + item.setPk_currtype(settlementCurrencyNcCode); + } else { + item.setPk_currtype("CNY"); + } + item.setPurchaseorder(""); + item.setTaxrate(String.valueOf(make.getTaxRate())); + item.setQuantity_de("0"); + item.setMoney_de(String.valueOf(make.getBillingAmount())); + item.setMoney_bal(String.valueOf(make.getBillingAmount())); + BigDecimal tax_de=make.getTaxAmount(); + BigDecimal notax_de=make.getTaxFreeFee(); + item.setNotax_de(String.valueOf(notax_de)); + item.setLocal_tax_de(String.valueOf(tax_de)); + item.setTax_de(String.valueOf(tax_de)); + item.setPrice(String.valueOf(make.getBillingAmount())); + item.setTaxprice(String.valueOf(make.getBillingAmount())); + //费用类别 + String feeType = make.getFeeType(); + String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); + if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { + item.setDef75(serviceItemsCodeNc); + } else { + item.setDef75("T04"); + } + String invoiceItem1 = make.getInvoiceItem(); + if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { + item.setDef29(invoiceItem1); + } + if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { + item.setDef29(nccodes.get(0)); + } + item.setTaxcodeid("ZL01"); + item.setInvoiceno(""); + ysitemList.add(item); + } + } + } + + Ysbodys bodys=new Ysbodys(); + bodys.setItem(ysitemList); + Ysbillhead billhead=new Ysbillhead(); + billhead.setPk_group("CNK"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + billhead.setPk_org(orgCodeNc); + billhead.setSett_org(orgCodeNc); + } else { + billhead.setPk_org("NG04"); + billhead.setSett_org("NG04"); + } + billhead.setCreationtime(dateString); + billhead.setCreator(makerCodeNc); + billhead.setPk_billtype("F0"); + billhead.setPk_tradetype("D0"); + billhead.setBillclass("ys"); + billhead.setIsinit("N"); + date=reconciliation.getCreateTime(); + dateString = sdf.format(date); + billhead.setBilldate(dateString); + billhead.setSyscode("0"); + billhead.setBillno(""); + billhead.setDef59(""); + billhead.setSrc_syscode("0"); + billhead.setBillstatus("0"); + billhead.setBillmaker(makerCodeNc); + billhead.setPk_busitype(""); + billhead.setBillyear(sdf1.format(date)); + billhead.setBillperiod(sdf2.format(date)); + billhead.setEffectstatus("0"); + billhead.setDef28("nqyw"); + billhead.setDef29(reconciliation.getBillNumber()); + billhead.setBodys(bodys); + Ysbill bill=new Ysbill(); + bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+1); + bill.setBillhead(billhead); + Ysufinterface ufinterface=new Ysufinterface(); + ufinterface.setAccount("NKNC"); + ufinterface.setBilltype("F0"); + ufinterface.setBusinessunitcode(""); + ufinterface.setFilename(""); + ufinterface.setIsexchange("Y"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + ufinterface.setOrgcode(orgCodeNc); + ufinterface.setReceiver(orgCodeNc); + } else { + ufinterface.setOrgcode("NG04"); + ufinterface.setReceiver("NG04"); + } + ufinterface.setReplace("Y"); + ufinterface.setRoottag(""); + ufinterface.setSender("nqyw"); + ufinterface.setBill(bill); + JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 + StringWriter sw = new StringWriter(); + marshaller.marshal(ufinterface, sw); + String xmlString = sw.toString(); // 这是要发送的XML字符串 + System.out.println(xmlString); + NcLog ncLog=new NcLog(); + ncLog.setOrderId(reconciliation.getBillManageId()); + ncLog.setRequestBody(xmlString); + ncLog.setResponeBody(""); + ncLog.setType(0L); + ncLog.setSendTime(new Date()); + ncLog.setOrganizationId(reconciliation.getOrganizationId()); + ncLog.setOrganizationName(reconciliation.getOrganizationName()); + ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); + ncLogMapper.insert(ncLog); + reconciliation.setSynchronousStatus(1); + reconciliation.setSynchronousTime(new Date()); + reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); + //reconciliationMapper.updateById(reconciliation); + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + StringEntity postingString = new StringEntity(xmlString, "UTF-8"); + httpPost.setEntity(postingString); + httpPost.setHeader("Content-type", "application/xml"); + try { + CloseableHttpResponse response = httpClient.execute(httpPost); + String responseString = EntityUtils.toString(response.getEntity()); + System.out.println(responseString); + ncLog.setResponeBody(responseString); + // 创建DOM解析器 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document document = builder.parse(new InputSource(new StringReader(responseString))); + + // 获取根元素 + Element root = document.getDocumentElement(); + + // 获取ufinterface元素的属性 + String billtype = root.getAttribute("billtype"); + String filename = root.getAttribute("filename"); + System.out.println("billtype: " + billtype); + System.out.println("filename: " + filename); + + // 获取sendresult节点 + NodeList sendResultList = root.getElementsByTagName("sendresult"); + if (sendResultList.getLength() > 0) { + Element sendResult = (Element) sendResultList.item(0); + + // 获取子元素内容 + String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); + String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); + String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); + + System.out.println("bdocid: " + bdocid); + System.out.println("resultcode: " + resultcode); + System.out.println("content: " + content); + if(resultcode.equals("1")){ + reconciliation.setSynchronousStatus(1); + }else{ + reconciliation.setSynchronousStatus(2); + } + } + ncLogMapper.updateById(ncLog); + billManageMapper.updateById(reconciliation); + response.close(); + } catch (Exception e) { + reconciliation.setSynchronousStatus(2); + billManageMapper.updateById(reconciliation); + e.printStackTrace(); + } finally { + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } catch (JAXBException e) { reconciliation.setSynchronousStatus(2); billManageMapper.updateById(reconciliation); @@ -469,6 +519,298 @@ public class BillManageImpl extends ServiceImpl im return true; } + //按发票推送版本 +// public boolean synchronousNc_TY(String businessDocumentDetaliId) { +// BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); +// if(reconciliation.getSynchronousStatus()==1){ +// throw new ServiceException("该记录已同步,不需要再次同步"); +// } +// try { +// Date date = reconciliation.getCreateTime(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); +// SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); +// String dateString = sdf.format(date); +// String invoiceId = reconciliation.getInvoiceId(); +// List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); +// if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0){ +// int count = 0; +// for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { +// count++; +// List ysitemList=new ArrayList(); +// String url = ""; +// Long organizationId = reconciliation.getOrganizationId(); +// String organizationName = reconciliation.getOrganizationName(); +// String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); +// if (ncUrl!=null&&ncUrl!="") { +// url = ncUrl; +// } else { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// throw new ServiceException("未找到该组织的推送地址!"); +// } +// String salesmanId = reconciliation.getSalesmanId(); +// String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); +// String deptValue = billManageMapper.getDeptValue(customerUserDept); +// String deptName = billManageMapper.getDeptName(customerUserDept); +// String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); +// String salesmanCodeNc=salespersonNcCode; +// String appointShipper=make.getActualInvoiceCustomerName(); +// String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); +// String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); +// String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); +// if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { +// ObjectMapper objectMapper = new ObjectMapper(); +// List> listNc = objectMapper.readValue( +// customerCodeNcJson, +// new TypeReference>>() {} +// ); +// if (listNc != null && listNc.size() > 0) { +// Map targetMap = listNc.stream() +// .filter(map -> { +// Object codeObj = map.get("code"); +// return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); +// }) +// .findFirst() +// .orElse(null); +// if (targetMap != null) { +// customerCodeNc = (String) targetMap.get("ncCustomer"); +// } +// } +// } +// String settlementCurrency=reconciliation.getSettlementCurrency(); +// String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); +// String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); +// String makerCodeNc = documentPreparerNcCode; +// String settlementCurrencyNcCode = settlementCurrency; +// String invoiceNumber=make.getInvoiceNumber(); +// List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); +// if (bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0) { +// for (BmsMakeOutInvoiceItem item1 : bmsMakeOutInvoiceItems) { +// if(item1.getInvoiceValue().compareTo(BigDecimal.ZERO)>0){ +// Ysitem item=new Ysitem(); +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setSo_deptid(deptValue); +// } else { +// item.setSo_deptid("NG0408"); +// } +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setPk_deptid(deptValue); +// } else { +// item.setPk_deptid("NG0408"); +// } +// //业务员nc +// item.setPk_psndoc(salesmanCodeNc); +// //客户nc +// item.setCustomer(customerCodeNc); +// item.setObjtype("0"); +// item.setDirection("1"); +// String invoiceItem = item1.getInvoiceItem(); +// List names = new ArrayList<>(); +// List nccodes = new ArrayList<>(); +// if (invoiceItem != null && !invoiceItem.isEmpty()) { +// String[] items = invoiceItem.split(","); +// for (String s : items) { +// String invoiceItemName1 = billManageMapper.getInvoiceItemName(s); +// String invoiceItemNcCode1 = billManageMapper.getInvoiceItemNcCode(s); +// names.add(invoiceItemName1); +// nccodes.add(invoiceItemNcCode1); +// } +// } +// String invoiceItemName = String.join(",", names); +// //item.setDef29(invoiceItemName); +// if (deptName != null && !deptName.isEmpty()) { +// item.setScomment(deptName+":应收"+appointShipper+invoiceItemName+invoiceNumber); +// } else { +// item.setScomment("业务部:应收"+appointShipper+invoiceItemName+invoiceNumber); +// } +// // item.setPk_currtype("CNY"); +// item.setPk_currtype(settlementCurrencyNcCode); +// item.setPurchaseorder(""); +// item.setTaxrate(String.valueOf(item1.getTaxRate())); +// item.setQuantity_de("0"); +// item.setMoney_de(String.valueOf(item1.getInvoiceValue())); +// item.setMoney_bal(String.valueOf(item1.getInvoiceValue())); +// BigDecimal tax_de=item1.getTaxAmount(); +// BigDecimal notax_de=item1.getTaxFreeFee(); +// item.setNotax_de(String.valueOf(notax_de)); +// item.setLocal_tax_de(String.valueOf(tax_de)); +// item.setTax_de(String.valueOf(tax_de)); +// item.setPrice(String.valueOf(item1.getInvoiceValue())); +// item.setTaxprice(String.valueOf(item1.getInvoiceValue())); +//// 费用类别 +// String feeType = item1.getFeeType(); +// String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); +// if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { +// item.setDef75(serviceItemsCodeNc); +// } else { +// item.setDef75("T04"); +// } +// String invoiceItem1 = item1.getInvoiceItem(); +// if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { +// String[] split = invoiceItem1.split(","); +// item.setDef29(split[0]); +// //item.setDef29(invoiceItem1); +// } +// if (nccodes != null && !nccodes.isEmpty()&&nccodes.size()>0) { +// item.setDef29(nccodes.get(0)); +// } +// item.setTaxcodeid("ZL01"); +// item.setInvoiceno(invoiceNumber); +// ysitemList.add(item); +// } +// } +// } +// +// Ysbodys bodys=new Ysbodys(); +// bodys.setItem(ysitemList); +// Ysbillhead billhead=new Ysbillhead(); +// billhead.setPk_group("CNK"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// billhead.setPk_org(orgCodeNc); +// billhead.setSett_org(orgCodeNc); +// } else { +// billhead.setPk_org("NG04"); +// billhead.setSett_org("NG04"); +// } +// billhead.setCreationtime(dateString); +// billhead.setCreator(makerCodeNc); +// billhead.setPk_billtype("F0"); +// billhead.setPk_tradetype("D0"); +// billhead.setBillclass("ys"); +// billhead.setIsinit("N"); +// date=reconciliation.getCreateTime(); +// dateString = sdf.format(date); +// billhead.setBilldate(dateString); +// billhead.setSyscode("0"); +// billhead.setBillno(""); +// billhead.setDef59(""); +// billhead.setSrc_syscode("0"); +// billhead.setBillstatus("0"); +// billhead.setBillmaker(makerCodeNc); +// billhead.setPk_busitype(""); +// billhead.setBillyear(sdf1.format(date)); +// billhead.setBillperiod(sdf2.format(date)); +// billhead.setEffectstatus("0"); +// billhead.setDef28("nqyw"); +// billhead.setDef29(reconciliation.getBillNumber()); +// billhead.setBodys(bodys); +// Ysbill bill=new Ysbill(); +// bill.setId("ys"+String.valueOf(reconciliation.getBillManageId())+"_"+count); +// bill.setBillhead(billhead); +// Ysufinterface ufinterface=new Ysufinterface(); +// ufinterface.setAccount("NKNC"); +// ufinterface.setBilltype("F0"); +// ufinterface.setBusinessunitcode(""); +// ufinterface.setFilename(""); +// ufinterface.setIsexchange("Y"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// ufinterface.setOrgcode(orgCodeNc); +// ufinterface.setReceiver(orgCodeNc); +// } else { +// ufinterface.setOrgcode("NG04"); +// ufinterface.setReceiver("NG04"); +// } +// ufinterface.setReplace("Y"); +// ufinterface.setRoottag(""); +// ufinterface.setSender("nqyw"); +// ufinterface.setBill(bill); +// JAXBContext jaxbContext = JAXBContext.newInstance(Ysufinterface.class); +// Marshaller marshaller = jaxbContext.createMarshaller(); +// marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); +// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 +// StringWriter sw = new StringWriter(); +// marshaller.marshal(ufinterface, sw); +// String xmlString = sw.toString(); // 这是要发送的XML字符串 +// System.out.println(xmlString); +// NcLog ncLog=new NcLog(); +// ncLog.setOrderId(reconciliation.getBillManageId()); +// ncLog.setRequestBody(xmlString); +// ncLog.setResponeBody(""); +// ncLog.setType(0L); +// ncLog.setSendTime(new Date()); +// ncLog.setOrganizationId(reconciliation.getOrganizationId()); +// ncLog.setOrganizationName(reconciliation.getOrganizationName()); +// ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); +// ncLogMapper.insert(ncLog); +// reconciliation.setSynchronousStatus(1); +// reconciliation.setSynchronousTime(new Date()); +// reconciliation.setNcId("ys"+String.valueOf(reconciliation.getBillManageId())); +// //reconciliationMapper.updateById(reconciliation); +// CloseableHttpClient httpClient = HttpClients.createDefault(); +// HttpPost httpPost = new HttpPost(url); +// StringEntity postingString = new StringEntity(xmlString, "UTF-8"); +// httpPost.setEntity(postingString); +// httpPost.setHeader("Content-type", "application/xml"); +// try { +// CloseableHttpResponse response = httpClient.execute(httpPost); +// String responseString = EntityUtils.toString(response.getEntity()); +// System.out.println(responseString); +// ncLog.setResponeBody(responseString); +// // 创建DOM解析器 +// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +// DocumentBuilder builder = factory.newDocumentBuilder(); +// Document document = builder.parse(new InputSource(new StringReader(responseString))); +// +// // 获取根元素 +// Element root = document.getDocumentElement(); +// +// // 获取ufinterface元素的属性 +// String billtype = root.getAttribute("billtype"); +// String filename = root.getAttribute("filename"); +// System.out.println("billtype: " + billtype); +// System.out.println("filename: " + filename); +// +// // 获取sendresult节点 +// NodeList sendResultList = root.getElementsByTagName("sendresult"); +// if (sendResultList.getLength() > 0) { +// Element sendResult = (Element) sendResultList.item(0); +// +// // 获取子元素内容 +// String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); +// String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); +// String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); +// +// System.out.println("bdocid: " + bdocid); +// System.out.println("resultcode: " + resultcode); +// System.out.println("content: " + content); +// if(resultcode.equals("1")){ +// reconciliation.setSynchronousStatus(1); +// }else{ +// reconciliation.setSynchronousStatus(2); +// } +// } +// ncLogMapper.updateById(ncLog); +// billManageMapper.updateById(reconciliation); +// response.close(); +// } catch (Exception e) { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } finally { +// try { +// httpClient.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// } else { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// } +// } catch (JAXBException e) { +// reconciliation.setSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } catch (JsonMappingException e) { +// throw new RuntimeException(e); +// } catch (JsonProcessingException e) { +// throw new RuntimeException(e); +// } +// return true; +// } + @Override public boolean synchronousNcSK(String businessDocumentDetaliIds) { String [] businessDocumentDetaliIdArray=businessDocumentDetaliIds.split(","); @@ -500,273 +842,314 @@ public class BillManageImpl extends ServiceImpl im SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); String dateString = sdf.format(date); - String invoiceId = reconciliation.getInvoiceId(); - ReconciliationDTO makeQuery=new ReconciliationDTO(); - makeQuery.setInnerNumber(invoiceId); - List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); - if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0) { - int count= 0; - for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { - count++; - List ysitemList=new ArrayList(); - ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); - reconciliationDTO.setInnerNumber(reconciliation.getBillNumber()); - String url = ""; - Long organizationId = reconciliation.getOrganizationId(); - String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); - String organizationName = reconciliation.getOrganizationName(); - String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); - if (ncUrl!=null&&ncUrl!="") { - url = ncUrl; - } else { - reconciliation.setSkSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - throw new ServiceException("未找到该组织的推送地址!"); - } - List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); - String makerCodeNc = ""; - if(bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0){ - if(ObjectUtil.isNotNull(bmsMakeOutInvoiceItems)){ - // 汇总 list 中 invoiceValue 的总值 - BigDecimal totalInvoiceValue = bmsMakeOutInvoiceItems.stream() - .map(BmsMakeOutInvoiceItem::getInvoiceValue) - .filter(java.util.Objects::nonNull) - .reduce(BigDecimal.ZERO, BigDecimal::add); + List billDetails = billDetailService.list(new LambdaQueryWrapper() + .eq(BillDetail::getBillManageId, reconciliation.getBillManageId()) + .eq(BillDetail::getDelFlag, 1)); - // 将 feeType 用、拼接起来 - String feeTypes = bmsMakeOutInvoiceItems.stream() - .map(BmsMakeOutInvoiceItem::getFeeType) - .filter(java.util.Objects::nonNull) - .collect(java.util.stream.Collectors.joining("、")); - - // 按 createTime 倒序排序并获取第一条记录 - BmsMakeOutInvoiceItem firstItem = bmsMakeOutInvoiceItems.stream() - .sorted((a, b) -> { - if (a.getCreateTime() == null) return 1; - if (b.getCreateTime() == null) return -1; - return b.getCreateTime().compareTo(a.getCreateTime()); - }) - .findFirst() - .orElse(null); - String salesmanId = reconciliation.getSalesmanId(); - String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); - String deptValue = billManageMapper.getDeptValue(customerUserDept); - String deptName = billManageMapper.getDeptName(customerUserDept); - String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); - String salesmanCodeNc=salespersonNcCode; - String appointShipper=make.getActualInvoiceCustomerName(); - String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); - String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); - String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); - if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { - ObjectMapper objectMapper = new ObjectMapper(); - List> listNc = objectMapper.readValue( - customerCodeNcJson, - new TypeReference>>() {} - ); - if (listNc != null && listNc.size() > 0) { - Map targetMap = listNc.stream() - .filter(map -> { - Object codeObj = map.get("code"); - return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); - }) - .findFirst() - .orElse(null); - if (targetMap != null) { - customerCodeNc = (String) targetMap.get("ncCustomer"); - } - } - } - String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); - String settlementCurrency=reconciliation.getSettlementCurrency(); - String settlementCurrencyNcCode = settlementCurrency; - makerCodeNc=documentPreparerNcCode; - SKitem item=new SKitem(); - if (deptValue != null && !deptValue.isEmpty()) { - item.setSo_deptid(deptValue); - } else { - item.setSo_deptid("NG0408"); - } - if (deptValue != null && !deptValue.isEmpty()) { - item.setPk_deptid(deptValue); - } else { - item.setPk_deptid("NG0408"); - } - item.setCheckdirection("ar"); - item.setPk_psndoc(salesmanCodeNc); - item.setCustomer(customerCodeNc); - item.setPurchaseorder(""); - item.setObjtype("0"); - item.setDirection("1"); - if (deptName != null && !deptName.isEmpty()) { - if (feeTypes != null && !feeTypes.isEmpty()) { - item.setScomment(deptName+":"+appointShipper+feeTypes); - } else { - item.setScomment(deptName+":"+appointShipper+feeTypes); - } - } else { - if (feeTypes != null && !feeTypes.isEmpty()) { - item.setScomment("业务部:"+appointShipper+feeTypes); - } else { - item.setScomment("业务部:"+appointShipper+feeTypes); - } - } - // 费用类别 - String feeType = firstItem.getFeeType(); - String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); - if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { - item.setDef75(serviceItemsCodeNc); - } else { - item.setDef75("T10"); - } - String invoiceItem1 = firstItem.getInvoiceItem(); - if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { - String[] split = invoiceItem1.split(","); - item.setDef29(split[0]); - } - item.setPk_currtype(settlementCurrencyNcCode); - item.setMoney_cr(String.valueOf(totalInvoiceValue)); - item.setMoney_bal(String.valueOf(totalInvoiceValue)); - ysitemList.add(item); - } - } - SKbodys bodys=new SKbodys(); - bodys.setItem(ysitemList); - SKbillhead billhead=new SKbillhead(); - billhead.setPk_group("CNK"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - billhead.setPk_org(orgCodeNc); - billhead.setSett_org(orgCodeNc); - } else { - billhead.setPk_org("NG04"); - billhead.setSett_org("NG04"); - } - billhead.setCreationtime(dateString); - billhead.setPk_billtype("F2"); - billhead.setCreator(makerCodeNc); - billhead.setPk_tradetype("D2"); - billhead.setBillclass("sk"); - billhead.setBilldate(dateString); - billhead.setSyscode("0"); - billhead.setBillno(""); - billhead.setDef59(""); - billhead.setSrc_syscode("0"); - billhead.setBillstatus("0"); - billhead.setBillmaker(makerCodeNc); - billhead.setPk_busitype(""); - billhead.setBillyear(sdf1.format(date)); - billhead.setBillperiod(sdf2.format(date)); - billhead.setEffectstatus("0"); - billhead.setDef28("nqyw"); - billhead.setDef29(reconciliation.getBillNumber()); - billhead.setBodys(bodys); - SKbill bill=new SKbill(); - bill.setId("sk"+String.valueOf(reconciliation.getBillManageId())+"_"+count); - bill.setBillhead(billhead); - SKufinterface ufinterface=new SKufinterface(); - ufinterface.setAccount("NKNC"); - ufinterface.setBilltype("F2"); - ufinterface.setBusinessunitcode(""); - ufinterface.setFilename(""); - ufinterface.setIsexchange("Y"); - if (orgCodeNc != null && !orgCodeNc.isEmpty()) { - ufinterface.setOrgcode(orgCodeNc); - ufinterface.setReceiver(orgCodeNc); - } else { - ufinterface.setOrgcode("NG04"); - ufinterface.setReceiver("NG04"); - } - ufinterface.setReplace("Y"); - ufinterface.setRoottag(""); - ufinterface.setSender("nqyw"); - ufinterface.setBill(bill); - JAXBContext jaxbContext = null; - //String xmlString =""; - jaxbContext = JAXBContext.newInstance(SKufinterface.class); - Marshaller marshaller = jaxbContext.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 - StringWriter sw = new StringWriter(); - marshaller.marshal(ufinterface, sw); - String xmlString = sw.toString(); // 这是要发送的XML字符串 - System.out.println(xmlString); - NcLog ncLog=new NcLog(); - ncLog.setOrderId(reconciliation.getBillManageId()); - ncLog.setRequestBody(xmlString); - ncLog.setResponeBody(""); - ncLog.setType(1L); - ncLog.setSendTime(new Date()); - ncLog.setOrganizationId(reconciliation.getOrganizationId()); - ncLog.setOrganizationName(reconciliation.getOrganizationName()); - ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); - ncLogMapper.insert(ncLog); - reconciliation.setSkSynchronousStatus(1); - reconciliation.setSkSynchronousTime(new Date()); - reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getBillManageId())); - //reconciliationMapper.updateById(reconciliation); - CloseableHttpClient httpClient = HttpClients.createDefault(); - HttpPost httpPost = new HttpPost(url); - StringEntity postingString = new StringEntity(xmlString, "UTF-8"); - httpPost.setEntity(postingString); - httpPost.setHeader("Content-type", "application/xml"); - try { - CloseableHttpResponse response = httpClient.execute(httpPost); - String responseString = EntityUtils.toString(response.getEntity()); - System.out.println(responseString); - ncLog.setResponeBody(responseString); - // 创建DOM解析器 - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document document = builder.parse(new InputSource(new StringReader(responseString))); - - // 获取根元素 - Element root = document.getDocumentElement(); - - // 获取ufinterface元素的属性 - String billtype = root.getAttribute("billtype"); - String filename = root.getAttribute("filename"); - System.out.println("billtype: " + billtype); - System.out.println("filename: " + filename); - - // 获取sendresult节点 - NodeList sendResultList = root.getElementsByTagName("sendresult"); - if (sendResultList.getLength() > 0) { - Element sendResult = (Element) sendResultList.item(0); - - // 获取子元素内容 - String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); - String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); - String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); - - System.out.println("bdocid: " + bdocid); - System.out.println("resultcode: " + resultcode); - System.out.println("content: " + content); - if(resultcode.equals("1")){ - reconciliation.setSkSynchronousStatus(1); - }else{ - reconciliation.setSkSynchronousStatus(2); - } - } - ncLogMapper.updateById(ncLog); - billManageMapper.updateById(reconciliation); - response.close(); - } catch (Exception e) { - reconciliation.setSkSynchronousStatus(2); - billManageMapper.updateById(reconciliation); - e.printStackTrace(); - } finally { - try { - httpClient.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + //保存税额等 + double allTaxRate = 0.0d; + BigDecimal allTaxAmount = BigDecimal.ZERO; + BigDecimal allTaxFreeFee = BigDecimal.ZERO; + for (BillDetail item : billDetails) { + String firstSubjectCode = item.getInvoiceItem(); + Double taxRate = billDetailMapper.getTaxRate(firstSubjectCode); + BigDecimal amount = item.getBillingAmount(); + BigDecimal taxAmount = amount.divide(BigDecimal.ONE.add(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))),10, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(taxRate).divide(BigDecimal.valueOf(100))).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal taxFreeFee = amount.subtract(taxAmount); + if (item.getTaxAmount() == null) { + item.setTaxAmount(taxAmount); } + if (item.getTaxFreeFee() == null) { + item.setTaxFreeFee(taxFreeFee); + } + if (item.getTaxRate() == null) { + item.setTaxRate(taxRate); + } + allTaxRate += taxRate; + allTaxAmount = allTaxAmount.add(taxAmount); + allTaxFreeFee = allTaxFreeFee.add(taxFreeFee); + } + + if (reconciliation.getTaxRate() == null) { + reconciliation.setTaxRate(allTaxRate); + } + if (reconciliation.getTaxAmount() == null) { + reconciliation.setTaxAmount(allTaxAmount); + } + if (reconciliation.getTaxFreeFee() == null) { + reconciliation.setTaxFreeFee(allTaxFreeFee); + } + + List ysitemList=new ArrayList(); + ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); + reconciliationDTO.setInnerNumber(reconciliation.getBillNumber()); + String url = ""; + Long organizationId = reconciliation.getOrganizationId(); + String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); + String organizationName = reconciliation.getOrganizationName(); + String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); + if (ncUrl!=null&&ncUrl!="") { + url = ncUrl; } else { reconciliation.setSkSynchronousStatus(2); billManageMapper.updateById(reconciliation); + throw new ServiceException("未找到该组织的推送地址!"); } + String makerCodeNc = ""; + if(billDetails != null && billDetails.size() > 0){ + if(ObjectUtil.isNotNull(billDetails)){ + // 汇总 list 中 invoiceValue 的总值 + BigDecimal totalInvoiceValue = billDetails.stream() + .map(BillDetail::getBillingAmount) + .filter(java.util.Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 将 feeType 用、拼接起来 + String feeTypes = billDetails.stream() + .map(BillDetail::getInvoiceItemName) + .filter(java.util.Objects::nonNull) + .collect(java.util.stream.Collectors.joining("、")); + + // 按 createTime 倒序排序并获取第一条记录 + BillDetail firstItem = billDetails.stream() + .sorted((a, b) -> { + if (a.getCreateTime() == null) return 1; + if (b.getCreateTime() == null) return -1; + return b.getCreateTime().compareTo(a.getCreateTime()); + }) + .findFirst() + .orElse(null); + String salesmanId = reconciliation.getSalesmanId(); + String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); + String deptValue = billManageMapper.getDeptValue(customerUserDept); + String deptName = billManageMapper.getDeptName(customerUserDept); + String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); + String salesmanCodeNc=salespersonNcCode; + Long settlementCustomersId = reconciliation.getSettlementCustomersId(); + SettlementCustomers settlementCustomers = settlementCustomersService.getById(settlementCustomersId); + if (settlementCustomers==null){ + throw new ServiceException("结算对象未找到!"); + } + Long settlementEntityId = settlementCustomers.getSettlementEntityId(); + Long shipperId = billManageMapper.getShipperId(settlementEntityId, organizationId); + if (shipperId==null||shipperId==0){ + throw new ServiceException("结算对象未找到!"); + } + String appointShipper=settlementCustomers.getSettlementEntity(); + String actualInvoiceCustomerId = String.valueOf(shipperId); + String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); + String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); + if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { + ObjectMapper objectMapper = new ObjectMapper(); + List> listNc = objectMapper.readValue( + customerCodeNcJson, + new TypeReference>>() {} + ); + if (listNc != null && listNc.size() > 0) { + Map targetMap = listNc.stream() + .filter(map -> { + Object codeObj = map.get("code"); + return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); + }) + .findFirst() + .orElse(null); + if (targetMap != null) { + customerCodeNc = (String) targetMap.get("ncCustomer"); + } + } + } + String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); + String settlementCurrency=reconciliation.getSettlementCurrency(); + String settlementCurrencyNcCode = settlementCurrency; + makerCodeNc=documentPreparerNcCode; + SKitem item=new SKitem(); + if (deptValue != null && !deptValue.isEmpty()) { + item.setSo_deptid(deptValue); + } else { + item.setSo_deptid("NG0408"); + } + if (deptValue != null && !deptValue.isEmpty()) { + item.setPk_deptid(deptValue); + } else { + item.setPk_deptid("NG0408"); + } + item.setCheckdirection("ar"); + item.setPk_psndoc(salesmanCodeNc); + item.setCustomer(customerCodeNc); + item.setPurchaseorder(""); + item.setObjtype("0"); + item.setDirection("1"); + if (deptName != null && !deptName.isEmpty()) { + if (feeTypes != null && !feeTypes.isEmpty()) { + item.setScomment(deptName+":"+appointShipper+feeTypes); + } else { + item.setScomment(deptName+":"+appointShipper+feeTypes); + } + } else { + if (feeTypes != null && !feeTypes.isEmpty()) { + item.setScomment("业务部:"+appointShipper+feeTypes); + } else { + item.setScomment("业务部:"+appointShipper+feeTypes); + } + } + // 费用类别 + String feeType = firstItem.getFeeType(); + String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); + if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { + item.setDef75(serviceItemsCodeNc); + } else { + item.setDef75("T10"); + } + String invoiceItem1 = firstItem.getInvoiceItem(); + if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { + String[] split = invoiceItem1.split(","); + item.setDef29(split[0]); + } + if (settlementCurrencyNcCode != null && !settlementCurrencyNcCode.isEmpty()) { + item.setPk_currtype(settlementCurrencyNcCode); + } else { + item.setPk_currtype("CNY"); + } + item.setMoney_cr(String.valueOf(totalInvoiceValue)); + item.setMoney_bal(String.valueOf(totalInvoiceValue)); + ysitemList.add(item); + } + } + SKbodys bodys=new SKbodys(); + bodys.setItem(ysitemList); + SKbillhead billhead=new SKbillhead(); + billhead.setPk_group("CNK"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + billhead.setPk_org(orgCodeNc); + billhead.setSett_org(orgCodeNc); + } else { + billhead.setPk_org("NG04"); + billhead.setSett_org("NG04"); + } + billhead.setCreationtime(dateString); + billhead.setPk_billtype("F2"); + billhead.setCreator(makerCodeNc); + billhead.setPk_tradetype("D2"); + billhead.setBillclass("sk"); + billhead.setBilldate(dateString); + billhead.setSyscode("0"); + billhead.setBillno(""); + billhead.setDef59(""); + billhead.setSrc_syscode("0"); + billhead.setBillstatus("0"); + billhead.setBillmaker(makerCodeNc); + billhead.setPk_busitype(""); + billhead.setBillyear(sdf1.format(date)); + billhead.setBillperiod(sdf2.format(date)); + billhead.setEffectstatus("0"); + billhead.setDef28("nqyw"); + billhead.setDef29(reconciliation.getBillNumber()); + billhead.setBodys(bodys); + SKbill bill=new SKbill(); + bill.setId("sk"+String.valueOf(reconciliation.getBillManageId())+"_"+1); + bill.setBillhead(billhead); + SKufinterface ufinterface=new SKufinterface(); + ufinterface.setAccount("NKNC"); + ufinterface.setBilltype("F2"); + ufinterface.setBusinessunitcode(""); + ufinterface.setFilename(""); + ufinterface.setIsexchange("Y"); + if (orgCodeNc != null && !orgCodeNc.isEmpty()) { + ufinterface.setOrgcode(orgCodeNc); + ufinterface.setReceiver(orgCodeNc); + } else { + ufinterface.setOrgcode("NG04"); + ufinterface.setReceiver("NG04"); + } + ufinterface.setReplace("Y"); + ufinterface.setRoottag(""); + ufinterface.setSender("nqyw"); + ufinterface.setBill(bill); + JAXBContext jaxbContext = null; + //String xmlString =""; + jaxbContext = JAXBContext.newInstance(SKufinterface.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 + StringWriter sw = new StringWriter(); + marshaller.marshal(ufinterface, sw); + String xmlString = sw.toString(); // 这是要发送的XML字符串 + System.out.println(xmlString); + NcLog ncLog=new NcLog(); + ncLog.setOrderId(reconciliation.getBillManageId()); + ncLog.setRequestBody(xmlString); + ncLog.setResponeBody(""); + ncLog.setType(1L); + ncLog.setSendTime(new Date()); + ncLog.setOrganizationId(reconciliation.getOrganizationId()); + ncLog.setOrganizationName(reconciliation.getOrganizationName()); + ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); + ncLogMapper.insert(ncLog); + reconciliation.setSkSynchronousStatus(1); + reconciliation.setSkSynchronousTime(new Date()); + reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getBillManageId())); + //reconciliationMapper.updateById(reconciliation); + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + StringEntity postingString = new StringEntity(xmlString, "UTF-8"); + httpPost.setEntity(postingString); + httpPost.setHeader("Content-type", "application/xml"); + try { + CloseableHttpResponse response = httpClient.execute(httpPost); + String responseString = EntityUtils.toString(response.getEntity()); + System.out.println(responseString); + ncLog.setResponeBody(responseString); + // 创建DOM解析器 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document document = builder.parse(new InputSource(new StringReader(responseString))); + + // 获取根元素 + Element root = document.getDocumentElement(); + + // 获取ufinterface元素的属性 + String billtype = root.getAttribute("billtype"); + String filename = root.getAttribute("filename"); + System.out.println("billtype: " + billtype); + System.out.println("filename: " + filename); + + // 获取sendresult节点 + NodeList sendResultList = root.getElementsByTagName("sendresult"); + if (sendResultList.getLength() > 0) { + Element sendResult = (Element) sendResultList.item(0); + + // 获取子元素内容 + String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); + String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); + String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); + + System.out.println("bdocid: " + bdocid); + System.out.println("resultcode: " + resultcode); + System.out.println("content: " + content); + if(resultcode.equals("1")){ + reconciliation.setSkSynchronousStatus(1); + }else{ + reconciliation.setSkSynchronousStatus(2); + } + } + ncLogMapper.updateById(ncLog); + billManageMapper.updateById(reconciliation); + response.close(); + } catch (Exception e) { + reconciliation.setSkSynchronousStatus(2); + billManageMapper.updateById(reconciliation); + e.printStackTrace(); + } finally { + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + } catch (JAXBException e) { reconciliation.setSkSynchronousStatus(2); billManageMapper.updateById(reconciliation); @@ -778,6 +1161,297 @@ public class BillManageImpl extends ServiceImpl im } return true; } + + //按发票推送版本 +// public boolean synchronousNcSK_TY(String businessDocumentDetaliId) { +// BillManage reconciliation=billManageMapper.selectById(businessDocumentDetaliId); +// if(reconciliation.getSkSynchronousStatus()==1){ +// throw new ServiceException("该记录已同步,不需要再次同步"); +// } +// try { +// Date date = reconciliation.getCreateTime(); +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); +// SimpleDateFormat sdf2 = new SimpleDateFormat("MM"); +// String dateString = sdf.format(date); +// String invoiceId = reconciliation.getInvoiceId(); +// ReconciliationDTO makeQuery=new ReconciliationDTO(); +// makeQuery.setInnerNumber(invoiceId); +// List bmsMakeOutInvoices = bmsMakeOutInvoiceMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoice::getInvoiceId, invoiceId)); +// if (bmsMakeOutInvoices != null && bmsMakeOutInvoices.size() > 0) { +// int count= 0; +// for (BmsMakeOutInvoice make : bmsMakeOutInvoices) { +// count++; +// List ysitemList=new ArrayList(); +// ReconciliationDTO reconciliationDTO=new ReconciliationDTO(); +// reconciliationDTO.setInnerNumber(reconciliation.getBillNumber()); +// String url = ""; +// Long organizationId = reconciliation.getOrganizationId(); +// String orgCodeNc = billManageMapper.getOrgCodeNc(organizationId); +// String organizationName = reconciliation.getOrganizationName(); +// String ncUrl = billManageMapper.getNcUrl("nc", organizationName, organizationId); +// if (ncUrl!=null&&ncUrl!="") { +// url = ncUrl; +// } else { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// throw new ServiceException("未找到该组织的推送地址!"); +// } +// List bmsMakeOutInvoiceItems = bmsMakeOutInvoiceItemMapper.selectList(new LambdaQueryWrapper().eq(BmsMakeOutInvoiceItem::getMakeId, make.getId())); +// String makerCodeNc = ""; +// if(bmsMakeOutInvoiceItems != null && bmsMakeOutInvoiceItems.size() > 0){ +// if(ObjectUtil.isNotNull(bmsMakeOutInvoiceItems)){ +// // 汇总 list 中 invoiceValue 的总值 +// BigDecimal totalInvoiceValue = bmsMakeOutInvoiceItems.stream() +// .map(BmsMakeOutInvoiceItem::getInvoiceValue) +// .filter(java.util.Objects::nonNull) +// .reduce(BigDecimal.ZERO, BigDecimal::add); +// +// // 将 feeType 用、拼接起来 +// String feeTypes = bmsMakeOutInvoiceItems.stream() +// .map(BmsMakeOutInvoiceItem::getFeeType) +// .filter(java.util.Objects::nonNull) +// .collect(java.util.stream.Collectors.joining("、")); +// +// // 按 createTime 倒序排序并获取第一条记录 +// BmsMakeOutInvoiceItem firstItem = bmsMakeOutInvoiceItems.stream() +// .sorted((a, b) -> { +// if (a.getCreateTime() == null) return 1; +// if (b.getCreateTime() == null) return -1; +// return b.getCreateTime().compareTo(a.getCreateTime()); +// }) +// .findFirst() +// .orElse(null); +// String salesmanId = reconciliation.getSalesmanId(); +// String customerUserDept = billManageMapper.getCustomerUserDept(salesmanId); +// String deptValue = billManageMapper.getDeptValue(customerUserDept); +// String deptName = billManageMapper.getDeptName(customerUserDept); +// String salespersonNcCode = billManageMapper.getsalespersonNcCode(salesmanId); +// String salesmanCodeNc=salespersonNcCode; +// String appointShipper=make.getActualInvoiceCustomerName(); +// String actualInvoiceCustomerId = make.getActualInvoiceCustomerId(); +// String customerCodeNc = billManageMapper.getCustomerCodeNc(actualInvoiceCustomerId); +// String customerCodeNcJson = billManageMapper.getCustomerCodeNcJson(actualInvoiceCustomerId); +// if (customerCodeNcJson != null && !customerCodeNcJson.isEmpty()) { +// ObjectMapper objectMapper = new ObjectMapper(); +// List> listNc = objectMapper.readValue( +// customerCodeNcJson, +// new TypeReference>>() {} +// ); +// if (listNc != null && listNc.size() > 0) { +// Map targetMap = listNc.stream() +// .filter(map -> { +// Object codeObj = map.get("code"); +// return codeObj != null && codeObj.toString().equals(reconciliation.getOrganizationId().toString()); +// }) +// .findFirst() +// .orElse(null); +// if (targetMap != null) { +// customerCodeNc = (String) targetMap.get("ncCustomer"); +// } +// } +// } +// String documentPreparerNcCode = billManageMapper.getDocumentPreparerNcCode(salesmanId); +// String settlementCurrency=reconciliation.getSettlementCurrency(); +// String settlementCurrencyNcCode = settlementCurrency; +// makerCodeNc=documentPreparerNcCode; +// SKitem item=new SKitem(); +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setSo_deptid(deptValue); +// } else { +// item.setSo_deptid("NG0408"); +// } +// if (deptValue != null && !deptValue.isEmpty()) { +// item.setPk_deptid(deptValue); +// } else { +// item.setPk_deptid("NG0408"); +// } +// item.setCheckdirection("ar"); +// item.setPk_psndoc(salesmanCodeNc); +// item.setCustomer(customerCodeNc); +// item.setPurchaseorder(""); +// item.setObjtype("0"); +// item.setDirection("1"); +// if (deptName != null && !deptName.isEmpty()) { +// if (feeTypes != null && !feeTypes.isEmpty()) { +// item.setScomment(deptName+":"+appointShipper+feeTypes); +// } else { +// item.setScomment(deptName+":"+appointShipper+feeTypes); +// } +// } else { +// if (feeTypes != null && !feeTypes.isEmpty()) { +// item.setScomment("业务部:"+appointShipper+feeTypes); +// } else { +// item.setScomment("业务部:"+appointShipper+feeTypes); +// } +// } +// // 费用类别 +// String feeType = firstItem.getFeeType(); +// String serviceItemsCodeNc = billManageMapper.getServiceItemsCodeNc(feeType); +// if (serviceItemsCodeNc != null && !serviceItemsCodeNc.isEmpty()) { +// item.setDef75(serviceItemsCodeNc); +// } else { +// item.setDef75("T10"); +// } +// String invoiceItem1 = firstItem.getInvoiceItem(); +// if (invoiceItem1 != null && !invoiceItem1.isEmpty()) { +// String[] split = invoiceItem1.split(","); +// item.setDef29(split[0]); +// } +// item.setPk_currtype(settlementCurrencyNcCode); +// item.setMoney_cr(String.valueOf(totalInvoiceValue)); +// item.setMoney_bal(String.valueOf(totalInvoiceValue)); +// ysitemList.add(item); +// } +// } +// SKbodys bodys=new SKbodys(); +// bodys.setItem(ysitemList); +// SKbillhead billhead=new SKbillhead(); +// billhead.setPk_group("CNK"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// billhead.setPk_org(orgCodeNc); +// billhead.setSett_org(orgCodeNc); +// } else { +// billhead.setPk_org("NG04"); +// billhead.setSett_org("NG04"); +// } +// billhead.setCreationtime(dateString); +// billhead.setPk_billtype("F2"); +// billhead.setCreator(makerCodeNc); +// billhead.setPk_tradetype("D2"); +// billhead.setBillclass("sk"); +// billhead.setBilldate(dateString); +// billhead.setSyscode("0"); +// billhead.setBillno(""); +// billhead.setDef59(""); +// billhead.setSrc_syscode("0"); +// billhead.setBillstatus("0"); +// billhead.setBillmaker(makerCodeNc); +// billhead.setPk_busitype(""); +// billhead.setBillyear(sdf1.format(date)); +// billhead.setBillperiod(sdf2.format(date)); +// billhead.setEffectstatus("0"); +// billhead.setDef28("nqyw"); +// billhead.setDef29(reconciliation.getBillNumber()); +// billhead.setBodys(bodys); +// SKbill bill=new SKbill(); +// bill.setId("sk"+String.valueOf(reconciliation.getBillManageId())+"_"+count); +// bill.setBillhead(billhead); +// SKufinterface ufinterface=new SKufinterface(); +// ufinterface.setAccount("NKNC"); +// ufinterface.setBilltype("F2"); +// ufinterface.setBusinessunitcode(""); +// ufinterface.setFilename(""); +// ufinterface.setIsexchange("Y"); +// if (orgCodeNc != null && !orgCodeNc.isEmpty()) { +// ufinterface.setOrgcode(orgCodeNc); +// ufinterface.setReceiver(orgCodeNc); +// } else { +// ufinterface.setOrgcode("NG04"); +// ufinterface.setReceiver("NG04"); +// } +// ufinterface.setReplace("Y"); +// ufinterface.setRoottag(""); +// ufinterface.setSender("nqyw"); +// ufinterface.setBill(bill); +// JAXBContext jaxbContext = null; +// //String xmlString =""; +// jaxbContext = JAXBContext.newInstance(SKufinterface.class); +// Marshaller marshaller = jaxbContext.createMarshaller(); +// marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); +// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // 格式化输出,可选 +// StringWriter sw = new StringWriter(); +// marshaller.marshal(ufinterface, sw); +// String xmlString = sw.toString(); // 这是要发送的XML字符串 +// System.out.println(xmlString); +// NcLog ncLog=new NcLog(); +// ncLog.setOrderId(reconciliation.getBillManageId()); +// ncLog.setRequestBody(xmlString); +// ncLog.setResponeBody(""); +// ncLog.setType(1L); +// ncLog.setSendTime(new Date()); +// ncLog.setOrganizationId(reconciliation.getOrganizationId()); +// ncLog.setOrganizationName(reconciliation.getOrganizationName()); +// ncLog.setTopOrganizationId(reconciliation.getTopOrganizationId()); +// ncLogMapper.insert(ncLog); +// reconciliation.setSkSynchronousStatus(1); +// reconciliation.setSkSynchronousTime(new Date()); +// reconciliation.setSkNcId("sk"+String.valueOf(reconciliation.getBillManageId())); +// //reconciliationMapper.updateById(reconciliation); +// CloseableHttpClient httpClient = HttpClients.createDefault(); +// HttpPost httpPost = new HttpPost(url); +// StringEntity postingString = new StringEntity(xmlString, "UTF-8"); +// httpPost.setEntity(postingString); +// httpPost.setHeader("Content-type", "application/xml"); +// try { +// CloseableHttpResponse response = httpClient.execute(httpPost); +// String responseString = EntityUtils.toString(response.getEntity()); +// System.out.println(responseString); +// ncLog.setResponeBody(responseString); +// // 创建DOM解析器 +// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); +// DocumentBuilder builder = factory.newDocumentBuilder(); +// Document document = builder.parse(new InputSource(new StringReader(responseString))); +// +// // 获取根元素 +// Element root = document.getDocumentElement(); +// +// // 获取ufinterface元素的属性 +// String billtype = root.getAttribute("billtype"); +// String filename = root.getAttribute("filename"); +// System.out.println("billtype: " + billtype); +// System.out.println("filename: " + filename); +// +// // 获取sendresult节点 +// NodeList sendResultList = root.getElementsByTagName("sendresult"); +// if (sendResultList.getLength() > 0) { +// Element sendResult = (Element) sendResultList.item(0); +// +// // 获取子元素内容 +// String bdocid = sendResult.getElementsByTagName("bdocid").item(0).getTextContent(); +// String resultcode = sendResult.getElementsByTagName("resultcode").item(0).getTextContent(); +// String content = sendResult.getElementsByTagName("content").item(0).getTextContent(); +// +// System.out.println("bdocid: " + bdocid); +// System.out.println("resultcode: " + resultcode); +// System.out.println("content: " + content); +// if(resultcode.equals("1")){ +// reconciliation.setSkSynchronousStatus(1); +// }else{ +// reconciliation.setSkSynchronousStatus(2); +// } +// } +// ncLogMapper.updateById(ncLog); +// billManageMapper.updateById(reconciliation); +// response.close(); +// } catch (Exception e) { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } finally { +// try { +// httpClient.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// +// } +// } else { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// } +// } catch (JAXBException e) { +// reconciliation.setSkSynchronousStatus(2); +// billManageMapper.updateById(reconciliation); +// e.printStackTrace(); +// } catch (JsonMappingException e) { +// throw new RuntimeException(e); +// } catch (JsonProcessingException e) { +// throw new RuntimeException(e); +// } +// return true; +// } @Override diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java index 399ad44c4..cfb053614 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billManage/repository/todo/BillManageDO.java @@ -264,4 +264,6 @@ public class BillManageDO extends BaseVOEntity{ private String paymentAccountId; @ApiModelProperty("收款帐户名称") private String paymentAccountName; + @ApiModelProperty("业务员ID") + private String salesmanId; } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java index 447b38446..6a5d308c7 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/po/BillingStatementPO.java @@ -100,6 +100,10 @@ public class BillingStatementPO extends BaseVOEntity{ @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") private Integer accountExpenseType; + @ApiModelProperty("收支类型(1-应收,2-应付)") + @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") + private Integer billType; + @ApiModelProperty("流水备注") @Excel(name = "流水备注") private String billingRemark; diff --git a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java index af1576753..23fc1d687 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/domain/billingStatement/repository/todo/BillingStatementDO.java @@ -101,6 +101,10 @@ public class BillingStatementDO extends BaseVOEntity{ @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") private Integer accountExpenseType; + @ApiModelProperty("收支类型(1-应收,2-应付)") + @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") + private Integer billType; + @ApiModelProperty("流水备注") @Excel(name = "流水备注") private String billingRemark; diff --git a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java index 48e195c69..855e5040b 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java +++ b/mhd_bms/src/main/java/com/mhd/bms/interfaces/dto/billingStatement/BillingStatementDTO.java @@ -102,6 +102,10 @@ public class BillingStatementDTO extends BaseVOEntity{ @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") private Integer accountExpenseType; + @ApiModelProperty("收支类型(1-应收,2-应付)") + @Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付") + private Integer billType; + @ApiModelProperty("流水备注") @Excel(name = "流水备注") private String billingRemark; diff --git a/mhd_bms/src/main/resources/bootstrap.yml b/mhd_bms/src/main/resources/bootstrap.yml index d68deb6eb..57159b97e 100644 --- a/mhd_bms/src/main/resources/bootstrap.yml +++ b/mhd_bms/src/main/resources/bootstrap.yml @@ -18,15 +18,15 @@ spring: discovery: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.33.0.129:6010 - server-addr: 10.102.192.30:6848 + server-addr: 10.33.0.129:6010 +# server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 config: # server-addr: 127.0.0.1:8848 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.33.0.129:6010 - server-addr: 10.102.192.30:6848 + server-addr: 10.33.0.129:6010 +# server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 group: DEFAULT_GROUP # 默认分组就是DEFAULT_GROUP,如果使用默认分组可以不配置 diff --git a/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml b/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml index e56269307..0fc27b019 100644 --- a/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml +++ b/mhd_bms/src/main/resources/mapper/BillDetailMapper.xml @@ -27,5 +27,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND bd.bill_manage_id = #{billManageId} + - + + + + \ No newline at end of file diff --git a/mhd_bms/src/main/resources/mapper/BillManageMapper.xml b/mhd_bms/src/main/resources/mapper/BillManageMapper.xml index 5c9b10211..c3dae03e5 100644 --- a/mhd_bms/src/main/resources/mapper/BillManageMapper.xml +++ b/mhd_bms/src/main/resources/mapper/BillManageMapper.xml @@ -169,4 +169,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT NC_CODE FROM NGWL_TEST_PRODUCT."SYS_ORGANIZATION" where DEL_FLAG = 1 and organization_id = #{organizationId} limit 1 + + \ No newline at end of file diff --git a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml index 54d6b7a3a..e2fd28e11 100644 --- a/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml +++ b/mhd_bms/src/main/resources/mapper/SettlementCustomersMapper.xml @@ -200,10 +200,6 @@ AND ( a.organization_id = #{settlementCustomersDO.organizationId} - OR b.org_code LIKE concat('%"code":"', #{settlementCustomersDO.organizationId}, '"%') - OR b.org_code LIKE concat('%code:', #{settlementCustomersDO.organizationId}, '%') - OR b.org_code LIKE concat('%code: ', #{settlementCustomersDO.organizationId}, '%') - OR b.org_code LIKE concat('%"code":', #{settlementCustomersDO.organizationId}, '%') ) @@ -216,4 +212,4 @@ and a.customer_type_code = #{settlementCustomersDO.customerTypeCode} - + \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/entity/ElectronicSignature.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/entity/ElectronicSignature.java new file mode 100644 index 000000000..65c987164 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/entity/ElectronicSignature.java @@ -0,0 +1,71 @@ +package com.mhd.oms.domain.electronicSignature.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * 电子签名主表 electronic_signature + */ +@Data +@TableName("ELECTRONIC_SIGNATURE") +public class ElectronicSignature extends BaseVOEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("签名ID") + @TableId(type = IdType.INPUT) + private Long signatureId; + + @ApiModelProperty("订单ID") + private Long orderId; + + @ApiModelProperty("订单号") + private String orderNumber; + + @ApiModelProperty("订单类型:IN-入库 OUT-出库") + private String orderType; + + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名时间") + private Date signatureTime; + + @ApiModelProperty("手写签名图片") + private String signaturePic; + + @ApiModelProperty("拍照取证图片") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; + + @ApiModelProperty("签名方式:1-扫描二维码 2-电子签名 3-打印手写签名 4-超时自动签名") + private Integer signatureMode; + + @ApiModelProperty("组织ID") + private Long organizationId; + + @ApiModelProperty("组织名称") + private String organizationName; + + @ApiModelProperty("一级组织ID") + private Long topOrganizationId; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("备注") + private String remark; +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/entity/ElectronicSignatureMaterialDetail.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/entity/ElectronicSignatureMaterialDetail.java new file mode 100644 index 000000000..3e5476227 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/entity/ElectronicSignatureMaterialDetail.java @@ -0,0 +1,83 @@ +package com.mhd.oms.domain.electronicSignature.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 电子签名物料明细表 electronic_signature_material_detail + */ +@Data +@TableName("ELECTRONIC_SIGNATURE_MATERIAL_DETAIL") +public class ElectronicSignatureMaterialDetail extends BaseVOEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("明细ID") + @TableId(type = IdType.INPUT) + private Long detailId; + + @ApiModelProperty("签名ID") + private Long signatureId; + + @ApiModelProperty("物料基础信息ID") + private Long materialBaseInfoId; + + @ApiModelProperty("物料编码") + private String materialCode; + + @ApiModelProperty("物料名称") + private String materialName; + + @ApiModelProperty("数量") + private BigDecimal quantity; + + @ApiModelProperty("单位代码") + private String unitCode; + + @ApiModelProperty("单位名称") + private String unitName; + + @ApiModelProperty("批次号") + private String batchNumber; + + @ApiModelProperty("LOT编号") + private String lotNumber; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("库区ID") + private Long storageSectionId; + + @ApiModelProperty("库区编码") + private String storageSectionCode; + + @ApiModelProperty("库区名称") + private String storageSectionName; + + @ApiModelProperty("库位ID") + private Long storageLocationId; + + @ApiModelProperty("库位编码") + private String storageLocationCode; + + @ApiModelProperty("库位名称") + private String storageLocationName; + + @ApiModelProperty("业务唯一ID") + private Long uniqueId; + + @ApiModelProperty("备注") + private String remark; +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/facade/IElectronicSignatureMaterialDetailService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/facade/IElectronicSignatureMaterialDetailService.java new file mode 100644 index 000000000..9ce87b028 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/facade/IElectronicSignatureMaterialDetailService.java @@ -0,0 +1,22 @@ +package com.mhd.oms.domain.electronicSignature.repository.facade; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; + +import java.util.List; + +/** + * 电子签名物料明细Service接口 + */ +public interface IElectronicSignatureMaterialDetailService extends IService { + + /** + * 根据签名ID逻辑删除明细 + */ + int deleteBySignatureId(Long signatureId); + + /** + * 批量插入明细 + */ + boolean batchInsert(List detailList); +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/facade/IElectronicSignatureService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/facade/IElectronicSignatureService.java new file mode 100644 index 000000000..64c38ba68 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/facade/IElectronicSignatureService.java @@ -0,0 +1,16 @@ +package com.mhd.oms.domain.electronicSignature.repository.facade; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignature; +import com.mhd.oms.domain.electronicSignature.repository.todo.ElectronicSignatureDO; + +/** + * 电子签名Service接口 + */ +public interface IElectronicSignatureService extends IService { + + /** + * 保存电子签名 + */ + Boolean saveSignature(ElectronicSignatureDO electronicSignatureDO); +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/mapper/ElectronicSignatureMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/mapper/ElectronicSignatureMapper.java new file mode 100644 index 000000000..5c29d4feb --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/mapper/ElectronicSignatureMapper.java @@ -0,0 +1,129 @@ +package com.mhd.oms.domain.electronicSignature.repository.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignature; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureQueryDTO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.Date; +import java.util.List; + +/** + * 电子签名Mapper接口 + */ +public interface ElectronicSignatureMapper extends BaseMapper { + + @Select("SELECT NGWL_TEST_OMS.SEQ_ELECTRONIC_SIGNATURE.NEXTVAL FROM DUAL") + Long nextSignatureId(); + + @Select("SELECT NGWL_TEST_OMS.SEQ_ES_MATERIAL_DETAIL.NEXTVAL FROM DUAL") + Long nextDetailId(); + + @Select("SELECT * FROM NGWL_TEST_OMS.ELECTRONIC_SIGNATURE WHERE ORDER_ID = #{orderId} AND ORDER_TYPE = #{orderType} AND DEL_FLAG = 1") + ElectronicSignature selectByOrderIdAndType(@Param("orderId") Long orderId, @Param("orderType") String orderType); + + /** + * 分页查询电子签名列表(需配合PageHelper使用) + */ + @Select("") + List selectSignatureList(@Param("params") ElectronicSignatureQueryDTO queryDTO); + + /** + * 根据签名ID查询 + */ + @Select("SELECT * FROM NGWL_TEST_OMS.ELECTRONIC_SIGNATURE WHERE SIGNATURE_ID = #{signatureId} AND DEL_FLAG = 1") + ElectronicSignature selectBySignatureId(@Param("signatureId") Long signatureId); + + /** + * 根据签名ID查询物料明细列表 + */ + @Select("SELECT * FROM NGWL_TEST_OMS.ELECTRONIC_SIGNATURE_MATERIAL_DETAIL WHERE SIGNATURE_ID = #{signatureId} AND DEL_FLAG = 1") + List selectMaterialDetailBySignatureId(@Param("signatureId") Long signatureId); + + /** + * 批量签名:根据签名ID列表更新签名信息 + */ + @Update("") + int batchUpdateSign(@Param("signatureIds") List signatureIds, + @Param("signatureTime") Date signatureTime, + @Param("signaturePic") String signaturePic, + @Param("evidencePics") String evidencePics, + @Param("signatureRemark") String signatureRemark, + @Param("signatureMode") Integer signatureMode); + + + @Update("") + int batchUpdateSignByOrder(@Param("signatureIds") List signatureIds, + @Param("signatureTime") Date signatureTime, + @Param("signaturePic") String signaturePic, + @Param("evidencePics") String evidencePics, + @Param("signatureRemark") String signatureRemark, + @Param("signatureMode") Integer signatureMode); + + /** + * 根据签名ID列表批量查询 + */ + @Select("") + List selectBySignatureIds(@Param("signatureIds") List signatureIds); + + + @Select("") + List selectByOrderIds(@Param("signatureIds") List signatureIds); + + + @Update("UPDATE NGWL_TEST_WMS.STOCK_IN_ORDER SET SIGNATURE_STATUS = 2,SIGNATURE_TIME =now() WHERE IN_ORDER_ID = #{id}") + int updateIn( @Param("id") Long id); + + @Update("UPDATE NGWL_TEST_WMS.STOCK_OUT_ORDER SET SIGNATURE_STATUS = 2,SIGNATURE_TIME =now() WHERE OUT_ORDER_ID = #{id}") + int updateOut(@Param("id") Long id); +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/mapper/ElectronicSignatureMaterialDetailMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/mapper/ElectronicSignatureMaterialDetailMapper.java new file mode 100644 index 000000000..cf325ca8d --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/mapper/ElectronicSignatureMaterialDetailMapper.java @@ -0,0 +1,19 @@ +package com.mhd.oms.domain.electronicSignature.repository.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +/** + * 电子签名物料明细Mapper接口 + */ +public interface ElectronicSignatureMaterialDetailMapper extends BaseMapper { + + @Update("UPDATE NGWL_TEST_OMS.ELECTRONIC_SIGNATURE_MATERIAL_DETAIL SET DEL_FLAG = 2 WHERE SIGNATURE_ID = #{signatureId} AND DEL_FLAG = 1") + int logicDeleteBySignatureId(@Param("signatureId") Long signatureId); + + @Select("SELECT NGWL_TEST_OMS.SEQ_ES_MATERIAL_DETAIL.NEXTVAL FROM DUAL") + Long nextDetailId(); +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/persistence/ElectronicSignatureImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/persistence/ElectronicSignatureImpl.java new file mode 100644 index 000000000..2138336cc --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/persistence/ElectronicSignatureImpl.java @@ -0,0 +1,30 @@ +package com.mhd.oms.domain.electronicSignature.repository.persistence; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignature; +import com.mhd.oms.domain.electronicSignature.repository.facade.IElectronicSignatureService; +import com.mhd.oms.domain.electronicSignature.repository.mapper.ElectronicSignatureMapper; +import com.mhd.oms.domain.electronicSignature.repository.todo.ElectronicSignatureDO; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 电子签名Service业务层处理 + */ +@Service +public class ElectronicSignatureImpl extends ServiceImpl implements IElectronicSignatureService { + + @Autowired + private ElectronicSignatureMapper electronicSignatureMapper; + + @Override + public Boolean saveSignature(ElectronicSignatureDO electronicSignatureDO) { + ElectronicSignature entity = new ElectronicSignature(); + BeanUtils.copyProperties(electronicSignatureDO, entity); + Long id = electronicSignatureMapper.nextSignatureId(); + entity.setSignatureId(id); + entity.setSignatureMode(2); // 2-电子签名 + return this.save(entity); + } +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/persistence/ElectronicSignatureMaterialDetailImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/persistence/ElectronicSignatureMaterialDetailImpl.java new file mode 100644 index 000000000..61b75efb9 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/persistence/ElectronicSignatureMaterialDetailImpl.java @@ -0,0 +1,38 @@ +package com.mhd.oms.domain.electronicSignature.repository.persistence; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; +import com.mhd.oms.domain.electronicSignature.repository.facade.IElectronicSignatureMaterialDetailService; +import com.mhd.oms.domain.electronicSignature.repository.mapper.ElectronicSignatureMaterialDetailMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 电子签名物料明细Service业务层处理 + */ +@Service +public class ElectronicSignatureMaterialDetailImpl extends ServiceImpl implements IElectronicSignatureMaterialDetailService { + + @Autowired + private ElectronicSignatureMaterialDetailMapper electronicSignatureMaterialDetailMapper; + + @Override + public int deleteBySignatureId(Long signatureId) { + return electronicSignatureMaterialDetailMapper.logicDeleteBySignatureId(signatureId); + } + + @Override + public boolean batchInsert(List detailList) { + if (detailList == null || detailList.isEmpty()) { + return true; + } + for (ElectronicSignatureMaterialDetail detail : detailList) { + Long detailId = electronicSignatureMaterialDetailMapper.nextDetailId(); + detail.setDetailId(detailId); + this.save(detail); + } + return true; + } +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/todo/ElectronicSignatureDO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/todo/ElectronicSignatureDO.java new file mode 100644 index 000000000..f2101049a --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/repository/todo/ElectronicSignatureDO.java @@ -0,0 +1,49 @@ +package com.mhd.oms.domain.electronicSignature.repository.todo; + +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; +import lombok.Data; + +import java.util.List; + +/** + * 电子签名保存入参 + */ +@Data +public class ElectronicSignatureDO { + + /** 订单ID */ + private Long orderId; + + /** 订单号 */ + private String orderNumber; + + /** 订单类型:IN-入库 OUT-出库 */ + private String orderType; + + /** 组织ID */ + private Long organizationId; + + /** 组织名称 */ + private String organizationName; + + /** 一级组织ID */ + private Long topOrganizationId; + + /** 仓库ID */ + private Long warehouseId; + + /** 仓库编码 */ + private String warehouseCode; + + /** 仓库名称 */ + private String warehouseName; + + /** 创建人 */ + private Long createBy; + + /** 创建人姓名 */ + private String createByName; + + /** 物料明细列表 */ + private List materialDetailList; +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/service/ElectronicSignatureDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/service/ElectronicSignatureDomainService.java new file mode 100644 index 000000000..a7a50c483 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/electronicSignature/service/ElectronicSignatureDomainService.java @@ -0,0 +1,311 @@ +package com.mhd.oms.domain.electronicSignature.service; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignature; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; +import com.mhd.oms.domain.electronicSignature.repository.facade.IElectronicSignatureMaterialDetailService; +import com.mhd.oms.domain.electronicSignature.repository.facade.IElectronicSignatureService; +import com.mhd.oms.domain.electronicSignature.repository.mapper.ElectronicSignatureMapper; +import com.mhd.oms.domain.electronicSignature.repository.todo.ElectronicSignatureDO; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureBatchSignDTO; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureQueryDTO; +import com.mhd.system.api.WmsServiceFeign; +import com.mhd.system.api.domain.SignatureBatchFeignDTO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 电子签名领域服务 + */ +@Service +@Slf4j +public class ElectronicSignatureDomainService { + + @Autowired + private IElectronicSignatureService electronicSignatureService; + + @Autowired + private IElectronicSignatureMaterialDetailService electronicSignatureMaterialDetailService; + + @Autowired + private ElectronicSignatureMapper electronicSignatureMapper; + + @Autowired(required = false) + private WmsServiceFeign wmsServiceFeign; + + /** + * 保存电子签名记录(生成待签名记录) + * 业务规则: + * 1. 查询是否已有签名记录 + * 2. 若已签名(SIGNATURE_STATUS=2),跳过 + * 3. 若待签名(SIGNATURE_STATUS=1),覆盖明细(先逻辑删除旧明细,再插入新明细) + * 4. 若不存在,新增主表+明细 + */ + @Transactional(rollbackFor = Exception.class) + public Boolean saveSignature(ElectronicSignatureDO electronicSignatureDO) { + Long orderId = electronicSignatureDO.getOrderId(); + String orderType = electronicSignatureDO.getOrderType(); + + // 查询是否已有签名记录 + ElectronicSignature existing = electronicSignatureMapper.selectByOrderIdAndType(orderId, orderType); + + if (existing != null) { + // 已签名,跳过 + if (existing.getSignatureStatus() != null && existing.getSignatureStatus() == 2) { + log.info("订单 {} 已签名,跳过生成签名记录", electronicSignatureDO.getOrderNumber()); + return true; + } + + // 待签名,覆盖:逻辑删除旧明细,插入新明细 + log.info("订单 {} 已有待签名记录,覆盖明细", electronicSignatureDO.getOrderNumber()); + electronicSignatureMaterialDetailService.deleteBySignatureId(existing.getSignatureId()); + batchInsertDetails(existing.getSignatureId(), electronicSignatureDO.getMaterialDetailList()); + return true; + } + + // 不存在,新增 + log.info("订单 {} 生成新的待签名记录", electronicSignatureDO.getOrderNumber()); + electronicSignatureService.saveSignature(electronicSignatureDO); + + // 查询刚插入的记录以获取签名ID + ElectronicSignature newEntity = electronicSignatureMapper.selectByOrderIdAndType(orderId, orderType); + if (newEntity != null) { + batchInsertDetails(newEntity.getSignatureId(), electronicSignatureDO.getMaterialDetailList()); + } + + return true; + } + + + + /** + * 保存电子签名记录(生成待签名记录) + * 业务规则: + * 1. 查询是否已有签名记录 + * 2. 若已签名(SIGNATURE_STATUS=2),跳过 + * 3. 若待签名(SIGNATURE_STATUS=1),覆盖明细(先逻辑删除旧明细,再插入新明细) + * 4. 若不存在,新增主表+明细 + */ + @Transactional(rollbackFor = Exception.class) + public Boolean inQqcode(ElectronicSignatureDO electronicSignatureDO) { + Long orderId = electronicSignatureDO.getOrderId(); + ElectronicSignature existing = electronicSignatureService.getOne(new LambdaQueryWrapper() + .eq(ElectronicSignature::getOrderId, orderId) + .eq(ElectronicSignature::getDelFlag, 1), false); + if (existing != null) { + existing.setSignatureTime(new Date()); // 设置签名时间 + existing.setSignatureStatus(2); // 设置签名状态为已签名 + existing.setSignatureMode(1); // 设置签名方式为1-二维码 + electronicSignatureService.updateById(existing); + electronicSignatureMapper.updateIn(existing.getOrderId()); + } + return true; + } + + @Transactional(rollbackFor = Exception.class) + public Boolean outQqcode(ElectronicSignatureDO electronicSignatureDO) { + Long orderId = electronicSignatureDO.getOrderId(); + ElectronicSignature existing = electronicSignatureService.getOne(new LambdaQueryWrapper() + .eq(ElectronicSignature::getOrderId, orderId) + .eq(ElectronicSignature::getDelFlag, 1), false); + if (existing != null) { + existing.setSignatureTime(new Date()); // 设置签名时间 + existing.setSignatureStatus(2); // 设置签名状态为已签名 + existing.setSignatureMode(1); // 设置签名方式为1-二维码 + electronicSignatureService.updateById(existing); + electronicSignatureMapper.updateOut(existing.getOrderId()); + } + return true; + } + + /** + * 分页查询电子签名列表 + */ + public List querySignatureList(ElectronicSignatureQueryDTO queryDTO) { + return electronicSignatureMapper.selectSignatureList(queryDTO); + } + + /** + * 根据订单编号查询电子签名列表 + */ + public List getByOrderNumber(ElectronicSignatureQueryDTO queryDTO) { + return electronicSignatureMapper.selectList(new LambdaQueryWrapper() + .eq(ElectronicSignature::getOrderNumber, queryDTO.getOrderNumber()) + .eq(ElectronicSignature::getDelFlag, 1)); + } + + /** + * 根据签名ID查询 + */ + public ElectronicSignature getSignatureById(Long signatureId) { + return electronicSignatureMapper.selectBySignatureId(signatureId); + } + + /** + * 根据签名ID查询物料明细 + */ + public List queryMaterialDetailBySignatureId(Long signatureId) { + return electronicSignatureMapper.selectMaterialDetailBySignatureId(signatureId); + } + + private void batchInsertDetails(Long signatureId, List detailList) { + if (detailList == null || detailList.isEmpty()) { + return; + } + for (ElectronicSignatureMaterialDetail detail : detailList) { + detail.setSignatureId(signatureId); + } + electronicSignatureMaterialDetailService.batchInsert(detailList); + } + + /** + * 批量签名:勾选多条记录后批量签名 + * + *

业务流程: + * 1. 查询OMS电子签名表,获取每条记录的 orderId + orderType + * 2. 更新OMS ELECTRONIC_SIGNATURE表:signatureStatus=2(已签名)、signatureTime、signaturePic、 + * evidencePics、signatureRemark、signatureMode + * 3. 按订单类型分组后,调用WMS Feign更新WMS stock_in_order / stock_out_order表 + *

+ */ + @Transactional(rollbackFor = Exception.class) + public int batchSign(ElectronicSignatureBatchSignDTO dto) { + List signatureIds = dto.getSignatureIds(); + if (CollectionUtil.isEmpty(signatureIds)) { + return 0; + } + + // 1. 查询签名记录,获取 orderId + orderType + List signatureList = electronicSignatureMapper.selectBySignatureIds(signatureIds); + if (CollectionUtil.isEmpty(signatureList)) { + log.warn("批量签名失败:未找到有效的签名记录"); + return 0; + } + + // 2. 更新OMS电子签名表 + Date now = new Date(); + String evidencePicsStr = null; + if (CollectionUtil.isNotEmpty(dto.getEvidencePics())) { + evidencePicsStr = String.join(",", dto.getEvidencePics()); + } + + int updated = electronicSignatureMapper.batchUpdateSign( + signatureIds, now, + dto.getSignaturePic(), + evidencePicsStr, + dto.getSignatureRemark(), + 2); + log.info("批量签名:OMS电子签名表更新 {} 条", updated); + + // 3. 按订单类型分组,调用WMS更新入/出库表 + if (wmsServiceFeign != null) { + try { + // 分组:IN-入库、OUT-出库 + List inOrderIds = signatureList.stream() + .filter(s -> "IN".equals(s.getOrderType())) + .map(ElectronicSignature::getOrderId) + .distinct() + .collect(Collectors.toList()); + List outOrderIds = signatureList.stream() + .filter(s -> "OUT".equals(s.getOrderType())) + .map(ElectronicSignature::getOrderId) + .distinct() + .collect(Collectors.toList()); + + // 构建 WMS 批量签名 DTO(一次调用同时处理入库+出库) + SignatureBatchFeignDTO wmsDto = new SignatureBatchFeignDTO(); + wmsDto.setInOrderIds(inOrderIds.isEmpty() ? null : inOrderIds); + wmsDto.setOutOrderIds(outOrderIds.isEmpty() ? null : outOrderIds); + wmsDto.setSignatureStatus(2); + wmsDto.setSignatureTime(now); + wmsDto.setSignaturePic(dto.getSignaturePic()); + wmsDto.setEvidencePics(evidencePicsStr); + wmsDto.setSignatureRemark(dto.getSignatureRemark()); + + log.info("批量签名:调用WMS更新入/出库单,入库{}条,出库{}条", + inOrderIds.size(), outOrderIds.size()); + wmsServiceFeign.batchSignWms(wmsDto); + } catch (Exception e) { + log.error("批量签名:调用WMS更新入/出库表失败", e); + // WMS更新失败不影响OMS表更新结果,仅记录日志 + } + } + + return updated; + } + + @Transactional(rollbackFor = Exception.class) + public int batchSignByWmsId(ElectronicSignatureBatchSignDTO dto) { + List signatureIds = dto.getSignatureIds(); + if (CollectionUtil.isEmpty(signatureIds)) { + return 0; + } + + // 1. 查询签名记录,获取 orderId + orderType + List signatureList = electronicSignatureMapper.selectByOrderIds(signatureIds); + if (CollectionUtil.isEmpty(signatureList)) { + log.warn("批量签名失败:未找到有效的签名记录"); + return 0; + } + + // 2. 更新OMS电子签名表 + Date now = new Date(); + String evidencePicsStr = null; + if (CollectionUtil.isNotEmpty(dto.getEvidencePics())) { + evidencePicsStr = String.join(",", dto.getEvidencePics()); + } + + int updated = electronicSignatureMapper.batchUpdateSignByOrder( + signatureIds, now, + dto.getSignaturePic(), + evidencePicsStr, + dto.getSignatureRemark(), + 2); + log.info("批量签名:OMS电子签名表更新 {} 条", updated); + + // 3. 按订单类型分组,调用WMS更新入/出库表 +// if (wmsServiceFeign != null) { +// try { +// // 分组:IN-入库、OUT-出库 +// List inOrderIds = signatureList.stream() +// .filter(s -> "IN".equals(s.getOrderType())) +// .map(ElectronicSignature::getOrderId) +// .distinct() +// .collect(Collectors.toList()); +// List outOrderIds = signatureList.stream() +// .filter(s -> "OUT".equals(s.getOrderType())) +// .map(ElectronicSignature::getOrderId) +// .distinct() +// .collect(Collectors.toList()); +// +// // 构建 WMS 批量签名 DTO(一次调用同时处理入库+出库) +// SignatureBatchFeignDTO wmsDto = new SignatureBatchFeignDTO(); +// wmsDto.setInOrderIds(inOrderIds.isEmpty() ? null : inOrderIds); +// wmsDto.setOutOrderIds(outOrderIds.isEmpty() ? null : outOrderIds); +// wmsDto.setSignatureStatus(2); +// wmsDto.setSignatureTime(now); +// wmsDto.setSignaturePic(dto.getSignaturePic()); +// wmsDto.setEvidencePics(evidencePicsStr); +// wmsDto.setSignatureRemark(dto.getSignatureRemark()); +// +// log.info("批量签名:调用WMS更新入/出库单,入库{}条,出库{}条", +// inOrderIds.size(), outOrderIds.size()); +// wmsServiceFeign.batchSignWms(wmsDto); +// } catch (Exception e) { +// log.error("批量签名:调用WMS更新入/出库表失败", e); +// // WMS更新失败不影响OMS表更新结果,仅记录日志 +// } +// } + + return updated; + } +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/facade/IExecutionInMaterialDetailService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/facade/IExecutionInMaterialDetailService.java index ffa353bb7..6fc5b8f08 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/facade/IExecutionInMaterialDetailService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/facade/IExecutionInMaterialDetailService.java @@ -3,6 +3,7 @@ package com.mhd.oms.domain.executionInMaterialDetail.repository.facade; import com.baomidou.mybatisplus.extension.service.IService; import com.mhd.oms.domain.executionInMaterialDetail.entity.ExecutionInMaterialDetail; import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.InventoryAdjustmentRecordPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailBaseDO; @@ -65,4 +66,9 @@ public interface IExecutionInMaterialDetailService extends IService getkctzjl(Long materialBaseInfoId, String orderNumber, String adjustType); + + /** + * 入库明细查询(关联入库执行单) + */ + public List queryInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO); } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/mapper/ExecutionInMaterialDetailMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/mapper/ExecutionInMaterialDetailMapper.java index c9fbc4970..caa15f2f5 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/mapper/ExecutionInMaterialDetailMapper.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/mapper/ExecutionInMaterialDetailMapper.java @@ -3,6 +3,7 @@ package com.mhd.oms.domain.executionInMaterialDetail.repository.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mhd.oms.domain.executionInMaterialDetail.entity.ExecutionInMaterialDetail; import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.InventoryAdjustmentRecordPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDO; @@ -30,4 +31,9 @@ public interface ExecutionInMaterialDetailMapper extends BaseMapper getkctzjl(@Param("materialBaseInfoId") Long materialBaseInfoId, @Param("orderNumber") String orderNumber, @Param("adjustType") String adjustType); + /** + * 入库明细查询(关联入库执行单) + */ + public List queryInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO); + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/persistence/ExecutionInMaterialDetailImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/persistence/ExecutionInMaterialDetailImpl.java index c013de9dd..986c5b728 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/persistence/ExecutionInMaterialDetailImpl.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/persistence/ExecutionInMaterialDetailImpl.java @@ -12,6 +12,7 @@ import com.mhd.oms.domain.executionInMaterialDetail.entity.ExecutionInMaterialDe import com.mhd.oms.domain.executionInMaterialDetail.repository.facade.IExecutionInMaterialDetailService; import com.mhd.oms.domain.executionInMaterialDetail.repository.mapper.ExecutionInMaterialDetailMapper; import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.InventoryAdjustmentRecordPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailBaseDO; @@ -309,4 +310,12 @@ public class ExecutionInMaterialDetailImpl extends ServiceImpl queryInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) { + return inMaterialDetailMapper.queryInOrderDetailList(queryOrderOverStockDO); + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/po/ExecutionInMaterialDetailWithOrderPO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/po/ExecutionInMaterialDetailWithOrderPO.java new file mode 100644 index 000000000..4697b3ba3 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/po/ExecutionInMaterialDetailWithOrderPO.java @@ -0,0 +1,30 @@ +package com.mhd.oms.domain.executionInMaterialDetail.repository.po; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 入库明细查询结果(关联入库执行单) + * + * @author gen + * @date 2024-07-24 + */ +@Data +public class ExecutionInMaterialDetailWithOrderPO extends ExecutionInMaterialDetailPO { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("入库单状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭") + private Integer inOrderStatus; + + @ApiModelProperty("入库单审核状态: 1-未审核 2-审核不通过 3-审核通过") + private Integer inOrderAuditStatus; + + @ApiModelProperty("货主ID") + private Long orderShipperId; + + @ApiModelProperty("货主编码") + private String orderShipperCode; + + @ApiModelProperty("货主名称") + private String orderShipperName; +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/todo/ExecutionInMaterialDetailQueryDTO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/todo/ExecutionInMaterialDetailQueryDTO.java new file mode 100644 index 000000000..b48723a4f --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/repository/todo/ExecutionInMaterialDetailQueryDTO.java @@ -0,0 +1,69 @@ +package com.mhd.oms.domain.executionInMaterialDetail.repository.todo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 入库明细查询参数 DTO + * + * @author gen + * @date 2024-07-24 + */ +@Data +public class ExecutionInMaterialDetailQueryDTO extends BaseVOEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("组织表ID") + private Long organizationId; + + @ApiModelProperty("一级组织表ID") + private Long topOrganizationId; + + @ApiModelProperty("入库单号") + private String inOrderNumber; + + @ApiModelProperty("仓库id") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("货主id") + private Long shipperId; + + @ApiModelProperty("货主名称") + private String shipperName; + + @ApiModelProperty("入库单类型编码") + private String inOrderTypeCode; + + @ApiModelProperty("入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭") + private Integer inStatus; + + @ApiModelProperty("预计到货时间 开始") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date inOrderExpectStartTime; + + @ApiModelProperty("预计到货时间 结束") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date inOrderExpectEndTime; + + @ApiModelProperty("物料基础信息id") + private Long materialBaseInfoId; + + @ApiModelProperty("物料编码") + private String materialCode; + + @ApiModelProperty("物料名称") + private String materialName; +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailApplicationService.java index 96a9749d3..5e03ad47a 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailApplicationService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailApplicationService.java @@ -2,7 +2,9 @@ package com.mhd.oms.domain.executionInMaterialDetail.service; import com.mhd.common.security.utils.SecurityUtils; import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import com.mhd.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -69,4 +71,18 @@ public class ExecutionInMaterialDetailApplicationService { return inMaterialDetailDomainService.getInfo(materialDetailId); } + /** + * 入库明细查询(关联入库执行单) + */ + public List queryInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); + if (topOrganizationId != null && topOrganizationId != 1) { + queryOrderOverStockDO.setTopOrganizationId(topOrganizationId); + } + } + return inMaterialDetailDomainService.queryInOrderDetailList(queryOrderOverStockDO); + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailAssembler.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailAssembler.java index cdd1ab53b..03bae5c68 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailAssembler.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailAssembler.java @@ -8,6 +8,8 @@ import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.security.utils.SecurityUtils; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDTO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailQueryDTO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import com.mhd.system.api.model.LoginUser; import org.springframework.stereotype.Component; @@ -62,4 +64,13 @@ public class ExecutionInMaterialDetailAssembler { return inMaterialDetailDO; } + /** + * 入库明细查询 DTO → QueryOrderOverStockDO + */ + public QueryOrderOverStockDO toQueryDO(ExecutionInMaterialDetailQueryDTO queryDTO) { + QueryOrderOverStockDO queryDO = new QueryOrderOverStockDO(); + BeanUtils.copyProperties(queryDTO, queryDO, IgnoreNullUtil.getNullPropertyNames(queryDTO)); + return queryDO; + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailDomainService.java index 7bc0a922b..318545fcd 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionInMaterialDetail/service/ExecutionInMaterialDetailDomainService.java @@ -2,7 +2,9 @@ package com.mhd.oms.domain.executionInMaterialDetail.service; import com.mhd.oms.domain.executionInMaterialDetail.repository.facade.IExecutionInMaterialDetailService; import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -62,4 +64,11 @@ public class ExecutionInMaterialDetailDomainService { } + /** + * 入库明细查询(关联入库执行单) + */ + public List queryInOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) { + return materialDetailService.queryInOrderDetailList(queryOrderOverStockDO); + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/facade/IExecutionOutMaterialDetailService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/facade/IExecutionOutMaterialDetailService.java index 78e1975b9..f2b6d3193 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/facade/IExecutionOutMaterialDetailService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/facade/IExecutionOutMaterialDetailService.java @@ -3,6 +3,7 @@ package com.mhd.oms.domain.executionOutMaterialDetail.repository.facade; import com.baomidou.mybatisplus.extension.service.IService; import com.mhd.oms.domain.executionOutMaterialDetail.entity.ExecutionOutMaterialDetail; import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailPO; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailBaseDO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailDO; import com.mhd.oms.domain.reservationInMaterialDetail.repository.todo.QueryOrderOverStockDO; @@ -62,4 +63,9 @@ public interface IExecutionOutMaterialDetailService extends IService queryOutOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO); } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/mapper/ExecutionOutMaterialDetailMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/mapper/ExecutionOutMaterialDetailMapper.java index 8268d7b9e..01b6b0f7b 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/mapper/ExecutionOutMaterialDetailMapper.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/mapper/ExecutionOutMaterialDetailMapper.java @@ -3,6 +3,7 @@ package com.mhd.oms.domain.executionOutMaterialDetail.repository.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.mhd.oms.domain.executionOutMaterialDetail.entity.ExecutionOutMaterialDetail; import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailPO; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailDO; import com.mhd.oms.domain.reservationInMaterialDetail.repository.todo.QueryOrderOverStockDO; import org.apache.ibatis.annotations.Param; @@ -67,4 +68,9 @@ public interface ExecutionOutMaterialDetailMapper extends BaseMapper queryOutOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO); } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/persistence/ExecutionOutMaterialDetailImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/persistence/ExecutionOutMaterialDetailImpl.java index 8d7e0babd..7b7180d12 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/persistence/ExecutionOutMaterialDetailImpl.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/persistence/ExecutionOutMaterialDetailImpl.java @@ -12,6 +12,7 @@ import com.mhd.oms.domain.executionOutMaterialDetail.entity.ExecutionOutMaterial import com.mhd.oms.domain.executionOutMaterialDetail.repository.facade.IExecutionOutMaterialDetailService; import com.mhd.oms.domain.executionOutMaterialDetail.repository.mapper.ExecutionOutMaterialDetailMapper; import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailPO; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailBaseDO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailDO; import com.mhd.oms.domain.executionStockInOrder.repository.mapper.ExecutionStockInOrderMapper; @@ -261,4 +262,13 @@ public class ExecutionOutMaterialDetailImpl extends ServiceImpl queryOutOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) { + return outMaterialDetailMapper.queryOutOrderDetailList(queryOrderOverStockDO); + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/po/ExecutionOutMaterialDetailWithOrderPO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/po/ExecutionOutMaterialDetailWithOrderPO.java new file mode 100644 index 000000000..6cc1c9823 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/po/ExecutionOutMaterialDetailWithOrderPO.java @@ -0,0 +1,44 @@ +package com.mhd.oms.domain.executionOutMaterialDetail.repository.po; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 出库明细查询结果(关联出库执行单) + * + * @author gen + * @date 2024-07-24 + */ +@Data +public class ExecutionOutMaterialDetailWithOrderPO extends ExecutionOutMaterialDetailPO { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("出库单状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") + private Integer outOrderStatus; + + @ApiModelProperty("出库单审核状态: 1-未审核 2-审核不通过 3-审核通过") + private Integer outOrderAuditStatus; + + @ApiModelProperty("货主ID") + private Long orderShipperId; + + @ApiModelProperty("货主编码") + private String orderShipperCode; + + @ApiModelProperty("货主名称") + private String orderShipperName; + + @ApiModelProperty("出仓日期") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date orderOutboundDate; + + @ApiModelProperty("出库时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date orderOutboundTime; +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/todo/ExecutionOutMaterialDetailQueryDTO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/todo/ExecutionOutMaterialDetailQueryDTO.java new file mode 100644 index 000000000..e21050c93 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/repository/todo/ExecutionOutMaterialDetailQueryDTO.java @@ -0,0 +1,69 @@ +package com.mhd.oms.domain.executionOutMaterialDetail.repository.todo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.mhd.common.core.web.domain.BaseVOEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 出库明细查询参数 DTO + * + * @author gen + * @date 2024-07-24 + */ +@Data +public class ExecutionOutMaterialDetailQueryDTO extends BaseVOEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("组织表ID") + private Long organizationId; + + @ApiModelProperty("一级组织表ID") + private Long topOrganizationId; + + @ApiModelProperty("出库单号") + private String outOrderNumber; + + @ApiModelProperty("仓库id") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("货主id") + private Long shipperId; + + @ApiModelProperty("货主名称") + private String shipperName; + + @ApiModelProperty("出库单类型编码") + private String outOrderTypeCode; + + @ApiModelProperty("出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-拣货中 6-波次中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") + private Integer outStatus; + + @ApiModelProperty("预计出库时间 开始") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date outOrderExpectStartTime; + + @ApiModelProperty("预计出库时间 结束") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date outOrderExpectEndTime; + + @ApiModelProperty("物料基础信息id") + private Long materialBaseInfoId; + + @ApiModelProperty("物料编码") + private String materialCode; + + @ApiModelProperty("物料名称") + private String materialName; +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailApplicationService.java new file mode 100644 index 000000000..8c6b862c8 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailApplicationService.java @@ -0,0 +1,38 @@ +package com.mhd.oms.domain.executionOutMaterialDetail.service; + +import com.mhd.common.security.utils.SecurityUtils; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO; +import com.mhd.oms.domain.reservationInMaterialDetail.repository.todo.QueryOrderOverStockDO; +import com.mhd.system.api.model.LoginUser; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 出库明细ApplicationService + * + * @author gen + * @date 2024-07-24 + */ +@Service +@Slf4j +public class ExecutionOutMaterialDetailApplicationService { + @Autowired + private ExecutionOutMaterialDetailDomainService outMaterialDetailDomainService; + + /** + * 出库明细查询(关联出库执行单) + */ + public List queryOutOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); + if (topOrganizationId != null && topOrganizationId != 1) { + queryOrderOverStockDO.setTopOrganizationId(topOrganizationId); + } + } + return outMaterialDetailDomainService.queryOutOrderDetailList(queryOrderOverStockDO); + } +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailAssembler.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailAssembler.java new file mode 100644 index 000000000..be2211cbd --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailAssembler.java @@ -0,0 +1,26 @@ +package com.mhd.oms.domain.executionOutMaterialDetail.service; + +import com.mhd.common.core.utils.IgnoreNullUtil; +import com.mhd.common.core.utils.bean.BeanUtils; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailQueryDTO; +import com.mhd.oms.domain.reservationInMaterialDetail.repository.todo.QueryOrderOverStockDO; +import org.springframework.stereotype.Component; + +/** + * 出库明细Assembler + * + * @author gen + * @date 2024-07-24 + */ +@Component +public class ExecutionOutMaterialDetailAssembler { + + /** + * 出库明细查询 DTO → QueryOrderOverStockDO + */ + public QueryOrderOverStockDO toQueryDO(ExecutionOutMaterialDetailQueryDTO queryDTO) { + QueryOrderOverStockDO queryDO = new QueryOrderOverStockDO(); + BeanUtils.copyProperties(queryDTO, queryDO, IgnoreNullUtil.getNullPropertyNames(queryDTO)); + return queryDO; + } +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailDomainService.java index c4c97c20d..27826ab29 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionOutMaterialDetail/service/ExecutionOutMaterialDetailDomainService.java @@ -5,7 +5,9 @@ package com.mhd.oms.domain.executionOutMaterialDetail.service; //import com.mhd.wms.domain.outMaterialDetail.repository.todo.ExecutionOutMaterialDetailDO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.facade.IExecutionOutMaterialDetailService; import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailPO; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailDO; +import com.mhd.oms.domain.reservationInMaterialDetail.repository.todo.QueryOrderOverStockDO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -64,4 +66,11 @@ public class ExecutionOutMaterialDetailDomainService { return outMaterialDetailService.getInfo(materialDetailId); } + /** + * 出库明细查询(关联出库执行单) + */ + public List queryOutOrderDetailList(QueryOrderOverStockDO queryOrderOverStockDO) { + return outMaterialDetailService.queryOutOrderDetailList(queryOrderOverStockDO); + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/entity/ExecutionStockInOrder.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/entity/ExecutionStockInOrder.java index bd785b871..a632a9046 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/entity/ExecutionStockInOrder.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/entity/ExecutionStockInOrder.java @@ -456,4 +456,7 @@ public class ExecutionStockInOrder extends BaseVOEntity { @ApiModelProperty("业务计价方式") private String businessPriceWay; + + @ApiModelProperty("通知单备注") + private String noticeRemark; } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/po/ExecutionStockInOrderPO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/po/ExecutionStockInOrderPO.java index 626c06a69..304015586 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/po/ExecutionStockInOrderPO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/po/ExecutionStockInOrderPO.java @@ -480,4 +480,6 @@ public class ExecutionStockInOrderPO extends BaseVOEntity { @ApiModelProperty("业务计价方式") private String businessPriceWay; private String khdm; + @ApiModelProperty("通知单备注") + private String noticeRemark; } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDO.java index 63062b7b0..9da4e4dd7 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDO.java @@ -511,4 +511,6 @@ public class ExecutionStockInOrderDO extends BaseVOEntity { @ApiModelProperty("业务计价方式") private String businessPriceWay; + @ApiModelProperty("通知单备注") + private String noticeRemark; } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDTO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDTO.java index f3b3977d4..2957ed604 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDTO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/repository/todo/ExecutionStockInOrderDTO.java @@ -508,4 +508,6 @@ public class ExecutionStockInOrderDTO extends ExecutionStockInOrderBaseDTO { @ApiModelProperty("业务计价方式") private String businessPriceWay; + @ApiModelProperty("通知单备注") + private String noticeRemark; } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/service/ExecutionStockInOrderDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/service/ExecutionStockInOrderDomainService.java index 9bf82170f..b7e5b8fab 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/service/ExecutionStockInOrderDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockInOrder/service/ExecutionStockInOrderDomainService.java @@ -30,6 +30,7 @@ import com.mhd.oms.domain.executionStockInOrder.repository.todo.ExecutionStockIn import com.mhd.oms.domain.executionStockOutOrder.entity.ExecutionStockOutOrder; import com.mhd.oms.domain.executionStockOutOrder.repository.facade.IExecutionStockOutOrderService; import com.mhd.oms.domain.reservationStockInOrder.repository.mapper.ReservationStockInOrderMapper; +import com.mhd.oms.domain.reserveStockInOrder.repository.mapper.ReserveStockInOrderMapper; import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.WmsServiceFeign; import com.mhd.system.api.domain.*; @@ -43,6 +44,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.lang.reflect.Field; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -89,6 +91,8 @@ public class ExecutionStockInOrderDomainService { // private IShelfMaterialDetailService shelfMaterialDetailService; @Resource private ReservationStockInOrderMapper stockInOrderMapper; + @Autowired + private ReserveStockInOrderMapper reserveStockInOrderMapper; /** * 分页查询入库单列表 */ @@ -96,14 +100,70 @@ public class ExecutionStockInOrderDomainService { return stockInOrderService.queryList(stockInOrderDO); } + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } /** * 新增入库单 */ @Transactional(rollbackFor = Exception.class) public Boolean insert(ExecutionStockInOrderDO stockInOrderDO) { - if (stockInOrderDO.getInOrderNumber() == null) { - stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK")); + //设置入库单号 + Long warehouseId = stockInOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = stockInOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(prefix + seq); } // //设置默认值 // setDefaultValues(stockInOrderDO); @@ -132,8 +192,35 @@ public class ExecutionStockInOrderDomainService { */ public Boolean batchInsert(List stockInOrderDOList) { for (ExecutionStockInOrderDO stockInOrderDO : stockInOrderDOList){ - if (StringUtils.isBlank(stockInOrderDO.getInOrderNumber())){ - stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK")); + //设置入库单号 + Long warehouseId = stockInOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = stockInOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(prefix + seq); } // //设置物料信息 // setMaterialDetailInfo(stockInOrderDO); diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockOutOrder/service/ExecutionStockOutOrderDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockOutOrder/service/ExecutionStockOutOrderDomainService.java index 27e1ea97f..36603f13e 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockOutOrder/service/ExecutionStockOutOrderDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/executionStockOutOrder/service/ExecutionStockOutOrderDomainService.java @@ -8,6 +8,7 @@ import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.utils.OrderSequence; import com.mhd.common.core.utils.StringUtils; import com.mhd.common.core.utils.bean.BeanUtils; +import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.security.utils.SecurityUtils; import com.mhd.oms.domain.businessDeliveryDetailsLink.entity.BusinessDeliveryDetailsLink; import com.mhd.oms.domain.businessDeliveryDetailsLink.repository.facade.IBusinessDeliveryDetailsLinkService; @@ -38,6 +39,8 @@ import com.mhd.oms.domain.reservationInventoryAdjustmentRecord.repository.mapper import com.mhd.oms.domain.reservationMaterialInventory.entity.ReservationMaterialInventory; import com.mhd.oms.domain.reservationMaterialInventory.repository.mapper.ReservationMaterialInventoryMapper; import com.mhd.oms.domain.reservationStockInOrder.repository.mapper.ReservationStockInOrderMapper; +import com.mhd.oms.domain.reserveStockInOrder.repository.mapper.ReserveStockInOrderMapper; +import com.mhd.oms.domain.reserveStockOutOrder.repository.mapper.ReserveStockOutOrderMapper; import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.WmsServiceFeign; import com.mhd.system.api.domain.*; @@ -50,6 +53,7 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -96,6 +100,8 @@ public class ExecutionStockOutOrderDomainService { private ReservationMaterialInventoryMapper reservationMaterialInventoryMapper; @Autowired private ReservationStockInOrderMapper stockInOrderMapper; + @Autowired + private ReserveStockOutOrderMapper reserveStockOutOrderMapper; /** * 分页查询出库单列表 */ @@ -103,14 +109,74 @@ public class ExecutionStockOutOrderDomainService { return stockOutOrderService.queryList(stockOutOrderDO); } - + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } /** * 新增出库单 */ @Transactional(rollbackFor = Exception.class) public Boolean insert(ExecutionStockOutOrderDO stockOutOrderDO) { - if (stockOutOrderDO.getOutOrderNumber() == null) { - stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); + //设置单号 + Long warehouseId = stockOutOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getOutOrderNoPrefix(); + if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { + prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); + } + if (prefix == null || prefix.isEmpty()) { + prefix = "CK"; + } + Long organizationId = stockOutOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(datePrefix + seq); + stockOutOrderDO.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(prefix + seq); + stockOutOrderDO.setBusinessOrderNo(prefix + seq); } // 与 update / batchInsert 一致:前端传计划数量为 quantity,非 outboundQuantity setMaterialDetailInfo(stockOutOrderDO); @@ -147,8 +213,40 @@ public class ExecutionStockOutOrderDomainService { @Transactional(rollbackFor = Exception.class) public Boolean batchInsert(List stockOutOrderDOList) { for (ExecutionStockOutOrderDO stockOutOrderDO : stockOutOrderDOList){ - if (StringUtils.isBlank(stockOutOrderDO.getOutOrderNumber())){ - stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); + //设置单号 + Long warehouseId = stockOutOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getOutOrderNoPrefix(); + if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { + prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); + } + if (prefix == null || prefix.isEmpty()) { + prefix = "CK"; + } + Long organizationId = stockOutOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(datePrefix + seq); + stockOutOrderDO.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(prefix + seq); + stockOutOrderDO.setBusinessOrderNo(prefix + seq); } //设置物料信息 setMaterialDetailInfo(stockOutOrderDO); diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/entity/ReservationStockInOrder.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/entity/ReservationStockInOrder.java index 1cc8956c4..f61291f28 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/entity/ReservationStockInOrder.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/entity/ReservationStockInOrder.java @@ -61,6 +61,10 @@ public class ReservationStockInOrder extends BaseVOEntity { @Excel(name = "入库单号") private String inOrderNumber; + @ApiModelProperty("执行入库单号") + @Excel(name = "执行入库单号") + private String executionInOrderNumber; + @ApiModelProperty("入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭") @Excel(name = "入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库 6-已取消 7-已关闭") private Integer status; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java index 93070d2f4..da63a1c38 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/persistence/ReservationStockInOrderImpl.java @@ -39,6 +39,7 @@ import com.mhd.oms.domain.reservationStockOutOrder.repository.facade.IReservatio import com.mhd.oms.domain.reservationStockOutOrder.repository.mapper.ReservationStockOutOrderMapper; import com.mhd.oms.domain.reservationStockOutOrder.repository.todo.ReservationStockOutOrderDO; import com.mhd.oms.domain.reservationStockOutOrder.service.ReservationStockOutOrderApplicationService; +import com.mhd.oms.domain.reserveStockInOrder.repository.mapper.ReserveStockInOrderMapper; import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.UserServiceFeign; import com.mhd.system.api.domain.SysDictData; @@ -87,7 +88,8 @@ public class ReservationStockInOrderImpl extends ServiceImpl orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } + @Transactional(rollbackFor = Exception.class) public Boolean insertDomain(ReservationStockInOrderDO stockInOrderDO) { - if (stockInOrderDO.getInOrderNumber() == null) { +// if (stockInOrderDO.getInOrderNumber() == null) { + + //设置入库单号 + Long warehouseId = stockInOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = stockInOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reservationStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(datePrefix + seq); + stockInOrderDO.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reservationStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(prefix + seq); + stockInOrderDO.setBusinessOrderNo(prefix + seq); + } stockInOrderDO.setInOrderNumber(reservationStockInOrderDomainService.generateReserveOrderNumber()); stockInOrderDO.setBusinessOrderNo(stockInOrderDO.getInOrderNumber()); - } +// } // //统计总计划数 BigDecimal quantity = stockInOrderDO.getMaterialDetailList().stream().map(ReservationInMaterialDetailDO::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); stockInOrderDO.setQuantity(quantity); diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/po/ReservationStockInOrderPO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/po/ReservationStockInOrderPO.java index a46613252..0fbd2e06a 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/po/ReservationStockInOrderPO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/po/ReservationStockInOrderPO.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.mhd.common.core.annotation.Excel; import com.mhd.common.core.web.domain.BaseVOEntity; import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder; +import com.mhd.oms.domain.executionStockInOrder.entity.ExecutionStockInOrder; import com.mhd.oms.domain.reservationInMaterialDetail.repository.po.ReservationInMaterialDetailPO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -62,6 +63,10 @@ public class ReservationStockInOrderPO extends BaseVOEntity { @Excel(name = "入库单号") private String inOrderNumber; + @ApiModelProperty("执行入库单号") + @Excel(name = "执行入库单号") + private String executionInOrderNumber; + @ApiModelProperty("入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库") @Excel(name = "入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库") private Integer status; @@ -242,6 +247,9 @@ public class ReservationStockInOrderPO extends BaseVOEntity { @ApiModelProperty("物料明细") private List materialDetailList; + @ApiModelProperty("执行单列表") + private List executionStockInOrderList; + @ApiModelProperty("越库单id") private Long overStockId; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDO.java index 642436946..fe2eb7cc2 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDO.java @@ -59,6 +59,10 @@ public class ReservationStockInOrderDO extends BaseVOEntity { @Excel(name = "入库单号") private String inOrderNumber; + @ApiModelProperty("执行入库单号") + @Excel(name = "执行入库单号") + private String executionInOrderNumber; + @ApiModelProperty("入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库") @Excel(name = "入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库") private Integer status; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDTO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDTO.java index 9c672d7c8..fb0ff4f6f 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDTO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/repository/todo/ReservationStockInOrderDTO.java @@ -59,6 +59,10 @@ public class ReservationStockInOrderDTO extends ReservationStockInOrderBaseDTO { @Excel(name = "入库单号") private String inOrderNumber; + @ApiModelProperty("执行入库单号") + @Excel(name = "执行入库单号") + private String executionInOrderNumber; + @ApiModelProperty("入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库") @Excel(name = "入库状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库") private Integer status; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderApplicationService.java index 348f3b829..fe3a31e02 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderApplicationService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderApplicationService.java @@ -136,13 +136,13 @@ public class ReservationStockInOrderApplicationService { } } // 前端有传warehouseId则优先使用传参;未传时才使用"用户关联仓库"作为默认值 - if (stockInOrderDO.getWarehouseId() == null) { - AssociationWarehouseCacheDO associationWarehouseCacheDO = - SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); - if (associationWarehouseCacheDO != null) { - stockInOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); - } - } +// if (stockInOrderDO.getWarehouseId() == null) { +// AssociationWarehouseCacheDO associationWarehouseCacheDO = +// SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); +// if (associationWarehouseCacheDO != null) { +// stockInOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); +// } +// } } // 库管角色过滤:不展示已创建(status=1)的入库单 diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderDomainService.java index 5a55e93e2..d2b872096 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockInOrder/service/ReservationStockInOrderDomainService.java @@ -99,6 +99,48 @@ public class ReservationStockInOrderDomainService { return stockInOrderService.queryList(stockInOrderDO); } + /** + * 生成入库预约单号 + */ +// public String generateReserveOrderNumber() { +// SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd"); +// String datePart = sdf.format(new Date()); +// String prefix = "R" + datePart; +// int todayCount = reservationStockInOrderMapper.countByOrderNumberPrefix(prefix); +// String seq = String.format("%03d", todayCount + 1); +// return prefix + seq; +// } + + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } + /** * 新增入库单 @@ -106,6 +148,40 @@ public class ReservationStockInOrderDomainService { @Transactional(rollbackFor = Exception.class) public Boolean insert(ReservationStockInOrderDO stockInOrderDO) { if (stockInOrderDO.getInOrderNumber() == null) { + + //设置入库单号 +// Long warehouseId = stockInOrderDO.getWarehouseId(); +// AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); +// if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { +// throw new ServiceException("获取仓库信息失败"); +// } +// //仓库信息 +// WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); +// String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); +// String prefix = warehouseFeignPO.getInOrderNoPrefix(); +// if (prefix == null || prefix.isEmpty()) { +// prefix = "RK"; +// } +// Long organizationId = stockInOrderDO.getOrganizationId(); +// Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); +// if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { +// //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 +// String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); +// String datePrefix = prefix + dateStr; +// List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockInOrderDO.setInOrderNumber(datePrefix + seq); +// stockInOrderDO.setBusinessOrderNo(datePrefix + seq); +// } else { +// //历史累加: 前缀 + 历史最大序号+1 +// List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockInOrderDO.setInOrderNumber(prefix + seq); +// stockInOrderDO.setBusinessOrderNo(prefix + seq); +// } + stockInOrderDO.setInOrderNumber(generateReserveOrderNumber()); stockInOrderDO.setBusinessOrderNo(stockInOrderDO.getInOrderNumber()); } @@ -136,9 +212,12 @@ public class ReservationStockInOrderDomainService { */ public Boolean batchInsert(List stockInOrderDOList) { for (ReservationStockInOrderDO stockInOrderDO : stockInOrderDOList){ - if (StringUtils.isBlank(stockInOrderDO.getInOrderNumber())){ - stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK")); + + if (stockInOrderDO.getInOrderNumber() == null) { + stockInOrderDO.setInOrderNumber(generateReserveOrderNumber()); + stockInOrderDO.setBusinessOrderNo(stockInOrderDO.getInOrderNumber()); } + // //设置物料信息 // setMaterialDetailInfo(stockInOrderDO); // //统计总物料种数 @@ -247,6 +326,12 @@ public class ReservationStockInOrderDomainService { String inOrderNumber = stockInOrderPO.getInOrderNumber(); List businessDocumentOrders = businessDocumentOrderMapper.selectList(new LambdaQueryWrapper().eq(BusinessDocumentOrder::getInOrderNumber, inOrderNumber).notIn(BusinessDocumentOrder::getOrderStatus,4,5)); stockInOrderPO.setBusinessDocumentOrderDOList(businessDocumentOrders); + //执行单 + List executionStockInOrders = executionStockInOrderMapper.selectList(new LambdaQueryWrapper() + .eq(ExecutionStockInOrder::getBusinessInOrderNumber, inOrderNumber) + .eq(ExecutionStockInOrder::getDelFlag, 1)); + stockInOrderPO.setExecutionStockInOrderList(executionStockInOrders); + inMaterialDetailDO.setInOrderNumber(inOrderNumber); inMaterialDetailDO.setLevel(1); List inMaterialDetailPOList = materialDetailService.queryList(inMaterialDetailDO); @@ -547,6 +632,7 @@ public class ReservationStockInOrderDomainService { // 按照 warehouseId 分组 Map> materialDetailGroupByWarehouse = materialDetailList.stream() .collect(Collectors.groupingBy(ReservationInMaterialDetail::getWarehouseId)); + List executionInOrderNumbers = new ArrayList<>(); materialDetailGroupByWarehouse.forEach((warehouseId, details) -> { Long topOrgId = reservationStockInOrderMapper.getTopOrgId(warehouseId); Long orgId = reservationStockInOrderMapper.getOrgId(warehouseId); @@ -574,7 +660,40 @@ public class ReservationStockInOrderDomainService { reservationStockInOrder.setWarehouseCode(warehouseCode); reservationStockInOrder.setWarehouseName(warehouseName); reservationStockInOrder.setBusinessInOrderNumber(inOrderNumber); - reservationStockInOrder.setInOrderNumber(generateExecutionOrderNumber(warehouseCode)); + + + //设置入库单号 + Long warehouseId1 = reservationStockInOrder.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId1); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = reservationStockInOrder.getOrganizationId(); + Long warehouseIdForCount = reservationStockInOrder.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setInOrderNumber(datePrefix + seq); +// reservationStockInOrder.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setInOrderNumber(prefix + seq); +// reservationStockInOrder.setBusinessOrderNo(prefix + seq); + } List inMaterialDetailList = new ArrayList<>(); int index = 1; @@ -597,8 +716,11 @@ public class ReservationStockInOrderDomainService { BigDecimal quantity = details.stream().map(ReservationInMaterialDetail::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); reservationStockInOrder.setQuantity(quantity); executionStockInOrderService.save(reservationStockInOrder); + executionInOrderNumbers.add(reservationStockInOrder.getInOrderNumber()); executionInMaterialDetailService.saveBatch(inMaterialDetailList); }); + byId.setExecutionInOrderNumber(String.join(",", executionInOrderNumbers)); + stockInOrderService.updateById(byId); } @@ -700,6 +822,7 @@ public class ReservationStockInOrderDomainService { // 按照 warehouseId 分组 Map> materialDetailGroupByWarehouse = materialDetailList.stream() .collect(Collectors.groupingBy(ReservationInMaterialDetail::getWarehouseId)); + List executionInOrderNumbers = new ArrayList<>(); materialDetailGroupByWarehouse.forEach((warehouseId, details) -> { if (warehouseId == null) warehouseId = warehouseId1; @@ -727,7 +850,40 @@ public class ReservationStockInOrderDomainService { reservationStockInOrder.setWarehouseCode(warehouseCode); reservationStockInOrder.setWarehouseName(warehouseName); reservationStockInOrder.setBusinessInOrderNumber(inOrderNumber); - reservationStockInOrder.setInOrderNumber(generateExecutionOrderNumber(warehouseCode)); + + + //设置入库单号 +// Long warehouseId1 = reservationStockInOrder.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = reservationStockInOrder.getOrganizationId(); + Long warehouseIdForCount = reservationStockInOrder.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setInOrderNumber(datePrefix + seq); +// reservationStockInOrder.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setInOrderNumber(prefix + seq); +// reservationStockInOrder.setBusinessOrderNo(prefix + seq); + } List inMaterialDetailList = new ArrayList<>(); int index = 1; @@ -749,6 +905,7 @@ public class ReservationStockInOrderDomainService { } BigDecimal quantity = details.stream().map(ReservationInMaterialDetail::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); reservationStockInOrder.setQuantity(quantity); + executionInOrderNumbers.add(reservationStockInOrder.getInOrderNumber()); executionStockInOrderService.save(reservationStockInOrder); executionInMaterialDetailService.saveBatch(inMaterialDetailList); ExecutionStockInOrderDO param = new ExecutionStockInOrderDO(); @@ -758,6 +915,8 @@ public class ReservationStockInOrderDomainService { param.setInOrderIds(inOrderIdList1); stockInOrderApplicationService.issueOrder(param); }); + byId.setExecutionInOrderNumber(String.join(",", executionInOrderNumbers)); + stockInOrderService.updateById(byId); } diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/entity/ReservationStockOutOrder.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/entity/ReservationStockOutOrder.java index 15c35bd98..5279cf42f 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/entity/ReservationStockOutOrder.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/entity/ReservationStockOutOrder.java @@ -50,6 +50,10 @@ public class ReservationStockOutOrder extends BaseVOEntity { @Excel(name = "出库单号") private String outOrderNumber; + @ApiModelProperty("执行出库单号") + @Excel(name = "执行出库单号") + private String executionOutOrderNumber; + @ApiModelProperty("出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭 12-已复核") @Excel(name = "出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭 12-已复核") private Integer status; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/po/ReservationStockOutOrderPO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/po/ReservationStockOutOrderPO.java index c819e15ff..b8bf6e520 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/po/ReservationStockOutOrderPO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/po/ReservationStockOutOrderPO.java @@ -3,6 +3,7 @@ package com.mhd.oms.domain.reservationStockOutOrder.repository.po; import com.fasterxml.jackson.annotation.JsonFormat; import com.mhd.common.core.annotation.Excel; import com.mhd.common.core.web.domain.BaseVOEntity; +import com.mhd.oms.domain.executionStockOutOrder.entity.ExecutionStockOutOrder; import com.mhd.oms.domain.reservationDeliveryDetailsLink.entity.ReservationDeliveryDetailsLink; import com.mhd.oms.domain.reservationDeliveryDetailsLink.repository.po.ReservationDeliveryDetailsLinkPO; import com.mhd.oms.domain.reservationOutMaterialDetail.repository.po.ReservationOutMaterialDetailPO; @@ -56,6 +57,10 @@ public class ReservationStockOutOrderPO extends BaseVOEntity { @Excel(name = "出库单号") private String outOrderNumber; + @ApiModelProperty("执行出库单号") + @Excel(name = "执行出库单号") + private String executionOutOrderNumber; + @ApiModelProperty("出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") @Excel(name = "出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") private Integer status; @@ -261,6 +266,9 @@ public class ReservationStockOutOrderPO extends BaseVOEntity { @ApiModelProperty("物料明细") private List materialDetailList; + + @ApiModelProperty("执行单列表") + private List executionStockOutOrderList; // // @ApiModelProperty("出库单复核统计") // private ReservationOutMaterialCheckPO outMaterialCheckPO; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDO.java index e34203385..3e9dd473d 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDO.java @@ -52,6 +52,10 @@ public class ReservationStockOutOrderDO extends BaseVOEntity { @Excel(name = "出库单号") private String outOrderNumber; + @ApiModelProperty("执行出库单号") + @Excel(name = "执行出库单号") + private String executionOutOrderNumber; + @ApiModelProperty("出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") @Excel(name = "出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") private Integer status; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDTO.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDTO.java index 11f0aa94b..6fecfa5d5 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDTO.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/repository/todo/ReservationStockOutOrderDTO.java @@ -50,6 +50,10 @@ public class ReservationStockOutOrderDTO extends ReservationStockOutOrderBaseDTO @Excel(name = "出库单号") private String outOrderNumber; + @ApiModelProperty("执行出库单号") + @Excel(name = "执行出库单号") + private String executionOutOrderNumber; + @ApiModelProperty("出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") @Excel(name = "出库状态: 1-已创建 2-已审核 3-部分分配 4-已分配 5-波次中 6-拣货中 7-拣货完成 8-复核中 9-已出库 10-已取消 11-已关闭") private Integer status; diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java index 877149037..1e4f07f3c 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderApplicationService.java @@ -16,6 +16,8 @@ import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.core.utils.uuid.IdGenerator; import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.security.utils.SecurityUtils; +import com.mhd.oms.domain.executionStockOutOrder.entity.ExecutionStockOutOrder; +import com.mhd.oms.domain.executionStockOutOrder.repository.mapper.ExecutionStockOutOrderMapper; import com.mhd.oms.domain.gwLog.entity.GwLog; import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper; import com.mhd.oms.domain.reservationDeliveryDetailsLink.entity.ReservationDeliveryDetailsLink; @@ -111,6 +113,8 @@ public class ReservationStockOutOrderApplicationService { private ReservationOutMaterialDetailMapper reservationOutMaterialDetailMapper; @Autowired private ReservationDeliveryDetailsLinkMapper reservationDeliveryDetailsLinkMapper; + @Autowired + private ExecutionStockOutOrderMapper executionStockOutOrderMapper; @Autowired private ReservationStockInOrderMapper reservationStockInOrderMapper; @@ -306,6 +310,13 @@ public class ReservationStockOutOrderApplicationService { return stockOutOrderPO; } stockOutOrderPO.setKhdm(userNcCode); + + //执行单 + List executionStockInOrders = executionStockOutOrderMapper.selectList(new LambdaQueryWrapper() + .eq(ExecutionStockOutOrder::getBusinessOutOrderNumber, stockOutOrderPO.getOutOrderNumber()) + .eq(ExecutionStockOutOrder::getDelFlag, 1)); + stockOutOrderPO.setExecutionStockOutOrderList(executionStockInOrders); + if (stockOutOrderPO.getMaterialDetailList() != null && stockOutOrderPO.getMaterialDetailList().size() > 0) { List materialDetailList = stockOutOrderPO.getMaterialDetailList(); if (CollectionUtils.isEmpty(materialDetailList)) { diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderDomainService.java index bf7018944..91887172f 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reservationStockOutOrder/service/ReservationStockOutOrderDomainService.java @@ -122,7 +122,35 @@ public class ReservationStockOutOrderDomainService { public List queryList(ReservationStockOutOrderDO stockOutOrderDO) { return stockOutOrderService.queryList(stockOutOrderDO); } - + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } /** * 新增出库单 @@ -133,6 +161,42 @@ public class ReservationStockOutOrderDomainService { stockOutOrderDO.setOutOrderNumber(generateReserveOrderNumber()); stockOutOrderDO.setBusinessOrderNo(stockOutOrderDO.getOutOrderNumber()); } + //设置单号 +// Long warehouseId = stockOutOrderDO.getWarehouseId(); +// AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); +// if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { +// throw new ServiceException("获取仓库信息失败"); +// } +// //仓库信息 +// WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); +// String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); +// String prefix = warehouseFeignPO.getOutOrderNoPrefix(); +// if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { +// prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); +// } +// if (prefix == null || prefix.isEmpty()) { +// prefix = "CK"; +// } +// Long organizationId = stockOutOrderDO.getOrganizationId(); +// Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); +// if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { +// //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 +// String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); +// String datePrefix = prefix + dateStr; +// List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockOutOrderDO.setOutOrderNumber(datePrefix + seq); +// stockOutOrderDO.setBusinessOrderNo(datePrefix + seq); +// } else { +// //历史累加: 前缀 + 历史最大序号+1 +// List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockOutOrderDO.setOutOrderNumber(prefix + seq); +// stockOutOrderDO.setBusinessOrderNo(prefix + seq); +// } + // 与 update / batchInsert 一致:前端传计划数量为 quantity,非 outboundQuantity setMaterialDetailInfo(stockOutOrderDO); stockOutOrderDO.setMaterialQuantity(stockOutOrderDO.getMaterialDetailList().size()); @@ -172,9 +236,13 @@ public class ReservationStockOutOrderDomainService { @Transactional(rollbackFor = Exception.class) public Boolean batchInsert(List stockOutOrderDOList) { for (ReservationStockOutOrderDO stockOutOrderDO : stockOutOrderDOList){ - if (StringUtils.isBlank(stockOutOrderDO.getOutOrderNumber())){ - stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); + + + if (stockOutOrderDO.getOutOrderNumber() == null) { + stockOutOrderDO.setOutOrderNumber(generateReserveOrderNumber()); + stockOutOrderDO.setBusinessOrderNo(stockOutOrderDO.getOutOrderNumber()); } + //设置物料信息 setMaterialDetailInfo(stockOutOrderDO); //统计种类 @@ -364,6 +432,7 @@ public class ReservationStockOutOrderDomainService { for (Long inOrderId : inOrderIds) { ReservationStockOutOrder byId = stockOutOrderService.getById(inOrderId); String inOrderNumber = byId.getOutOrderNumber(); + List executionInOrderNumbers = new ArrayList<>(); List materialDetailList = outMaterialDetailService.list(new QueryWrapper().lambda().eq(ReservationOutMaterialDetail::getOutOrderNumber, inOrderNumber)); // 按照 warehouseId 分组 @@ -396,7 +465,43 @@ public class ReservationStockOutOrderDomainService { // reservationStockInOrder.setTopOrganizationId(topOrgId); reservationStockInOrder.setBusinessOutOrderNumber(inOrderNumber); - reservationStockInOrder.setOutOrderNumber(generateExecutionOrderNumber(warehouseCode)); +// reservationStockInOrder.setOutOrderNumber(generateExecutionOrderNumber(warehouseCode)); + + //设置单号 + Long warehouseId1 = reservationStockInOrder.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId1); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getOutOrderNoPrefix(); + if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { + prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); + } + if (prefix == null || prefix.isEmpty()) { + prefix = "CK"; + } + Long organizationId = stockOutOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setOutOrderNumber(datePrefix + seq); +// reservationStockInOrder.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setOutOrderNumber(prefix + seq); +// reservationStockInOrder.setBusinessOrderNo(prefix + seq); + } List inMaterialDetailList = new ArrayList<>(); @@ -415,8 +520,11 @@ public class ReservationStockOutOrderDomainService { BigDecimal quantity = details.stream().map(ReservationOutMaterialDetail::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); reservationStockInOrder.setQuantity(quantity); executionStockOutOrderService.save(reservationStockInOrder); + executionInOrderNumbers.add(reservationStockInOrder.getOutOrderNumber()); executionOutMaterialDetailService.saveBatch(inMaterialDetailList); }); + byId.setExecutionOutOrderNumber(String.join(",", executionInOrderNumbers)); + stockOutOrderService.updateById(byId); } return update; } @@ -496,6 +604,7 @@ public class ReservationStockOutOrderDomainService { // 按照 warehouseId 分组 Map> materialDetailGroupByWarehouse = materialDetailList.stream() .collect(Collectors.groupingBy(ReservationOutMaterialDetail::getWarehouseId)); + List executionInOrderNumbers = new ArrayList<>(); materialDetailGroupByWarehouse.forEach((warehouseId, details) -> { if (warehouseId == null) warehouseId = warehouseId1; Long topOrgId = reservationStockInOrderMapper.getTopOrgId(warehouseId); @@ -521,7 +630,43 @@ public class ReservationStockOutOrderDomainService { reservationStockInOrder.setWarehouseCode(warehouseCode); reservationStockInOrder.setWarehouseName(warehouseName); reservationStockInOrder.setBusinessOutOrderNumber(inOrderNumber); - reservationStockInOrder.setOutOrderNumber(generateExecutionOrderNumber(warehouseCode)); + + + //设置单号 +// Long warehouseId1 = reservationStockInOrder.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getOutOrderNoPrefix(); + if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { + prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); + } + if (prefix == null || prefix.isEmpty()) { + prefix = "CK"; + } + Long organizationId = stockOutOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setOutOrderNumber(datePrefix + seq); +// reservationStockInOrder.setBusinessOrderNo(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = reserveStockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + reservationStockInOrder.setOutOrderNumber(prefix + seq); +// reservationStockInOrder.setBusinessOrderNo(prefix + seq); + } List inMaterialDetailList = new ArrayList<>(); for (ReservationOutMaterialDetail reservationOutMaterialDetail : details) { @@ -538,6 +683,7 @@ public class ReservationStockOutOrderDomainService { } BigDecimal quantity = details.stream().map(ReservationOutMaterialDetail::getQuantity).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); reservationStockInOrder.setQuantity(quantity); + executionInOrderNumbers.add(reservationStockInOrder.getOutOrderNumber()); executionStockOutOrderService.save(reservationStockInOrder); executionOutMaterialDetailService.saveBatch(inMaterialDetailList); @@ -549,6 +695,8 @@ public class ReservationStockOutOrderDomainService { param.setOutOrderIds(ids); stockOutOrderApplicationService.issueOrder(param); }); + byId.setExecutionOutOrderNumber(String.join(",", executionInOrderNumbers)); + stockOutOrderService.updateById(byId); } return update; } diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/repository/mapper/ReserveStockInOrderMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/repository/mapper/ReserveStockInOrderMapper.java index 9bbc47a3d..9514c9df1 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/repository/mapper/ReserveStockInOrderMapper.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/repository/mapper/ReserveStockInOrderMapper.java @@ -77,4 +77,12 @@ public interface ReserveStockInOrderMapper extends BaseMapper getMaxStockInOrderByPrefixAndOrgAndWarehouse(@Param("prefix") String prefix, + @Param("organizationId") Long organizationId, + @Param("warehouseId") Long warehouseId); } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/service/ReserveStockInOrderDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/service/ReserveStockInOrderDomainService.java index c69b34725..09f51e85f 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/service/ReserveStockInOrderDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockInOrder/service/ReserveStockInOrderDomainService.java @@ -105,6 +105,37 @@ public class ReserveStockInOrderDomainService { public Boolean insert(ReserveStockInOrderDO stockInOrderDO) { if (stockInOrderDO.getInOrderNumber() == null) { stockInOrderDO.setInOrderNumber(generateReserveOrderNumber()); +// Long warehouseId = stockInOrderDO.getWarehouseId(); +// AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); +// if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { +// throw new ServiceException("获取仓库信息失败"); +// } +// //仓库信息 +// WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); +// String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); +// String prefix = warehouseFeignPO.getInOrderNoPrefix(); +// if (prefix == null || prefix.isEmpty()) { +// prefix = "RK"; +// } +// Long organizationId = stockInOrderDO.getOrganizationId(); +// Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); +// if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { +// //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 +// String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); +// String datePrefix = prefix + dateStr; +// List orderNumbers = reservationStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockInOrderDO.setInOrderNumber(datePrefix + seq); +// stockInOrderDO.setBusinessOrderNo(datePrefix + seq); +// } else { +// //历史累加: 前缀 + 历史最大序号+1 +// List orderNumbers = reservationStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockInOrderDO.setInOrderNumber(prefix + seq); +// stockInOrderDO.setBusinessOrderNo(prefix + seq); +// } } // //设置默认值 // setDefaultValues(stockInOrderDO); @@ -136,9 +167,41 @@ public class ReserveStockInOrderDomainService { */ public Boolean batchInsert(List stockInOrderDOList) { for (ReserveStockInOrderDO stockInOrderDO : stockInOrderDOList){ - if (StringUtils.isBlank(stockInOrderDO.getInOrderNumber())){ + String inOrderNumber = stockInOrderDO.getInOrderNumber(); + if (stockInOrderDO.getInOrderNumber() == null){ stockInOrderDO.setInOrderNumber(generateReserveOrderNumber()); } +// Long warehouseId = stockInOrderDO.getWarehouseId(); +// AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); +// if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { +// throw new ServiceException("获取仓库信息失败"); +// } +// //仓库信息 +// WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); +// String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); +// String prefix = warehouseFeignPO.getInOrderNoPrefix(); +// if (prefix == null || prefix.isEmpty()) { +// prefix = "RK"; +// } +// Long organizationId = stockInOrderDO.getOrganizationId(); +// Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); +// if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { +// //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 +// String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); +// String datePrefix = prefix + dateStr; +// List orderNumbers = reservationStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockInOrderDO.setInOrderNumber(datePrefix + seq); +// stockInOrderDO.setBusinessOrderNo(datePrefix + seq); +// } else { +// //历史累加: 前缀 + 历史最大序号+1 +// List orderNumbers = reservationStockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockInOrderDO.setInOrderNumber(prefix + seq); +// stockInOrderDO.setBusinessOrderNo(prefix + seq); +// } // //设置物料信息 // setMaterialDetailInfo(stockInOrderDO); // //统计总物料种数 @@ -477,15 +540,15 @@ public class ReserveStockInOrderDomainService { String oldInOrderNumber = reservationStockInOrder.getInOrderNumber(); // 生成新业务单号,防止与已生成的入库业务单号重复 String newOrderNumber = reservationStockInOrderDomainService.generateReserveOrderNumber(); - reservationStockInOrder.setInOrderNumber(newOrderNumber); - reservationStockInOrder.setBusinessOrderNo(newOrderNumber); +// reservationStockInOrder.setInOrderNumber(newOrderNumber); +// reservationStockInOrder.setBusinessOrderNo(newOrderNumber); List materialDetailList = materialDetailService.list(new QueryWrapper().lambda().eq(ReserveInMaterialDetail::getInOrderNumber, oldInOrderNumber)); List inMaterialDetailList = new ArrayList<>(); int index = 1; for (ReserveInMaterialDetail reserveInMaterialDetail : materialDetailList) { ReservationInMaterialDetail reservationInMaterialDetail = new ReservationInMaterialDetail(); BeanUtils.copyProperties(reserveInMaterialDetail, reservationInMaterialDetail,"materialDetailId"); - reservationInMaterialDetail.setInOrderNumber(newOrderNumber); // 使用新单号保持与主表关联 +// reservationInMaterialDetail.setInOrderNumber(newOrderNumber); // 使用新单号保持与主表关联 reservationInMaterialDetail.setQuantity(reserveInMaterialDetail.getReserveQuantity()); String lot = generateDateSerialNumber(); lot = lot+"-"+index; @@ -993,4 +1056,34 @@ public class ReserveStockInOrderDomainService { return prefix + seq; } + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/repository/mapper/ReserveStockOutOrderMapper.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/repository/mapper/ReserveStockOutOrderMapper.java index 128716b68..ad3757e68 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/repository/mapper/ReserveStockOutOrderMapper.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/repository/mapper/ReserveStockOutOrderMapper.java @@ -50,4 +50,12 @@ public interface ReserveStockOutOrderMapper extends BaseMapper getWarehouseByType(@Param("warehouseType") String warehouseType); + + /** + * 跨4张入库单表查询指定前缀+组织+仓库的所有入库单号(用于取最大序号+1,防止删单后单号重复) + * 包含: reserve_stock_in_order, reservation_stock_in_order, execution_stock_in_order, WMS stock_in_order + */ + List getMaxStockOutOrderByPrefixAndOrgAndWarehouse(@Param("prefix") String prefix, + @Param("organizationId") Long organizationId, + @Param("warehouseId") Long warehouseId); } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/service/ReserveStockOutOrderDomainService.java b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/service/ReserveStockOutOrderDomainService.java index cb75be175..508e64d9b 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/service/ReserveStockOutOrderDomainService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/domain/reserveStockOutOrder/service/ReserveStockOutOrderDomainService.java @@ -7,6 +7,7 @@ import com.mhd.common.core.exception.ServiceException; import com.mhd.common.core.utils.OrderSequence; import com.mhd.common.core.utils.StringUtils; import com.mhd.common.core.utils.bean.BeanUtils; +import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.security.utils.SecurityUtils; import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper; import com.mhd.oms.domain.reservationInMaterialDetail.entity.ReservationInMaterialDetail; @@ -34,10 +35,7 @@ import com.mhd.oms.domain.reserveStockOutOrder.repository.po.ReserveStockOutOrde import com.mhd.oms.domain.reserveStockOutOrder.repository.todo.ReserveStockOutOrderDO; import com.mhd.system.api.SystemServiceFeign; import com.mhd.system.api.WmsServiceFeign; -import com.mhd.system.api.domain.OutMaterialDetail; -import com.mhd.system.api.domain.OutMaterialDetailTZPD; -import com.mhd.system.api.domain.StockOutOrder; -import com.mhd.system.api.domain.StockOutOrderTZPD; +import com.mhd.system.api.domain.*; import com.mhd.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -78,6 +76,8 @@ public class ReserveStockOutOrderDomainService { @Autowired private ReservationStockOutOrderDomainService reservationStockOutOrderDomainService; + @Autowired + private SystemServiceFeign systemServiceFeign; /** * 分页查询出库单列表 @@ -90,7 +90,35 @@ public class ReserveStockOutOrderDomainService { return stockOutOrderService.detailsList(stockOutOrderDO); } - + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } /** * 新增出库单 */ @@ -99,6 +127,43 @@ public class ReserveStockOutOrderDomainService { if (stockOutOrderDO.getOutOrderNumber() == null) { stockOutOrderDO.setOutOrderNumber(generateReserveOrderNumber()); } + //设置单号 +// Long warehouseId = stockOutOrderDO.getWarehouseId(); +// AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); +// if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { +// throw new ServiceException("获取仓库信息失败"); +// } +// //仓库信息 +// WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); +// String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); +// String prefix = warehouseFeignPO.getOutOrderNoPrefix(); +// if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { +// prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); +// } +// if (prefix == null || prefix.isEmpty()) { +// prefix = "CK"; +// } +// Long organizationId = stockOutOrderDO.getOrganizationId(); +// Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); +// if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { +// //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 +// String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); +// String datePrefix = prefix + dateStr; +// List orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockOutOrderDO.setOutOrderNumber(datePrefix + seq); +// stockOutOrderDO.setBusinessOrderNo(datePrefix + seq); +// } else { +// //历史累加: 前缀 + 历史最大序号+1 +// List orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); +// int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); +// String seq = String.format("%03d", maxSeq + 1); +// stockOutOrderDO.setOutOrderNumber(prefix + seq); +// stockOutOrderDO.setBusinessOrderNo(prefix + seq); +// } + + // 与 update / batchInsert 一致:前端传计划数量为 quantity,非 outboundQuantity setMaterialDetailInfo(stockOutOrderDO); stockOutOrderDO.setMaterialQuantity(stockOutOrderDO.getMaterialDetailList().size()); @@ -126,7 +191,7 @@ public class ReserveStockOutOrderDomainService { @Transactional(rollbackFor = Exception.class) public Boolean batchInsert(List stockOutOrderDOList) { for (ReserveStockOutOrderDO stockOutOrderDO : stockOutOrderDOList){ - if (StringUtils.isBlank(stockOutOrderDO.getOutOrderNumber())){ + if (stockOutOrderDO.getOutOrderNumber() == null) { stockOutOrderDO.setOutOrderNumber(generateReserveOrderNumber()); } //设置物料信息 @@ -288,9 +353,9 @@ public class ReserveStockOutOrderDomainService { List list = outMaterialDetailService.list(new LambdaQueryWrapper().eq(ReserveOutMaterialDetail::getOutOrderNumber, stockOutOrderDO.getOutOrderNumber())); for (ReserveOutMaterialDetail reserveOutMaterialDetail : list) { - reserveOutMaterialDetail.setWarehouseId(stockOutOrderDO.getWarehouseId()); - reserveOutMaterialDetail.setWarehouseCode(stockOutOrderDO.getWarehouseCode()); - reserveOutMaterialDetail.setWarehouseName(stockOutOrderDO.getWarehouseName()); +// reserveOutMaterialDetail.setWarehouseId(stockOutOrderDO.getWarehouseId()); +// reserveOutMaterialDetail.setWarehouseCode(stockOutOrderDO.getWarehouseCode()); +// reserveOutMaterialDetail.setWarehouseName(stockOutOrderDO.getWarehouseName()); outMaterialDetailService.updateById(reserveOutMaterialDetail); } //todo下发推送到wms @@ -310,8 +375,8 @@ public class ReserveStockOutOrderDomainService { String oldOutOrderNumber = reservationStockOutOrder.getOutOrderNumber(); // 生成出库业务单号,防止与已生成的出库业务单号重复 String newOrderNumber = reservationStockOutOrderDomainService.generateReserveOrderNumber(); - reservationStockOutOrder.setOutOrderNumber(newOrderNumber); - reservationStockOutOrder.setBusinessOrderNo(newOrderNumber); +// reservationStockOutOrder.setOutOrderNumber(newOrderNumber); +// reservationStockOutOrder.setBusinessOrderNo(newOrderNumber); reservationStockOutOrderService.save(reservationStockOutOrder); List materialDetailList = outMaterialDetailService.list(new QueryWrapper().lambda().eq(ReserveOutMaterialDetail::getOutOrderNumber, oldOutOrderNumber)); List inMaterialDetailList = new ArrayList<>(); @@ -319,7 +384,7 @@ public class ReserveStockOutOrderDomainService { for (ReserveOutMaterialDetail reserveOutMaterialDetail : materialDetailList) { ReservationOutMaterialDetail reservationOutMaterialDetail = new ReservationOutMaterialDetail(); BeanUtils.copyProperties(reserveOutMaterialDetail, reservationOutMaterialDetail,"materialDetailId"); - reservationOutMaterialDetail.setOutOrderNumber(newOrderNumber); // 使用新单号保持与主表关联 +// reservationOutMaterialDetail.setOutOrderNumber(newOrderNumber); // 使用新单号保持与主表关联 String lot = generateDateSerialNumber(); lot = lot+"-"+index; index++; diff --git a/mhd_oms/src/main/java/com/mhd/oms/infrastructure/feign/ThirdPartyServiceFeign.java b/mhd_oms/src/main/java/com/mhd/oms/infrastructure/feign/ThirdPartyServiceFeign.java index 97a45ed49..8c86ae1ad 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/infrastructure/feign/ThirdPartyServiceFeign.java +++ b/mhd_oms/src/main/java/com/mhd/oms/infrastructure/feign/ThirdPartyServiceFeign.java @@ -22,7 +22,7 @@ import java.util.Map; /** * 三方服务 Feign */ -@FeignClient(contextId = "thirdPartyServiceFeign", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.102.192.31:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class) public interface ThirdPartyServiceFeign { //查询当前组织所有三方接口信息 @@ -141,4 +141,4 @@ public interface ThirdPartyServiceFeign { @PostMapping("/esignSaasV3/downloadSignContract") R downloadSignContract(@RequestBody Map mapResult); -} +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureBatchSignDTO.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureBatchSignDTO.java new file mode 100644 index 000000000..4f99415b8 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureBatchSignDTO.java @@ -0,0 +1,30 @@ +package com.mhd.oms.interfaces.dto.electronicSignature; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 电子签名批量签名请求DTO + * + *

勾选多条记录后批量签名,更新OMS电子签名表 + 调用WMS更新入/出库单表。

+ */ +@Data +public class ElectronicSignatureBatchSignDTO { + + @ApiModelProperty(value = "签名ID列表", required = true) + private List signatureIds; + + @ApiModelProperty("手写签名图片(base64或URL,单张)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片URL列表(多张)") + private List evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; + + @ApiModelProperty("签名方式:1-扫描二维码 2-电子签名 3-打印手写签名 4-超时自动签名") + private Integer signatureMode; +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureQueryDTO.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureQueryDTO.java new file mode 100644 index 000000000..54c33b6de --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureQueryDTO.java @@ -0,0 +1,55 @@ +package com.mhd.oms.interfaces.dto.electronicSignature; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 电子签名列表查询DTO + */ +@Data +public class ElectronicSignatureQueryDTO { + + @ApiModelProperty("订单类型:IN-入库 OUT-出库") + private String orderType; + + @ApiModelProperty("订单号(模糊查询)") + private String orderNumber; + + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名方式:1-扫描二维码 2-电子签名 3-打印手写签名 4-超时自动签名") + private Integer signatureMode; + + @ApiModelProperty("组织ID") + private Long organizationId; + + @ApiModelProperty("组织名称(模糊查询)") + private String organizationName; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库名称(模糊查询)") + private String warehouseName; + + @ApiModelProperty("创建时间起") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTimeFrom; + + @ApiModelProperty("创建时间止") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTimeTo; + + @ApiModelProperty("页码") + private Integer pageNum; + + @ApiModelProperty("每页条数") + private Integer pageSize; +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureSaveDTO.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureSaveDTO.java new file mode 100644 index 000000000..915ee0fe1 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureSaveDTO.java @@ -0,0 +1,108 @@ +package com.mhd.oms.interfaces.dto.electronicSignature; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 电子签名保存DTO(接收WMS端Feign调用) + */ +@Data +public class ElectronicSignatureSaveDTO { + + @ApiModelProperty("订单ID") + private Long orderId; + + @ApiModelProperty("订单号") + private String orderNumber; + + @ApiModelProperty("订单类型:IN-入库 OUT-出库") + private String orderType; + + @ApiModelProperty("组织ID") + private Long organizationId; + + @ApiModelProperty("组织名称") + private String organizationName; + + @ApiModelProperty("一级组织ID") + private Long topOrganizationId; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("创建人") + private Long createBy; + + @ApiModelProperty("创建人姓名") + private String createByName; + + @ApiModelProperty("物料明细列表") + private List materialDetailList; + + @Data + public static class MaterialDetailItem { + + @ApiModelProperty("物料基础信息ID") + private Long materialBaseInfoId; + + @ApiModelProperty("物料编码") + private String materialCode; + + @ApiModelProperty("物料名称") + private String materialName; + + @ApiModelProperty("数量") + private BigDecimal quantity; + + @ApiModelProperty("单位代码") + private String unitCode; + + @ApiModelProperty("单位名称") + private String unitName; + + @ApiModelProperty("批次号") + private String batchNumber; + + @ApiModelProperty("LOT编号") + private String lotNumber; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("库区ID") + private Long storageSectionId; + + @ApiModelProperty("库区编码") + private String storageSectionCode; + + @ApiModelProperty("库区名称") + private String storageSectionName; + + @ApiModelProperty("库位ID") + private Long storageLocationId; + + @ApiModelProperty("库位编码") + private String storageLocationCode; + + @ApiModelProperty("库位名称") + private String storageLocationName; + + @ApiModelProperty("业务唯一ID") + private Long uniqueId; + } +} diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureVO.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureVO.java new file mode 100644 index 000000000..147e1bb73 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/dto/electronicSignature/ElectronicSignatureVO.java @@ -0,0 +1,127 @@ +package com.mhd.oms.interfaces.dto.electronicSignature; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 电子签名列表返回VO + */ +@Data +public class ElectronicSignatureVO { + + @ApiModelProperty("签名ID") + private Long signatureId; + + @ApiModelProperty("订单ID") + private Long orderId; + + @ApiModelProperty("订单号") + private String orderNumber; + + @ApiModelProperty("订单类型:IN-入库 OUT-出库") + private String orderType; + + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名状态名称") + private String signatureStatusName; + + @ApiModelProperty("签名时间") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片") + private String signaturePic; + + @ApiModelProperty("拍照取证图片") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; + + @ApiModelProperty("签名方式:1-扫描二维码 2-电子签名 3-打印手写签名 4-超时自动签名") + private Integer signatureMode; + + @ApiModelProperty("签名方式名称") + private String signatureModeName; + + @ApiModelProperty("组织ID") + private Long organizationId; + + @ApiModelProperty("组织名称") + private String organizationName; + + @ApiModelProperty("仓库ID") + private Long warehouseId; + + @ApiModelProperty("仓库编码") + private String warehouseCode; + + @ApiModelProperty("仓库名称") + private String warehouseName; + + @ApiModelProperty("创建人") + private Long createBy; + + @ApiModelProperty("创建人姓名") + private String createByName; + + @ApiModelProperty("创建时间") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("物料明细列表") + private List materialDetailList; + + @Data + public static class MaterialDetailVO { + + @ApiModelProperty("明细ID") + private Long detailId; + + @ApiModelProperty("物料基础信息ID") + private Long materialBaseInfoId; + + @ApiModelProperty("物料编码") + private String materialCode; + + @ApiModelProperty("物料名称") + private String materialName; + + @ApiModelProperty("数量") + private BigDecimal quantity; + + @ApiModelProperty("单位代码") + private String unitCode; + + @ApiModelProperty("单位名称") + private String unitName; + + @ApiModelProperty("批次号") + private String batchNumber; + + @ApiModelProperty("LOT编号") + private String lotNumber; + + @ApiModelProperty("库区编码") + private String storageSectionCode; + + @ApiModelProperty("库区名称") + private String storageSectionName; + + @ApiModelProperty("库位编码") + private String storageLocationCode; + + @ApiModelProperty("库位名称") + private String storageLocationName; + } +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/electronicSignature/ElectronicSignatureApi.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/electronicSignature/ElectronicSignatureApi.java new file mode 100644 index 000000000..2415cf6ed --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/electronicSignature/ElectronicSignatureApi.java @@ -0,0 +1,227 @@ +package com.mhd.oms.interfaces.facade.electronicSignature; + +import com.github.pagehelper.PageHelper; +import com.mhd.common.core.web.controller.BaseController; +import com.mhd.common.core.web.domain.AjaxResult; +import com.mhd.common.core.web.page.TableDataInfo; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignature; +import com.mhd.oms.domain.electronicSignature.entity.ElectronicSignatureMaterialDetail; +import com.mhd.oms.domain.electronicSignature.repository.todo.ElectronicSignatureDO; +import com.mhd.oms.domain.electronicSignature.service.ElectronicSignatureDomainService; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureBatchSignDTO; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureQueryDTO; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureSaveDTO; +import com.mhd.oms.interfaces.dto.electronicSignature.ElectronicSignatureVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 电子签名Api + */ +@Slf4j +@RestController +@RequestMapping("/electronicSignatureApi") +@Api(tags = "电子签名") +public class ElectronicSignatureApi extends BaseController { + + @Autowired + private ElectronicSignatureDomainService electronicSignatureDomainService; + + /** + * 保存电子签名记录(WMS端Feign调用) + */ + @ApiOperation("保存电子签名记录") + @PostMapping("/saveSignature") + public AjaxResult saveSignature(@RequestBody ElectronicSignatureSaveDTO saveDTO) { + try { + ElectronicSignatureDO signatureDO = toDO(saveDTO); + electronicSignatureDomainService.saveSignature(signatureDO); + return AjaxResult.success("电子签名记录保存成功"); + } catch (Exception e) { + log.error("保存电子签名记录失败", e); + return AjaxResult.error("保存电子签名记录失败:" + e.getMessage()); + } + } + + + /** + * 保存电子签名记录(WMS端Feign调用) + */ + @ApiOperation("二维码签名") + @PostMapping("/inQqcode") + public AjaxResult inQqcode(@RequestBody ElectronicSignatureSaveDTO saveDTO) { + try { + ElectronicSignatureDO signatureDO = toDO(saveDTO); + electronicSignatureDomainService.inQqcode(signatureDO); + return AjaxResult.success("电子签名记录保存成功"); + } catch (Exception e) { + log.error("保存电子签名记录失败", e); + return AjaxResult.error("保存电子签名记录失败:" + e.getMessage()); + } + } + + @ApiOperation("二维码签名") + @PostMapping("/outQqcode") + public AjaxResult outQqcode(@RequestBody ElectronicSignatureSaveDTO saveDTO) { + try { + ElectronicSignatureDO signatureDO = toDO(saveDTO); + electronicSignatureDomainService.outQqcode(signatureDO); + return AjaxResult.success("电子签名记录保存成功"); + } catch (Exception e) { + log.error("保存电子签名记录失败", e); + return AjaxResult.error("保存电子签名记录失败:" + e.getMessage()); + } + } + + /** + * 分页查询电子签名列表 + */ + @ApiOperation("分页查询电子签名列表") + @GetMapping("/list") + public TableDataInfo list(ElectronicSignatureQueryDTO queryDTO) { + PageHelper.startPage(queryDTO.getPageNum() == null ? 1 : queryDTO.getPageNum(), + queryDTO.getPageSize() == null ? 10 : queryDTO.getPageSize()); + List list = electronicSignatureDomainService.querySignatureList(queryDTO); + List voList = list.stream() + .map(this::toVO) + .collect(Collectors.toList()); + return getDataTable(voList); + } + + /** + * 根据订单编号查询电子签名列表 + */ + @ApiOperation("根据订单编号查询电子签名列表") + @GetMapping("/getByOrderNumber") + public AjaxResult getByOrderNumber(ElectronicSignatureQueryDTO queryDTO) { + List list = electronicSignatureDomainService.getByOrderNumber(queryDTO); + return AjaxResult.success(list); + } + + /** + * 查询签名详情(含物料明细) + */ + @ApiOperation("查询签名详情(含物料明细)") + @GetMapping("/detail") + public AjaxResult detail(Long signatureId) { + if (signatureId == null) { + return AjaxResult.error("签名ID不能为空"); + } + ElectronicSignature signature = electronicSignatureDomainService.getSignatureById(signatureId); + if (signature == null) { + return AjaxResult.error("未找到签名记录"); + } + ElectronicSignatureVO vo = toVO(signature); + // 查询物料明细 + List details = + electronicSignatureDomainService.queryMaterialDetailBySignatureId(signatureId); + if (details != null && !details.isEmpty()) { + vo.setMaterialDetailList(details.stream().map(d -> { + ElectronicSignatureVO.MaterialDetailVO dto = new ElectronicSignatureVO.MaterialDetailVO(); + BeanUtils.copyProperties(d, dto); + return dto; + }).collect(Collectors.toList())); + } + return AjaxResult.success(vo); + } + + /** + * 勾选记录批量签名 + * + *

前端勾选多条待签名的电子签名记录,传入签名ID列表(signatureIds)、签名图片(signaturePic)、 + * 签名备注(signatureRemark)、签名方式(signatureMode),后端:

+ *
    + *
  • 更新 OMS ELECTRONIC_SIGNATURE 表:signatureStatus=2(已签名)、signatureTime=当前时间、signaturePic、evidencePics、signatureRemark、signatureMode
  • + *
  • 通过 Feign 调用 WMS 更新 stock_in_order / stock_out_order 表的对应签名字段
  • + *
+ */ + @ApiOperation("批量签名(勾选记录后批量更新签名状态为已签名)") + @PostMapping("/batchSign") + public AjaxResult batchSign(@RequestBody ElectronicSignatureBatchSignDTO dto) { + if (dto.getSignatureIds() == null || dto.getSignatureIds().isEmpty()) { + return AjaxResult.error("请选择需要签名的记录"); + } + try { + int count = electronicSignatureDomainService.batchSign(dto); + if (count > 0) { + return AjaxResult.success("批量签名成功,共更新 " + count + " 条记录"); + } else { + return AjaxResult.error("批量签名失败:未找到有效的待签名记录"); + } + } catch (Exception e) { + log.error("批量签名失败", e); + return AjaxResult.error("批量签名失败:" + e.getMessage()); + } + } + + + @ApiOperation("批量签名(勾选记录后批量更新签名状态为已签名)") + @PostMapping("/batchSignByWmsId") + public AjaxResult batchSignByWmsId(@RequestBody ElectronicSignatureBatchSignDTO dto) { + if (dto.getSignatureIds() == null || dto.getSignatureIds().isEmpty()) { + return AjaxResult.error("请选择需要签名的记录"); + } + try { + int count = electronicSignatureDomainService.batchSignByWmsId(dto); + if (count > 0) { + return AjaxResult.success("批量签名成功,共更新 " + count + " 条记录"); + } else { + return AjaxResult.error("批量签名失败:未找到有效的待签名记录"); + } + } catch (Exception e) { + log.error("批量签名失败", e); + return AjaxResult.error("批量签名失败:" + e.getMessage()); + } + } + + private ElectronicSignatureDO toDO(ElectronicSignatureSaveDTO dto) { + ElectronicSignatureDO signatureDO = new ElectronicSignatureDO(); + BeanUtils.copyProperties(dto, signatureDO, "materialDetailList"); + + // 转换物料明细 + if (dto.getMaterialDetailList() != null) { + List detailList = new ArrayList<>(); + for (ElectronicSignatureSaveDTO.MaterialDetailItem item : dto.getMaterialDetailList()) { + ElectronicSignatureMaterialDetail detail = new ElectronicSignatureMaterialDetail(); + BeanUtils.copyProperties(item, detail); + detailList.add(detail); + } + signatureDO.setMaterialDetailList(detailList); + } + + return signatureDO; + } + + private ElectronicSignatureVO toVO(ElectronicSignature entity) { + ElectronicSignatureVO vo = new ElectronicSignatureVO(); + BeanUtils.copyProperties(entity, vo); + + // 签名状态名称 + if (entity.getSignatureStatus() != null) { + vo.setSignatureStatusName(entity.getSignatureStatus() == 1 ? "待签名" : entity.getSignatureStatus() == 2 ? "已签名" : null); + } + // 签名方式名称 + if (entity.getSignatureMode() != null) { + switch (entity.getSignatureMode()) { + case 1: vo.setSignatureModeName("扫描二维码"); break; + case 2: vo.setSignatureModeName("电子签名"); break; + case 3: vo.setSignatureModeName("打印手写签名"); break; + case 4: vo.setSignatureModeName("超时自动签名"); break; + default: break; + } + } + return vo; + } +} \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionInMaterialDetail/ExecutionInMaterialDetailApi.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionInMaterialDetail/ExecutionInMaterialDetailApi.java index 1ec474347..56546052e 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionInMaterialDetail/ExecutionInMaterialDetailApi.java +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionInMaterialDetail/ExecutionInMaterialDetailApi.java @@ -4,8 +4,11 @@ import com.mhd.common.core.web.controller.BaseController; import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.core.web.page.TableDataInfo; import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailPO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.po.ExecutionInMaterialDetailWithOrderPO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDO; import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailDTO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.ExecutionInMaterialDetailQueryDTO; +import com.mhd.oms.domain.executionInMaterialDetail.repository.todo.QueryOrderOverStockDO; import com.mhd.oms.domain.executionInMaterialDetail.service.ExecutionInMaterialDetailApplicationService; import com.mhd.oms.domain.executionInMaterialDetail.service.ExecutionInMaterialDetailAssembler; import io.swagger.annotations.ApiOperation; @@ -80,4 +83,17 @@ public class ExecutionInMaterialDetailApi extends BaseController { } + /** + * 入库明细查询(关联入库执行单) + */ + @ApiOperation("入库明细查询(关联入库执行单)") + @GetMapping("/listWithOrder") + public TableDataInfo listWithOrder(ExecutionInMaterialDetailQueryDTO queryDTO) + { + QueryOrderOverStockDO queryDO = inMaterialDetailAssembler.toQueryDO(queryDTO); + startPage(); + List list = inMaterialDetailApplicationService.queryInOrderDetailList(queryDO); + return getDataTable(list); + } + } \ No newline at end of file diff --git a/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionOutMaterialDetail/ExecutionOutMaterialDetailApi.java b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionOutMaterialDetail/ExecutionOutMaterialDetailApi.java new file mode 100644 index 000000000..dc8e1a808 --- /dev/null +++ b/mhd_oms/src/main/java/com/mhd/oms/interfaces/facade/executionOutMaterialDetail/ExecutionOutMaterialDetailApi.java @@ -0,0 +1,44 @@ +package com.mhd.oms.interfaces.facade.executionOutMaterialDetail; + +import com.mhd.common.core.web.controller.BaseController; +import com.mhd.common.core.web.page.TableDataInfo; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.po.ExecutionOutMaterialDetailWithOrderPO; +import com.mhd.oms.domain.executionOutMaterialDetail.repository.todo.ExecutionOutMaterialDetailQueryDTO; +import com.mhd.oms.domain.executionOutMaterialDetail.service.ExecutionOutMaterialDetailApplicationService; +import com.mhd.oms.domain.executionOutMaterialDetail.service.ExecutionOutMaterialDetailAssembler; +import com.mhd.oms.domain.reservationInMaterialDetail.repository.todo.QueryOrderOverStockDO; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 出库明细Api + * + * @author gen + * @date 2024-07-24 + */ +@RestController +@RequestMapping("/executionOutMaterialDetailApi") +public class ExecutionOutMaterialDetailApi extends BaseController { + @Autowired + private ExecutionOutMaterialDetailApplicationService outMaterialDetailApplicationService; + @Resource + private ExecutionOutMaterialDetailAssembler outMaterialDetailAssembler; + + /** + * 出库明细查询(关联出库执行单) + */ + @ApiOperation("出库明细查询(关联出库执行单)") + @GetMapping("/listWithOrder") + public TableDataInfo listWithOrder(ExecutionOutMaterialDetailQueryDTO queryDTO) { + QueryOrderOverStockDO queryDO = outMaterialDetailAssembler.toQueryDO(queryDTO); + startPage(); + List list = outMaterialDetailApplicationService.queryOutOrderDetailList(queryDO); + return getDataTable(list); + } +} diff --git a/mhd_oms/src/main/resources/mapper/executionInMaterialDetail/executionInMaterialDetailMapper.xml b/mhd_oms/src/main/resources/mapper/executionInMaterialDetail/executionInMaterialDetailMapper.xml index 7a0150499..fd4e7b2d0 100644 --- a/mhd_oms/src/main/resources/mapper/executionInMaterialDetail/executionInMaterialDetailMapper.xml +++ b/mhd_oms/src/main/resources/mapper/executionInMaterialDetail/executionInMaterialDetailMapper.xml @@ -358,4 +358,106 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + \ No newline at end of file diff --git a/mhd_oms/src/main/resources/mapper/executionOutMaterialDetail/ExecutionOutMaterialDetailMapper.xml b/mhd_oms/src/main/resources/mapper/executionOutMaterialDetail/ExecutionOutMaterialDetailMapper.xml index ece1200c9..8fd4090a8 100644 --- a/mhd_oms/src/main/resources/mapper/executionOutMaterialDetail/ExecutionOutMaterialDetailMapper.xml +++ b/mhd_oms/src/main/resources/mapper/executionOutMaterialDetail/ExecutionOutMaterialDetailMapper.xml @@ -448,4 +448,109 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + + + \ No newline at end of file diff --git a/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml b/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml index 17660e241..dd5b3f7cf 100644 --- a/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml +++ b/mhd_oms/src/main/resources/mapper/reservationStockInOrder/ReservationStockInOrderMapper.xml @@ -107,6 +107,7 @@ + @@ -144,7 +145,7 @@ a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.reservation_audit_time,a.reservation_audit_name ,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.RESERVATION_ORDER_SOURCE,a.tms_order_number ,a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.STORAGE_TIME,a.in_quantity, - a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME + a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,a.execution_in_order_number diff --git a/mhd_oms/src/main/resources/mapper/reservationStockOutOrder/ReservationStockOutOrderMapper.xml b/mhd_oms/src/main/resources/mapper/reservationStockOutOrder/ReservationStockOutOrderMapper.xml index d143852cf..ac2b11596 100644 --- a/mhd_oms/src/main/resources/mapper/reservationStockOutOrder/ReservationStockOutOrderMapper.xml +++ b/mhd_oms/src/main/resources/mapper/reservationStockOutOrder/ReservationStockOutOrderMapper.xml @@ -108,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -126,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" a.CUSTOMS_INSPECTION_FLAG,a.NEED_DECLARE_FLAG,a.NEED_TRANSPORT_FLAG,a.picture_app,a.reservation_audit_time,a.reservation_audit_name ,a.reservation_audit_id,a.issue_name,a.issue_id,a.issue_time,a.issue_status,a.tms_order_number, a.DIRECTOR_NAME ,a.DIRECTOR_PHONE,a.DIRECTOR_ID,a.RESERVATION_ORDER_SOURCE,a.OUTBOUND_TIME,a.RETURN_QUANTITY,a.DELIVERY_NAME,a.CUSTOMER_NUMBER,a.INVOICE_NUMBER,a.RETURN_ORDER_NUMBER,a.TOTAL_AMOUNT, - a.ROUTE,a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME + a.ROUTE,a.PUSH_TIME,a.PUSH_STATUS,a.PUSH_BY,a.PUSH_BY_NAME,a.execution_out_order_number diff --git a/mhd_oms/src/main/resources/mapper/reserveStockInOrder/ReserveStockInOrderMapper.xml b/mhd_oms/src/main/resources/mapper/reserveStockInOrder/ReserveStockInOrderMapper.xml index 2272d6a7d..555dce1d4 100644 --- a/mhd_oms/src/main/resources/mapper/reserveStockInOrder/ReserveStockInOrderMapper.xml +++ b/mhd_oms/src/main/resources/mapper/reserveStockInOrder/ReserveStockInOrderMapper.xml @@ -831,4 +831,53 @@ WHERE in_order_number = #{inOrderNumber} + + + \ No newline at end of file diff --git a/mhd_oms/src/main/resources/mapper/reserveStockOutOrder/ReserveStockOutOrderMapper.xml b/mhd_oms/src/main/resources/mapper/reserveStockOutOrder/ReserveStockOutOrderMapper.xml index 1c4a103dd..5d27761f8 100644 --- a/mhd_oms/src/main/resources/mapper/reserveStockOutOrder/ReserveStockOutOrderMapper.xml +++ b/mhd_oms/src/main/resources/mapper/reserveStockOutOrder/ReserveStockOutOrderMapper.xml @@ -548,4 +548,54 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + + + + \ No newline at end of file diff --git a/mhd_product/src/main/java/com/linke/product/interfaces/facade/menu/MenuApi.java b/mhd_product/src/main/java/com/linke/product/interfaces/facade/menu/MenuApi.java index e843d6cee..122211337 100644 --- a/mhd_product/src/main/java/com/linke/product/interfaces/facade/menu/MenuApi.java +++ b/mhd_product/src/main/java/com/linke/product/interfaces/facade/menu/MenuApi.java @@ -1,6 +1,5 @@ package com.linke.product.interfaces.facade.menu; -import cn.hutool.core.io.resource.InputStreamResource; import cn.hutool.core.util.StrUtil; import com.linke.product.application.service.menu.MenuApplicationService; import com.linke.product.domain.menu.entity.Menu; @@ -32,10 +31,12 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; import javax.annotation.PostConstruct; -import java.io.File; -import java.io.InputStream; +import javax.servlet.http.HttpServletRequest; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -210,8 +211,58 @@ public class MenuApi extends BaseController { return AjaxResult.success(menuApplicationService.uploadMinio(file)); }*/ + /** + * 判断调用方IP是否为内网环境(192.168开头) + */ + private boolean isLocalNetwork(HttpServletRequest request) { + String ip = request.getHeader("X-Forwarded-For"); + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + // X-Forwarded-For 可能包含多个IP,取第一个 + if (ip != null && ip.contains(",")) { + ip = ip.split(",")[0].trim(); + } + return ip != null && ip.startsWith("192.168"); + } + + /** + * 本地上传文件到 D:/upload 目录 + */ + private String uploadToLocal(MultipartFile file) throws IOException { + String localUploadDir = "D:\\upload"; + File dir = new File(localUploadDir); + if (!dir.exists()) { + dir.mkdirs(); + } + String originalFilename = file.getOriginalFilename(); + String fileExtension = ""; + if (originalFilename != null && originalFilename.contains(".")) { + fileExtension = originalFilename.substring(originalFilename.lastIndexOf(".")); + } + String fileName = UUID.randomUUID().toString() + fileExtension; + File destFile = new File(dir, fileName); + file.transferTo(destFile); + // 返回本地文件路径标识,格式: LOCAL:D:/upload/xxx.ext + return "LOCAL:" + destFile.getAbsolutePath(); + } + @PostMapping("/upload") - public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) { + public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, HttpServletRequest request) { + try { + if (isLocalNetwork(request)) { + String localPath = uploadToLocal(file); + return AjaxResult.success(localPath); + } + } catch (IOException e) { + return AjaxResult.error("本地上传文件失败: " + e.getMessage()); + } String fileKey = fileStorageService.uploadFile(file); return AjaxResult.success(fileKey); } @@ -281,34 +332,36 @@ public class MenuApi extends BaseController { @PostMapping("/batchUpload") - public AjaxResult batchUpload(@RequestParam("files") List files) { + public AjaxResult batchUpload(@RequestParam("files") List files, HttpServletRequest request) { if (files == null || files.size() == 0) { return AjaxResult.error("上传文件不能为空"); } List fileUrls = new ArrayList<>(); + boolean localMode = isLocalNetwork(request); for (MultipartFile multipartFile : files) { - String fileKey = fileStorageService.uploadFile(multipartFile); - fileUrls.add(fileKey); + if (localMode) { + try { + String localPath = uploadToLocal(multipartFile); + fileUrls.add(localPath); + } catch (IOException e) { + return AjaxResult.error("本地上传文件失败: " + e.getMessage()); + } + } else { + String fileKey = fileStorageService.uploadFile(multipartFile); + fileUrls.add(fileKey); + } } return AjaxResult.success(fileUrls); } @GetMapping("/download") - public ResponseEntity downloadFromOBS( + public ResponseEntity downloadFromOBS( @RequestParam String obsUrl, - @RequestParam String filename) { + @RequestParam String filename, + HttpServletRequest request) { try { - // 1. 连接到OBS临时URL - URL url = new URL(obsUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - - // 2. 获取输入流 - InputStream inputStream = connection.getInputStream(); - - // 3. 设置响应头 HttpHeaders headers = new HttpHeaders(); headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\""); @@ -316,17 +369,49 @@ public class MenuApi extends BaseController { headers.add(HttpHeaders.PRAGMA, "no-cache"); headers.add(HttpHeaders.EXPIRES, "0"); - // 4. 根据文件类型设置Content-Type + // 判断是否为内网环境,从本地文件读取 + if (isLocalNetwork(request) && obsUrl != null && obsUrl.startsWith("LOCAL:")) { + String localFilePath = obsUrl.substring("LOCAL:".length()); + File localFile = new File(localFilePath); + if (!localFile.exists()) { + throw new RuntimeException("本地文件不存在: " + localFilePath); + } + byte[] fileBytes = Files.readAllBytes(localFile.toPath()); + String contentType = Files.probeContentType(localFile.toPath()); + MediaType mediaType = contentType != null ? + MediaType.valueOf(contentType) : + MediaType.APPLICATION_OCTET_STREAM; + headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileBytes.length)); + return ResponseEntity.ok() + .headers(headers) + .contentType(mediaType) + .body(fileBytes); + } + + // 连接OBS临时URL下载 + URL url = new URL(obsUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("GET"); + + InputStream inputStream = connection.getInputStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[8192]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + baos.write(buffer, 0, bytesRead); + } + inputStream.close(); + byte[] fileBytes = baos.toByteArray(); + String contentType = connection.getContentType(); MediaType mediaType = contentType != null ? MediaType.valueOf(contentType) : MediaType.APPLICATION_OCTET_STREAM; - - // 5. 返回流式响应 + headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileBytes.length)); return ResponseEntity.ok() .headers(headers) .contentType(mediaType) - .body(new InputStreamResource(inputStream)); + .body(fileBytes); } catch (Exception e) { throw new RuntimeException("下载文件失败", e); @@ -340,8 +425,31 @@ public class MenuApi extends BaseController { public ResponseEntity downloadStreaming( @RequestParam String bucketName, @RequestParam String objectKey, - @RequestParam String filename) { + @RequestParam String filename, + HttpServletRequest request) { + // 判断是否为内网环境,从本地文件读取 + if (isLocalNetwork(request) && objectKey != null && objectKey.startsWith("LOCAL:")) { + String localFilePath = objectKey.substring("LOCAL:".length()); + File localFile = new File(localFilePath); + return ResponseEntity.ok() + .header(HttpHeaders.CONTENT_DISPOSITION, + "attachment; filename=\"" + filename + "\"") + .contentType(MediaType.APPLICATION_OCTET_STREAM) + .contentLength(localFile.length()) + .body(outputStream -> { + try (InputStream inputStream = new FileInputStream(localFile)) { + byte[] buffer = new byte[8192]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.flush(); + } + }); + } + + // OBS方式下载 return ResponseEntity.ok() .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + filename + "\"") @@ -349,19 +457,9 @@ public class MenuApi extends BaseController { .body(outputStream -> { ObsClient obsClient1 = null; try { - System.out.println( - "AccessKey:" + obsProperties.getAccessKey() + - "SecretKey:" + obsProperties.getSecretKey() - + "Endpoint:" + obsProperties.getEndpoint() - ); - logger.error( - "AccessKey:" + obsProperties.getAccessKey() + - "SecretKey:" + obsProperties.getSecretKey() - + "Endpoint:" + obsProperties.getEndpoint() - ); obsClient1 = new ObsClient(obsProperties.getAccessKey(), obsProperties.getSecretKey(), obsProperties.getEndpoint()); - GetObjectRequest request = new GetObjectRequest(bucketName, objectKey); - ObsObject obsObject = obsClient1.getObject(request); + GetObjectRequest req = new GetObjectRequest(bucketName, objectKey); + ObsObject obsObject = obsClient1.getObject(req); try (InputStream inputStream = obsObject.getObjectContent()) { byte[] buffer = new byte[8192]; diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/reviewOrder/ReviewOrderApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/reviewOrder/ReviewOrderApplicationService.java index 8b805a8e7..3e6d14052 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/reviewOrder/ReviewOrderApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/reviewOrder/ReviewOrderApplicationService.java @@ -476,7 +476,8 @@ public class ReviewOrderApplicationService { handoverTaskOrderDO.setShipperId(stockOutOrderPO.getShipperId()); handoverTaskOrderDO.setShipperName(stockOutOrderPO.getShipperName()); handoverTaskOrderDO.setSerialNumber(OrderSequence.getOrderCode("JJZYLS")); - handoverTaskOrderDO.setTaskNumber(OrderSequence.getOrderCode("JJZY")); +// handoverTaskOrderDO.setTaskNumber(OrderSequence.getOrderCode("JJZY")); + handoverTaskOrderDO.setTaskNumber("HD-"+stockOutOrderPO.getOutOrderNumber()); handoverTaskOrderDO.setStatus(1); handoverTaskOrderDO.setOrderTypeCode(stockOutOrderPO.getOrderTypeCode()); handoverTaskOrderDO.setOrderTypeName(stockOutOrderPO.getOrderTypeName()); @@ -1302,4 +1303,4 @@ public class ReviewOrderApplicationService { setter.accept(parsed); } } -} +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/signature/SignatureAutoTaskService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/signature/SignatureAutoTaskService.java new file mode 100644 index 000000000..d85968fe9 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/signature/SignatureAutoTaskService.java @@ -0,0 +1,84 @@ +package com.mhd.wms.application.service.signature; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.mhd.wms.domain.stockInOrder.entity.StockInOrder; +import com.mhd.wms.domain.stockInOrder.repository.facade.IStockInOrderService; +import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder; +import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 签名自动任务:超过上架时间/出库交接时间 24 小时的订单自动设为已签名 + */ +@Slf4j +@Service +public class SignatureAutoTaskService { + + @Autowired + private IStockInOrderService stockInOrderService; + @Autowired + private IStockOutOrderService stockOutOrderService; + + /** 每30分钟执行一次 */ + @Scheduled(fixedDelay = 1800000) + public void autoSignature() { + Date cutoffTime = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000L); + int inCount = autoSignInOrders(cutoffTime); + int outCount = autoSignOutOrders(cutoffTime); + if (inCount > 0 || outCount > 0) { + log.info("签名自动任务完成 - 入库签名:{}条,出库签名:{}条", inCount, outCount); + } + } + + /** + * 入库单自动签名:completionTime 超过 24h 且 signatureStatus=1(待签名) 的设为已签名 + */ + private int autoSignInOrders(Date cutoffTime) { + List list = stockInOrderService.list( + new LambdaQueryWrapper() + .eq(StockInOrder::getSignatureStatus, 1) + .eq(StockInOrder::getStatus, 5) + .lt(StockInOrder::getCompletionTime, cutoffTime) + .isNotNull(StockInOrder::getCompletionTime) + ); + if (list.isEmpty()) return 0; + List ids = list.stream().map(StockInOrder::getInOrderId).collect(Collectors.toList()); + stockInOrderService.update(new LambdaUpdateWrapper() + .in(StockInOrder::getInOrderId, ids) + .set(StockInOrder::getSignatureStatus, 2) + .set(StockInOrder::getSignatureTime, new Date()) + .set(StockInOrder::getSignatureRemark, "系统自动签名:上架完成超过24小时") + ); + return ids.size(); + } + + /** + * 出库单自动签名:completeTime 超过 24h 且 signatureStatus=1(待签名) 的设为已签名 + */ + private int autoSignOutOrders(Date cutoffTime) { + List list = stockOutOrderService.list( + new LambdaQueryWrapper() + .eq(StockOutOrder::getSignatureStatus, 1) + .eq(StockOutOrder::getStatus, 9) + .lt(StockOutOrder::getCompleteTime, cutoffTime) + .isNotNull(StockOutOrder::getCompleteTime) + ); + if (list.isEmpty()) return 0; + List ids = list.stream().map(StockOutOrder::getOutOrderId).collect(Collectors.toList()); + stockOutOrderService.update(new LambdaUpdateWrapper() + .in(StockOutOrder::getOutOrderId, ids) + .set(StockOutOrder::getSignatureStatus, 2) + .set(StockOutOrder::getSignatureTime, new Date()) + .set(StockOutOrder::getSignatureRemark, "系统自动签名:出库交接完成超过24小时") + ); + return ids.size(); + } +} diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/stockInOrder/StockInOrderApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/stockInOrder/StockInOrderApplicationService.java index d7e1b1138..62294a361 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/stockInOrder/StockInOrderApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/stockInOrder/StockInOrderApplicationService.java @@ -160,7 +160,7 @@ public class StockInOrderApplicationService { if (loginUser != null && loginUser.getUserPo() != null){ Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); Long frontendOrganizationId = stockInOrderDO.getOrganizationId(); // 前端传递的 organizationId - + // 数据权限:根据 organizationId 来设置查询权限 // 当前登录用户的 organizationId 为 2827 时,可查全部组织数据;其他组织只能查自己 if (userOrganizationId != null && userOrganizationId == 2827L) { @@ -282,6 +282,94 @@ public class StockInOrderApplicationService { return stockInOrderPOS; } + /** + * PDA入库签名列表查询 + * + *

参照简易模式快捷入库列表 {@link #queryList(StockInOrderDO)} 实现: + * 查询入库单状态为「已入库」(status=5) 的入库单列表, + * 支持按「作业任务人员」(workUserName) like 模糊查询以及其他常规查询条件。

+ */ + public List querySignatureList(StockInOrderDO stockInOrderDO) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null && loginUser.getUserPo() != null) { + Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); + Long frontendOrganizationId = stockInOrderDO.getOrganizationId(); + + // 数据权限:与 queryList 保持一致 + if (userOrganizationId != null && userOrganizationId == 2827L) { + if (frontendOrganizationId != null) { + stockInOrderDO.setOrganizationId(frontendOrganizationId); + stockInOrderDO.setTopOrganizationId(null); + } else { + stockInOrderDO.setOrganizationId(null); + stockInOrderDO.setTopOrganizationId(null); + } + } else { + if (frontendOrganizationId != null && userOrganizationId != null) { + if (!frontendOrganizationId.equals(userOrganizationId)) { + stockInOrderDO.setOrganizationId(userOrganizationId); + } + } else { + if (userOrganizationId != null) { + stockInOrderDO.setOrganizationId(userOrganizationId); + } + } + if (stockInOrderDO.getOrganizationId() == null) { + Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); + if (topOrganizationId != null && topOrganizationId != 1) { + stockInOrderDO.setTopOrganizationId(topOrganizationId); + } + } else { + stockInOrderDO.setTopOrganizationId(2827L); + } + } + // 默认仓库 + if (stockInOrderDO.getWarehouseId() == null) { + AssociationWarehouseCacheDO associationWarehouseCacheDO = + SystemServiceCacheUtil.getAssociationWarehouseCache(loginUser.getUserid()); + if (associationWarehouseCacheDO != null) { + stockInOrderDO.setWarehouseId(associationWarehouseCacheDO.getWarehouseId()); + } + } + } + + // 入库签名列表固定「已入库」状态过滤 +// if (stockInOrderDO.getStatus() == null) { +// stockInOrderDO.setStatus(5); +// } + + List stockInOrderPOS = stockInOrderDomainService.querySignatureList(stockInOrderDO); + // 状态/签名字段翻译,便于 PDA 端直接展示 + for (StockInOrderPO stockInOrderPO : stockInOrderPOS) { + // 状态名称 + Integer status = stockInOrderPO.getStatus(); + if (status != null) { + if (status == 5) { + stockInOrderPO.setStatusName("已入库"); + } else if (status == 4) { + stockInOrderPO.setStatusName("上架中"); + } else if (status == 3) { + stockInOrderPO.setStatusName("收货中"); + } else if (status == 2) { + stockInOrderPO.setStatusName("已审核"); + } else if (status == 1) { + stockInOrderPO.setStatusName("已创建"); + } + } + // 签名状态名称 + Integer signatureStatus = stockInOrderPO.getSignatureStatus(); + if (signatureStatus != null) { + if (signatureStatus == 1) { + stockInOrderPO.setSignatureStatusName("待签名"); + } else if (signatureStatus == 2) { + stockInOrderPO.setSignatureStatusName("已签名"); + } + } + } + return stockInOrderPOS; + } + + /** * 新增入库单 @@ -569,6 +657,11 @@ public class StockInOrderApplicationService { /** * 获取入库单详细信息 + * + *

回显入库单基本信息、物料明细以及 PDA入库签名相关字段 + * (签名状态、签名时间、签名图片、签名备注)。
+ * 与 PDA入库签名列表({@link #querySignatureList(StockInOrderDO)})字段保持一致, + * 供 PDA 端「入库签名详情页 - 电子签名/物料明细」两个 tab 数据回显使用。

*/ public StockInOrderPO getInfo(Long inOrderId) { @@ -646,6 +739,24 @@ public class StockInOrderApplicationService { info.setMaterialDetailList(materialDetailList); } + // PDA入库签名 - 签名状态名称翻译(待签名/已签名),便于 PDA 详情页直接展示 + Integer signatureStatus = info.getSignatureStatus(); + if (signatureStatus != null) { + if (signatureStatus == 1) { + info.setSignatureStatusName("待签名"); + } else if (signatureStatus == 2) { + info.setSignatureStatusName("已签名"); + } + } + + // 入库单状态名称翻译 + Integer status = info.getStatus(); + if (status != null) { + if (status == 5) { + info.setStatusName("已入库"); + } + } + return info; } @@ -668,6 +779,11 @@ public class StockInOrderApplicationService { return b; } + public Boolean remarkEasyMode(StockInOrderDO stockInOrderDO){ + Boolean b = stockInOrderDomainService.remarkEasyMode(stockInOrderDO); + return b; + } + public Boolean updateQuantity( BigDecimal quantity, Long materialDetailId,BigDecimal area, BigDecimal volume,BigDecimal weight){ Boolean result = false; @@ -2807,4 +2923,31 @@ public class StockInOrderApplicationService { } stockInOrderService.updateById(entity); } + + /** + * PDA批量入库签名 + */ + public AjaxResult batchSignature(com.mhd.wms.interfaces.dto.signature.BatchSignatureDTO dto) { + List inOrderIds = dto.getInOrderIds(); + if (inOrderIds == null || inOrderIds.isEmpty()) { + return AjaxResult.error("请选择需要签名的入库单"); + } + int success = 0; + Date now = new Date(); + for (Long id : inOrderIds) { + StockInOrder entity = new StockInOrder(); + entity.setInOrderId(id); + entity.setSignatureStatus(dto.getSignatureStatus() != null ? dto.getSignatureStatus() : 2); + entity.setSignatureTime(dto.getSignatureTime() != null ? dto.getSignatureTime() : now); + entity.setSignaturePic(dto.getSignaturePic()); + if (dto.getEvidencePics() != null && !dto.getEvidencePics().isEmpty()) { + entity.setEvidencePics(String.join(",", dto.getEvidencePics())); + } + entity.setSignatureRemark(dto.getSignatureRemark()); + stockInOrderService.updateById(entity); + success++; + } + return AjaxResult.success("批量签名成功,共" + success + "条"); + } + } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java b/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java index 9dbe157ba..f3b4cda24 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/application/service/stockOutOrder/StockOutOrderApplicationService.java @@ -322,6 +322,60 @@ public class StockOutOrderApplicationService { return stockOutOrderPOS; } + /** + * PDA出库签名列表查询 + * + *

参照简易模式快捷出库列表实现,默认 status=已出库(9),支持 workUserNameLike 模糊查询。

+ */ + public List querySignatureList(StockOutOrderDO stockOutOrderDO) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null && loginUser.getUserPo() != null) { + Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); + Long frontendOrganizationId = stockOutOrderDO.getOrganizationId(); + if (userOrganizationId != null && userOrganizationId == 2827L) { + if (frontendOrganizationId != null) { + stockOutOrderDO.setOrganizationId(frontendOrganizationId); + stockOutOrderDO.setTopOrganizationId(null); + } else { + stockOutOrderDO.setOrganizationId(null); + stockOutOrderDO.setTopOrganizationId(null); + } + } else { + if (frontendOrganizationId != null && userOrganizationId != null) { + if (!frontendOrganizationId.equals(userOrganizationId)) { + stockOutOrderDO.setOrganizationId(userOrganizationId); + } + } else { + if (userOrganizationId != null) { + stockOutOrderDO.setOrganizationId(userOrganizationId); + } + } + if (stockOutOrderDO.getOrganizationId() == null) { + Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId(); + if (topOrganizationId != null && topOrganizationId != 1) { + stockOutOrderDO.setTopOrganizationId(topOrganizationId); + } + } else { + stockOutOrderDO.setTopOrganizationId(2827L); + } + } + } + if (stockOutOrderDO.getStatus() == null) { + stockOutOrderDO.setStatus(9); + } + List list = stockOutOrderDomainService.querySignatureList(stockOutOrderDO); + for (StockOutOrderPO po : list) { + Integer ss = po.getSignatureStatus(); + if (ss != null) { + po.setSignatureStatusName(ss == 1 ? "待签名" : ss == 2 ? "已签名" : null); + } + if (po.getStatus() != null && po.getStatus() == 9) { + po.setStatusName("已出库"); + } + } + return list; + } + /** * 新增出库单 @@ -430,6 +484,15 @@ public class StockOutOrderApplicationService { List list = deliveryDetailsLinkService.list(new LambdaQueryWrapper().eq(DeliveryDetailsLink::getOrderNumber, stockOutOrderPO.getOutOrderNumber())); stockOutOrderPO.setDeliveryDetailsLinkList(list); + // PDA出库签名 - 签名状态名称翻译 + Integer signatureStatus = stockOutOrderPO.getSignatureStatus(); + if (signatureStatus != null) { + stockOutOrderPO.setSignatureStatusName(signatureStatus == 1 ? "待签名" : signatureStatus == 2 ? "已签名" : null); + } + if (stockOutOrderPO.getStatus() != null && stockOutOrderPO.getStatus() == 9) { + stockOutOrderPO.setStatusName("已出库"); + } + return stockOutOrderPO; } @@ -2047,4 +2110,30 @@ public class StockOutOrderApplicationService { stockOutOrderService.updateById(entity); } + /** + * PDA批量出库签名 + */ + public AjaxResult batchSignature(com.mhd.wms.interfaces.dto.signature.BatchSignatureDTO dto) { + List outOrderIds = dto.getOutOrderIds(); + if (outOrderIds == null || outOrderIds.isEmpty()) { + return AjaxResult.error("请选择需要签名的出库单"); + } + int success = 0; + Date now = new Date(); + for (Long id : outOrderIds) { + StockOutOrder entity = new StockOutOrder(); + entity.setOutOrderId(id); + entity.setSignatureStatus(dto.getSignatureStatus() != null ? dto.getSignatureStatus() : 2); + entity.setSignatureTime(dto.getSignatureTime() != null ? dto.getSignatureTime() : now); + entity.setSignaturePic(dto.getSignaturePic()); + if (dto.getEvidencePics() != null && !dto.getEvidencePics().isEmpty()) { + entity.setEvidencePics(String.join(",", dto.getEvidencePics())); + } + entity.setSignatureRemark(dto.getSignatureRemark()); + stockOutOrderService.updateById(entity); + success++; + } + return AjaxResult.success("批量签名成功,共" + success + "条"); + } + } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java index 504e379fe..033cbae2f 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/handoverTaskOrder/service/HandoverTaskOrderDomainService.java @@ -328,7 +328,9 @@ public class HandoverTaskOrderDomainService { if (soo != null && "1".equals(soo.getNeedDeclareFlag())) { continue; // 需报关,跳过 } - pushOms(handoverTaskOrderId); + if (soo != null && !"yang_pin_chu_ku".equals(soo.getBusinessType())) { + pushOms(handoverTaskOrderId); + } } HandoverTaskOrder handoverTaskOrder = handoverTaskOrderService.getById(handoverTaskOrderIds.get(0)); stockOutOrderService.update(null,new UpdateWrapper().lambda().set(StockOutOrder::getBillingJson,handoverTaskOrderDO.getBillingJson()).eq(StockOutOrder::getOutOrderNumber,handoverTaskOrder.getOrderNumber())); @@ -441,13 +443,17 @@ public class HandoverTaskOrderDomainService { materialInventoryParamDO.setExpiryDate(materialInventoryPO.getExpiryDate()); materialInventoryParamDO.setType("4"); materialInventoryParamDO.setWarehouseId(materialInventoryPO.getWarehouseId()); - materialInventoryService.kctzjl(materialInventoryParamDO, "出库", loginUser); - materialInventoryService.xgkc(materialInventoryParamDO); + MaterialInventoryOmsParamDO materialInventoryOmsParamDO = new MaterialInventoryOmsParamDO(); BeanUtils.copyProperties(materialInventoryParamDO, materialInventoryOmsParamDO); materialInventoryOmsParamDO.setKctzType("出库"); materialInventoryOmsParamDO.setLoginUser(loginUser); - omsServiceFeign.omsEdit(materialInventoryOmsParamDO); + if (stockOutOrder != null && !"yang_pin_chu_ku".equals(stockOutOrder.getBusinessType())) { + materialInventoryService.kctzjl(materialInventoryParamDO,"出库",loginUser); + materialInventoryService.xgkc(materialInventoryParamDO); + //库存推送oms + omsServiceFeign.omsEdit(materialInventoryOmsParamDO); + } } } } diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/entity/InMaterialDetail.java b/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/entity/InMaterialDetail.java index 3d592e406..a9e0f5e26 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/entity/InMaterialDetail.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/entity/InMaterialDetail.java @@ -399,6 +399,22 @@ public class InMaterialDetail extends BaseVOEntity { @DateTimeFormat(pattern="yyyy-MM-dd") private Date drinkDate; + @ApiModelProperty("来货验收是否合格;1 合格,0 不合格") + @Excel(name = "来货验收是否合格;1 合格,0 不合格") + private String arrivalAcceptQualified; + + @ApiModelProperty("包装是否破损;1 破损,0 完好") + @Excel(name = "包装是否破损;1 破损,0 完好") + private String packageDamaged; + + @ApiModelProperty("是否解冻 / 水渍;1 是,0 否") + @Excel(name = "是否解冻 / 水渍;1 是,0 否") + private String isThawWaterstain; + + @ApiModelProperty("问题货是否已通知客户;1 已通知,0 未通知") + @Excel(name = "问题货是否已通知客户;1 已通知,0 未通知") + private String notifyCustomerAbnormal; + //订单行号 private String lineNumGw; diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/po/InMaterialDetailPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/po/InMaterialDetailPO.java index b53b7a071..03c5ff163 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/po/InMaterialDetailPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/po/InMaterialDetailPO.java @@ -424,6 +424,22 @@ public class InMaterialDetailPO extends StockInOrderBasePO { @DateTimeFormat(pattern="yyyy-MM-dd") private Date drinkDate; + @ApiModelProperty("来货验收是否合格;1 合格,0 不合格") + @Excel(name = "来货验收是否合格;1 合格,0 不合格") + private String arrivalAcceptQualified; + + @ApiModelProperty("包装是否破损;1 破损,0 完好") + @Excel(name = "包装是否破损;1 破损,0 完好") + private String packageDamaged; + + @ApiModelProperty("是否解冻 / 水渍;1 是,0 否") + @Excel(name = "是否解冻 / 水渍;1 是,0 否") + private String isThawWaterstain; + + @ApiModelProperty("问题货是否已通知客户;1 已通知,0 未通知") + @Excel(name = "问题货是否已通知客户;1 已通知,0 未通知") + private String notifyCustomerAbnormal; + //订单行号 private String lineNumGw; //物料规格 diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/todo/InMaterialDetailDO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/todo/InMaterialDetailDO.java index 10474e43a..4a8c8c94b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/todo/InMaterialDetailDO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/inMaterialDetail/repository/todo/InMaterialDetailDO.java @@ -390,6 +390,22 @@ public class InMaterialDetailDO extends StockInOrderBaseDO { @DateTimeFormat(pattern="yyyy-MM-dd") private Date drinkDate; + @ApiModelProperty("来货验收是否合格;1 合格,0 不合格") + @Excel(name = "来货验收是否合格;1 合格,0 不合格") + private String arrivalAcceptQualified; + + @ApiModelProperty("包装是否破损;1 破损,0 完好") + @Excel(name = "包装是否破损;1 破损,0 完好") + private String packageDamaged; + + @ApiModelProperty("是否解冻 / 水渍;1 是,0 否") + @Excel(name = "是否解冻 / 水渍;1 是,0 否") + private String isThawWaterstain; + + @ApiModelProperty("问题货是否已通知客户;1 已通知,0 未通知") + @Excel(name = "问题货是否已通知客户;1 已通知,0 未通知") + private String notifyCustomerAbnormal; + //订单行号 private String lineNumGw; //物料规格 diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java b/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java index eeb450474..0123e24cc 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/outMaterialDetail/repository/persistence/OutMaterialDetailImpl.java @@ -405,7 +405,12 @@ public class OutMaterialDetailImpl extends ServiceImpl stockOutOrderList = stockOutOrderMapper.selectList(new QueryWrapper().lambda() + .eq(StockOutOrder::getOutOrderNumber, outOrderNumber) + .eq(StockOutOrder::getDelFlag, 1)); + if (!CollectionUtils.isEmpty(stockOutOrderList) && "yang_pin_chu_ku".equals(stockOutOrderList.get(0).getBusinessType())) { + xgkc(outMaterialDetailList,outOrderNumber,loginUser); + } //保存物料明细信息 outMaterialDetailList.forEach(outMaterialDetail -> { outMaterialDetail.setIsAllocated("1"); @@ -535,7 +540,12 @@ public class OutMaterialDetailImpl extends ServiceImpl stockOutOrderList = stockOutOrderMapper.selectList(new QueryWrapper().lambda() + .eq(StockOutOrder::getOutOrderNumber, outOrderNumber) + .eq(StockOutOrder::getDelFlag, 1)); + if (!CollectionUtils.isEmpty(stockOutOrderList) && "yang_pin_chu_ku".equals(stockOutOrderList.get(0).getBusinessType())) { + qxfp(outMaterialDetailDOList,outOrderNumber,loginUser); + } return stockOutOrderPO; } @@ -973,7 +983,14 @@ public class OutMaterialDetailImpl extends ServiceImpl stockOutOrderList = stockOutOrderMapper.selectList(new QueryWrapper().lambda() + .eq(StockOutOrder::getOutOrderNumber, outOrderNumber) + .eq(StockOutOrder::getDelFlag, 1)); + if (!CollectionUtils.isEmpty(stockOutOrderList) && "yang_pin_chu_ku".equals(stockOutOrderList.get(0).getBusinessType())) { + qxfp(outMaterialDetailDOList,outOrderNumber,loginUser); + } + return stockOutOrderPO; } @@ -1076,7 +1093,12 @@ public class OutMaterialDetailImpl extends ServiceImpl children = outMaterialDetail.getChildren(); if (!CollectionUtils.isEmpty(children)) { - childrenqxfp(children,outOrderNumber,loginUser); + List stockOutOrderList = stockOutOrderMapper.selectList(new QueryWrapper().lambda() + .eq(StockOutOrder::getOutOrderNumber, outOrderNumber) + .eq(StockOutOrder::getDelFlag, 1)); + if (!CollectionUtils.isEmpty(stockOutOrderList) && "yang_pin_chu_ku".equals(stockOutOrderList.get(0).getBusinessType())) { + childrenqxfp(children,outOrderNumber,loginUser); + } } } } diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/PickingOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/PickingOrderDomainService.java index c69e8d428..d79187f09 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/PickingOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/PickingOrderDomainService.java @@ -870,7 +870,7 @@ public class PickingOrderDomainService { handoverTaskOrderDO.setShipperId(pickingOrderPO.getShipperId()); handoverTaskOrderDO.setShipperName(pickingOrderPO.getShipperName()); handoverTaskOrderDO.setSerialNumber(OrderSequence.getOrderCode("JJZYLS")); - handoverTaskOrderDO.setTaskNumber(OrderSequence.getOrderCode("JJZY")); + handoverTaskOrderDO.setTaskNumber("HD-"+pickingOrderPO.getOutOrderNumber()); handoverTaskOrderDO.setStatus(1); handoverTaskOrderDO.setOrderTypeCode(pickingOrderPO.getOrderTypeCode()); handoverTaskOrderDO.setOrderTypeName(pickingOrderPO.getOrderTypeName()); diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/ReviewOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/ReviewOrderDomainService.java index f2e8dd727..56ecf7782 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/ReviewOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/pickingOrder/service/ReviewOrderDomainService.java @@ -115,7 +115,8 @@ public class ReviewOrderDomainService { Date now = new Date(); ReviewOrder header = new ReviewOrder(); - header.setReviewOrderNumber(reviewOrderNumber); +// header.setReviewOrderNumber(reviewOrderNumber); + header.setReviewOrderNumber("RE-"+stockOutOrder.getOutOrderNumber()); header.setOutOrderId(stockOutOrder.getOutOrderId()); header.setOutOrderNumber(stockOutOrder.getOutOrderNumber()); header.setOrganizationId(stockOutOrder.getOrganizationId()); @@ -329,4 +330,4 @@ public class ReviewOrderDomainService { } return loginUser.getUsername(); } -} +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/reviewOrder/repository/po/ReviewOrderPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/reviewOrder/repository/po/ReviewOrderPO.java index 6317e37ea..719ac71c3 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/reviewOrder/repository/po/ReviewOrderPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/reviewOrder/repository/po/ReviewOrderPO.java @@ -2,6 +2,8 @@ package com.mhd.wms.domain.reviewOrder.repository.po; import com.mhd.common.core.web.domain.BaseVOEntity; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -18,24 +20,28 @@ import java.util.List; @ApiModel(value = "复核单主表", description = "复核单主表展示") public class ReviewOrderPO extends BaseVOEntity { + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("复核单主键") private Long reviewOrderId; @ApiModelProperty("复核单号") private String reviewOrderNumber; + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("出库单ID") private Long outOrderId; @ApiModelProperty("出库单号") private String outOrderNumber; + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("组织ID") private Long organizationId; @ApiModelProperty("组织名称") private String organizationName; + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("一级组织ID") private Long topOrganizationId; @@ -50,6 +56,7 @@ public class ReviewOrderPO extends BaseVOEntity { @ApiModelProperty("复核下发时间") private Date issuedTime; + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("仓库ID") private Long warehouseId; @@ -59,6 +66,7 @@ public class ReviewOrderPO extends BaseVOEntity { @ApiModelProperty("仓库名称") private String warehouseName; + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("客户ID") private Long customerId; @@ -68,6 +76,7 @@ public class ReviewOrderPO extends BaseVOEntity { @ApiModelProperty("客户名称") private String customerName; + @JsonSerialize(using = ToStringSerializer.class) @ApiModelProperty("货主ID") private Long shipperId; diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/entity/StockInOrder.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/entity/StockInOrder.java index 79d8b2dd6..a4e1862a3 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/entity/StockInOrder.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/entity/StockInOrder.java @@ -392,4 +392,22 @@ public class StockInOrder extends BaseVOEntity { @ApiModelProperty("任务下发用户ID") private String taskIssueUserId; + + // ========== PDA入库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64/URL,单张)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张OSS URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/mapper/StockInOrderMapper.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/mapper/StockInOrderMapper.java index 15c9d20b5..37aabe0c5 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/mapper/StockInOrderMapper.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/mapper/StockInOrderMapper.java @@ -32,4 +32,14 @@ public interface StockInOrderMapper extends BaseMapper StockInOrderPO selectByInOrderNumber(@Param("inOrderNumber") String inOrderNumber); String queryWarehouseUserId(@Param("organizationId") Long organizationId, @Param("warehouseId") Long warehouseId, @Param("topOrganizationId") Long topOrganizationId); + + void updateExecution(@Param("inOrderNumber") String inOrderNumber, @Param("remark") String remark); + + /** + * 跨4张入库单表查询指定前缀+组织+仓库的所有入库单号(用于取最大序号+1,防止删单后单号重复) + * 包含: reserve_stock_in_order, reservation_stock_in_order, execution_stock_in_order, WMS stock_in_order + */ + List getMaxStockInOrderByPrefixAndOrgAndWarehouse(@Param("prefix") String prefix, + @Param("organizationId") Long organizationId, + @Param("warehouseId") Long warehouseId); } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/po/StockInOrderPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/po/StockInOrderPO.java index 20c92b22b..6c00d4db1 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/po/StockInOrderPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/po/StockInOrderPO.java @@ -456,4 +456,25 @@ public class StockInOrderPO extends BaseVOEntity { @ApiModelProperty("任务下发用户ID") private String taskIssueUserId; + + // ========== PDA入库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名状态名称") + private String signatureStatusName; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64/URL)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张OSS URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/todo/StockInOrderDO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/todo/StockInOrderDO.java index c18ae7f4f..05ed6e678 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/todo/StockInOrderDO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/repository/todo/StockInOrderDO.java @@ -449,6 +449,34 @@ public class StockInOrderDO extends BaseVOEntity { @ApiModelProperty("任务移除用户ID") private String removeUserId; + // ========== PDA入库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名状态名称") + private String signatureStatusName; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64/URL)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张OSS URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; + + /** + * PDA入库签名列表专用:作业任务人员模糊查询字段(与 workUserName LIKE 同义, + * 单独提供是为了避免和现有 workUserName(精确/等值)逻辑冲突)。 + */ + @ApiModelProperty("作业任务人员模糊查询") + private String workUserNameLike; + @ApiModelProperty("是否返回物料明细(导出时传 true)") private Boolean needDetail; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/service/StockInOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/service/StockInOrderDomainService.java index 8abce3094..05a15484b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/service/StockInOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockInOrder/service/StockInOrderDomainService.java @@ -1,5 +1,6 @@ package com.mhd.wms.domain.stockInOrder.service; +import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson2.JSONObject; @@ -16,8 +17,11 @@ import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.core.utils.uuid.IdGenerator; import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.security.utils.SecurityUtils; +import com.mhd.system.api.OmsServiceFeign; import com.mhd.system.api.SystemServiceFeign; +import com.mhd.system.api.domain.ElectronicSignatureSyncDTO; import com.mhd.system.api.domain.PackDetailFeignPO; +import com.mhd.system.api.domain.WarehouseFeignPO; import com.mhd.system.api.model.LoginUser; import com.mhd.wms.domain.inMaterialDetail.entity.InMaterialDetail; import com.mhd.wms.domain.inMaterialDetail.repository.facade.IInMaterialDetailService; @@ -42,6 +46,7 @@ import com.mhd.wms.domain.shelfMaterialDetail.repository.po.ShelfMaterialDetailP import com.mhd.wms.domain.shelfMaterialDetail.repository.todo.ShelfMaterialDetailDO; import com.mhd.wms.domain.stockInOrder.entity.StockInOrder; import com.mhd.wms.domain.stockInOrder.repository.facade.IStockInOrderService; +import com.mhd.wms.domain.stockInOrder.repository.mapper.StockInOrderMapper; import com.mhd.wms.domain.stockInOrder.repository.po.StockInOrderPO; import com.mhd.wms.domain.stockInOrder.repository.todo.StockInOrderDO; import com.mhd.wms.domain.stockReceiptOrder.entity.StockReceiptOrder; @@ -82,6 +87,8 @@ public class StockInOrderDomainService { @Autowired private IStockInOrderService stockInOrderService; @Autowired + private StockInOrderMapper stockInOrderMapper; + @Autowired private IInMaterialDetailService materialDetailService; @Autowired private StockReceiptOrderDomainService stockReceiptOrderDomainService; @@ -97,6 +104,8 @@ public class StockInOrderDomainService { private IMaterialWarehouseControlService materialWarehouseControlService; @Resource private SystemServiceFeign systemServiceFeign; + @Resource + private OmsServiceFeign omsServiceFeign; @Autowired private IReceiptMaterialDetailService receiptMaterialDetailService; @Autowired @@ -115,13 +124,99 @@ public class StockInOrderDomainService { return stockInOrderService.queryList(stockInOrderDO); } + /** + * PDA入库签名列表查询 + * + *

参照简易模式快捷入库列表({@link #queryList(StockInOrderDO)})实现, + * 默认查询 status=已入库(5) 的入库单;同时支持「作业任务人员」模糊查询及其他业务字段。

+ * + * @param stockInOrderDO 查询条件 + * @return 入库单列表 + */ + public List querySignatureList(StockInOrderDO stockInOrderDO) { + // 入库签名列表固定按「已入库」状态过滤 + if (stockInOrderDO.getStatus() == null) { +// stockInOrderDO.setStatus(5); + List list = new ArrayList<>(); + list.add(2); + list.add(3); + list.add(4); + list.add(5); + stockInOrderDO.setStatusList(list); + } + // 委托给 queryList,复用 selectStockInOrderPo1 中现有的查询条件(包括新加的 workUserNameLike、signatureStatus) + return stockInOrderService.queryList(stockInOrderDO); + } + + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } + /** * 新增入库单 */ @Transactional(rollbackFor = Exception.class) public Boolean insert(StockInOrderDO stockInOrderDO) { - stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK")); +// stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK")); + +//设置入库单号 + Long warehouseId = stockInOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = stockInOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = stockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = stockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(prefix + seq); + } + // //设置默认值 // setDefaultValues(stockInOrderDO); // //设置物料信息 @@ -146,8 +241,35 @@ public class StockInOrderDomainService { */ public Boolean batchInsert(List stockInOrderDOList) { for (StockInOrderDO stockInOrderDO : stockInOrderDOList){ - if (StringUtils.isBlank(stockInOrderDO.getInOrderNumber())){ - stockInOrderDO.setInOrderNumber(OrderSequence.getOrderCode("RK")); + //设置入库单号 + Long warehouseId = stockInOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getInOrderNoPrefix(); + if (prefix == null || prefix.isEmpty()) { + prefix = "RK"; + } + Long organizationId = stockInOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockInOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = stockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = stockInOrderMapper.getMaxStockInOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockInOrderDO.setInOrderNumber(prefix + seq); } // //设置物料信息 // setMaterialDetailInfo(stockInOrderDO); @@ -403,6 +525,8 @@ public class StockInOrderDomainService { if (StringUtils.isEmpty(inOrderNumber)) { return; } + + StockInOrder stockInOrder = stockInOrderService.getOne(new QueryWrapper().lambda() .eq(StockInOrder::getInOrderNumber, inOrderNumber) .eq(StockInOrder::getDelFlag, 1) @@ -410,6 +534,15 @@ public class StockInOrderDomainService { if (stockInOrder == null || AUDIT_STATUS_PASS == stockInOrder.getAuditStatus()) { return; } + + //生成电子签名 + StockInOrderPO info = getInfo(stockInOrder.getInOrderId()); + List materialDetails = materialDetailService.list(new QueryWrapper().lambda() + .eq(InMaterialDetail::getInOrderNumber, inOrderNumber) + .eq(InMaterialDetail::getDelFlag, 1)); + genElectronicSignature(info,materialDetails); + + StockInOrderDO auditDO = new StockInOrderDO(); auditDO.setInOrderIds(Collections.singletonList(stockInOrder.getInOrderId())); auditDO.setAuditStatus(AUDIT_STATUS_PASS); @@ -503,6 +636,52 @@ public class StockInOrderDomainService { .in(StockInOrder::getInOrderId, stockInOrderDO.getInOrderIds())); } + + @Transactional(rollbackFor = Exception.class) + public Boolean remarkEasyMode(StockInOrderDO stockInOrderDO) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + + String userRealName = loginUser.getUserPo() != null && loginUser.getUserPo().getUserName() != null + ? loginUser.getUserPo().getUserName() + : (loginUser.getRealname() != null ? loginUser.getRealname() : loginUser.getUsername()); + String inOrderNumber = stockInOrderDO.getInOrderNumber(); + + List materialDetailList = stockInOrderDO.getMaterialDetailList(); + List receiptMaterialDetailList = materialDetailList.stream() + .filter(m -> m.getRemark() != null && m.getRemark() != "") + .collect(Collectors.toList()); + String orderRemark = stockInOrderDO.getRemark(); + if (receiptMaterialDetailList!=null && receiptMaterialDetailList.size()>0) { + for (InMaterialDetailDO inMaterialDetailDO : receiptMaterialDetailList) { + String notifyCustomerAbnormal = inMaterialDetailDO.getNotifyCustomerAbnormal(); + String isThawWaterstain = inMaterialDetailDO.getIsThawWaterstain(); + String packageDamaged = inMaterialDetailDO.getPackageDamaged(); + String arrivalAcceptQualified = inMaterialDetailDO.getArrivalAcceptQualified(); + String remark = inMaterialDetailDO.getRemark(); + Long materialDetailId = inMaterialDetailDO.getMaterialDetailId(); + InMaterialDetail inMaterialDetail = materialDetailService.getById(materialDetailId); + inMaterialDetail.setNotifyCustomerAbnormal(notifyCustomerAbnormal); + inMaterialDetail.setIsThawWaterstain(isThawWaterstain); + inMaterialDetail.setPackageDamaged(packageDamaged); + inMaterialDetail.setArrivalAcceptQualified(arrivalAcceptQualified); + inMaterialDetail.setRemark(remark); + orderRemark = orderRemark + "," + remark; + materialDetailService.updateById(inMaterialDetail); + } + } + if (orderRemark != null && !orderRemark.isEmpty()) { + String[] remarks = orderRemark.split(","); + List list = Arrays.asList(remarks); + orderRemark = list.stream().distinct().collect(Collectors.joining(",")); + stockInOrderService.update(null, new UpdateWrapper().lambda() + .set(StockInOrder::getRemark, orderRemark) + .eq(StockInOrder::getInOrderNumber, inOrderNumber) + .eq(StockInOrder::getDelFlag, 1)); + stockInOrderMapper.updateExecution(inOrderNumber, orderRemark); + } + return true; + } + @Transactional(rollbackFor = Exception.class) public Boolean receiptEasyMode(StockInOrderDO stockInOrderDO) { LoginUser loginUser = SecurityUtils.getLoginUser(); @@ -592,7 +771,8 @@ public class StockInOrderDomainService { stockShelfOrder = list.get(0); } else { BeanUtils.copyProperties(stockReceiptOrder, stockShelfOrder); - stockShelfOrder.setShelfOrderNumber(OrderSequence.getOrderCode("SJ")); +// stockShelfOrder.setShelfOrderNumber(OrderSequence.getOrderCode("SJ")); + stockShelfOrder.setShelfOrderNumber("SH-"+inOrderNumber); stockShelfOrder.setBatchNo(batchNo); stockShelfOrderService.save(stockShelfOrder); } @@ -861,7 +1041,8 @@ public class StockInOrderDomainService { stockInOrderPOList.forEach(p -> { StockReceiptOrderDO stockReceiptOrderDO = new StockReceiptOrderDO(); BeanUtils.copyProperties(p, stockReceiptOrderDO); - stockReceiptOrderDO.setReceiptOrderNumber(OrderSequence.getOrderCode("SH")); + stockReceiptOrderDO.setReceiptOrderNumber("RV-"+p.getInOrderNumber()); +// stockReceiptOrderDO.setReceiptOrderNumber(OrderSequence.getOrderCode("SH")); List inMaterialDetailPOs = inMaterialDetailListMap.get(p.getInOrderNumber()); if (!CollectionUtils.isEmpty(inMaterialDetailPOs)){ List receiptMaterialDetailDOList = new ArrayList<>(); @@ -1227,4 +1408,55 @@ public class StockInOrderDomainService { public List queryNoticePrintDetail(StockInOrderDO stockInOrderDO) { return stockInOrderService.queryNoticePrintDetail(stockInOrderDO); } + + + /** + * 生成入库电子签名记录(上架完成触发) + */ + private void genElectronicSignature(StockInOrderPO stockShelfOrderPO, List shelfMaterialDetailList) { + try { + ElectronicSignatureSyncDTO dto = new ElectronicSignatureSyncDTO(); + dto.setOrderId(stockShelfOrderPO.getInOrderId()); + dto.setOrderNumber(stockShelfOrderPO.getInOrderNumber()); + dto.setOrderType("IN"); + dto.setOrganizationId(stockShelfOrderPO.getOrganizationId()); + dto.setOrganizationName(stockShelfOrderPO.getOrganizationName()); + dto.setTopOrganizationId(stockShelfOrderPO.getTopOrganizationId()); + dto.setWarehouseId(stockShelfOrderPO.getWarehouseId()); + dto.setWarehouseCode(stockShelfOrderPO.getWarehouseCode()); + dto.setWarehouseName(stockShelfOrderPO.getWarehouseName()); + + List items = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(shelfMaterialDetailList)) { + for (InMaterialDetail detail : shelfMaterialDetailList) { + ElectronicSignatureSyncDTO.MaterialDetailItem item = new ElectronicSignatureSyncDTO.MaterialDetailItem(); + item.setMaterialBaseInfoId(detail.getMaterialBaseInfoId()); + item.setMaterialCode(detail.getMaterialCode()); + item.setMaterialName(detail.getMaterialName()); + item.setQuantity(detail.getShelvesQuantity()); + item.setUnitCode(detail.getUnitCode()); + item.setUnitName(detail.getUnitName()); + item.setBatchNumber(detail.getBatchNumber()); + item.setLotNumber(detail.getLotNo()); + item.setWarehouseId(detail.getWarehouseId()); + item.setWarehouseCode(detail.getWarehouseCode()); + item.setWarehouseName(detail.getWarehouseName()); + item.setStorageSectionId(detail.getStorageSectionId()); + item.setStorageSectionCode(detail.getStorageCode()); + item.setStorageSectionName(detail.getStorageName()); + item.setStorageLocationId(detail.getStorageLocationId()); + item.setStorageLocationCode(detail.getStorageLocationCode()); + item.setStorageLocationName(detail.getStorageLocationName()); + item.setUniqueId(detail.getUniqueId()); + items.add(item); + } + } + dto.setMaterialDetailList(items); + + log.info("生成入库电子签名记录,订单号:{},物料条目数:{}", stockShelfOrderPO.getInOrderNumber(), items.size()); + omsServiceFeign.saveSignature(dto); + } catch (Exception e) { + log.error("生成入库电子签名记录失败,订单号:{}", stockShelfOrderPO.getInOrderNumber(), e); + } + } } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/entity/StockOutOrder.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/entity/StockOutOrder.java index ca13c0772..3ea609c6c 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/entity/StockOutOrder.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/entity/StockOutOrder.java @@ -434,4 +434,22 @@ public class StockOutOrder extends BaseVOEntity { @ApiModelProperty("任务下发用户ID") private String taskIssueUserId; + + // ========== PDA出库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64/URL,单张)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张OSS URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/mapper/StockOutOrderMapper.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/mapper/StockOutOrderMapper.java index 53b9dc775..6cb3b57b1 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/mapper/StockOutOrderMapper.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/mapper/StockOutOrderMapper.java @@ -46,4 +46,12 @@ public interface StockOutOrderMapper extends BaseMapper { public String getOpWhLoc(@Param("id") Long id); public String getInLotNo(@Param("inOrderNumber") String inOrderNumber, @Param("baseId") Long baseId); + + /** + * 跨4张入库单表查询指定前缀+组织+仓库的所有入库单号(用于取最大序号+1,防止删单后单号重复) + * 包含: reserve_stock_in_order, reservation_stock_in_order, execution_stock_in_order, WMS stock_in_order + */ + List getMaxStockOutOrderByPrefixAndOrgAndWarehouse(@Param("prefix") String prefix, + @Param("organizationId") Long organizationId, + @Param("warehouseId") Long warehouseId); } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/po/StockOutOrderPO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/po/StockOutOrderPO.java index 52bb67a96..b0938dab6 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/po/StockOutOrderPO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/po/StockOutOrderPO.java @@ -463,4 +463,28 @@ public class StockOutOrderPO extends BaseVOEntity { @ApiModelProperty("任务下发用户ID") private String taskIssueUserId; + + // ========== PDA出库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名状态名称") + private String signatureStatusName; + + @ApiModelProperty("出库单状态名称") + private String statusName; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64/URL)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张OSS URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/todo/StockOutOrderDO.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/todo/StockOutOrderDO.java index 2b036c595..6a53cc15b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/todo/StockOutOrderDO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/repository/todo/StockOutOrderDO.java @@ -516,4 +516,26 @@ public class StockOutOrderDO extends BaseVOEntity { @ApiModelProperty("是否返回物料明细(导出时传 true)") private Boolean needDetail; + + // ========== PDA出库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64/URL)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片(逗号分隔多张OSS URL)") + private String evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; + + /** PDA出库签名列表专用:作业任务人员模糊查询字段 */ + @ApiModelProperty("作业任务人员模糊查询") + private String workUserNameLike; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/service/StockOutOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/service/StockOutOrderDomainService.java index 4c106af4b..427055070 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/service/StockOutOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockOutOrder/service/StockOutOrderDomainService.java @@ -1,5 +1,6 @@ package com.mhd.wms.domain.stockOutOrder.service; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; @@ -14,10 +15,9 @@ import com.mhd.common.core.utils.StringUtils; import com.mhd.common.core.utils.bean.BeanUtils; import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.security.utils.SecurityUtils; +import com.mhd.system.api.OmsServiceFeign; import com.mhd.system.api.SystemServiceFeign; -import com.mhd.system.api.domain.BatchDetailFeignPO; -import com.mhd.system.api.domain.DeliveryDetailsLink; -import com.mhd.system.api.domain.PackDetailFeignPO; +import com.mhd.system.api.domain.*; import com.mhd.system.api.model.LoginUser; import com.mhd.wms.application.service.handoverTaskOrder.HandoverTaskOrderApplicationService; import com.mhd.wms.application.service.pickingOrder.PickingOrderApplicationService; @@ -88,6 +88,7 @@ import com.mhd.wms.domain.stockInOrder.repository.todo.StockInOrderDO; import com.mhd.wms.domain.stockInOrder.service.StockInOrderDomainService; import com.mhd.wms.domain.stockOutOrder.entity.StockOutOrder; import com.mhd.wms.domain.stockOutOrder.repository.facade.IStockOutOrderService; +import com.mhd.wms.domain.stockOutOrder.repository.mapper.StockOutOrderMapper; import com.mhd.wms.domain.stockOutOrder.repository.po.StockOutOrderPO; import com.mhd.wms.domain.stockOutOrder.repository.todo.StockOutOrderDO; import com.mhd.wms.domain.waveOrder.factorys.WaveOrderServiceFactory; @@ -168,6 +169,8 @@ public class StockOutOrderDomainService { @Autowired private StockInOrderMapper stockInOrderMapper; @Autowired + private StockOutOrderMapper stockOutOrderMapper; + @Autowired private PickingOrderApplicationService pickingOrderApplicationService; @Autowired private HandoverTaskOrderApplicationService handoverTaskOrderApplicationService; @@ -177,6 +180,8 @@ public class StockOutOrderDomainService { private ReviewOrderMapper reviewOrderMapper; @Autowired private ReviewMaterialDetailMapper reviewMaterialDetailMapper; + @Autowired + private OmsServiceFeign omsServiceFeign; /** * 分页查询出库单列表 @@ -185,13 +190,89 @@ public class StockOutOrderDomainService { return stockOutOrderService.queryList(stockOutOrderDO); } + /** + * PDA出库签名列表查询,默认 status=已出库(9) + */ + public List querySignatureList(StockOutOrderDO stockOutOrderDO) { + if (stockOutOrderDO.getStatus() == null) { + stockOutOrderDO.setStatus(9); + } + return stockOutOrderService.queryList(stockOutOrderDO); + } + + + /** + * 从单号列表中提取最大序号 + * 单号格式: prefix + 数字序号(如 RK260807001 中 prefix=RK260807, 序号=001) + * 即使中间有删单,也能保证序号递增不重复 + * + * @param orderNumbers 匹配的单号列表 + * @param prefixLength 前缀长度(序号从该位置开始截取) + * @return 最大序号值,列表为空时返回0 + */ + private int extractMaxSequenceNumber(List orderNumbers, int prefixLength) { + if (orderNumbers == null || orderNumbers.isEmpty()) { + return 0; + } + int maxSeq = 0; + for (String orderNumber : orderNumbers) { + if (orderNumber != null && orderNumber.length() > prefixLength) { + try { + String seqStr = orderNumber.substring(prefixLength); + int seq = Integer.parseInt(seqStr); + if (seq > maxSeq) { + maxSeq = seq; + } + } catch (NumberFormatException e) { + // 序号部分非数字,跳过 + } + } + } + return maxSeq; + } + /** * 新增出库单 */ @Transactional(rollbackFor = Exception.class) public Boolean insert(StockOutOrderDO stockOutOrderDO) { - stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); +// stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); + + //设置单号 + Long warehouseId = stockOutOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getOutOrderNoPrefix(); + if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { + prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); + } + if (prefix == null || prefix.isEmpty()) { + prefix = "CK"; + } + Long organizationId = stockOutOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(prefix + seq); + } + //设置物料信息 //setMaterialDetailInfo(stockOutOrderDO); //统计种类 @@ -219,8 +300,38 @@ public class StockOutOrderDomainService { @Transactional(rollbackFor = Exception.class) public Boolean batchInsert(List stockOutOrderDOList) { for (StockOutOrderDO stockOutOrderDO : stockOutOrderDOList){ - if (StringUtils.isBlank(stockOutOrderDO.getOutOrderNumber())){ - stockOutOrderDO.setOutOrderNumber(OrderSequence.getOrderCode("CK")); + //设置单号 + Long warehouseId = stockOutOrderDO.getWarehouseId(); + AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(warehouseId); + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("获取仓库信息失败"); + } + //仓库信息 + WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); + String orderNoGenerateRule = warehouseFeignPO.getOrderNoGenerateRule(); + String prefix = warehouseFeignPO.getOutOrderNoPrefix(); + if ("yang_pin_chu_ku".equals(stockOutOrderDO.getBusinessType())) { + prefix = warehouseFeignPO.getSampleOutOrderNoPrefix(); + } + if (prefix == null || prefix.isEmpty()) { + prefix = "CK"; + } + Long organizationId = stockOutOrderDO.getOrganizationId(); + Long warehouseIdForCount = stockOutOrderDO.getWarehouseId(); + if (orderNoGenerateRule != null && "0".equals(orderNoGenerateRule)) { + //日期累加: 前缀 + 当前日期yymmdd + 当天最大序号+1 + String dateStr = new SimpleDateFormat("yyMMdd").format(new Date()); + String datePrefix = prefix + dateStr; + List orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(datePrefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, datePrefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(datePrefix + seq); + } else { + //历史累加: 前缀 + 历史最大序号+1 + List orderNumbers = stockOutOrderMapper.getMaxStockOutOrderByPrefixAndOrgAndWarehouse(prefix, organizationId, warehouseIdForCount); + int maxSeq = extractMaxSequenceNumber(orderNumbers, prefix.length()); + String seq = String.format("%03d", maxSeq + 1); + stockOutOrderDO.setOutOrderNumber(prefix + seq); } //设置物料信息 setMaterialDetailInfo(stockOutOrderDO); @@ -785,7 +896,8 @@ public class StockOutOrderDomainService { PickingOrderDO pickingOrderDO = new PickingOrderDO(); BeanUtils.copyProperties(p, pickingOrderDO); pickingOrderDO.setOrderNumber(p.getOutOrderNumber()); - pickingOrderDO.setPickingOrderNumber(OrderSequence.getOrderCode("JH")); +// pickingOrderDO.setPickingOrderNumber(OrderSequence.getOrderCode("JH")); + pickingOrderDO.setPickingOrderNumber("PK-"+p.getOutOrderNumber()); pickingOrderDO.setQuantity(p.getAllocationQuantity()); if (pickingOrderDO.getWarehouseId() == null && p.getWarehouseId() != null) { pickingOrderDO.setWarehouseId(p.getWarehouseId()); @@ -1089,6 +1201,8 @@ public class StockOutOrderDomainService { handoverTaskOrderDO.setHandoverTaskOrderIds(handoverTaskOrderId); handoverTaskOrderDomainService.completeHandover(handoverTaskOrderDO); } + //出库交接后生成电子签名记录 + genElectronicSignature(stockOutOrder); return Boolean.TRUE; } @@ -1122,7 +1236,7 @@ public class StockOutOrderDomainService { PickingOrderDO pickingOrderDO = new PickingOrderDO(); BeanUtils.copyProperties(p, pickingOrderDO); pickingOrderDO.setOrderNumber(p.getOutOrderNumber()); - pickingOrderDO.setPickingOrderNumber(OrderSequence.getOrderCode("JH")); + pickingOrderDO.setPickingOrderNumber("PK-"+p.getOutOrderNumber()); pickingOrderDO.setQuantity(p.getAllocationQuantity()); if (pickingOrderDO.getWarehouseId() == null && p.getWarehouseId() != null) { pickingOrderDO.setWarehouseId(p.getWarehouseId()); @@ -2038,7 +2152,7 @@ public class StockOutOrderDomainService { handoverTaskOrderDO.setShipperId(stockOutOrderPO.getShipperId()); handoverTaskOrderDO.setShipperName(stockOutOrderPO.getShipperName()); handoverTaskOrderDO.setSerialNumber(OrderSequence.getOrderCode("JJZYLS")); - handoverTaskOrderDO.setTaskNumber(OrderSequence.getOrderCode("JJZY")); + handoverTaskOrderDO.setTaskNumber("HD-"+stockOutOrderPO.getOutOrderNumber()); handoverTaskOrderDO.setStatus(1); handoverTaskOrderDO.setOrderTypeCode(stockOutOrderPO.getOrderTypeCode()); handoverTaskOrderDO.setOrderTypeName(stockOutOrderPO.getOrderTypeName()); @@ -2373,4 +2487,106 @@ public class StockOutOrderDomainService { public List queryOutStockNoticePrintDetailGF(StockOutOrderDTO stockOutOrderDTO) { return stockOutOrderService.queryOutStockNoticePrintDetailGF(stockOutOrderDTO); } + + /** + * 生成出库电子签名记录(出库交接触发,StockOutOrder实体入口) + */ + private void genElectronicSignature(StockOutOrder stockOutOrder) { + try { + StockOutOrderDO queryDO = new StockOutOrderDO(); + queryDO.setOutOrderNumber(stockOutOrder.getOutOrderNumber()); + List poList = stockOutOrderService.queryList(queryDO); + if (CollectionUtil.isEmpty(poList)) { + log.warn("生成出库电子签名记录失败,未查到出库单:{}", stockOutOrder.getOutOrderNumber()); + return; + } + genElectronicSignature(poList.get(0)); + } catch (Exception e) { + log.error("生成出库电子签名记录失败,订单号:{}", stockOutOrder.getOutOrderNumber(), e); + } + } + + /** + * 生成出库电子签名记录 + */ + private void genElectronicSignature(StockOutOrderPO stockOutOrderPO) { + try { + // 查询出库物料明细 + List detailList = outMaterialDetailService.list( + new LambdaQueryWrapper() + .eq(OutMaterialDetail::getOutOrderNumber, stockOutOrderPO.getOutOrderNumber())); + + ElectronicSignatureSyncDTO dto = new ElectronicSignatureSyncDTO(); + dto.setOrderId(stockOutOrderPO.getOutOrderId()); + dto.setOrderNumber(stockOutOrderPO.getOutOrderNumber()); + dto.setOrderType("OUT"); + dto.setOrganizationId(stockOutOrderPO.getOrganizationId()); + dto.setOrganizationName(stockOutOrderPO.getOrganizationName()); + dto.setTopOrganizationId(stockOutOrderPO.getTopOrganizationId()); + dto.setWarehouseId(stockOutOrderPO.getWarehouseId()); + dto.setWarehouseCode(stockOutOrderPO.getWarehouseCode()); + dto.setWarehouseName(stockOutOrderPO.getWarehouseName()); + + List items = new ArrayList<>(); + if (org.springframework.util.CollectionUtils.isEmpty(detailList)) { + // 回退:直接通过 IOutMaterialDetailService 查询 PO 列表 + OutMaterialDetailDO queryDO = new OutMaterialDetailDO(); + queryDO.setOutOrderNumber(stockOutOrderPO.getOutOrderNumber()); + List poList = outMaterialDetailService.queryList(queryDO); + if (!org.springframework.util.CollectionUtils.isEmpty(poList)) { + for (OutMaterialDetailPO detail : poList) { + ElectronicSignatureSyncDTO.MaterialDetailItem item = new ElectronicSignatureSyncDTO.MaterialDetailItem(); + item.setMaterialBaseInfoId(detail.getMaterialBaseInfoId()); + item.setMaterialCode(detail.getMaterialCode()); + item.setMaterialName(detail.getMaterialName()); + item.setQuantity(detail.getCheckQuantity()); + item.setUnitCode(detail.getUnitCode()); + item.setUnitName(detail.getUnitName()); + item.setBatchNumber(detail.getBatchNumber()); + item.setLotNumber(detail.getLotNo()); + item.setWarehouseId(detail.getWarehouseId()); + item.setWarehouseCode(detail.getWarehouseCode()); + item.setWarehouseName(detail.getWarehouseName()); + item.setStorageSectionId(detail.getStorageSectionId()); + item.setStorageSectionCode(detail.getStorageCode()); + item.setStorageSectionName(detail.getStorageName()); + item.setStorageLocationId(detail.getStorageLocationId()); + item.setStorageLocationCode(detail.getStorageLocationCode()); + item.setStorageLocationName(detail.getStorageLocationName()); + item.setUniqueId(detail.getUniqueId()); + items.add(item); + } + } + } else { + for (OutMaterialDetail detail : detailList) { + ElectronicSignatureSyncDTO.MaterialDetailItem item = new ElectronicSignatureSyncDTO.MaterialDetailItem(); + item.setMaterialBaseInfoId(detail.getMaterialBaseInfoId()); + item.setMaterialCode(detail.getMaterialCode()); + item.setMaterialName(detail.getMaterialName()); + item.setQuantity(detail.getCheckQuantity()); + item.setUnitCode(detail.getUnitCode()); + item.setUnitName(detail.getUnitName()); + item.setBatchNumber(detail.getBatchNumber()); + item.setLotNumber(detail.getLotNo()); + item.setWarehouseId(detail.getWarehouseId()); + item.setWarehouseCode(detail.getWarehouseCode()); + item.setWarehouseName(detail.getWarehouseName()); + item.setStorageSectionId(detail.getStorageSectionId()); + item.setStorageSectionCode(detail.getStorageCode()); + item.setStorageSectionName(detail.getStorageName()); + item.setStorageLocationId(detail.getStorageLocationId()); + item.setStorageLocationCode(detail.getStorageLocationCode()); + item.setStorageLocationName(detail.getStorageLocationName()); + item.setUniqueId(detail.getUniqueId()); + items.add(item); + } + } + dto.setMaterialDetailList(items); + + log.info("生成出库电子签名记录,订单号:{},物料条目数:{}", stockOutOrderPO.getOutOrderNumber(), items.size()); + omsServiceFeign.saveSignature(dto); + } catch (Exception e) { + log.error("生成出库电子签名记录失败,订单号:{}", stockOutOrderPO.getOutOrderNumber(), e); + } + } } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockReceiptOrder/service/StockReceiptOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockReceiptOrder/service/StockReceiptOrderDomainService.java index 7600aa443..e323c2b06 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockReceiptOrder/service/StockReceiptOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockReceiptOrder/service/StockReceiptOrderDomainService.java @@ -173,7 +173,7 @@ public class StockReceiptOrderDomainService { stockReceiptOrderDOList.forEach(stockReceiptOrderDO -> { StockReceiptOrder stockReceiptOrder = JSONUtil.toBean(JSONUtil.toJsonStr(stockReceiptOrderDO), StockReceiptOrder.class); // 仓库以入库单为准;delive_task 在 genDeliveTask 中从 stock_in_order 读取。收货单实体仓库字段 exist=false 不落库。 - stockReceiptOrder.setReceiptOrderNumber(OrderSequence.getOrderCode("SH")); + stockReceiptOrder.setReceiptOrderNumber("RV-"+stockReceiptOrderDO.getInOrderNumber()); stockReceiptOrder.setCreateBy(loginUser.getUserid()); stockReceiptOrder.setCreateByName(userRealName); stockReceiptOrder.setCreateTime(new Date()); @@ -1583,7 +1583,7 @@ public class StockReceiptOrderDomainService { } else { stockShelfOrderDO.setTaskDistributionTime(null); } - stockShelfOrderDO.setShelfOrderNumber(OrderSequence.getOrderCode("SJ")); + stockShelfOrderDO.setShelfOrderNumber("SH-"+stockReceiptOrderPO.getInOrderNumber()); stockShelfOrderDO.setStatus(1); //本次上架数量 BigDecimal receiptQuantity = BigDecimal.ZERO; diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/stockShelfOrder/service/StockShelfOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/stockShelfOrder/service/StockShelfOrderDomainService.java index b2c66cbc3..bf0b3c47b 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/stockShelfOrder/service/StockShelfOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/stockShelfOrder/service/StockShelfOrderDomainService.java @@ -22,6 +22,7 @@ import com.mhd.common.core.web.domain.AjaxResult; import com.mhd.common.security.utils.SecurityUtils; import com.mhd.system.api.OmsServiceFeign; import com.mhd.system.api.SystemServiceFeign; +import com.mhd.system.api.domain.ElectronicSignatureSyncDTO; import com.mhd.system.api.domain.ContainerFeignPO; import com.mhd.system.api.domain.MaterialInventoryOmsParamDO; import com.mhd.system.api.model.LoginUser; @@ -186,7 +187,8 @@ public class StockShelfOrderDomainService { BeanUtils.copyProperties(stockShelfOrderDO, stockShelfOrder, "createBy","createByName","createTime", "updateBy","updateByName","updateTime"); if (StringUtils.isBlank(stockShelfOrder.getShelfOrderNumber())){ - stockShelfOrder.setShelfOrderNumber(OrderSequence.getOrderCode("SJ")); +// stockShelfOrder.setShelfOrderNumber(OrderSequence.getOrderCode("SJ")); + stockShelfOrder.setShelfOrderNumber("SH-"+stockShelfOrder.getInOrderNumber()); } // PDA收货完成=是否下发是(1),PC收货完成/无单收货/整单收货=是否下发否(2),DO未设置时默认2 stockShelfOrder.setTaskDistribution(stockShelfOrderDO.getTaskDistribution() != null ? stockShelfOrderDO.getTaskDistribution() : 2); @@ -877,6 +879,8 @@ public class StockShelfOrderDomainService { } if (businessOrderNumber != null) stockShelfOrderService.updateOmsReserveOrder(businessOrderNumber, shelvesQuantity == null ? null : shelvesQuantity); + //生成电子签名记录 +// genElectronicSignature(stockShelfOrderPO, shelfMaterialDetailList); return true; } @@ -2016,4 +2020,54 @@ public class StockShelfOrderDomainService { } } } + + /** + * 生成入库电子签名记录(上架完成触发) + */ + private void genElectronicSignature(StockShelfOrderPO stockShelfOrderPO, List shelfMaterialDetailList) { + try { + ElectronicSignatureSyncDTO dto = new ElectronicSignatureSyncDTO(); + dto.setOrderId(stockShelfOrderPO.getShelfOrderId()); + dto.setOrderNumber(stockShelfOrderPO.getShelfOrderNumber()); + dto.setOrderType("IN"); + dto.setOrganizationId(stockShelfOrderPO.getOrganizationId()); + dto.setOrganizationName(stockShelfOrderPO.getOrganizationName()); + dto.setTopOrganizationId(stockShelfOrderPO.getTopOrganizationId()); + dto.setWarehouseId(stockShelfOrderPO.getWarehouseId()); + dto.setWarehouseCode(stockShelfOrderPO.getWarehouseCode()); + dto.setWarehouseName(stockShelfOrderPO.getWarehouseName()); + + List items = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(shelfMaterialDetailList)) { + for (ShelfMaterialDetail detail : shelfMaterialDetailList) { + ElectronicSignatureSyncDTO.MaterialDetailItem item = new ElectronicSignatureSyncDTO.MaterialDetailItem(); + item.setMaterialBaseInfoId(detail.getMaterialBaseInfoId()); + item.setMaterialCode(detail.getMaterialCode()); + item.setMaterialName(detail.getMaterialName()); + item.setQuantity(detail.getShelvesQuantity()); + item.setUnitCode(detail.getUnitCode()); + item.setUnitName(detail.getUnitName()); + item.setBatchNumber(detail.getBatchNumber()); + item.setLotNumber(detail.getLotNumber()); + item.setWarehouseId(detail.getWarehouseId()); + item.setWarehouseCode(detail.getWarehouseCode()); + item.setWarehouseName(detail.getWarehouseName()); + item.setStorageSectionId(detail.getStorageSectionId()); + item.setStorageSectionCode(detail.getStorageCode()); + item.setStorageSectionName(detail.getStorageName()); + item.setStorageLocationId(detail.getStorageLocationId()); + item.setStorageLocationCode(detail.getStorageLocationCode()); + item.setStorageLocationName(detail.getStorageLocationName()); + item.setUniqueId(detail.getUniqueId()); + items.add(item); + } + } + dto.setMaterialDetailList(items); + + log.info("生成入库电子签名记录,订单号:{},物料条目数:{}", stockShelfOrderPO.getShelfOrderNumber(), items.size()); + omsServiceFeign.saveSignature(dto); + } catch (Exception e) { + log.error("生成入库电子签名记录失败,订单号:{}", stockShelfOrderPO.getShelfOrderNumber(), e); + } + } } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/domain/waveOrder/service/WaveOrderDomainService.java b/mhd_wms/src/main/java/com/mhd/wms/domain/waveOrder/service/WaveOrderDomainService.java index ab5ebd551..de1f6c560 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/domain/waveOrder/service/WaveOrderDomainService.java +++ b/mhd_wms/src/main/java/com/mhd/wms/domain/waveOrder/service/WaveOrderDomainService.java @@ -211,7 +211,7 @@ public class WaveOrderDomainService { PickingOrderDO pickingOrderDO = new PickingOrderDO(); BeanUtils.copyProperties(p, pickingOrderDO); pickingOrderDO.setOrderNumber(p.getWaveOrderNumber()); - pickingOrderDO.setPickingOrderNumber(OrderSequence.getOrderCode("JH")); + pickingOrderDO.setPickingOrderNumber("PK-"+p.getWaveOrderNumber()); pickingOrderDO.setQuantity(p.getAllocationQuantity()); pickingOrderDO.setWeightLimit(p.getWeightLimit()); pickingOrderDO.setVolumeLimit(p.getVolumeLimit()); @@ -329,4 +329,4 @@ public class WaveOrderDomainService { } return result; } -} +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/inMaterialDetail/InMaterialDetailDTO.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/inMaterialDetail/InMaterialDetailDTO.java index 4895b9d89..a467d6816 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/inMaterialDetail/InMaterialDetailDTO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/inMaterialDetail/InMaterialDetailDTO.java @@ -387,6 +387,23 @@ public class InMaterialDetailDTO extends BaseVOEntity { @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") @DateTimeFormat(pattern="yyyy-MM-dd") private Date drinkDate; + + @ApiModelProperty("来货验收是否合格;1 合格,0 不合格") + @Excel(name = "来货验收是否合格;1 合格,0 不合格") + private String arrivalAcceptQualified; + + @ApiModelProperty("包装是否破损;1 破损,0 完好") + @Excel(name = "包装是否破损;1 破损,0 完好") + private String packageDamaged; + + @ApiModelProperty("是否解冻 / 水渍;1 是,0 否") + @Excel(name = "是否解冻 / 水渍;1 是,0 否") + private String isThawWaterstain; + + @ApiModelProperty("问题货是否已通知客户;1 已通知,0 未通知") + @Excel(name = "问题货是否已通知客户;1 已通知,0 未通知") + private String notifyCustomerAbnormal; + //订单行号 private String lineNumGw; //物料规格 diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/signature/BatchSignatureDTO.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/signature/BatchSignatureDTO.java new file mode 100644 index 000000000..39be83601 --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/signature/BatchSignatureDTO.java @@ -0,0 +1,44 @@ +package com.mhd.wms.interfaces.dto.signature; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + +/** + * PDA批量签名请求DTO + * + *

支持四种签名方式:电子签名、附件上传、扫二维码、系统自动。

+ */ +@Data +public class BatchSignatureDTO { + + @ApiModelProperty("入库单ID列表") + private List inOrderIds; + + @ApiModelProperty("出库单ID列表") + private List outOrderIds; + + @ApiModelProperty("签名状态:2-已签名(PDA端直接传2表示签完)") + private Integer signatureStatus; + + @ApiModelProperty("签名时间(PDA端可传当前时间)") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTime; + + @ApiModelProperty("手写签名图片(base64或URL,单张)") + private String signaturePic; + + @ApiModelProperty("拍照取证图片列表(base64或URL,多张)") + private List evidencePics; + + @ApiModelProperty("签名备注") + private String signatureRemark; + + @ApiModelProperty("签名方式:1-扫描二维码 2-电子签名 3-打印手写签名 4-超时自动签名") + private Integer signatureMode; +} \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockInOrder/StockInOrderDTO.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockInOrder/StockInOrderDTO.java index 738b81cc3..c1588f31d 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockInOrder/StockInOrderDTO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockInOrder/StockInOrderDTO.java @@ -448,4 +448,24 @@ public class StockInOrderDTO extends StockInOrderBaseDTO { @ApiModelProperty("是否返回物料明细(导出时传 true)") private Boolean needDetail; + + // ========== PDA入库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + @ApiModelProperty("签名时间起") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTimeFrom; + + @ApiModelProperty("签名时间止") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date signatureTimeTo; + + /** + * PDA入库签名列表专用:作业任务人员模糊查询字段。 + */ + @ApiModelProperty("作业任务人员(模糊查询)") + private String workUserNameLike; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockOutOrder/StockOutOrderDTO.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockOutOrder/StockOutOrderDTO.java index 278b10162..3f4377b96 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockOutOrder/StockOutOrderDTO.java +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/dto/stockOutOrder/StockOutOrderDTO.java @@ -505,4 +505,12 @@ public class StockOutOrderDTO extends StockOutOrderBaseDTO { @ApiModelProperty("是否返回物料明细(导出时传 true)") private Boolean needDetail; + + // ========== PDA出库签名字段 ========== + @ApiModelProperty("签名状态:1-待签名 2-已签名") + private Integer signatureStatus; + + /** PDA出库签名列表专用:作业任务人员模糊查询字段 */ + @ApiModelProperty("作业任务人员(模糊查询)") + private String workUserNameLike; } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockInOrder/StockInOrderApi.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockInOrder/StockInOrderApi.java index 988275c98..b90157e39 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockInOrder/StockInOrderApi.java +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockInOrder/StockInOrderApi.java @@ -64,6 +64,25 @@ public class StockInOrderApi extends BaseController { return getDataTable(list); } + /** + * PDA入库签名列表查询 + * + *

查询入库单状态「已入库」(status=5) 的入库单列表, + * 同时支持「作业任务人员」(workUserName) like 模糊查询, + * 参照简易模式快捷入库列表实现。响应中包含签名相关字段(签名状态、签名时间、签名图片、签名备注)。

+ */ + @ApiOperation("PDA入库签名列表查询") + @GetMapping("/signatureList") + public TableDataInfo signatureList(StockInOrderDTO stockInOrderDTO) { + //转换实体 + StockInOrderDO stockInOrderDO = stockInOrderAssembler.toDO(stockInOrderDTO); + startPage(); + List list = stockInOrderApplicationService.querySignatureList(stockInOrderDO); + return getDataTable(list); + } + + + /** * 编辑入库单 */ @@ -219,6 +238,28 @@ public class StockInOrderApi extends BaseController { return AjaxResult.success(stockInOrderApplicationService.receiptEasyMode(stockInOrderDO)); } + + /** + * 审核入库单 + */ + @ApiOperation("pda简易模式调整备注") + @PostMapping(value = "/remarkEasyMode") + public AjaxResult remarkEasyMode(@RequestBody StockInOrderDTO stockInOrderDTO) { + StockInOrderDO stockInOrderDO = stockInOrderAssembler.toDO(stockInOrderDTO); + List materialDetailList = stockInOrderDTO.getMaterialDetailList(); + if (materialDetailList != null && !materialDetailList.isEmpty()) { + List inMaterialDetailDOList = new ArrayList<>(); + for (InMaterialDetailDTO dto : materialDetailList) { + InMaterialDetailDO detailDO = new InMaterialDetailDO(); + BeanUtils.copyProperties(dto, detailDO); + inMaterialDetailDOList.add(detailDO); + } + stockInOrderDO.setMaterialDetailList(inMaterialDetailDOList); + } + + return AjaxResult.success(stockInOrderApplicationService.remarkEasyMode(stockInOrderDO)); + } + @ApiOperation("pda简易模式修改计划数量") @GetMapping(value = "/updateQuantity") public AjaxResult updateQuantity(@RequestParam BigDecimal quantity, @@ -295,4 +336,15 @@ public class StockInOrderApi extends BaseController { return stockInOrderApplicationService.batchPush(idList); } + /** + * PDA批量入库签名 + * + *

勾选多条入库记录批量签名,更新入库表的签名状态、签名时间、签名图片、签名备注。

+ */ + @ApiOperation("PDA批量入库签名") + @PostMapping("/batchSignature") + public AjaxResult batchSignature(@RequestBody com.mhd.wms.interfaces.dto.signature.BatchSignatureDTO dto) { + return stockInOrderApplicationService.batchSignature(dto); + } + } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockOutOrder/StockOutOrderApi.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockOutOrder/StockOutOrderApi.java index b10e122ef..17c88caa6 100644 --- a/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockOutOrder/StockOutOrderApi.java +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockOutOrder/StockOutOrderApi.java @@ -116,6 +116,22 @@ public class StockOutOrderApi extends BaseController { return handoverTaskOrderDomainService.customsConfirmOut(outOrderNumbers); } + /** + * PDA出库签名列表查询 + * + *

查询出库单状态「已出库」(status=9) 的出库单列表, + * 支持「作业任务人员」(workUserName) like 模糊查询, + * 参照简易模式快捷出库列表实现。

+ */ + @ApiOperation("PDA出库签名列表查询") + @GetMapping("/signatureList") + public TableDataInfo signatureList(StockOutOrderDTO stockOutOrderDTO) { + StockOutOrderDO stockOutOrderDO = stockOutOrderAssembler.toDO(stockOutOrderDTO); + startPage(); + List list = stockOutOrderApplicationService.querySignatureList(stockOutOrderDO); + return getDataTable(list); + } + /** * 上传并解析出仓委托单Excel */ @@ -582,4 +598,15 @@ public class StockOutOrderApi extends BaseController { } return stockOutOrderApplicationService.batchPush(idList); } + + /** + * PDA批量出库签名 + * + *

勾选多条出库记录批量签名,更新出库表的签名状态、签名时间、签名图片、签名备注。

+ */ + @ApiOperation("PDA批量出库签名") + @PostMapping("/batchSignature") + public AjaxResult batchSignature(@RequestBody com.mhd.wms.interfaces.dto.signature.BatchSignatureDTO dto) { + return stockOutOrderApplicationService.batchSignature(dto); + } } \ No newline at end of file diff --git a/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockSignature/StockSignatureApi.java b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockSignature/StockSignatureApi.java new file mode 100644 index 000000000..c686d681d --- /dev/null +++ b/mhd_wms/src/main/java/com/mhd/wms/interfaces/facadeApi/stockSignature/StockSignatureApi.java @@ -0,0 +1,85 @@ +package com.mhd.wms.interfaces.facadeApi.stockSignature; + +import com.mhd.common.core.web.controller.BaseController; +import com.mhd.common.core.web.domain.AjaxResult; +import com.mhd.system.api.domain.SignatureBatchFeignDTO; +import com.mhd.wms.application.service.stockInOrder.StockInOrderApplicationService; +import com.mhd.wms.application.service.stockOutOrder.StockOutOrderApplicationService; +import com.mhd.wms.interfaces.dto.signature.BatchSignatureDTO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 库存签名API(供OMS端Feign调用,统一更新WMS入/出库单签名字段) + * + *

OMS端批量签名后,通过Feign调用此API, + * 更新WMS stock_in_order / stock_out_order 表的签名状态、签名时间、签名图片、签名备注。

+ */ +@Slf4j +@RestController +@RequestMapping("/stockSignatureApi") +@Api(tags = "库存签名(OMS→WMS)") +public class StockSignatureApi extends BaseController { + + @Autowired + private StockInOrderApplicationService stockInOrderApplicationService; + + @Autowired + private StockOutOrderApplicationService stockOutOrderApplicationService; + + /** + * 批量签名(OMS→WMS) + * + *

接收SignatureBatchFeignDTO,映射为BatchSignatureDTO后,分别调用 + * StockInOrderApplicationService.batchSignature 和 + * StockOutOrderApplicationService.batchSignature。

+ */ + @ApiOperation("OMS批量签名-更新WMS入/出库单签名字段") + @PostMapping("/batchSign") + public AjaxResult batchSign(@RequestBody SignatureBatchFeignDTO dto) { + if (dto == null) { + return AjaxResult.error("请求参数不能为空"); + } + boolean hasIn = dto.getInOrderIds() != null && !dto.getInOrderIds().isEmpty(); + boolean hasOut = dto.getOutOrderIds() != null && !dto.getOutOrderIds().isEmpty(); + if (!hasIn && !hasOut) { + return AjaxResult.error("请指定入库单ID列表或出库单ID列表"); + } + + // 映射 SignatureBatchFeignDTO → BatchSignatureDTO + BatchSignatureDTO batchDTO = new BatchSignatureDTO(); + batchDTO.setInOrderIds(dto.getInOrderIds()); + batchDTO.setOutOrderIds(dto.getOutOrderIds()); + batchDTO.setSignatureStatus(dto.getSignatureStatus() != null ? dto.getSignatureStatus() : 2); + batchDTO.setSignatureTime(dto.getSignatureTime()); + batchDTO.setSignaturePic(dto.getSignaturePic()); + batchDTO.setSignatureRemark(dto.getSignatureRemark()); + // evidencePics: Feign DTO中是comma-separated String → List + if (dto.getEvidencePics() != null && !dto.getEvidencePics().isEmpty()) { + batchDTO.setEvidencePics(java.util.Arrays.asList(dto.getEvidencePics().split(","))); + } + + String msg = ""; + if (hasIn) { + AjaxResult inResult = stockInOrderApplicationService.batchSignature(batchDTO); + log.info("OMS→WMS批量入库签名完成:{}条,结果:{}", dto.getInOrderIds().size(), + inResult != null ? inResult.get("msg") : "OK"); + msg += "入库签名完成"; + } + if (hasOut) { + AjaxResult outResult = stockOutOrderApplicationService.batchSignature(batchDTO); + log.info("OMS→WMS批量出库签名完成:{}条,结果:{}", dto.getOutOrderIds().size(), + outResult != null ? outResult.get("msg") : "OK"); + if (!msg.isEmpty()) msg += ","; + msg += "出库签名完成"; + } + + return AjaxResult.success(msg); + } +} diff --git a/mhd_wms/src/main/resources/bootstrap.yml b/mhd_wms/src/main/resources/bootstrap.yml index 39eb710cb..fc7380c20 100644 --- a/mhd_wms/src/main/resources/bootstrap.yml +++ b/mhd_wms/src/main/resources/bootstrap.yml @@ -14,18 +14,18 @@ spring: nacos: discovery: # server-addr: 127.0.0.1:8848 - server-addr: 10.33.0.129:6010 +# server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境 # server-addr: 10.102.192.105:6848 config: # server-addr: 127.0.0.1:8848 - server-addr: 10.33.0.129:6010 +# server-addr: 10.33.0.129:6010 # 线上测试环境配置 容器名+端口号 -# server-addr: 10.102.192.30:6848 + server-addr: 10.102.192.30:6848 username: nacos password: manhuoda@2023 #线上正式环境 diff --git a/mhd_wms/src/main/resources/mapper/handoverTaskOrder/HandoverTaskOrderMapper.xml b/mhd_wms/src/main/resources/mapper/handoverTaskOrder/HandoverTaskOrderMapper.xml index f6c5ac19f..197871c3d 100644 --- a/mhd_wms/src/main/resources/mapper/handoverTaskOrder/HandoverTaskOrderMapper.xml +++ b/mhd_wms/src/main/resources/mapper/handoverTaskOrder/HandoverTaskOrderMapper.xml @@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - a.handover_task_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.serial_number, a.task_number, a.status, a.platform_id, + a.handover_task_order_id AS handover_task_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.serial_number, a.task_number, a.status, a.platform_id, a.platform_code, a.platform_name, a.platform_use_time_id, a.platform_use_start_time, a.platform_use_end_time, a.platform_use_status, a.order_type_code, a.order_type_name, a.expect_time, a.warehouse_id, a.warehouse_code, a.warehouse_name, a.shipper_id, a.shipper_name, a.order_number, a.picking_order_number, a.remark, a.task_distribution, a.task_distribution_time, a.create_time, a.create_by, a.create_by_name, a.update_time, diff --git a/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml b/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml index 86a8a0466..d03ce31fc 100644 --- a/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml +++ b/mhd_wms/src/main/resources/mapper/reviewOrder/ReviewOrderMapper.xml @@ -4,7 +4,7 @@ - + @@ -84,7 +84,7 @@ - a.review_order_id, + a.review_order_id AS review_order_id, a.review_order_number, a.out_order_id, a.out_order_number, diff --git a/mhd_wms/src/main/resources/mapper/stockInOrder/StockInOrderMapper.xml b/mhd_wms/src/main/resources/mapper/stockInOrder/StockInOrderMapper.xml index 7cfb2cdb0..cf4f00962 100644 --- a/mhd_wms/src/main/resources/mapper/stockInOrder/StockInOrderMapper.xml +++ b/mhd_wms/src/main/resources/mapper/stockInOrder/StockInOrderMapper.xml @@ -105,6 +105,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + @@ -138,7 +143,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" a."TO", a.CONTACT_PERSON, a.VEHICLE_INFO, a.CONSIGNMENT_NO, a.TEL, a.DRIVER_SIGNATURE, a.FAX, a.DECLARATION_AREA, a.MANUFACTURER, a.CUSTOMS_BROKER_INFO, a.DELIVERY_ADDRESS, a.ENTRY_EXIT_CUSTOMS, a.ORIGIN_DESTINATION_COUNTRY, a.CARRIER, a.CONTAINER_NO, a.TRANSPORT_METHOD, a.SUPERVISION_METHOD, a.CUSTOMS_INSPECTION, a.NEED_CUSTOMS_DECLARATION, a.NEED_TRANSPORT, - a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.stock_in_order,a.business_order_no,a.WORK_USER_ID,a.WORK_TASK_RECEIVE_STATUS,a.TASK_ISSUE_USER_ID,a.WORK_USER_NAME + a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.stock_in_order,a.business_order_no,a.WORK_USER_ID,a.WORK_TASK_RECEIVE_STATUS,a.TASK_ISSUE_USER_ID,a.WORK_USER_NAME, + a.SIGNATURE_STATUS, a.SIGNATURE_TIME, a.SIGNATURE_PIC, a.EVIDENCE_PICS, a.SIGNATURE_REMARK @@ -356,6 +362,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.TASK_ISSUE_USER_ID like concat('%', #{queryUserId}, '%') + + + and a.WORK_USER_NAME like concat('%', #{workUserNameLike}, '%') + + + + and a.SIGNATURE_STATUS = #{signatureStatus} + and a."TO" like concat('%', #{to}, '%') @@ -595,4 +609,64 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE warehouse_id = #{warehouseId} AND del_flag = 1 AND organization_id = #{organizationId} AND top_organization_id = #{topOrganizationId} + + + update NGWL_TEST_OMS.EXECUTION_STOCK_IN_ORDER + + NOTICE_REMARK = #{remark}, + update_time = sysdate() + + where in_order_number = #{inOrderNumber} and del_flag = 1 + + + + + + \ No newline at end of file diff --git a/mhd_wms/src/main/resources/mapper/stockOutOrder/StockOutOrderMapper.xml b/mhd_wms/src/main/resources/mapper/stockOutOrder/StockOutOrderMapper.xml index ff7954d80..8babfe003 100644 --- a/mhd_wms/src/main/resources/mapper/stockOutOrder/StockOutOrderMapper.xml +++ b/mhd_wms/src/main/resources/mapper/stockOutOrder/StockOutOrderMapper.xml @@ -104,6 +104,11 @@ + + + + + @@ -124,7 +129,8 @@ a.CUSTOMS_DECLARER_INFO,a.DELIVERY_ADDR,a.ENTRY_EXIT_CUSTOMS,a.DEPARTURE_ARRIVAL_COUNTRY,a.CARRIER,a.CONTAINER_NO,a.CONTAINER_NO_NAME,a.OUTBOUND_DATE, a.COMPLETE_TIME,a.ORDER_DATE,a.TRANSPORT_MODE_CODE,a.TRANSPORT_MODE_NAME,a.SUPERVISION_MODE_CODE,a.SUPERVISION_MODE_NAME, a.CUSTOMS_INSPECTION_FLAG,a.NEED_DECLARE_FLAG,a.NEED_TRANSPORT_FLAG,a.picture_app,a.billing_json,a.SETTLEMENT_CURRENCY, - a.SALESMAN_ID,a.SALESMAN_NAME,a.business_order_no,a.RETURN_QUANTITY,a.WORK_USER_ID,a.WORK_TASK_RECEIVE_STATUS,a.TASK_ISSUE_USER_ID,a.WORK_USER_NAME + a.SALESMAN_ID,a.SALESMAN_NAME,a.business_order_no,a.RETURN_QUANTITY,a.WORK_USER_ID,a.WORK_TASK_RECEIVE_STATUS,a.TASK_ISSUE_USER_ID,a.WORK_USER_NAME, + a.SIGNATURE_STATUS, a.SIGNATURE_TIME, a.SIGNATURE_PIC, a.EVIDENCE_PICS, a.SIGNATURE_REMARK @@ -340,6 +346,14 @@ and a.PUSH_STATUS = #{pushStatus} + + + and a.WORK_USER_NAME like concat('%', #{workUserNameLike}, '%') + + + + and a.SIGNATURE_STATUS = #{signatureStatus} + and exists ( @@ -512,4 +526,53 @@ + + + \ No newline at end of file