库存对比相关--未完结

test
wj 1 year ago
parent e192f70aba
commit 41babe7e64

@ -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"));
}
}

@ -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<StockCompareVo> page = stockCompareService.pageVo(query);
PageInfo<StockCompareVo> pageInfo;
pageInfo = new PageInfo<>(page.getRecords());
PageSimpleResponse<StockCompareVo> 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<InvProductDetailSelectVo> page = stockCompareDetailService.invProductDetailSelectPage(invProductDetailSelectQuery);
PageSimpleResponse<InvProductDetailSelectVo> 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<StockCompareDetailEntity> page = stockCompareDetailService.page(param.getPageObj()
, Wrappers.lambdaQuery(StockCompareDetailEntity.class)
.eq(StockCompareDetailEntity::getCompareId, param.getCompareId())
.orderByAsc(StockCompareDetailEntity::getProductId, StockCompareDetailEntity::getMainAction)
);
PageInfo<StockCompareDetailEntity> pageInfo;
pageInfo = new PageInfo<>(page.getRecords());
PageSimpleResponse<StockCompareDetailEntity> 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("移除成功");
}
}

@ -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<StockCompareDetailMapper, StockCompareDetailEntity, StockCompareDetailEntity> {
Page<InvProductDetailSelectVo> invProductDetailSelectPage(Page pageObj, @Param("param") InvProductDetailSelectQuery query);
}

@ -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_compareMapper
* @createDate 2023-10-23 11:40:33
* @Entity com.glxp.api.entity.inv.StockCompareEntity
*/
public interface StockCompareMapper extends BaseMapperPlus<StockCompareMapper,StockCompareEntity,StockCompareEntity> {
Page<StockCompareVo> pageVo(Page pageObj,@Param("param") StockCompareQuery query);
}

@ -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;
}

@ -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;
/**
*
* <p>
* 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;
}

@ -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;
}

@ -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;
}

@ -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<Long> productIds;
}

@ -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;
}

@ -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;
}

@ -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<selectInfo> 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, "请选择产品信息");
}
}
}

@ -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, "备注描述不能为空");
}
}
}

@ -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;
}

@ -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_detailService
*/
public interface StockCompareDetailService extends CustomService<StockCompareDetailEntity> {
Page<InvProductDetailSelectVo> invProductDetailSelectPage(InvProductDetailSelectQuery query);
}

@ -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_compareService
*/
public interface StockCompareService extends CustomService<StockCompareEntity> {
Page<StockCompareVo> pageVo(StockCompareQuery query);
Long save(Long userId, StockCompareParam param);
void addProduct(StockCompareDetailParam param);
void delete(Long compareId);
}

@ -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_compareService
*/
@Service
public class StockCompareDetailServiceImpl extends CustomServiceImpl<StockCompareDetailMapper, StockCompareDetailEntity>
implements StockCompareDetailService {
@Override
public Page<InvProductDetailSelectVo> invProductDetailSelectPage(InvProductDetailSelectQuery query) {
return super.baseMapper.invProductDetailSelectPage(query.getPageObj(),query);
}
}

@ -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_compareService
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class StockCompareServiceImpl extends CustomServiceImpl<StockCompareMapper, StockCompareEntity> implements StockCompareService {
private final StockCompareDetailService stockCompareDetailService;
private final ThrSystemService thrSystemService;
private final InvWarehouseService invWarehouseService;
private final IBasicBussinessTypeService basicBussinessTypeService;
@Override
public Page<StockCompareVo> 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<InvProductDetailSelectVo> result = new ArrayList<>(invProductDetailSelectQuery.getLimit());
Page<InvProductDetailSelectVo> 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<InvProductDetailSelectVo> pageInfo = new PageInfo<>(page.getRecords());
hasNext = pageInfo.isHasNextPage();
} while (hasNext);
List<StockCompareDetailEntity> 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);
}
}

@ -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;
}

@ -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;
}

@ -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

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.api.dao.inv.StockCompareDetailMapper">
<select id="invProductDetailSelectPage" resultType="com.glxp.api.vo.inv.InvProductDetailSelectVo">
SELECT
ipd.relId productId,
udi.${param.thirdTableField} thrProductId,
p.cpmctymc,
p.ggxh,
p.nameCode,
p.cpms,
p.manufactory,
p.zczbhhzbapzbh,
p.ylqxzcrbarmc,
ipd.mainAction,
sum( ipd.count ) count
FROM
inv_product_detail ipd
LEFT JOIN basic_udirel udi ON udi.id = ipd.relId
LEFT JOIN basic_products p ON p.uuid = udi.uuid
<where>
udi.${param.thirdTableField} is not null
and ipd.invCode = #{param.invCode}
and ipd.updateTime between concat(#{param.compareStartDate},' 00:00:00') and
concat(#{param.compareEndDate},' 23:59:59')
<if test="param.mainAction!=null and param.mainAction!=''">
and ipd.mainAction = #{param.mainAction}
</if>
<if test="param.action!=null and param.action!=''">
and ipd.action = #{param.action}
</if>
<if test="param.productIds!=null">
and ipd.relId in
<foreach collection="param.productIds" open="(" item="item" separator="," close=")">
#{item}
</foreach>
</if>
</where>
GROUP BY
ipd.relId,
ipd.mainAction
ORDER BY
ipd.relId,
ipd.mainAction
</select>
</mapper>

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glxp.api.dao.inv.StockCompareMapper">
<!-- select sc.*,aw.name invName,bt.name actionName,au.employeeName createUserName
from inv_stock_compare sc
left join auth_warehouse aw on aw.code = sc.invCode
left join basic_bussiness_type bt on bt.action = sc.action
left join auth_user au on au.id = sc.createUser -->
<select id="pageVo" resultType="com.glxp.api.vo.inv.StockCompareVo">
select sc.*,au.employeeName createUserName
from inv_stock_compare sc
left join auth_user au on au.id = sc.createUser
<where>
<if test="param.id!=null and param.id!=''">
and sc.id = #{param.id}
</if>
<if test="param.thrSysId!=null and param.thrSysId!=''">
and sc.thrSysId = #{param.thrSysId}
</if>
<if test="param.invCode!=null and param.invCode!=''">
and sc.invCode = #{param.invCode}
</if>
<if test="param.mainAction!=null and param.mainAction!=''">
and sc.mainAction = #{param.mainAction}
</if>
<if test="param.action!=null and param.action!=''">
and sc.action = #{param.action}
</if>
<if test="param.status!=null">
and sc.status = #{param.status}
</if>
<if test="param.remark!=null and param.remark!=''">
and sc.remark like concat('%',#{param.remark},'%')
</if>
</where>
order by sc.createTime desc
</select>
</mapper>

@ -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;
Loading…
Cancel
Save