diff --git a/src/main/java/com/glxp/api/config/HdSchemaExecutor.java b/src/main/java/com/glxp/api/config/HdSchemaExecutor.java index ae19a438..061da469 100644 --- a/src/main/java/com/glxp/api/config/HdSchemaExecutor.java +++ b/src/main/java/com/glxp/api/config/HdSchemaExecutor.java @@ -77,6 +77,7 @@ public class HdSchemaExecutor implements ApplicationRunner { // schema.add(new SchemaData("v2.1", "schema_v2.1.sql")); // schema.add(new SchemaData("v2.2", "schema_v2.2.sql")); schema.add(new SchemaData("v2.3", "schema_v2.3.sql")); + schema.add(new SchemaData("v2.4", "schema_v2.4.sql")); } } diff --git a/src/main/java/com/glxp/api/controller/inv/StockCompareController.java b/src/main/java/com/glxp/api/controller/inv/StockCompareController.java new file mode 100644 index 00000000..bd70892d --- /dev/null +++ b/src/main/java/com/glxp/api/controller/inv/StockCompareController.java @@ -0,0 +1,145 @@ +package com.glxp.api.controller.inv; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.controller.BaseController; +import com.glxp.api.entity.inv.StockCompareDetailEntity; +import com.glxp.api.entity.inv.StockCompareEntity; +import com.glxp.api.entity.thrsys.ThrSystemEntity; +import com.glxp.api.enums.StockCompareStatusEnum; +import com.glxp.api.exception.JsonException; +import com.glxp.api.req.inv.*; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.service.inv.StockCompareDetailService; +import com.glxp.api.service.inv.StockCompareService; +import com.glxp.api.vo.inv.InvProductDetailSelectVo; +import com.glxp.api.vo.inv.StockCompareVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@RestController +@RequestMapping +@Slf4j +@RequiredArgsConstructor +public class StockCompareController extends BaseController { + + private final StockCompareService stockCompareService; + private final StockCompareDetailService stockCompareDetailService; + + @PostMapping("/udiwms/stockCompare/page") + public BaseResponse page(@RequestBody StockCompareQuery query) { + + Page page = stockCompareService.pageVo(query); + + PageInfo pageInfo; + pageInfo = new PageInfo<>(page.getRecords()); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(page.getRecords()); + return ResultVOUtils.success(pageInfo); + + } + + @PostMapping("/udiwms/stockCompare/selectInvProductDetail") + public BaseResponse selectInvProductDetail(@RequestBody @Valid InvProductDetailSelectRequest param) { + StockCompareEntity stockCompare = stockCompareService.getById(param.getCompareId()); + if (stockCompare == null) { + return ResultVOUtils.error(500, "对比纪录不存在"); + } + + InvProductDetailSelectQuery invProductDetailSelectQuery = new InvProductDetailSelectQuery(stockCompare.getInvCode(), stockCompare.getMainAction() + , stockCompare.getAction(), stockCompare.getCompareStartDate(), stockCompare.getCompareEndDate() + , stockCompare.getThirdTableField(), null); + + invProductDetailSelectQuery.setPage(param.getPage()); + invProductDetailSelectQuery.setLimit(param.getLimit()); + Page page = stockCompareDetailService.invProductDetailSelectPage(invProductDetailSelectQuery); + PageSimpleResponse simplePage = new PageSimpleResponse<>((int) page.getTotal(), page.getRecords()); + return ResultVOUtils.success(simplePage); + } + + @PostMapping("/udiwms/stockCompare/save") + public BaseResponse save(@RequestBody StockCompareParam param) { + Long id = stockCompareService.save(super.getUserId(), param); + return ResultVOUtils.success("保存成功", id); + } + + @DeleteMapping("/udiwms/stockCompare/delete/{compareId}") + public BaseResponse delete(@PathVariable Long compareId) { + stockCompareService.delete(compareId); + return ResultVOUtils.successMsg("删除成功"); + } + + @PostMapping("/udiwms/stockCompare/addProduct") + public BaseResponse addProduct(@RequestBody @Valid StockCompareDetailParam param) { + stockCompareService.addProduct(param); + return ResultVOUtils.successMsg("添加成功"); + } + + /** + * 立即对比 + * + * @param compareId 对比数据id + * @return + */ + @PostMapping("/udiwms/stockCompare/compare/{compareId}") + public BaseResponse compare(@PathVariable Long compareId) { + StockCompareEntity stockCompare = stockCompareService.getById(compareId); + if (stockCompare == null) { + return ResultVOUtils.error(500, "对比记录不存在"); + } + return ResultVOUtils.successMsg("对比成功"); + } + + + @PostMapping("/udiwms/stockCompare/detail/page") + public BaseResponse stockCompareDetailPage(@RequestBody @Valid InvProductDetailSelectRequest param) { + StockCompareEntity stockCompare = stockCompareService.getById(param.getCompareId()); + if (stockCompare == null) { + return ResultVOUtils.error(500, "对比记录不存在"); + } + if (param.getPage() != null) { + int offset = (param.getPage() - 1) * param.getLimit(); + PageHelper.offsetPage(offset, param.getLimit()); + } + Page page = stockCompareDetailService.page(param.getPageObj() + , Wrappers.lambdaQuery(StockCompareDetailEntity.class) + .eq(StockCompareDetailEntity::getCompareId, param.getCompareId()) + .orderByAsc(StockCompareDetailEntity::getProductId, StockCompareDetailEntity::getMainAction) + ); + + + PageInfo pageInfo; + pageInfo = new PageInfo<>(page.getRecords()); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(page.getRecords()); + return ResultVOUtils.success(pageSimpleResponse); + } + + + @DeleteMapping("/udiwms/stockCompare/detail/del") + public BaseResponse stockCompareDetailPage(@RequestBody @Valid StockCompareDetailDelParam param) { + StockCompareEntity stockCompare = stockCompareService.getById(param.getCompareId()); + if (stockCompare == null) { + return ResultVOUtils.error(500, "对比记录不存在"); + } + if (stockCompare.getStatus() != StockCompareStatusEnum.DRAFT) { + throw new JsonException(500, String.format("非%s状态无法移除", StockCompareStatusEnum.DRAFT.getDesc())); + } + stockCompareDetailService.remove(Wrappers.lambdaQuery(StockCompareDetailEntity.class) + .eq(StockCompareDetailEntity::getCompareId, param.getCompareId()) + .eq(StockCompareDetailEntity::getProductId, param.getProductId()) + .eq(StockCompareDetailEntity::getMainAction, param.getMainAction()) + ); + return ResultVOUtils.successMsg("移除成功"); + } + +} diff --git a/src/main/java/com/glxp/api/dao/inv/StockCompareDetailMapper.java b/src/main/java/com/glxp/api/dao/inv/StockCompareDetailMapper.java new file mode 100644 index 00000000..10c47990 --- /dev/null +++ b/src/main/java/com/glxp/api/dao/inv/StockCompareDetailMapper.java @@ -0,0 +1,24 @@ +package com.glxp.api.dao.inv; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.glxp.api.dao.BaseMapperPlus; +import com.glxp.api.entity.inv.StockCompareDetailEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.glxp.api.req.inv.InvProductDetailSelectQuery; +import com.glxp.api.vo.inv.InvProductDetailSelectVo; +import org.apache.ibatis.annotations.Param; + +/** + * @author Administrator + * @description 针对表【inv_stock_compare_detail(库存对比明细)】的数据库操作Mapper + * @createDate 2023-10-23 11:59:24 + * @Entity com.glxp.api.entity.inv.StockCompareDetailEntity + */ +public interface StockCompareDetailMapper extends BaseMapperPlus { + + Page invProductDetailSelectPage(Page pageObj, @Param("param") InvProductDetailSelectQuery query); +} + + + + diff --git a/src/main/java/com/glxp/api/dao/inv/StockCompareMapper.java b/src/main/java/com/glxp/api/dao/inv/StockCompareMapper.java new file mode 100644 index 00000000..d1acaf05 --- /dev/null +++ b/src/main/java/com/glxp/api/dao/inv/StockCompareMapper.java @@ -0,0 +1,24 @@ +package com.glxp.api.dao.inv; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.glxp.api.dao.BaseMapperPlus; +import com.glxp.api.entity.inv.StockCompareEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.glxp.api.req.inv.StockCompareQuery; +import com.glxp.api.vo.inv.StockCompareVo; +import org.apache.ibatis.annotations.Param; + +/** +* @author Administrator +* @description 针对表【inv_stock_compare】的数据库操作Mapper +* @createDate 2023-10-23 11:40:33 +* @Entity com.glxp.api.entity.inv.StockCompareEntity +*/ +public interface StockCompareMapper extends BaseMapperPlus { + + Page pageVo(Page pageObj,@Param("param") StockCompareQuery query); +} + + + + diff --git a/src/main/java/com/glxp/api/entity/inv/StockCompareDetailEntity.java b/src/main/java/com/glxp/api/entity/inv/StockCompareDetailEntity.java new file mode 100644 index 00000000..708e50b4 --- /dev/null +++ b/src/main/java/com/glxp/api/entity/inv/StockCompareDetailEntity.java @@ -0,0 +1,94 @@ +package com.glxp.api.entity.inv; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 库存对比明细 + * inv_stock_compare_detail + */ +@TableName(value = "inv_stock_compare_detail") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class StockCompareDetailEntity { + /** + * 对比id + */ + @TableField(value = "compareId") + private Long compareId; + + /** + * 产品id + */ + @TableField(value = "productId") + private Long productId; + + /** + * 第三方产品编码 + */ + @TableField(value = "thrProductId") + private String thrProductId; + + /** + * DI + */ + @TableField(value = "nameCode") + private String nameCode; + + /** + * 产品描述 + */ + @TableField(value = "cpms") + private String cpms; + + /** + * 产品名称 + */ + @TableField(value = "productName") + private String productName; + + /** + * 规格型号 + */ + @TableField(value = "ggxh") + private String ggxh; + + /** + * 生产厂家 + */ + @TableField(value = "manufactory") + private String manufactory; + + /** + * 医疗器械注册/备案人名称 + */ + @TableField(value = "ylqxzcrbarmc") + private String ylqxzcrbarmc; + + /** + * 注册证编号/备案批准编号 + */ + @TableField(value = "zczbhhzbapzbh") + private String zczbhhzbapzbh; + + @TableField(value = "mainAction") + private String mainAction; + + @TableField(value = "count") + private Integer count; + + @TableField(value = "thrCount") + private Integer thrCount; + + /** + * 对比入库数量 + */ + @TableField(value = "compareCount") + private Integer compareCount; +} \ No newline at end of file diff --git a/src/main/java/com/glxp/api/entity/inv/StockCompareEntity.java b/src/main/java/com/glxp/api/entity/inv/StockCompareEntity.java new file mode 100644 index 00000000..8d275312 --- /dev/null +++ b/src/main/java/com/glxp/api/entity/inv/StockCompareEntity.java @@ -0,0 +1,128 @@ +package com.glxp.api.entity.inv; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.glxp.api.enums.StockCompareStatusEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * 库存对比表 + *

+ * inv_stock_compare + */ +@TableName(value = "inv_stock_compare") +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class StockCompareEntity { + /** + * + */ + @TableId(value = "id") + private Long id; + + /** + * 状态 + */ + @TableField(value = "status") + private StockCompareStatusEnum status; + + /** + * 第三方系统id + */ + @TableField(value = "thrSysId") + private String thrSysId; + + /** + * 第三方系统名称 + */ + @TableField(value = "thrSysName") + private String thrSysName; + + /** + * 第三方系统字段名 + */ + @TableField(value = "thirdTableField") + private String thirdTableField; + + /** + * 仓库编码 + */ + @TableField(value = "invCode") + private String invCode; + + /** + * 仓库名称 + */ + @TableField(value = "invName") + private String invName; + + /** + * 出入库类型 + */ + @TableField(value = "mainAction") + private String mainAction; + + /** + * 单据类型编码 + */ + @TableField(value = "`action`") + private String action; + + /** + * 单据类型名称 + */ + @TableField(value = "actionName") + private String actionName; + + /** + * 筛选开始时间 + */ + @TableField(value = "compareStartDate") + private LocalDate compareStartDate; + + /** + * 筛选结束时间 + */ + @TableField(value = "compareEndDate") + private LocalDate compareEndDate; + + /** + * 对比时间 + */ + @TableField(value = "compareTime") + private LocalDateTime compareTime; + + + /** + * 是否区分批次号 + */ + @TableField(value = "siftBatchNo") + private Boolean siftBatchNo; + + /** + * 备注 + */ + @TableField(value = "remark") + private String remark; + + /** + * 创建时间 + */ + @TableField(value = "createTime") + private LocalDateTime createTime; + + /** + * 创建人id + */ + @TableField(value = "createUser") + private Long createUser; +} \ No newline at end of file diff --git a/src/main/java/com/glxp/api/enums/PrescirbeDetailTypeEnum.java b/src/main/java/com/glxp/api/enums/PrescirbeDetailTypeEnum.java new file mode 100644 index 00000000..02c78a1b --- /dev/null +++ b/src/main/java/com/glxp/api/enums/PrescirbeDetailTypeEnum.java @@ -0,0 +1,23 @@ +package com.glxp.api.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import lombok.AllArgsConstructor; +import lombok.Getter; + + +@Getter +@AllArgsConstructor +public enum PrescirbeDetailTypeEnum { + + DRUG("drug", "药物"), + INSTRUMENT("instrument", "器械"), + PROJECT("project", "项目"), + OTHER("other", "其他"), + ; + + @EnumValue + private final String key; + + private final String desc; + +} diff --git a/src/main/java/com/glxp/api/enums/StockCompareStatusEnum.java b/src/main/java/com/glxp/api/enums/StockCompareStatusEnum.java new file mode 100644 index 00000000..3478febb --- /dev/null +++ b/src/main/java/com/glxp/api/enums/StockCompareStatusEnum.java @@ -0,0 +1,26 @@ +package com.glxp.api.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 对比记录状态 + */ +@Getter +@AllArgsConstructor +public enum StockCompareStatusEnum { + + DRAFT("draft", -1, "草稿"), + EXECUTING("executing", 1, "对比中"), + FINISHED("finished", 3, "对比完成"), + ERROR("error", 9, "异常"), + ; + + private final String key; + + @EnumValue + private final Integer value; + + private final String desc; +} diff --git a/src/main/java/com/glxp/api/req/inv/InvProductDetailSelectQuery.java b/src/main/java/com/glxp/api/req/inv/InvProductDetailSelectQuery.java new file mode 100644 index 00000000..df3e8d5b --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/InvProductDetailSelectQuery.java @@ -0,0 +1,25 @@ +package com.glxp.api.req.inv; + +import com.glxp.api.util.page.ListPageRequest; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; +import java.util.Set; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class InvProductDetailSelectQuery extends ListPageRequest { + // @NotBlank(message = "仓库信息不能为空") + String invCode; + String mainAction; + String action; + // @NotNull(message = "对比开始日期不能为空") + LocalDate compareStartDate; + // @NotNull(message = "对比结束日期不能为空") + LocalDate compareEndDate; + String thirdTableField; + Set productIds; +} diff --git a/src/main/java/com/glxp/api/req/inv/InvProductDetailSelectRequest.java b/src/main/java/com/glxp/api/req/inv/InvProductDetailSelectRequest.java new file mode 100644 index 00000000..99b03c18 --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/InvProductDetailSelectRequest.java @@ -0,0 +1,18 @@ +package com.glxp.api.req.inv; + +import com.glxp.api.util.page.ListPageRequest; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotNull; +import java.time.LocalDate; +import java.util.Set; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class InvProductDetailSelectRequest extends ListPageRequest { + @NotNull(message = "请求标识不能为空") + Long compareId; +} diff --git a/src/main/java/com/glxp/api/req/inv/StockCompareDetailDelParam.java b/src/main/java/com/glxp/api/req/inv/StockCompareDetailDelParam.java new file mode 100644 index 00000000..549e9040 --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/StockCompareDetailDelParam.java @@ -0,0 +1,19 @@ +package com.glxp.api.req.inv; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class StockCompareDetailDelParam { + + @NotNull(message = "缺少请求标识") + Long compareId; + @NotNull(message = "缺少请求标识") + Long productId; + @NotBlank(message = "缺少请求标识") + String mainAction; + String batchNo; + +} diff --git a/src/main/java/com/glxp/api/req/inv/StockCompareDetailParam.java b/src/main/java/com/glxp/api/req/inv/StockCompareDetailParam.java new file mode 100644 index 00000000..33170edf --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/StockCompareDetailParam.java @@ -0,0 +1,42 @@ +package com.glxp.api.req.inv; + +import cn.hutool.core.collection.CollectionUtil; +import com.glxp.api.exception.JsonException; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.Set; + +@Data +public class StockCompareDetailParam { + + @NotNull(message = "非法参数") + private Long compareId; + +// private StockCompareParam compareInfo; + + @NotNull(message = "非法参数") + private Boolean isAll = false; + + private Set productIds; + + @Data + @EqualsAndHashCode + public static class selectInfo { + @NotNull(message = "产品id不能为空") + Long productId; + + String batchNo; + } + + public void valid() { + if (isAll) { + productIds = null; + } else if (CollectionUtil.isEmpty(productIds)) { + throw new JsonException(500, "请选择产品信息"); + } + } + +} diff --git a/src/main/java/com/glxp/api/req/inv/StockCompareParam.java b/src/main/java/com/glxp/api/req/inv/StockCompareParam.java new file mode 100644 index 00000000..6ac12a56 --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/StockCompareParam.java @@ -0,0 +1,47 @@ +package com.glxp.api.req.inv; + +import cn.hutool.core.util.StrUtil; +import com.glxp.api.exception.JsonException; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class StockCompareParam { + + private Integer thrSysId; + + private String invCode; + + private String mainAction; + + private String action; + + private LocalDate compareStartDate; + + private LocalDate compareEndDate; + + private String remark; + + public void valid() { + if (thrSysId == null) { + throw new JsonException(500, "请选择第三方系统"); + } + if (invCode == null) { + throw new JsonException(500, "请选择仓库信息"); + } + if (compareStartDate == null || compareEndDate == null) { + throw new JsonException(500, "请选择对比时间"); + } + if (compareStartDate.isAfter(compareEndDate)) { + throw new JsonException(500, "对比时间异常,开始时间不能在结束时间之后"); + } + if (!compareEndDate.isBefore(LocalDate.now())) { + throw new JsonException(500, "对比时间异常,结束时间要在今天之前"); + } + if (StrUtil.isBlank(remark)) { + throw new JsonException(500, "备注描述不能为空"); + } + } + +} diff --git a/src/main/java/com/glxp/api/req/inv/StockCompareQuery.java b/src/main/java/com/glxp/api/req/inv/StockCompareQuery.java new file mode 100644 index 00000000..d9fbac10 --- /dev/null +++ b/src/main/java/com/glxp/api/req/inv/StockCompareQuery.java @@ -0,0 +1,22 @@ +package com.glxp.api.req.inv; + +import com.glxp.api.enums.StockCompareStatusEnum; +import com.glxp.api.util.page.ListPageRequest; +import lombok.Data; + +@Data +public class StockCompareQuery extends ListPageRequest { + + private String id; + private String thrSysId; + + private StockCompareStatusEnum status; + + private String invCode; + + private String mainAction; + + private String action; + private String remark; + +} diff --git a/src/main/java/com/glxp/api/service/inv/StockCompareDetailService.java b/src/main/java/com/glxp/api/service/inv/StockCompareDetailService.java new file mode 100644 index 00000000..ea87ea76 --- /dev/null +++ b/src/main/java/com/glxp/api/service/inv/StockCompareDetailService.java @@ -0,0 +1,21 @@ +package com.glxp.api.service.inv; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.glxp.api.entity.inv.StockCompareDetailEntity; +import com.glxp.api.req.inv.InvProductDetailSelectQuery; +import com.glxp.api.service.CustomService; +import com.glxp.api.vo.inv.InvProductDetailSelectVo; + +/** + * 针对表【inv_stock_compare_detail】的数据库操作Service实现 + */ +public interface StockCompareDetailService extends CustomService { + + Page invProductDetailSelectPage(InvProductDetailSelectQuery query); + +} + + + + diff --git a/src/main/java/com/glxp/api/service/inv/StockCompareService.java b/src/main/java/com/glxp/api/service/inv/StockCompareService.java new file mode 100644 index 00000000..1c6dfe06 --- /dev/null +++ b/src/main/java/com/glxp/api/service/inv/StockCompareService.java @@ -0,0 +1,31 @@ +package com.glxp.api.service.inv; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.glxp.api.entity.inv.StockCompareEntity; +import com.glxp.api.dao.inv.StockCompareMapper; +import com.glxp.api.req.inv.StockCompareDetailParam; +import com.glxp.api.req.inv.StockCompareParam; +import com.glxp.api.req.inv.StockCompareQuery; +import com.glxp.api.service.CustomService; +import com.glxp.api.vo.inv.StockCompareVo; +import org.springframework.stereotype.Service; + +/** + * 针对表【inv_stock_compare】的数据库操作Service实现 + */ +public interface StockCompareService extends CustomService { + + Page pageVo(StockCompareQuery query); + + Long save(Long userId, StockCompareParam param); + + void addProduct(StockCompareDetailParam param); + + void delete(Long compareId); +} + + + + diff --git a/src/main/java/com/glxp/api/service/inv/impl/StockCompareDetailServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/StockCompareDetailServiceImpl.java new file mode 100644 index 00000000..4926d0b2 --- /dev/null +++ b/src/main/java/com/glxp/api/service/inv/impl/StockCompareDetailServiceImpl.java @@ -0,0 +1,29 @@ +package com.glxp.api.service.inv.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.glxp.api.dao.inv.StockCompareDetailMapper; +import com.glxp.api.entity.inv.StockCompareDetailEntity; +import com.glxp.api.req.inv.InvProductDetailSelectQuery; +import com.glxp.api.service.CustomServiceImpl; +import com.glxp.api.service.inv.StockCompareDetailService; +import com.glxp.api.vo.inv.InvProductDetailSelectVo; +import org.springframework.stereotype.Service; + + +/** + * 针对表【inv_stock_compare】的数据库操作Service实现 + */ +@Service +public class StockCompareDetailServiceImpl extends CustomServiceImpl + implements StockCompareDetailService { + + @Override + public Page invProductDetailSelectPage(InvProductDetailSelectQuery query) { + return super.baseMapper.invProductDetailSelectPage(query.getPageObj(),query); + } +} + + + + diff --git a/src/main/java/com/glxp/api/service/inv/impl/StockCompareServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/StockCompareServiceImpl.java new file mode 100644 index 00000000..1367df09 --- /dev/null +++ b/src/main/java/com/glxp/api/service/inv/impl/StockCompareServiceImpl.java @@ -0,0 +1,170 @@ +package com.glxp.api.service.inv.impl; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.glxp.api.dao.inv.StockCompareMapper; +import com.glxp.api.entity.auth.InvWarehouseEntity; +import com.glxp.api.entity.basic.BasicBussinessTypeEntity; +import com.glxp.api.entity.inv.StockCompareDetailEntity; +import com.glxp.api.entity.inv.StockCompareEntity; +import com.glxp.api.entity.thrsys.ThrSystemEntity; +import com.glxp.api.enums.StockCompareStatusEnum; +import com.glxp.api.exception.JsonException; +import com.glxp.api.req.inv.InvProductDetailSelectQuery; +import com.glxp.api.req.inv.StockCompareDetailParam; +import com.glxp.api.req.inv.StockCompareDetailParam.selectInfo; +import com.glxp.api.req.inv.StockCompareParam; +import com.glxp.api.req.inv.StockCompareQuery; +import com.glxp.api.service.CustomServiceImpl; +import com.glxp.api.service.auth.InvWarehouseService; +import com.glxp.api.service.basic.IBasicBussinessTypeService; +import com.glxp.api.service.inv.StockCompareDetailService; +import com.glxp.api.service.inv.StockCompareService; +import com.glxp.api.service.thrsys.ThrSystemService; +import com.glxp.api.util.SnowflakeUtil; +import com.glxp.api.vo.inv.InvProductDetailSelectVo; +import com.glxp.api.vo.inv.StockCompareVo; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + + +/** + * 针对表【inv_stock_compare】的数据库操作Service实现 + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class StockCompareServiceImpl extends CustomServiceImpl implements StockCompareService { + + private final StockCompareDetailService stockCompareDetailService; + + private final ThrSystemService thrSystemService; + private final InvWarehouseService invWarehouseService; + private final IBasicBussinessTypeService basicBussinessTypeService; + + @Override + public Page pageVo(StockCompareQuery query) { + if (query.getPage() != null) { + int offset = (query.getPage() - 1) * query.getLimit(); + PageHelper.offsetPage(offset, query.getLimit()); + } + return super.baseMapper.pageVo(query.getPageObj(), query); + } + + @Override + @Transactional + public Long save(Long userId, StockCompareParam param) { + param.valid(); + ThrSystemEntity thrSystemEntity = thrSystemService.getById(String.valueOf(param.getThrSysId())); + if (thrSystemEntity == null) { + throw new JsonException(500, "未找到该第三方系统"); + } + if (!thrSystemEntity.getEnabled()) { + throw new JsonException(500, "该第三方系统已被禁用"); + } + InvWarehouseEntity inv = invWarehouseService.findByInvSubByCode(param.getInvCode()); + if (inv == null) { + throw new JsonException(500, "未找到该仓库"); + } + String actionName = ""; + if (StrUtil.isNotBlank(param.getAction())) { + BasicBussinessTypeEntity action = basicBussinessTypeService.findByAction(param.getAction()); + if (action == null) { + throw new JsonException(500, "未找到该单据类型"); + } + actionName = action.getName(); + } + StockCompareEntity build = StockCompareEntity.builder() + .id(SnowflakeUtil.getId()) + .status(StockCompareStatusEnum.DRAFT) + .thrSysId(thrSystemEntity.getId()) + .thrSysName(thrSystemEntity.getThirdName()) + .thirdTableField(thrSystemEntity.getThirdId()) + .invCode(param.getInvCode()) + .invName(inv.getName()) + .action(StrUtil.blankToDefault(param.getAction(), "")) + .actionName(actionName) + .mainAction(StrUtil.blankToDefault(param.getMainAction(), "")) + .remark(param.getRemark()) + .compareStartDate(param.getCompareStartDate()) + .compareEndDate(param.getCompareEndDate()) + .siftBatchNo(false) + .createTime(LocalDateTime.now()) + .createUser(userId) + .build(); + super.save(build); + return build.getId(); + } + + @Transactional + @Override + public void delete(Long compareId) { + super.removeById(compareId); + stockCompareDetailService.remove(Wrappers.lambdaQuery(StockCompareDetailEntity.class) + .eq(StockCompareDetailEntity::getCompareId, compareId)); + } + + @Override + @Transactional + public void addProduct(StockCompareDetailParam param) { + param.valid(); + StockCompareEntity build = super.getById(param.getCompareId()); + if (build == null) { + throw new JsonException(500, "对比记录不存在"); + } + if (build.getStatus() != StockCompareStatusEnum.DRAFT) { + throw new JsonException(500, String.format("非%s状态无法再次添加", StockCompareStatusEnum.DRAFT.getDesc())); + } + InvProductDetailSelectQuery invProductDetailSelectQuery = new InvProductDetailSelectQuery(build.getInvCode(), build.getMainAction() + , build.getAction(), build.getCompareStartDate(), build.getCompareEndDate() + , build.getThirdTableField(), param.getIsAll() ? null : param.getProductIds().stream().map(selectInfo::getProductId).collect(Collectors.toSet())); + + invProductDetailSelectQuery.setPage(1); + invProductDetailSelectQuery.setLimit(param.getIsAll() ? 100 : param.getProductIds().size()); + List result = new ArrayList<>(invProductDetailSelectQuery.getLimit()); + Page page = null; + boolean hasNext = false; + do { + PageHelper.startPage(invProductDetailSelectQuery.getPage(),invProductDetailSelectQuery.getLimit()); + page = stockCompareDetailService.invProductDetailSelectPage(invProductDetailSelectQuery); + invProductDetailSelectQuery.setPage(invProductDetailSelectQuery.getPage() + 1); + result.addAll(page.getRecords()); + + PageInfo pageInfo = new PageInfo<>(page.getRecords()); + hasNext = pageInfo.isHasNextPage(); + } while (hasNext); + List stockCompareDetailList = new ArrayList<>(result.size()); + result.forEach(i -> { + StockCompareDetailEntity stockCompareDetail = StockCompareDetailEntity.builder() + .compareId(param.getCompareId()) + .productId(i.getProductId()) + .thrProductId(i.getThrProductId()) + .productName(i.getCpmctymc()) + .mainAction(i.getMainAction()) + .nameCode(i.getNameCode()) + .cpms(i.getCpms()) + .ggxh(i.getGgxh()) + .manufactory(i.getManufactory()) + .ylqxzcrbarmc(i.getYlqxzcrbarmc()) + .zczbhhzbapzbh(i.getZczbhhzbapzbh()) + .count(i.getCount()) + .build(); + stockCompareDetailList.add(stockCompareDetail); + }); + stockCompareDetailService.replaceBatch(stockCompareDetailList); + } +} + + + + diff --git a/src/main/java/com/glxp/api/vo/inv/InvProductDetailSelectVo.java b/src/main/java/com/glxp/api/vo/inv/InvProductDetailSelectVo.java new file mode 100644 index 00000000..708469fa --- /dev/null +++ b/src/main/java/com/glxp/api/vo/inv/InvProductDetailSelectVo.java @@ -0,0 +1,22 @@ +package com.glxp.api.vo.inv; + +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class InvProductDetailSelectVo { + private Long productId; + private String thrProductId; + private String cpmctymc; + private String ggxh; + private String nameCode; + private String cpms; + private String manufactory; + private String zczbhhzbapzbh; + private String ylqxzcrbarmc; + private String mainAction; + private Integer count; + +} diff --git a/src/main/java/com/glxp/api/vo/inv/StockCompareVo.java b/src/main/java/com/glxp/api/vo/inv/StockCompareVo.java new file mode 100644 index 00000000..c7b7eba7 --- /dev/null +++ b/src/main/java/com/glxp/api/vo/inv/StockCompareVo.java @@ -0,0 +1,24 @@ +package com.glxp.api.vo.inv; + +import com.glxp.api.entity.inv.StockCompareEntity; +import lombok.Data; + +@Data +public class StockCompareVo extends StockCompareEntity { + + private String statusDesc; + + public String getStatusDesc() { + if (super.getStatus() != null) { + return super.getStatus().getDesc(); + } + return statusDesc; + } +// +// private String invName; +// +// private String actionName; + + private String createUserName; + +} diff --git a/src/main/resources/application-wj.yml b/src/main/resources/application-wj.yml new file mode 100644 index 00000000..9120c60f --- /dev/null +++ b/src/main/resources/application-wj.yml @@ -0,0 +1,61 @@ +server: + port: 9991 + +spring: + datasource: + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3333/udi_wms?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + username: root + password: 123456 + hikari: + connection-timeout: 60000 + maximum-pool-size: 20 + minimum-idle: 10 + + + redis: + database: 8 + host: 127.0.0.1 + port: 6377 + password: 123456 + timeout: 300 + jedis: + pool: + max-active: 8 + max-wait: -1 + max-idle: 8 + min-idle: 0 + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + servlet: + multipart: + max-file-size: 500MB + max-request-size: 500MB + +ok: + http: + connect-timeout: 3000 + read-timeout: 3000 + write-timeout: 3000 + max-idle-connections: 200 + keep-alive-duration: 300 + + +logging: + level: + com.glxp.api.dao: debug + +file_path: D:/udi/udiwms/udiwmsfile/ +file_lpath: /udiwms/image/register/file/getImage +file_url: http://127.0.0.1:9991 + + +UDI_KEY: 6b137c66-6286-46c6-8efa-c2f5dd9237df +UDI_SERVER_URL: https://www.udims.com/UDI_DL_Server_test +SPMS_KEY: lCOdWCBKS6Kw45wdnnqUTELXyuSKnXEs +back_file_path: D:/share/udisps/back/ +API_KEY: 1101 +API_SECRET: zBITspLNvuoEd4FaamlSoqxRHmNsmQ6L +WEB_TITLE: 平潭协和医院 +SPMS_WEBSOCKET_TOKEN: 07rKFDFkQvBkbxgc7aUBlONo4gWNdx8b \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inv/StockCompareDetailMapper.xml b/src/main/resources/mybatis/mapper/inv/StockCompareDetailMapper.xml new file mode 100644 index 00000000..7f4bd633 --- /dev/null +++ b/src/main/resources/mybatis/mapper/inv/StockCompareDetailMapper.xml @@ -0,0 +1,49 @@ + + + + + + diff --git a/src/main/resources/mybatis/mapper/inv/StockCompareMapper.xml b/src/main/resources/mybatis/mapper/inv/StockCompareMapper.xml new file mode 100644 index 00000000..b693e3e7 --- /dev/null +++ b/src/main/resources/mybatis/mapper/inv/StockCompareMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + diff --git a/src/main/resources/schemas/schema_v2.4.sql b/src/main/resources/schemas/schema_v2.4.sql new file mode 100644 index 00000000..56156e6d --- /dev/null +++ b/src/main/resources/schemas/schema_v2.4.sql @@ -0,0 +1,54 @@ +# 字段新增 (表名,字段名,字段类型,修改方式(1:新增,2:修改,3:删除) + +-- ---------------------------- +-- Table structure for inv_stock_compare +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `inv_stock_compare` +( + `id` bigint NOT NULL, + `status` int NOT NULL COMMENT '状态', + `thrSysId` int NOT NULL COMMENT '第三方系统id', + `thrSysName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '第三方系统名称', + `thirdTableField` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '第三方系统字段名', + `invCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '仓库编码', + `invName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '仓库名称', + `mainAction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '出入库类型', + `action` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据类型编码', + `actionName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '单据类型名称', + `compareStartDate` date NOT NULL COMMENT '筛选开始时间', + `compareEndDate` date NOT NULL COMMENT '筛选结束时间', + `compareTime` datetime NULL DEFAULT NULL COMMENT '对比时间', + `siftBatchNo` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否区分批次号', + `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '备注', + `createTime` datetime NOT NULL COMMENT '创建时间', + `createUser` bigint NOT NULL COMMENT '创建人id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB + CHARACTER SET = utf8mb4 + COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存对比表' + ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Table structure for inv_stock_compare_detail +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `inv_stock_compare_detail` +( + `compareId` bigint NOT NULL COMMENT '对比id', + `productId` bigint NOT NULL COMMENT '产品id', + `thrProductId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '第三方产品编码', + `nameCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT 'DI', + `productName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品名称', + `cpms` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '产品描述', + `ggxh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '规格型号', + `manufactory` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '生产厂家', + `ylqxzcrbarmc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '医疗器械注册/备案人名称', + `zczbhhzbapzbh` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_cs NOT NULL COMMENT '注册证编号/备案批准编号', + `mainAction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '出入库类型', + `count` int NOT NULL COMMENT '对应数量', + `thrCount` int NULL DEFAULT NULL COMMENT '第三方数量', + `compareCount` int NULL DEFAULT NULL COMMENT '对比数量', + PRIMARY KEY (`compareId`, `productId`, `mainAction`) USING BTREE +) ENGINE = InnoDB + CHARACTER SET = utf8mb4 + COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存对比明细' + ROW_FORMAT = Dynamic; \ No newline at end of file