dev
This commit is contained in:
parent
9ac00fe203
commit
518812e177
|
|
@ -0,0 +1,27 @@
|
|||
package com.syjiaer.clinic.server.common.enums;
|
||||
|
||||
public enum ChrgitmLvEnum {
|
||||
ONE("01", "甲"),
|
||||
TWO("02", "乙"),
|
||||
THREE("03", "丙");
|
||||
private final String code;
|
||||
private final String name;
|
||||
ChrgitmLvEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public static ChrgitmLvEnum getChrgitmLvEnumByCode(String code) {
|
||||
for (ChrgitmLvEnum chrgitmLvEnum : ChrgitmLvEnum.values()) {
|
||||
if (chrgitmLvEnum.getCode().equals(code)) {
|
||||
return chrgitmLvEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import com.syjiaer.clinic.server.entity.goods.Goods;
|
|||
import com.syjiaer.clinic.server.entity.goods.GoodsView;
|
||||
import com.syjiaer.clinic.server.entity.goods.dto.GoodsQuery;
|
||||
import com.syjiaer.clinic.server.entity.goods.vo.GoodsDetailVo;
|
||||
import com.syjiaer.clinic.server.entity.goods.vo.GoodsSearchVo;
|
||||
import com.syjiaer.clinic.server.service.goods.GoodsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -101,10 +102,10 @@ public class GoodsController extends BaseController {
|
|||
* 商品搜索 一键建档内的搜索
|
||||
*/
|
||||
@RequestMapping("search")
|
||||
public Result<Object> search() {
|
||||
public Result<List<GoodsSearchVo>> search() {
|
||||
Map<String, Object> parms = getParms();
|
||||
String keyword = (String) parms.get("keyword");
|
||||
List<Goods> searchResult = goodsService.search(keyword);;
|
||||
List<GoodsSearchVo> searchResult = goodsService.search(keyword);;
|
||||
return success(searchResult);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.syjiaer.clinic.server.common.vo.Page;
|
|||
import com.syjiaer.clinic.server.common.vo.Result;
|
||||
import com.syjiaer.clinic.server.controller.BaseController;
|
||||
import com.syjiaer.clinic.server.entity.item.Item;
|
||||
import com.syjiaer.clinic.server.entity.item.vo.ItemSearchVo;
|
||||
import com.syjiaer.clinic.server.service.item.ItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
@ -60,7 +61,7 @@ public class ItemController extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping("/search")
|
||||
public Result<List<Item>> search() {
|
||||
public Result<List<ItemSearchVo>> search() {
|
||||
String keyword = parmsUtil.getString("keyword");
|
||||
|
||||
return success(itemService.search(keyword));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
package com.syjiaer.clinic.server.entity.goods.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@Data
|
||||
public class GoodsSearchVo {
|
||||
@ApiModelProperty("自增主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("商品名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("商品类型")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("通用名")
|
||||
private String commonName;
|
||||
|
||||
@ApiModelProperty("医保目录编码")
|
||||
private String hilistCode;
|
||||
|
||||
@ApiModelProperty("单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("进货价")
|
||||
private BigDecimal purchaseUnitPrice;
|
||||
|
||||
@ApiModelProperty("生厂商")
|
||||
private String producer;
|
||||
|
||||
@ApiModelProperty("条形码")
|
||||
private String barcode;
|
||||
|
||||
@ApiModelProperty("最小制剂单位")
|
||||
private String medicineDosageUnit;
|
||||
|
||||
@ApiModelProperty("最小包装数量")
|
||||
private Integer minPackagingNumber;
|
||||
|
||||
@ApiModelProperty("最小包装单位")
|
||||
private String minPackagingUnit;
|
||||
|
||||
@ApiModelProperty("保质期")
|
||||
private Integer expiryTime;
|
||||
|
||||
@ApiModelProperty("国药准字")
|
||||
private String approvalCode;
|
||||
|
||||
@ApiModelProperty("拓展字段")
|
||||
private String extra;
|
||||
|
||||
@ApiModelProperty("分类ID")
|
||||
private Integer cateId;
|
||||
|
||||
@ApiModelProperty("软删除 1为删除")
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty("利润分类")
|
||||
private String profitCate;
|
||||
|
||||
@ApiModelProperty("标签")
|
||||
private String tags;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("利率")
|
||||
private Double interestRate;
|
||||
|
||||
@ApiModelProperty("库存整数量 ")
|
||||
private Integer inventoryWholeNumber;
|
||||
|
||||
@ApiModelProperty("标识码 由追溯码生成")
|
||||
private String idCode;
|
||||
|
||||
@ApiModelProperty("库存分数量")
|
||||
private Integer inventoryFragmentNumber;
|
||||
|
||||
@ApiModelProperty("0不允许拆零 1允许拆零")
|
||||
private Boolean trdnFlag;
|
||||
|
||||
@ApiModelProperty("拆零价格")
|
||||
private BigDecimal disassemblyPrice;
|
||||
|
||||
@ApiModelProperty("最小制剂数量")
|
||||
private String medicineDosageNum;
|
||||
|
||||
@ApiModelProperty("包装单位")
|
||||
private String packagingUnit;
|
||||
|
||||
@ApiModelProperty("售卖模式")
|
||||
private Integer pricingModel;
|
||||
|
||||
@ApiModelProperty("加成率 30=30%")
|
||||
private Integer makeUp;
|
||||
|
||||
@ApiModelProperty("0禁售 1可售")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty("库存预警数量")
|
||||
private Integer inventoryWarnNumber;
|
||||
|
||||
@ApiModelProperty("到期预警天数")
|
||||
private Integer expiryWarnDays;
|
||||
|
||||
@ApiModelProperty("使用次数")
|
||||
private Integer useNum;
|
||||
|
||||
@ApiModelProperty("全拼")
|
||||
private String pinyinFull;
|
||||
|
||||
@ApiModelProperty("拼音首字母")
|
||||
private String pinyinFirst;
|
||||
|
||||
@ApiModelProperty("甲乙丙类")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty("限制条件")
|
||||
private String limit;
|
||||
@ApiModelProperty("库存")
|
||||
private String inventory;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.syjiaer.clinic.server.entity.item.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class ItemSearchVo {
|
||||
|
||||
@ApiModelProperty("自增主键")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("项目创建时间")
|
||||
private LocalDateTime createDatetime;
|
||||
|
||||
@ApiModelProperty("项目创建人")
|
||||
private String createBy;
|
||||
|
||||
@ApiModelProperty("项目修改时间")
|
||||
private LocalDateTime updateDatetime;
|
||||
|
||||
@ApiModelProperty("项目修改人")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty("项目名称")
|
||||
private String itemName;
|
||||
|
||||
@ApiModelProperty("项目医保目录编码")
|
||||
private String itemSocialCode;
|
||||
|
||||
@ApiModelProperty("单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty("售价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty("进货价")
|
||||
private BigDecimal purchaseUnitPrice;
|
||||
|
||||
@ApiModelProperty("逻辑删除")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("使用次数")
|
||||
private Integer useNum;
|
||||
|
||||
@ApiModelProperty("全拼")
|
||||
private String pinyinFull;
|
||||
|
||||
@ApiModelProperty("拼音首字母")
|
||||
private String pinyinFirst;
|
||||
|
||||
@ApiModelProperty("甲乙丙类")
|
||||
private String chrgitmLv;
|
||||
|
||||
@ApiModelProperty("限制条件")
|
||||
private String limit;
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import com.syjiaer.clinic.server.common.api.input.IM3501;
|
|||
import com.syjiaer.clinic.server.common.api.input.IM3502;
|
||||
import com.syjiaer.clinic.server.common.api.request.SocialRequest;
|
||||
import com.syjiaer.clinic.server.common.constants.Constants;
|
||||
import com.syjiaer.clinic.server.common.enums.ChrgitmLvEnum;
|
||||
import com.syjiaer.clinic.server.common.enums.GoodsPricingModelEnum;
|
||||
import com.syjiaer.clinic.server.common.enums.GoodsTypeEnum;
|
||||
import com.syjiaer.clinic.server.common.enums.InventorySocialTypeEnum;
|
||||
|
|
@ -16,11 +17,14 @@ import com.syjiaer.clinic.server.common.vo.Page;
|
|||
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||
import com.syjiaer.clinic.server.entity.goods.dto.GoodsQuery;
|
||||
import com.syjiaer.clinic.server.entity.goods.vo.GoodsDetailVo;
|
||||
import com.syjiaer.clinic.server.entity.goods.vo.GoodsSearchVo;
|
||||
import com.syjiaer.clinic.server.entity.inventory.Inventory;
|
||||
import com.syjiaer.clinic.server.entity.item.Item;
|
||||
import com.syjiaer.clinic.server.entity.social.SocialDirectoryUpinfo;
|
||||
import com.syjiaer.clinic.server.entity.social.vo.SocialDirectoryView;
|
||||
import com.syjiaer.clinic.server.mapper.goods.GoodsMapper;
|
||||
import com.syjiaer.clinic.server.mapper.inventory.InventoryMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryUpinfoMapper;
|
||||
import com.syjiaer.clinic.server.service.social.SocialDirectoryService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -43,16 +47,19 @@ public class GoodsService {
|
|||
private InventoryMapper inventoryMapper;
|
||||
@Autowired
|
||||
private SocialDirectoryService socialDirectoryService;
|
||||
@Autowired
|
||||
private SocialDirectoryUpinfoMapper socialDirectoryUpinfoMapper;
|
||||
|
||||
/*
|
||||
* 新建商品
|
||||
* @param goods 商品信息
|
||||
*/
|
||||
public Goods createGoods(Goods goods) {
|
||||
|
||||
if (goods.getPricingModel().equals(GoodsPricingModelEnum.Bonus.getPricingModel()) && goods.getMakeUp() == null){
|
||||
if (goods.getPricingModel().equals(GoodsPricingModelEnum.Bonus.getPricingModel()) && goods.getMakeUp() == null) {
|
||||
throw new MessageException("售价为进价加成时,加成率不能为空");
|
||||
}
|
||||
if (goods.getPricingModel().equals(GoodsPricingModelEnum.Fixed.getPricingModel()) && goods.getUnitPrice() == null){
|
||||
if (goods.getPricingModel().equals(GoodsPricingModelEnum.Fixed.getPricingModel()) && goods.getUnitPrice() == null) {
|
||||
throw new MessageException("售价为固定售价时,售价不能为空");
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +70,7 @@ public class GoodsService {
|
|||
.multiply(new BigDecimal(goods.getMakeUp() + 100)).divide(new BigDecimal(100), 6, RoundingMode.HALF_DOWN));
|
||||
}
|
||||
|
||||
if (goods.getTrdnFlag()==null||!goods.getTrdnFlag()){
|
||||
if (goods.getTrdnFlag() == null || !goods.getTrdnFlag()) {
|
||||
goods.setDisassemblyPrice(null);
|
||||
}
|
||||
if (goods.getInventoryWholeNumber() == null) {
|
||||
|
|
@ -93,6 +100,7 @@ public class GoodsService {
|
|||
}
|
||||
return goods;
|
||||
}
|
||||
|
||||
/*
|
||||
* 重新初始化医保库存
|
||||
*/
|
||||
|
|
@ -104,6 +112,7 @@ public class GoodsService {
|
|||
// 重新初始化医保库存
|
||||
requestReturnInit(goods);
|
||||
}
|
||||
|
||||
/*
|
||||
* 重新初始化医保库存
|
||||
* @param goods 商品信息
|
||||
|
|
@ -118,7 +127,7 @@ public class GoodsService {
|
|||
inventoryWrapper.eq("good_id", goods.getId());
|
||||
inventoryWrapper.orderByDesc("id");
|
||||
List<Inventory> inventories = inventoryMapper.selectList(inventoryWrapper);
|
||||
if (inventories.isEmpty()){
|
||||
if (inventories.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +135,7 @@ public class GoodsService {
|
|||
SocialDirectoryView socialDirectory = socialDirectoryService.fullInfo(goods.getHilistCode());
|
||||
IM3501 im3501 = new IM3501();
|
||||
BigDecimal number = new BigDecimal(goods.getInventoryWholeNumber());
|
||||
BigDecimal price =goods.getUnitPrice();
|
||||
BigDecimal price = goods.getUnitPrice();
|
||||
if (goods.getTrdnFlag()) {
|
||||
number = number.multiply(new BigDecimal(goods.getMinPackagingNumber())).add(new BigDecimal(goods.getInventoryFragmentNumber()));
|
||||
price = goods.getDisassemblyPrice();
|
||||
|
|
@ -152,10 +161,11 @@ public class GoodsService {
|
|||
.setFixmedinsBchno(String.valueOf(latestInventory.getInventoryPurchaseCode()))
|
||||
.setRxFlag((String) jsonObject.get("rx_flag"))
|
||||
.setInvChgTime(latestInventory.getCreateDatetime())
|
||||
.setTrdnFlag(goods.getTrdnFlag()?"1":"0")
|
||||
.setTrdnFlag(goods.getTrdnFlag() ? "1" : "0")
|
||||
.setCnt(number);
|
||||
socialRequest.call3502(im3502);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取商品详情
|
||||
* @param goodsQuery 商品查询条件
|
||||
|
|
@ -180,12 +190,12 @@ public class GoodsService {
|
|||
if (goodsQuery.getCateId() != null) {
|
||||
queryWrapper.eq("cate_id", goodsQuery.getCateId());
|
||||
}
|
||||
if (goodsQuery.isStatus()){
|
||||
if (goodsQuery.isStatus()) {
|
||||
//是否只查询可售商品
|
||||
queryWrapper.eq("status", goodsQuery.isStatus());
|
||||
}
|
||||
if (goodsQuery.getInventoryNumber() != null){
|
||||
queryWrapper.and(wrapper ->{
|
||||
if (goodsQuery.getInventoryNumber() != null) {
|
||||
queryWrapper.and(wrapper -> {
|
||||
wrapper.gt("inventory_whole_number", goodsQuery.getInventoryNumber());
|
||||
wrapper.or().gt("inventory_fragment_number", goodsQuery.getInventoryNumber());
|
||||
});
|
||||
|
|
@ -206,14 +216,14 @@ public class GoodsService {
|
|||
}
|
||||
Page<Goods> page = selectPage(goodsQuery, queryWrapper);
|
||||
List<GoodsDetailVo> goodsDetailVoList = new ArrayList<>();
|
||||
for (Goods goods:page.getList()){
|
||||
for (Goods goods : page.getList()) {
|
||||
GoodsDetailVo goodsDetailVo = new GoodsDetailVo();
|
||||
BeanUtils.copyProperties(goods, goodsDetailVo);
|
||||
QueryWrapper<Inventory> inventoryQuery = new QueryWrapper<>();
|
||||
inventoryQuery.eq("good_id", goods.getId());
|
||||
inventoryQuery.orderByAsc("expiry_date");
|
||||
List<Inventory> inventoryList = inventoryMapper.selectList(inventoryQuery);
|
||||
if (!inventoryList.isEmpty()){
|
||||
if (!inventoryList.isEmpty()) {
|
||||
goodsDetailVo.setRecentlyExpiryDate(inventoryList.get(0).getExpiryDate());
|
||||
|
||||
BigDecimal costPrice = inventoryList.stream()
|
||||
|
|
@ -225,7 +235,7 @@ public class GoodsService {
|
|||
goodsDetailVo.setCostPrice(costPrice);
|
||||
}
|
||||
SocialDirectoryView dbSocialInfo = socialDirectoryService.fullInfo(goods.getHilistCode());
|
||||
if (dbSocialInfo != null){
|
||||
if (dbSocialInfo != null) {
|
||||
goodsDetailVo.setHilistPricUplmtAmt(dbSocialInfo.getHilistPricUplmtAmt());
|
||||
goodsDetailVo.setHilistLmtpricType(dbSocialInfo.getHilistLmtpricType());
|
||||
goodsDetailVo.setSelfpayProp(dbSocialInfo.getSelfpayProp());
|
||||
|
|
@ -239,6 +249,7 @@ public class GoodsService {
|
|||
result.setTotal_page(page.getTotal_page());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 分页查询商品
|
||||
* @param goodsQuery 查询条件
|
||||
|
|
@ -258,14 +269,15 @@ public class GoodsService {
|
|||
page.setTotal_page(totalPage);
|
||||
return page;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据关键字搜索商品
|
||||
* @param keyword 关键字
|
||||
*/
|
||||
public List<Goods> search(String keyword) {
|
||||
public List<GoodsSearchVo> search(String keyword) {
|
||||
QueryWrapper<Goods> queryWrapper = new QueryWrapper<>();
|
||||
|
||||
if (keyword != null && !keyword.isEmpty()){
|
||||
if (keyword != null && !keyword.isEmpty()) {
|
||||
keyword = keyword.toUpperCase();
|
||||
queryWrapper.like("name", keyword);
|
||||
queryWrapper.or();
|
||||
|
|
@ -281,9 +293,31 @@ public class GoodsService {
|
|||
}
|
||||
queryWrapper.orderByDesc("use_num");
|
||||
|
||||
|
||||
queryWrapper.last("limit 20");
|
||||
return goodsMapper.selectList(queryWrapper);
|
||||
|
||||
List<Goods> list = goodsMapper.selectList(queryWrapper);
|
||||
List<GoodsSearchVo> goodsSearchVoList = new ArrayList<>();
|
||||
for (Goods goods : list) {
|
||||
GoodsSearchVo goodsSearchVo = new GoodsSearchVo();
|
||||
BeanUtils.copyProperties(goods, goodsSearchVo);
|
||||
String inventory = goods.getInventoryWholeNumber() +goods.getPackagingUnit();
|
||||
if (goods.getInventoryFragmentNumber() != 0){
|
||||
inventory += goods.getInventoryFragmentNumber() + goods.getMinPackagingNumber();
|
||||
}
|
||||
goodsSearchVo.setInventory(inventory);
|
||||
SocialDirectoryUpinfo socialDirectoryUpinfo = socialDirectoryUpinfoMapper.selectByCode(goods.getHilistCode());
|
||||
if (socialDirectoryUpinfo != null) {
|
||||
ChrgitmLvEnum chrgitmLvEnum = ChrgitmLvEnum.getChrgitmLvEnumByCode(socialDirectoryUpinfo.getChrgitmLv());
|
||||
goodsSearchVo.setCategory(chrgitmLvEnum == null ? null : chrgitmLvEnum.getName());
|
||||
}
|
||||
goodsSearchVoList.add(goodsSearchVo);
|
||||
}
|
||||
|
||||
|
||||
return goodsSearchVoList;
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据id获取商品信息
|
||||
* @param id 商品id
|
||||
|
|
@ -295,32 +329,34 @@ public class GoodsService {
|
|||
}
|
||||
return goods;
|
||||
}
|
||||
|
||||
/*
|
||||
* 添加标识码
|
||||
* 参数 goodsId 商品ID
|
||||
* 参数 idCode 标识码
|
||||
*/
|
||||
public void addIdCode(int goodsId, String idCode){
|
||||
public void addIdCode(int goodsId, String idCode) {
|
||||
Goods dbGoods = goodsMapper.selectById(goodsId);
|
||||
if (dbGoods == null){
|
||||
if (dbGoods == null) {
|
||||
throw new MessageException("商品不存在");
|
||||
}
|
||||
List<String> idCodeList = null;
|
||||
if (dbGoods.getIdCode() == null){
|
||||
if (dbGoods.getIdCode() == null) {
|
||||
idCodeList = new ArrayList<>();
|
||||
}else {
|
||||
} else {
|
||||
idCodeList = new ArrayList<>(Arrays.asList(dbGoods.getIdCode().split(",")));
|
||||
}
|
||||
if (idCodeList.contains(idCode)){
|
||||
if (idCodeList.contains(idCode)) {
|
||||
//重复标识码
|
||||
return;
|
||||
}
|
||||
idCodeList.add(idCode);
|
||||
Goods updateGoods = new Goods();
|
||||
updateGoods.setId(dbGoods.getId());
|
||||
updateGoods.setIdCode(String.join(",",idCodeList));
|
||||
updateGoods.setIdCode(String.join(",", idCodeList));
|
||||
goodsMapper.updateById(updateGoods);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取二级分类绑定的商品数量
|
||||
* 参数 cateId 二级分类ID
|
||||
|
|
@ -331,27 +367,28 @@ public class GoodsService {
|
|||
return goodsMapper.selectCount(queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新商品库存信息
|
||||
* 参数 id 商品ID
|
||||
*/
|
||||
public void updateInventoryInfoById(Integer id){
|
||||
public void updateInventoryInfoById(Integer id) {
|
||||
Goods dbGoods = goodsMapper.selectById(id);
|
||||
if (dbGoods==null){
|
||||
if (dbGoods == null) {
|
||||
return;
|
||||
}
|
||||
QueryWrapper<Inventory> goodWrapper = new QueryWrapper<>();
|
||||
goodWrapper.eq("good_id", id);
|
||||
goodWrapper.orderByDesc("id");
|
||||
List<Inventory> inventories = inventoryMapper.selectList(goodWrapper);
|
||||
if (inventories==null||inventories.isEmpty()) {
|
||||
if (inventories == null || inventories.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Goods updateGoods = new Goods();
|
||||
updateGoods.setId(dbGoods.getId());
|
||||
//更新最近进货价格
|
||||
updateGoods.setPurchaseUnitPrice(inventories.get(0).getPurchaseUnitPrice());
|
||||
if (dbGoods.getPricingModel().equals(GoodsPricingModelEnum.Bonus.getPricingModel())){
|
||||
if (dbGoods.getPricingModel().equals(GoodsPricingModelEnum.Bonus.getPricingModel())) {
|
||||
//更新售价
|
||||
updateGoods.setUnitPrice(updateGoods.getPurchaseUnitPrice()
|
||||
.multiply(new BigDecimal(dbGoods.getMakeUp() + 100))
|
||||
|
|
@ -360,7 +397,7 @@ public class GoodsService {
|
|||
//更新库存
|
||||
Integer totalWholeNumber = 0;
|
||||
Integer totalFragmentNumber = 0;
|
||||
for (Inventory inventory : inventories){
|
||||
for (Inventory inventory : inventories) {
|
||||
totalWholeNumber += inventory.getWholeNumber();
|
||||
totalFragmentNumber += inventory.getFragmentNumber();
|
||||
}
|
||||
|
|
@ -371,6 +408,7 @@ public class GoodsService {
|
|||
|
||||
/**
|
||||
* 根据id查询goods
|
||||
*
|
||||
* @param goodsId 商品id
|
||||
* @return 商品
|
||||
*/
|
||||
|
|
@ -387,11 +425,11 @@ public class GoodsService {
|
|||
|
||||
|
||||
public void updateNumAddOne(List<Integer> ids) {
|
||||
for (Integer goodsId : ids){
|
||||
for (Integer goodsId : ids) {
|
||||
UpdateWrapper<Goods> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.setSql("use_num = use_num+1");
|
||||
updateWrapper.eq("id",goodsId);
|
||||
goodsMapper.update(null,updateWrapper);
|
||||
updateWrapper.eq("id", goodsId);
|
||||
goodsMapper.update(null, updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,26 +2,37 @@ package com.syjiaer.clinic.server.service.item;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.syjiaer.clinic.server.common.enums.ChrgitmLvEnum;
|
||||
import com.syjiaer.clinic.server.common.exception.MessageException;
|
||||
import com.syjiaer.clinic.server.common.util.PinYinUtil;
|
||||
import com.syjiaer.clinic.server.common.vo.Page;
|
||||
import com.syjiaer.clinic.server.entity.goods.Goods;
|
||||
import com.syjiaer.clinic.server.entity.goods.vo.GoodsSearchVo;
|
||||
import com.syjiaer.clinic.server.entity.item.Item;
|
||||
import com.syjiaer.clinic.server.entity.item.vo.ItemSearchVo;
|
||||
import com.syjiaer.clinic.server.entity.manager.ManagerUser;
|
||||
import com.syjiaer.clinic.server.entity.social.SocialDiagnose;
|
||||
import com.syjiaer.clinic.server.entity.social.SocialDirectoryUpinfo;
|
||||
import com.syjiaer.clinic.server.mapper.item.ItemMapper;
|
||||
import com.syjiaer.clinic.server.mapper.social.SocialDirectoryUpinfoMapper;
|
||||
import com.syjiaer.clinic.server.service.BaseService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ItemService extends BaseService {
|
||||
@Autowired
|
||||
private ItemMapper itemMapper;
|
||||
@Autowired
|
||||
private SocialDirectoryUpinfoMapper socialDirectoryUpinfoMapper;
|
||||
|
||||
/*
|
||||
* 获取项目列表
|
||||
* @param pageNum 页码
|
||||
|
|
@ -38,8 +49,9 @@ public class ItemService extends BaseService {
|
|||
queryWrapper.eq("tel", tel);
|
||||
}
|
||||
queryWrapper.eq("del_flag", 0);
|
||||
return pageHelper(pageNum, pageSize, queryWrapper, itemMapper,"create_datetime",false);
|
||||
return pageHelper(pageNum, pageSize, queryWrapper, itemMapper, "create_datetime", false);
|
||||
}
|
||||
|
||||
/*
|
||||
* 根据id获取项目信息
|
||||
* @param id 项目id
|
||||
|
|
@ -47,6 +59,7 @@ public class ItemService extends BaseService {
|
|||
public Item get(int id) {
|
||||
return itemMapper.selectById(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 创建项目
|
||||
* @param item 项目信息
|
||||
|
|
@ -55,22 +68,22 @@ public class ItemService extends BaseService {
|
|||
if (item == null) {
|
||||
throw new MessageException("item参数为空");
|
||||
}
|
||||
if (item.getItemName() == null || item.getItemName().isEmpty()){
|
||||
if (item.getItemName() == null || item.getItemName().isEmpty()) {
|
||||
throw new MessageException("项目名称不能为空");
|
||||
}
|
||||
if (item.getItemSocialCode() == null || item.getItemSocialCode().isEmpty()){
|
||||
if (item.getItemSocialCode() == null || item.getItemSocialCode().isEmpty()) {
|
||||
throw new MessageException("项目医保目录编码不能为空");
|
||||
}
|
||||
if (item.getUnit() == null || item.getUnit().isEmpty()){
|
||||
if (item.getUnit() == null || item.getUnit().isEmpty()) {
|
||||
throw new MessageException("单位不能为空");
|
||||
}
|
||||
if (item.getUnitPrice() == null || item.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0){
|
||||
if (item.getUnitPrice() == null || item.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new MessageException("售价不能小于0");
|
||||
}
|
||||
ManagerUser managerUser = getManagerUser();
|
||||
item.setCreateDatetime(LocalDateTime.now());
|
||||
item.setCreateBy(managerUser.getName());
|
||||
String pinyin_full= PinYinUtil.getPinyinFull(item.getItemName());
|
||||
String pinyin_full = PinYinUtil.getPinyinFull(item.getItemName());
|
||||
pinyin_full = pinyin_full.toUpperCase();
|
||||
item.setPinyinFull(pinyin_full);
|
||||
item.setPinyinFirst(PinYinUtil.getPinyinFirstLetters(item.getItemName()).toUpperCase());
|
||||
|
|
@ -94,18 +107,31 @@ public class ItemService extends BaseService {
|
|||
updateItem.setDelFlag(1);
|
||||
itemMapper.updateById(updateItem);
|
||||
}
|
||||
public List<Item> search(String keyword){
|
||||
|
||||
public List<ItemSearchVo> search(String keyword) {
|
||||
QueryWrapper<Item> queryWrapper = new QueryWrapper<>();
|
||||
if (keyword != null && !keyword.isEmpty()){
|
||||
if (keyword != null && !keyword.isEmpty()) {
|
||||
String upperKeyword = keyword.toUpperCase();
|
||||
queryWrapper.like("item_name", upperKeyword);
|
||||
queryWrapper.or().like("pinyin_full", upperKeyword);
|
||||
queryWrapper.or().like("pinyin_first", upperKeyword);
|
||||
|
||||
}
|
||||
queryWrapper.orderByDesc("use_num","update_datetime");
|
||||
queryWrapper.orderByDesc("use_num", "update_datetime");
|
||||
queryWrapper.last("limit 20");
|
||||
return itemMapper.selectList(queryWrapper);
|
||||
List<Item> items = itemMapper.selectList(queryWrapper);
|
||||
List<ItemSearchVo> itemSearchVos = new ArrayList<>();
|
||||
for (Item item : items) {
|
||||
ItemSearchVo itemSearchVo = new ItemSearchVo();
|
||||
BeanUtils.copyProperties(item, itemSearchVo);
|
||||
SocialDirectoryUpinfo socialDirectoryUpinfo = socialDirectoryUpinfoMapper.selectByCode(item.getItemSocialCode());
|
||||
if (socialDirectoryUpinfo != null) {
|
||||
ChrgitmLvEnum chrgitmLvEnum = ChrgitmLvEnum.getChrgitmLvEnumByCode(socialDirectoryUpinfo.getChrgitmLv());
|
||||
itemSearchVo.setChrgitmLv(chrgitmLvEnum == null ? null : chrgitmLvEnum.getName());
|
||||
}
|
||||
itemSearchVos.add(itemSearchVo);
|
||||
}
|
||||
return itemSearchVos;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -116,21 +142,21 @@ public class ItemService extends BaseService {
|
|||
if (item == null) {
|
||||
throw new MessageException("item参数为空");
|
||||
}
|
||||
if (item.getItemName() == null || item.getItemName().isEmpty()){
|
||||
if (item.getItemName() == null || item.getItemName().isEmpty()) {
|
||||
throw new MessageException("项目名称不能为空");
|
||||
}
|
||||
if (item.getItemSocialCode() == null || item.getItemSocialCode().isEmpty()){
|
||||
if (item.getItemSocialCode() == null || item.getItemSocialCode().isEmpty()) {
|
||||
throw new MessageException("项目医保目录编码不能为空");
|
||||
}
|
||||
if (item.getUnit() == null || item.getUnit().isEmpty()){
|
||||
if (item.getUnit() == null || item.getUnit().isEmpty()) {
|
||||
throw new MessageException("单位不能为空");
|
||||
}
|
||||
if (item.getUnitPrice() == null || item.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0){
|
||||
if (item.getUnitPrice() == null || item.getUnitPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new MessageException("售价不能小于0");
|
||||
}
|
||||
item.setUpdateBy(getManagerUser().getName());
|
||||
item.setUpdateDatetime(LocalDateTime.now());
|
||||
String pinyin_full= PinYinUtil.getPinyinFull(item.getItemName());
|
||||
String pinyin_full = PinYinUtil.getPinyinFull(item.getItemName());
|
||||
pinyin_full = pinyin_full.toUpperCase();
|
||||
item.setPinyinFull(pinyin_full);
|
||||
item.setPinyinFirst(PinYinUtil.getPinyinFirstLetters(item.getItemName()).toUpperCase());
|
||||
|
|
@ -139,11 +165,11 @@ public class ItemService extends BaseService {
|
|||
|
||||
|
||||
public void updateNumAddOne(List<Integer> ids) {
|
||||
for (Integer itemId : ids){
|
||||
for (Integer itemId : ids) {
|
||||
UpdateWrapper<Item> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.setSql("use_num = use_num+1");
|
||||
updateWrapper.eq("id",itemId);
|
||||
itemMapper.update(null,updateWrapper);
|
||||
updateWrapper.eq("id", itemId);
|
||||
itemMapper.update(null, updateWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public class SocialDiagnoseService extends BaseService {
|
|||
.or().like("pinyin_first", key));
|
||||
}
|
||||
queryWrapper.orderByDesc("use_num","id");
|
||||
queryWrapper.last("limit 20");
|
||||
queryWrapper.last("limit 60");
|
||||
return socialDiagnoseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue